From 678ddce11c131a8e6746fe386c40ddc8d99d01c3 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Thu, 27 Jan 2022 10:29:33 -0800 Subject: Support light navigation bar In order to propagate the information about whether the IME is using light navigation bar or not from android.view.ViewRootImpl to android.inputmethodservice.NavigationBarController within the same process, this CL adds a new @hide method to Window.Callback as follows. ViewRootImpl#performTraversals() -> DecorView#onSystemBarAppearanceChanged() -> Window.Callback#onSystemBarAppearanceChanged() -> SoftInputWindow#onSystemBarAppearanceChanged() -> NavigationBarController#onSystemBarAppearanceChanged() Button color transition will be implemented in a subsequent CL. 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: I08566034bebfafff6777ce0152cd6ca1f66f6cad --- .../java/android/inputmethodservice/SoftInputWindow.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'core/java/android/inputmethodservice/SoftInputWindow.java') diff --git a/core/java/android/inputmethodservice/SoftInputWindow.java b/core/java/android/inputmethodservice/SoftInputWindow.java index 6c8eb41d8724..0893d2aad740 100644 --- a/core/java/android/inputmethodservice/SoftInputWindow.java +++ b/core/java/android/inputmethodservice/SoftInputWindow.java @@ -23,7 +23,6 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; import android.annotation.IntDef; import android.app.Dialog; -import android.content.Context; import android.graphics.Rect; import android.os.Debug; import android.os.IBinder; @@ -32,6 +31,7 @@ import android.util.proto.ProtoOutputStream; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.WindowInsetsController; import android.view.WindowManager; import java.lang.annotation.Retention; @@ -47,6 +47,7 @@ final class SoftInputWindow extends Dialog { private final KeyEvent.DispatcherState mDispatcherState; private final Rect mBounds = new Rect(); + private final InputMethodService mService; @Retention(SOURCE) @IntDef(value = {WindowState.TOKEN_PENDING, WindowState.TOKEN_SET, @@ -120,7 +121,7 @@ final class SoftInputWindow extends Dialog { /** * Create a SoftInputWindow that uses a custom style. * - * @param context The Context in which the DockWindow should run. In + * @param service The {@link InputMethodService} in which the DockWindow should run. In * particular, it uses the window manager and theme from this context * to present its UI. * @param theme A style resource describing the theme to use for the window. @@ -129,8 +130,10 @@ final class SoftInputWindow extends Dialog { * using styles. This theme is applied on top of the current theme in * context. If 0, the default dialog theme will be used. */ - SoftInputWindow(Context context, int theme, KeyEvent.DispatcherState dispatcherState) { - super(context, theme); + SoftInputWindow(InputMethodService service, int theme, + KeyEvent.DispatcherState dispatcherState) { + super(service, theme); + mService = service; mDispatcherState = dispatcherState; } @@ -261,6 +264,11 @@ final class SoftInputWindow extends Dialog { } } + @Override + public void onSystemBarAppearanceChanged(@WindowInsetsController.Appearance int appearance) { + mService.mNavigationBarController.onSystemBarAppearanceChanged(appearance); + } + void dumpDebug(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); mBounds.dumpDebug(proto, BOUNDS); -- cgit v1.2.3