|
4 | 4 | import android.app.Activity; |
5 | 5 | import android.os.Build; |
6 | 6 | import android.os.Bundle; |
7 | | -import android.support.annotation.NonNull; |
8 | 7 | import android.text.Spanned; |
9 | 8 | import android.view.LayoutInflater; |
10 | 9 | import android.view.View; |
11 | 10 | import android.view.ViewGroup; |
12 | | -import android.webkit.ConsoleMessage; |
13 | | -import android.webkit.JsResult; |
14 | | -import android.webkit.WebChromeClient; |
15 | | -import android.webkit.WebSettings; |
16 | 11 | import android.webkit.WebView; |
17 | | -import android.webkit.WebViewClient; |
18 | 12 | import android.widget.ToggleButton; |
19 | 13 |
|
20 | 14 | import com.android.volley.toolbox.ImageLoader; |
@@ -79,7 +73,7 @@ public void onCreate(Bundle savedInstanceState) { |
79 | 73 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
80 | 74 | View view = inflater.inflate(R.layout.fragment_editor, container, false); |
81 | 75 | mWebView = (EditorWebViewAbstract) view.findViewById(R.id.webview); |
82 | | - initWebView(); |
| 76 | + initJsEditor(); |
83 | 77 |
|
84 | 78 | ToggleButton mediaButton = (ToggleButton) view.findViewById(R.id.format_bar_button_media); |
85 | 79 | mTagToggleButtonMap.put(TAG_FORMAT_BAR_BUTTON_MEDIA, mediaButton); |
@@ -117,30 +111,7 @@ public void onDetach() { |
117 | 111 | super.onDetach(); |
118 | 112 | } |
119 | 113 |
|
120 | | - @SuppressLint("SetJavaScriptEnabled") |
121 | | - private void initWebView() { |
122 | | - WebSettings webSettings = mWebView.getSettings(); |
123 | | - webSettings.setJavaScriptEnabled(true); |
124 | | - webSettings.setDefaultTextEncodingName("utf-8"); |
125 | | - mWebView.setWebViewClient(new WebViewClient() { |
126 | | - public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { |
127 | | - AppLog.e(T.EDITOR, description); |
128 | | - } |
129 | | - }); |
130 | | - mWebView.setWebChromeClient(new WebChromeClient() { |
131 | | - @Override |
132 | | - public boolean onConsoleMessage(@NonNull ConsoleMessage cm) { |
133 | | - AppLog.d(T.EDITOR, cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId()); |
134 | | - return true; |
135 | | - } |
136 | | - |
137 | | - @Override |
138 | | - public boolean onJsAlert(WebView view, String url, String message, JsResult result) { |
139 | | - AppLog.d(T.EDITOR, message); |
140 | | - return true; |
141 | | - } |
142 | | - }); |
143 | | - |
| 114 | + private void initJsEditor() { |
144 | 115 | String htmlEditor = Utils.getHtmlFromFile(mActivity, "android-editor.html"); |
145 | 116 |
|
146 | 117 | mWebView.addJavascriptInterface(new JsCallbackReceiver(this), JS_CALLBACK_HANDLER); |
|
0 commit comments