diff --git a/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMManager.java b/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMManager.java index fb473feca7..5d99912a2b 100644 --- a/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMManager.java +++ b/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMManager.java @@ -14,6 +14,7 @@ import java.util.HashMap; import android.annotation.SuppressLint; import android.app.Dialog; +import android.app.KeyguardManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -82,7 +83,8 @@ public final class KMManager { // Globe key actions public enum GlobeKeyAction { GLOBE_KEY_ACTION_SHOW_MENU, - GLOBE_KEY_ACTION_SWITCH_TO_NEXT_KEYBOARD, + GLOBE_KEY_ACTION_SWITCH_TO_NEXT_KEYBOARD, // Switch to next Keyman keyboard + GLOBE_KEY_ACTION_ADVANCE_TO_NEXT_SYSTEM_KEYBOARD, // Advance to next system keyboard GLOBE_KEY_ACTION_DO_NOTHING, } @@ -92,6 +94,7 @@ public final class KMManager { private static boolean didCopyAssets = false; private static GlobeKeyAction inappKbGlobeKeyAction = GlobeKeyAction.GLOBE_KEY_ACTION_SHOW_MENU; private static GlobeKeyAction sysKbGlobeKeyAction = GlobeKeyAction.GLOBE_KEY_ACTION_SHOW_MENU; + private static int sysKbIndexOnLockScreen = -1; protected static boolean InAppKeyboardLoaded = false; protected static boolean SystemKeyboardLoaded = false; @@ -1364,10 +1367,29 @@ public final class KMManager { if (KMManager.shouldAllowSetKeyboard()) { if (SystemKeyboard.keyboardPickerEnabled) { + KeyguardManager km = (KeyguardManager) appContext.getSystemService(Context.KEYGUARD_SERVICE); + if(km.inKeyguardRestrictedInputMode()) { + // Override system keyboard globe key action if screen is locked: + // 1. Switch to next Keyman keyboard (no menu) + // 2. When all the Keyman keyboards have been cycled through, advance to the next system keyboard + if (sysKbIndexOnLockScreen == -1) { + sysKbIndexOnLockScreen = getCurrentKeyboardIndex(context); + sysKbGlobeKeyAction = GlobeKeyAction.GLOBE_KEY_ACTION_SWITCH_TO_NEXT_KEYBOARD; + } else if (sysKbIndexOnLockScreen == getCurrentKeyboardIndex(context)) { + sysKbGlobeKeyAction = GlobeKeyAction.GLOBE_KEY_ACTION_ADVANCE_TO_NEXT_SYSTEM_KEYBOARD; + } + } else { + // If screen isn't locked, revert to default system globe key action + sysKbIndexOnLockScreen = -1; + sysKbGlobeKeyAction = GlobeKeyAction.GLOBE_KEY_ACTION_SHOW_MENU; + } + if (sysKbGlobeKeyAction == GlobeKeyAction.GLOBE_KEY_ACTION_SHOW_MENU) { showKeyboardPicker(context, KeyboardType.KEYBOARD_TYPE_SYSTEM); } else if (sysKbGlobeKeyAction == GlobeKeyAction.GLOBE_KEY_ACTION_SWITCH_TO_NEXT_KEYBOARD) { switchToNextKeyboard(context); + } else if (sysKbGlobeKeyAction == GlobeKeyAction.GLOBE_KEY_ACTION_ADVANCE_TO_NEXT_SYSTEM_KEYBOARD) { + advanceToNextInputMode(); } } else { switchToNextKeyboard(context); diff --git a/android/history.md b/android/history.md index f1f68a88b2..2c82d92977 100644 --- a/android/history.md +++ b/android/history.md @@ -1,5 +1,9 @@ # Keyman for Android +## 2019-06-28 11.0.2103 stable +* Changes: + * Allow user to change keyboard from lock screen (#1709) + ## 2019-02-27 11.0.2102 stable * Bug fix: * Fix crash from language picker trying to show error dialog (#1634)