mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-23 08:07:40 +00:00
Refactor setIsChiral
This commit is contained in:
parent
47d2e30af3
commit
bf3e05e2a4
2 changed files with 14 additions and 20 deletions
|
|
@ -11,10 +11,12 @@ import static android.content.Context.VIBRATOR_SERVICE;
|
|||
|
||||
public abstract class KMKeyboardJSHandler {
|
||||
private Context context;
|
||||
private KMKeyboard k = null;
|
||||
private static int KM_VIBRATE_DURATION = 100; // milliseconds
|
||||
|
||||
KMKeyboardJSHandler(Context context) {
|
||||
KMKeyboardJSHandler(Context context, KMKeyboard k) {
|
||||
this.context = context;
|
||||
this.k = k;
|
||||
}
|
||||
|
||||
// This annotation is required in Jelly Bean and later:
|
||||
|
|
@ -55,7 +57,11 @@ public abstract class KMKeyboardJSHandler {
|
|||
|
||||
// Store the current keyboard chirality status from KMW in the Keyboard
|
||||
@JavascriptInterface
|
||||
public abstract void setIsChiral(boolean isChiral);
|
||||
public void setIsChiral(boolean isChiral) {
|
||||
if (k != null) {
|
||||
k.setChirality(isChiral);
|
||||
}
|
||||
}
|
||||
|
||||
// Insert the selected string s
|
||||
@JavascriptInterface
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ public final class KMManager {
|
|||
InAppKeyboard.setVerticalScrollBarEnabled(false);
|
||||
InAppKeyboard.setHorizontalScrollBarEnabled(false);
|
||||
InAppKeyboard.setWebViewClient(new KMInAppKeyboardWebViewClient(appContext));
|
||||
InAppKeyboard.addJavascriptInterface(new KMInAppKeyboardJSHandler(appContext), "jsInterface");
|
||||
InAppKeyboard.addJavascriptInterface(new KMInAppKeyboardJSHandler(appContext, InAppKeyboard), "jsInterface");
|
||||
InAppKeyboard.loadKeyboard();
|
||||
}
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ public final class KMManager {
|
|||
SystemKeyboard.setVerticalScrollBarEnabled(false);
|
||||
SystemKeyboard.setHorizontalScrollBarEnabled(false);
|
||||
SystemKeyboard.setWebViewClient(new KMSystemKeyboardWebViewClient(appContext));
|
||||
SystemKeyboard.addJavascriptInterface(new KMSystemKeyboardJSHandler(appContext), "jsInterface");
|
||||
SystemKeyboard.addJavascriptInterface(new KMSystemKeyboardJSHandler(appContext, SystemKeyboard), "jsInterface");
|
||||
SystemKeyboard.loadKeyboard();
|
||||
}
|
||||
}
|
||||
|
|
@ -1586,14 +1586,8 @@ public final class KMManager {
|
|||
|
||||
private static final class KMInAppKeyboardJSHandler extends KMKeyboardJSHandler {
|
||||
|
||||
KMInAppKeyboardJSHandler(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
// Store the current keyboard chirality status from KMW in InAppKeyboard
|
||||
@JavascriptInterface
|
||||
public void setIsChiral(boolean isChiral) {
|
||||
InAppKeyboard.setChirality(isChiral);
|
||||
KMInAppKeyboardJSHandler(Context context, KMKeyboard k) {
|
||||
super(context, k);
|
||||
}
|
||||
|
||||
// This annotation is required in Jelly Bean and later:
|
||||
|
|
@ -1674,14 +1668,8 @@ public final class KMManager {
|
|||
}
|
||||
|
||||
private static final class KMSystemKeyboardJSHandler extends KMKeyboardJSHandler {
|
||||
KMSystemKeyboardJSHandler(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
// Store the current keyboard chirality status from KMW in SystemKeyboard
|
||||
@JavascriptInterface
|
||||
public void setIsChiral(boolean isChiral) {
|
||||
SystemKeyboard.setChirality(isChiral);
|
||||
KMSystemKeyboardJSHandler(Context context, KMKeyboard k) {
|
||||
super(context, k);
|
||||
}
|
||||
|
||||
// This annotation is required in Jelly Bean and later:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue