diff options
| author | Yohei Yukawa <yukawa@google.com> | 2022-01-31 18:56:50 -0800 |
|---|---|---|
| committer | Yohei Yukawa <yukawa@google.com> | 2022-01-31 18:56:50 -0800 |
| commit | af1695a78aaf307fc7b9284aafefff5bab5a1448 (patch) | |
| tree | 1846b29a062bf21e83b06d6d28fec43eb3dda919 /core/java/android/inputmethodservice/NavigationBarController.java | |
| parent | f376ad2df11cb5f86872618d407f7a13d5002fba (diff) | |
Introduce Window.DecorCallback
This is a follow up CL to my previous CL [1], which introduced a
hidden callback method into Window.Callback.
This CL does not change any observable behavior but consolidate that
hidden callback into a newly introduced Window.DecorCallback
interface. In this approach, we no longer need to worry about
accidental method name collision in Window.Callback implementations
classes.
Here is the new callback chain.
ViewRootImpl#performTraversals()
-> DecorView#onSystemBarAppearanceChanged()
-> Window.dispatchOnSystemBarAppearanceChanged()
-> NavigationBarController.Impl#onSystemBarAppearanceChanged()
[1]: I08566034bebfafff6777ce0152cd6ca1f66f6cad
678ddce11c131a8e6746fe386c40ddc8d99d01c3
Bug: 215549533
Test: Manually tested with ThemedNavBarKeyboard sample
1. Build aosp_coral-userdebug and flash it
2. adb root
3. adb shell setprop \
persist.sys.ime.can_render_gestural_nav_buttons true
4. adb reboot
5. make -j ThemedNavBarKeyboard
6. adb install -r \
$OUT/system/app/ThemedNavBarKeyboard/ThemedNavBarKeyboard.apk
7. adb shell ime enable \
com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard
8. adb shell ime set \
com.example.android.themednavbarkeyboard/.ThemedNavBarKeyboard
9. Open the Dialer app
10. Focus in the top edit field.
11. Tap "EXTENDED LIGHT NAVIGARION BAR" mode
12. Make sure that the navigation button color is optimized for light
navigation bar.
13. Tap "STANDARD LIGHT NAVIGARION BAR" mode
14. Make sure that the navigation button color is optimized for light
navigation bar.
Change-Id: I5168f76dfc9526e925c565dbfa87597b5543fcdc
Diffstat (limited to 'core/java/android/inputmethodservice/NavigationBarController.java')
| -rw-r--r-- | core/java/android/inputmethodservice/NavigationBarController.java | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/core/java/android/inputmethodservice/NavigationBarController.java b/core/java/android/inputmethodservice/NavigationBarController.java index 508172d13aa3..9cea82b91f5a 100644 --- a/core/java/android/inputmethodservice/NavigationBarController.java +++ b/core/java/android/inputmethodservice/NavigationBarController.java @@ -65,6 +65,9 @@ final class NavigationBarController { @NonNull ViewTreeObserver.InternalInsetsInfo dest) { } + default void onSoftInputWindowCreated(@NonNull SoftInputWindow softInputWindow) { + } + default void onViewInitialized() { } @@ -78,9 +81,6 @@ final class NavigationBarController { boolean shouldShowImeSwitcherWhenImeIsShown) { } - default void onSystemBarAppearanceChanged(@Appearance int appearance) { - } - default String toDebugString() { return "No-op implementation"; } @@ -101,6 +101,10 @@ final class NavigationBarController { mImpl.updateTouchableInsets(originalInsets, dest); } + void onSoftInputWindowCreated(@NonNull SoftInputWindow softInputWindow) { + mImpl.onSoftInputWindowCreated(softInputWindow); + } + void onViewInitialized() { mImpl.onViewInitialized(); } @@ -117,15 +121,11 @@ final class NavigationBarController { mImpl.setShouldShowImeSwitcherWhenImeIsShown(shouldShowImeSwitcherWhenImeIsShown); } - void onSystemBarAppearanceChanged(@Appearance int appearance) { - mImpl.onSystemBarAppearanceChanged(appearance); - } - String toDebugString() { return mImpl.toDebugString(); } - private static final class Impl implements Callback { + private static final class Impl implements Callback, Window.DecorCallback { private static final int DEFAULT_COLOR_ADAPT_TRANSITION_TIME = 1700; // Copied from com.android.systemui.animation.Interpolators#LEGACY_DECELERATE @@ -362,6 +362,13 @@ final class NavigationBarController { } @Override + public void onSoftInputWindowCreated(@NonNull SoftInputWindow softInputWindow) { + final Window window = softInputWindow.getWindow(); + mAppearance = window.getSystemBarAppearance(); + window.setDecorCallback(this); + } + + @Override public void onViewInitialized() { if (mDestroyed) { return; |
