-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved JsCallbackHandler to its own file
- Added a JsCallbackListener interface for callbacks from the handler to the editor fragment - Updated ZSSEditor.callback to send the full callback path
- Loading branch information
Showing
4 changed files
with
72 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
WordPressEditor/src/main/java/org/wordpress/android/editor/JsCallbackHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.wordpress.android.editor; | ||
|
||
import android.webkit.JavascriptInterface; | ||
|
||
import org.wordpress.android.util.AppLog; | ||
|
||
public class JsCallbackHandler { | ||
private static final String CALLBACK_LOG = "callback-log"; | ||
|
||
private static final String CALLBACK_DOM_LOADED = "callback-dom-loaded"; | ||
|
||
private static final String CALLBACK_SELECTION_STYLE = "callback-selection-style"; | ||
private static final String CALLBACK_SELECTION_CHANGED = "callback-selection-changed"; | ||
|
||
private static final String CALLBACK_FOCUS_IN = "callback-focus-in"; | ||
private static final String CALLBACK_FOCUS_OUT = "callback-focus-out"; | ||
|
||
private static final String CALLBACK_IMAGE_REPLACED = "callback-image-replaced"; | ||
private static final String CALLBACK_IMAGE_TAP = "callback-image-tap"; | ||
private static final String CALLBACK_INPUT = "callback-input"; | ||
private static final String CALLBACK_LINK_TAP = "callback-link-tap"; | ||
|
||
private static final String CALLBACK_NEW_FIELD = "callback-new-field"; | ||
|
||
private final JsCallbackListener mJsCallbackListener; | ||
|
||
public JsCallbackHandler(EditorFragmentAbstract editorFragmentAbstract) { | ||
mJsCallbackListener = (JsCallbackListener) editorFragmentAbstract; | ||
} | ||
|
||
@JavascriptInterface | ||
public void executeCallback(String callbackId, String params) { | ||
switch (callbackId) { | ||
case CALLBACK_DOM_LOADED: | ||
mJsCallbackListener.onDomLoaded(); | ||
break; | ||
case CALLBACK_LOG: | ||
// Strip 'msg=' from beginning of string | ||
AppLog.d(AppLog.T.EDITOR, callbackId + ": " + params.substring(4)); | ||
break; | ||
default: | ||
AppLog.d(AppLog.T.EDITOR, "unhandled callback: " + callbackId + ":" + params); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
WordPressEditor/src/main/java/org/wordpress/android/editor/JsCallbackListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.wordpress.android.editor; | ||
|
||
public interface JsCallbackListener { | ||
void onDomLoaded(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters