From 64f18ec8a7d60b963ad1427a864aecdbb82f378b Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Sun, 31 Mar 2019 18:23:54 +0700 Subject: [PATCH 1/3] Allow user to switch keyboard on lock screen --- .../app/src/main/java/com/tavultesoft/kmea/KMManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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..9a911d910a 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; @@ -1364,7 +1365,11 @@ public final class KMManager { if (KMManager.shouldAllowSetKeyboard()) { if (SystemKeyboard.keyboardPickerEnabled) { - if (sysKbGlobeKeyAction == GlobeKeyAction.GLOBE_KEY_ACTION_SHOW_MENU) { + KeyguardManager km = (KeyguardManager) appContext.getSystemService(Context.KEYGUARD_SERVICE); + if(km.inKeyguardRestrictedInputMode()) { + // If screen is locked, override GlobeKeyAction to switch to next keyboard + advanceToNextInputMode(); + } else 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); From d6f532a332f39eac0a8dbb23180bbbd1cbc618e6 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Sun, 23 Jun 2019 03:48:58 -0500 Subject: [PATCH 2/3] Update system keyboard globe action on lock screen Per PR comment set the globe key to: 1. switch to next Keyman keyboard 2. until all Keyman keyboards selected, then advance to next input mode --- .../java/com/tavultesoft/kmea/KMManager.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) 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 9a911d910a..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 @@ -83,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, } @@ -93,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; @@ -1367,12 +1369,27 @@ public final class KMManager { if (SystemKeyboard.keyboardPickerEnabled) { KeyguardManager km = (KeyguardManager) appContext.getSystemService(Context.KEYGUARD_SERVICE); if(km.inKeyguardRestrictedInputMode()) { - // If screen is locked, override GlobeKeyAction to switch to next keyboard - advanceToNextInputMode(); - } else if (sysKbGlobeKeyAction == GlobeKeyAction.GLOBE_KEY_ACTION_SHOW_MENU) { + // 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); From 91536a01960a7f26cb71da2c0eb996e0384aeb9a Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 27 Jun 2019 11:30:26 -0500 Subject: [PATCH 3/3] Update history.md --- android/history.md | 4 ++++ 1 file changed, 4 insertions(+) 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)