From bb7d04778dd1f45d24b6d0bd1f1b2a2256233cef Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Wed, 5 Jan 2022 15:34:50 -0800 Subject: [PATCH] Support non-default back-disposition in ThemedNavBarKeyboard With this CL, you can let ThemedNavBarKeyboard call InputMethodService#setBackDisposition(int) with either the following values * BACK_DISPOSITION_DEFAULT * BACK_DISPOSITION_ADJUST_NOTHING so that you can see how those two flags work. Bug: 213337792 Test: Manually verified as follows 1. Flash aosp_coral-userdebug into the device 2. make -j ThemedNavBarKeyboard 3. adb install -r $ANDROID_PRODUCT_OUT/system/app/ThemedNavBarKeyboard/ThemedNavBarKeyboard.apk 4. adb shell ime enable com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 5. adb shell ime set com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard 6. Tap any edit field 7. Make sure that the back button is left-pointing triangle 8. Tap "BACK_DISPOSITION_ADJUST_NOTHING" on the IME 9. Make sure that the back button is down-pointing triangle Change-Id: I71aa1dd23d72e8891cb3887efe5db1a48b6a017d --- .../ThemedNavBarKeyboard.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/samples/ThemedNavBarKeyboard/src/com/example/android/themednavbarkeyboard/ThemedNavBarKeyboard.java b/samples/ThemedNavBarKeyboard/src/com/example/android/themednavbarkeyboard/ThemedNavBarKeyboard.java index 5e09a8341..e618f2065 100644 --- a/samples/ThemedNavBarKeyboard/src/com/example/android/themednavbarkeyboard/ThemedNavBarKeyboard.java +++ b/samples/ThemedNavBarKeyboard/src/com/example/android/themednavbarkeyboard/ThemedNavBarKeyboard.java @@ -189,6 +189,29 @@ public class ThemedNavBarKeyboard extends InputMethodService { switchToSeparateNavBarMode(Color.DKGRAY, false /* lightNavBar */); setBackgroundColor(MINT_COLOR); + { + final LinearLayout subLayout = new LinearLayout(context); + { + final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT); + lp.weight = 50; + subLayout.addView(createButton("BACK_DISPOSITION\nDEFAULT", () -> { + setBackDisposition(BACK_DISPOSITION_DEFAULT); + }), lp); + } + { + final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT); + lp.weight = 50; + subLayout.addView(createButton("BACK_DISPOSITION\nADJUST_NOTHING", () -> { + setBackDisposition(BACK_DISPOSITION_ADJUST_NOTHING); + }), lp); + } + addView(subLayout); + } + addView(createButton("Floating Mode", () -> { switchToFloatingMode(); setBackgroundColor(Color.TRANSPARENT);