Loading core/java/android/inputmethodservice/InputMethodService.java +1 −1 Original line number Diff line number Diff line Loading @@ -475,7 +475,7 @@ public class InputMethodService extends AbstractInputMethodService { private InputMethodPrivilegedOperations mPrivOps = new InputMethodPrivilegedOperations(); @NonNull private final NavigationBarController mNavigationBarController = final NavigationBarController mNavigationBarController = new NavigationBarController(this); @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) Loading core/java/android/inputmethodservice/NavigationBarController.java +47 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ package android.inputmethodservice; import static android.content.Intent.ACTION_OVERLAY_CHANGED; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; import android.annotation.FloatRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.StatusBarManager; Loading @@ -40,6 +42,7 @@ import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.Window; import android.view.WindowInsets; import android.view.WindowInsetsController.Appearance; import android.view.WindowManagerPolicyConstants; import android.widget.FrameLayout; Loading Loading @@ -68,6 +71,9 @@ final class NavigationBarController { default void onDestroy() { } default void onSystemBarAppearanceChanged(@Appearance int appearance) { } default String toDebugString() { return "No-op implementation"; } Loading Loading @@ -100,6 +106,10 @@ final class NavigationBarController { mImpl.onDestroy(); } void onSystemBarAppearanceChanged(@Appearance int appearance) { mImpl.onSystemBarAppearanceChanged(appearance); } String toDebugString() { return mImpl.toDebugString(); } Loading @@ -120,6 +130,9 @@ final class NavigationBarController { @Nullable private BroadcastReceiver mSystemOverlayChangedReceiver; @Appearance private int mAppearance; Impl(@NonNull InputMethodService inputMethodService) { mService = inputMethodService; } Loading Loading @@ -187,6 +200,8 @@ final class NavigationBarController { } mNavigationBarFrame.setBackground(null); setIconTintInternal(calculateTargetDarkIntensity(mAppearance)); } private void uninstallNavigationBarFrameIfNecessary() { Loading Loading @@ -388,10 +403,42 @@ final class NavigationBarController { } } @Override public void onSystemBarAppearanceChanged(@Appearance int appearance) { if (mDestroyed) { return; } mAppearance = appearance; if (mNavigationBarFrame == null) { return; } final float targetDarkIntensity = calculateTargetDarkIntensity(mAppearance); setIconTintInternal(targetDarkIntensity); } private void setIconTintInternal(float darkIntensity) { final NavigationBarView navigationBarView = mNavigationBarFrame.findViewByPredicate(NavigationBarView.class::isInstance); if (navigationBarView == null) { return; } navigationBarView.setDarkIntensity(darkIntensity); } @FloatRange(from = 0.0f, to = 1.0f) private static float calculateTargetDarkIntensity(@Appearance int appearance) { final boolean lightNavBar = (appearance & APPEARANCE_LIGHT_NAVIGATION_BARS) != 0; return lightNavBar ? 1.0f : 0.0f; } @Override public String toDebugString() { return "{mRenderGesturalNavButtons=" + mRenderGesturalNavButtons + " mNavigationBarFrame=" + mNavigationBarFrame + " mAppearance=0x" + Integer.toHexString(mAppearance) + "}"; } } Loading core/java/android/inputmethodservice/SoftInputWindow.java +12 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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, Loading Loading @@ -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. Loading @@ -129,8 +130,10 @@ final class SoftInputWindow extends Dialog { * using styles. This theme is applied on top of the current theme in * <var>context</var>. 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; } Loading Loading @@ -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); Loading core/java/android/view/Window.java +11 −0 Original line number Diff line number Diff line Loading @@ -607,6 +607,17 @@ public abstract class Window { * @param hasCapture True if the window has pointer capture. */ default public void onPointerCaptureChanged(boolean hasCapture) { }; /** * Called from * {@link com.android.internal.policy.DecorView#onSystemBarAppearanceChanged(int)}. * * @param appearance The newly applied appearance. * @hide */ default void onSystemBarAppearanceChanged( @WindowInsetsController.Appearance int appearance) { } } /** @hide */ Loading core/java/android/view/WindowCallbackWrapper.java +5 −0 Original line number Diff line number Diff line Loading @@ -163,5 +163,10 @@ public class WindowCallbackWrapper implements Window.Callback { public void onPointerCaptureChanged(boolean hasCapture) { mWrapped.onPointerCaptureChanged(hasCapture); } @Override public void onSystemBarAppearanceChanged(@WindowInsetsController.Appearance int appearance) { mWrapped.onSystemBarAppearanceChanged(appearance); } } Loading
core/java/android/inputmethodservice/InputMethodService.java +1 −1 Original line number Diff line number Diff line Loading @@ -475,7 +475,7 @@ public class InputMethodService extends AbstractInputMethodService { private InputMethodPrivilegedOperations mPrivOps = new InputMethodPrivilegedOperations(); @NonNull private final NavigationBarController mNavigationBarController = final NavigationBarController mNavigationBarController = new NavigationBarController(this); @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) Loading
core/java/android/inputmethodservice/NavigationBarController.java +47 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ package android.inputmethodservice; import static android.content.Intent.ACTION_OVERLAY_CHANGED; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; import android.annotation.FloatRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.StatusBarManager; Loading @@ -40,6 +42,7 @@ import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.Window; import android.view.WindowInsets; import android.view.WindowInsetsController.Appearance; import android.view.WindowManagerPolicyConstants; import android.widget.FrameLayout; Loading Loading @@ -68,6 +71,9 @@ final class NavigationBarController { default void onDestroy() { } default void onSystemBarAppearanceChanged(@Appearance int appearance) { } default String toDebugString() { return "No-op implementation"; } Loading Loading @@ -100,6 +106,10 @@ final class NavigationBarController { mImpl.onDestroy(); } void onSystemBarAppearanceChanged(@Appearance int appearance) { mImpl.onSystemBarAppearanceChanged(appearance); } String toDebugString() { return mImpl.toDebugString(); } Loading @@ -120,6 +130,9 @@ final class NavigationBarController { @Nullable private BroadcastReceiver mSystemOverlayChangedReceiver; @Appearance private int mAppearance; Impl(@NonNull InputMethodService inputMethodService) { mService = inputMethodService; } Loading Loading @@ -187,6 +200,8 @@ final class NavigationBarController { } mNavigationBarFrame.setBackground(null); setIconTintInternal(calculateTargetDarkIntensity(mAppearance)); } private void uninstallNavigationBarFrameIfNecessary() { Loading Loading @@ -388,10 +403,42 @@ final class NavigationBarController { } } @Override public void onSystemBarAppearanceChanged(@Appearance int appearance) { if (mDestroyed) { return; } mAppearance = appearance; if (mNavigationBarFrame == null) { return; } final float targetDarkIntensity = calculateTargetDarkIntensity(mAppearance); setIconTintInternal(targetDarkIntensity); } private void setIconTintInternal(float darkIntensity) { final NavigationBarView navigationBarView = mNavigationBarFrame.findViewByPredicate(NavigationBarView.class::isInstance); if (navigationBarView == null) { return; } navigationBarView.setDarkIntensity(darkIntensity); } @FloatRange(from = 0.0f, to = 1.0f) private static float calculateTargetDarkIntensity(@Appearance int appearance) { final boolean lightNavBar = (appearance & APPEARANCE_LIGHT_NAVIGATION_BARS) != 0; return lightNavBar ? 1.0f : 0.0f; } @Override public String toDebugString() { return "{mRenderGesturalNavButtons=" + mRenderGesturalNavButtons + " mNavigationBarFrame=" + mNavigationBarFrame + " mAppearance=0x" + Integer.toHexString(mAppearance) + "}"; } } Loading
core/java/android/inputmethodservice/SoftInputWindow.java +12 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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, Loading Loading @@ -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. Loading @@ -129,8 +130,10 @@ final class SoftInputWindow extends Dialog { * using styles. This theme is applied on top of the current theme in * <var>context</var>. 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; } Loading Loading @@ -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); Loading
core/java/android/view/Window.java +11 −0 Original line number Diff line number Diff line Loading @@ -607,6 +607,17 @@ public abstract class Window { * @param hasCapture True if the window has pointer capture. */ default public void onPointerCaptureChanged(boolean hasCapture) { }; /** * Called from * {@link com.android.internal.policy.DecorView#onSystemBarAppearanceChanged(int)}. * * @param appearance The newly applied appearance. * @hide */ default void onSystemBarAppearanceChanged( @WindowInsetsController.Appearance int appearance) { } } /** @hide */ Loading
core/java/android/view/WindowCallbackWrapper.java +5 −0 Original line number Diff line number Diff line Loading @@ -163,5 +163,10 @@ public class WindowCallbackWrapper implements Window.Callback { public void onPointerCaptureChanged(boolean hasCapture) { mWrapped.onPointerCaptureChanged(hasCapture); } @Override public void onSystemBarAppearanceChanged(@WindowInsetsController.Appearance int appearance) { mWrapped.onSystemBarAppearanceChanged(appearance); } }