Merge "Introduce Window.DecorCallback"
This commit is contained in:
committed by
Android (Google) Code Review
commit
bd79361922
@@ -475,7 +475,7 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
private InputMethodPrivilegedOperations mPrivOps = new InputMethodPrivilegedOperations();
|
||||
|
||||
@NonNull
|
||||
final NavigationBarController mNavigationBarController =
|
||||
private final NavigationBarController mNavigationBarController =
|
||||
new NavigationBarController(this);
|
||||
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
@@ -1504,7 +1504,7 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.initSoftInputWindow");
|
||||
mWindow = new SoftInputWindow(this, mTheme, mDispatcherState);
|
||||
|
||||
mNavigationBarController.onSoftInputWindowCreated(mWindow);
|
||||
{
|
||||
final Window window = mWindow.getWindow();
|
||||
{
|
||||
|
||||
@@ -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
|
||||
@@ -361,6 +361,13 @@ final class NavigationBarController {
|
||||
== WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSoftInputWindowCreated(@NonNull SoftInputWindow softInputWindow) {
|
||||
final Window window = softInputWindow.getWindow();
|
||||
mAppearance = window.getSystemBarAppearance();
|
||||
window.setDecorCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewInitialized() {
|
||||
if (mDestroyed) {
|
||||
|
||||
@@ -31,7 +31,6 @@ 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;
|
||||
@@ -264,11 +263,6 @@ 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);
|
||||
|
||||
@@ -295,6 +295,9 @@ public abstract class Window {
|
||||
private OnWindowDismissedCallback mOnWindowDismissedCallback;
|
||||
private OnWindowSwipeDismissedCallback mOnWindowSwipeDismissedCallback;
|
||||
private WindowControllerCallback mWindowControllerCallback;
|
||||
@WindowInsetsController.Appearance
|
||||
private int mSystemBarAppearance;
|
||||
private DecorCallback mDecorCallback;
|
||||
private OnRestrictedCaptionAreaChangedListener mOnRestrictedCaptionAreaChangedListener;
|
||||
private Rect mRestrictedCaptionAreaRect;
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
@@ -607,17 +610,6 @@ 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 */
|
||||
@@ -672,6 +664,17 @@ public abstract class Window {
|
||||
void updateNavigationBarColor(int color);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public interface DecorCallback {
|
||||
/**
|
||||
* Called from
|
||||
* {@link com.android.internal.policy.DecorView#onSystemBarAppearanceChanged(int)}.
|
||||
*
|
||||
* @param appearance The newly applied appearance.
|
||||
*/
|
||||
void onSystemBarAppearanceChanged(@WindowInsetsController.Appearance int appearance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for clients that want to be aware of where caption draws content.
|
||||
*/
|
||||
@@ -996,6 +999,26 @@ public abstract class Window {
|
||||
return mWindowControllerCallback;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public final void setDecorCallback(DecorCallback decorCallback) {
|
||||
mDecorCallback = decorCallback;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@WindowInsetsController.Appearance
|
||||
public final int getSystemBarAppearance() {
|
||||
return mSystemBarAppearance;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public final void dispatchOnSystemBarAppearanceChanged(
|
||||
@WindowInsetsController.Appearance int appearance) {
|
||||
mSystemBarAppearance = appearance;
|
||||
if (mDecorCallback != null) {
|
||||
mDecorCallback.onSystemBarAppearanceChanged(appearance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback for changes of area where caption will draw its content.
|
||||
*
|
||||
|
||||
@@ -163,10 +163,5 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1035,10 +1035,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
||||
public void onSystemBarAppearanceChanged(@WindowInsetsController.Appearance int appearance) {
|
||||
updateColorViews(null /* insets */, true /* animate */);
|
||||
if (mWindow != null) {
|
||||
final Window.Callback callback = mWindow.getCallback();
|
||||
if (callback != null) {
|
||||
callback.onSystemBarAppearanceChanged(appearance);
|
||||
}
|
||||
mWindow.dispatchOnSystemBarAppearanceChanged(appearance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user