[go: nahoru, domu]

Skip to content

Commit

Permalink
add dependency on WordPressUtils and use AppLog instead of Log
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Feb 4, 2015
1 parent 86805a0 commit 1b5d1fd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
package org.wordpress.android.editor;

import android.annotation.SuppressLint;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.webkit.ConsoleMessage;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class EditorActivity extends ActionBarActivity {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.res.AssetManager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -15,6 +14,9 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;

import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -63,32 +65,31 @@ public void onDetach() {
super.onDetach();
}

// TODO: use AppLog instead of Log
@SuppressLint("SetJavaScriptEnabled")
private void initWebView() {
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDefaultTextEncodingName("utf-8");
mWebView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.e("WordPress-Editor", description);
AppLog.e(T.EDITOR, description);
}
});
mWebView.setWebChromeClient(new WebChromeClient() {
public boolean onConsoleMessage(ConsoleMessage cm) {
Log.e("WordPress-Editor", cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
AppLog.e(T.EDITOR, cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
return true;
}

@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
Log.e("WordPress-Editor", message);
AppLog.e(T.EDITOR, message);
return true;
}

@Override
public void onConsoleMessage(String message, int lineNumber, String sourceId) {
Log.e("WordPress-Editor", message + " -- from line " + lineNumber + " of " + sourceId);
AppLog.e(T.EDITOR, message + " -- from line " + lineNumber + " of " + sourceId);
}
});
String htmlEditor = getHtmlEditor();
Expand Down Expand Up @@ -117,7 +118,7 @@ private String getHtmlEditor() {
try {
return getStringFromAsset("android-editor.html");
} catch (IOException e) {
Log.e("WordPress-Editor", e.getMessage());
AppLog.e(T.EDITOR, e.getMessage());
return null;
}
}
Expand Down
4 changes: 4 additions & 0 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ buildscript {
}
}

repositories {
mavenCentral()
}

apply plugin: 'com.android.application'

android {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include ':editor'
include ':example'
include ':libs:utils:WordPressUtils'

0 comments on commit 1b5d1fd

Please sign in to comment.