Merge "Window Manager Flag Migration (1/n)"
This commit is contained in:
@@ -602,4 +602,22 @@ public class InsetsController implements WindowInsetsController {
|
||||
mAnimCallbackScheduled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSystemBarsAppearance(@Appearance int appearance) {
|
||||
if (mViewRoot.mWindowAttributes.insetsFlags.appearance != appearance) {
|
||||
mViewRoot.mWindowAttributes.insetsFlags.appearance = appearance;
|
||||
mViewRoot.mWindowAttributesChanged = true;
|
||||
mViewRoot.scheduleTraversals();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSystemBarsBehavior(@Behavior int behavior) {
|
||||
if (mViewRoot.mWindowAttributes.insetsFlags.behavior != behavior) {
|
||||
mViewRoot.mWindowAttributes.insetsFlags.behavior = behavior;
|
||||
mViewRoot.mWindowAttributesChanged = true;
|
||||
mViewRoot.scheduleTraversals();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
core/java/android/view/InsetsFlags.java
Normal file
67
core/java/android/view/InsetsFlags.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.view;
|
||||
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_SIDE_BARS;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_TOP_BAR;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_BARS;
|
||||
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE;
|
||||
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
|
||||
|
||||
import android.view.WindowInsetsController.Appearance;
|
||||
import android.view.WindowInsetsController.Behavior;
|
||||
|
||||
/**
|
||||
* Contains the information about {@link Appearance} and {@link Behavior} of system windows which
|
||||
* can produce insets. This is for carrying the request from a client to the system server.
|
||||
* @hide
|
||||
*/
|
||||
public class InsetsFlags {
|
||||
|
||||
@ViewDebug.ExportedProperty(flagMapping = {
|
||||
@ViewDebug.FlagToString(
|
||||
mask = APPEARANCE_OPAQUE_BARS,
|
||||
equals = APPEARANCE_OPAQUE_BARS,
|
||||
name = "OPAQUE_BARS"),
|
||||
@ViewDebug.FlagToString(
|
||||
mask = APPEARANCE_LOW_PROFILE_BARS,
|
||||
equals = APPEARANCE_LOW_PROFILE_BARS,
|
||||
name = "LOW_PROFILE_BARS"),
|
||||
@ViewDebug.FlagToString(
|
||||
mask = APPEARANCE_LIGHT_TOP_BAR,
|
||||
equals = APPEARANCE_LIGHT_TOP_BAR,
|
||||
name = "LIGHT_TOP_BAR"),
|
||||
@ViewDebug.FlagToString(
|
||||
mask = APPEARANCE_LIGHT_SIDE_BARS,
|
||||
equals = APPEARANCE_LIGHT_SIDE_BARS,
|
||||
name = "LIGHT_SIDE_BARS")
|
||||
})
|
||||
public @Appearance int appearance;
|
||||
|
||||
@ViewDebug.ExportedProperty(flagMapping = {
|
||||
@ViewDebug.FlagToString(
|
||||
mask = BEHAVIOR_SHOW_BARS_BY_SWIPE,
|
||||
equals = BEHAVIOR_SHOW_BARS_BY_SWIPE,
|
||||
name = "SHOW_BARS_BY_SWIPE"),
|
||||
@ViewDebug.FlagToString(
|
||||
mask = BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE,
|
||||
equals = BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE,
|
||||
name = "SHOW_TRANSIENT_BARS_BY_SWIPE")
|
||||
})
|
||||
public @Behavior int behavior;
|
||||
}
|
||||
@@ -18,9 +18,14 @@ package android.view;
|
||||
|
||||
import static android.view.WindowInsets.Type.ime;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.graphics.Insets;
|
||||
import android.view.WindowInsets.Type.InsetType;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Interface to control windows that generate insets.
|
||||
*
|
||||
@@ -29,6 +34,73 @@ import android.view.WindowInsets.Type.InsetType;
|
||||
*/
|
||||
public interface WindowInsetsController {
|
||||
|
||||
/**
|
||||
* Makes system bars become opaque with solid dark background and light foreground.
|
||||
* @hide
|
||||
*/
|
||||
int APPEARANCE_OPAQUE_BARS = 1;
|
||||
|
||||
/**
|
||||
* Makes items on system bars become less noticeable without changing the layout of the bars.
|
||||
* @hide
|
||||
*/
|
||||
int APPEARANCE_LOW_PROFILE_BARS = 1 << 1;
|
||||
|
||||
/**
|
||||
* Changes the foreground color for the light top bar so that the items on the bar can be read
|
||||
* clearly.
|
||||
*/
|
||||
int APPEARANCE_LIGHT_TOP_BAR = 1 << 2;
|
||||
|
||||
/**
|
||||
* Changes the foreground color for the light side bars so that the items on the bar can be read
|
||||
* clearly.
|
||||
*/
|
||||
int APPEARANCE_LIGHT_SIDE_BARS = 1 << 3;
|
||||
|
||||
/** Determines the appearance of system bars. */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(flag = true, value = {APPEARANCE_OPAQUE_BARS, APPEARANCE_LOW_PROFILE_BARS,
|
||||
APPEARANCE_LIGHT_TOP_BAR, APPEARANCE_LIGHT_SIDE_BARS})
|
||||
@interface Appearance {
|
||||
}
|
||||
|
||||
/**
|
||||
* The default option for {@link #setSystemBarsBehavior(int)}. The side bars will be forcibly
|
||||
* shown by the system on any user interaction on the corresponding display if the side bars are
|
||||
* hidden by {@link #hide(int)} or {@link WindowInsetsAnimationController#changeInsets(Insets)}.
|
||||
*/
|
||||
int BEHAVIOR_SHOW_SIDE_BARS_BY_TOUCH = 0;
|
||||
|
||||
/**
|
||||
* Option for {@link #setSystemBarsBehavior(int)}: Window would like to remain interactive when
|
||||
* hiding the side bars by calling {@link #hide(int)} or
|
||||
* {@link WindowInsetsAnimationController#changeInsets(Insets)}.
|
||||
*
|
||||
* <p>When system bars are hidden in this mode, they can be revealed with system gestures, such
|
||||
* as swiping from the edge of the screen where the bar is hidden from.</p>
|
||||
*/
|
||||
int BEHAVIOR_SHOW_BARS_BY_SWIPE = 1;
|
||||
|
||||
/**
|
||||
* Option for {@link #setSystemBarsBehavior(int)}: Window would like to remain interactive when
|
||||
* hiding the side bars by calling {@link #hide(int)} or
|
||||
* {@link WindowInsetsAnimationController#changeInsets(Insets)}.
|
||||
*
|
||||
* <p>When system bars are hidden in this mode, they can be revealed temporarily with system
|
||||
* gestures, such as swiping from the edge of the screen where the bar is hidden from. These
|
||||
* transient system bars will overlay app’s content, may have some degree of transparency, and
|
||||
* will automatically hide after a short timeout.</p>
|
||||
*/
|
||||
int BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE = 2;
|
||||
|
||||
/** Determines the behavior of system bars when hiding them by calling {@link #hide}. */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(value = {BEHAVIOR_SHOW_SIDE_BARS_BY_TOUCH, BEHAVIOR_SHOW_BARS_BY_SWIPE,
|
||||
BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE})
|
||||
@interface Behavior {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a set of windows that cause insets appear on screen.
|
||||
* <p>
|
||||
@@ -108,4 +180,20 @@ public interface WindowInsetsController {
|
||||
default void hideInputMethod() {
|
||||
hide(ime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the appearance of system bars.
|
||||
*
|
||||
* @param appearance Bitmask of {@link Appearance} flags.
|
||||
* @see Appearance
|
||||
*/
|
||||
void setSystemBarsAppearance(@Appearance int appearance);
|
||||
|
||||
/**
|
||||
* Controls the behavior of system bars.
|
||||
*
|
||||
* @param behavior Determines how the bars behave when being hidden by the application.
|
||||
* @see Behavior
|
||||
*/
|
||||
void setSystemBarsBehavior(@Behavior int behavior);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package android.view;
|
||||
|
||||
import static android.content.pm.ActivityInfo.COLOR_MODE_DEFAULT;
|
||||
import static android.view.WindowLayoutParamsProto.ALPHA;
|
||||
import static android.view.WindowLayoutParamsProto.APPEARANCE;
|
||||
import static android.view.WindowLayoutParamsProto.BEHAVIOR;
|
||||
import static android.view.WindowLayoutParamsProto.BUTTON_BRIGHTNESS;
|
||||
import static android.view.WindowLayoutParamsProto.COLOR_MODE;
|
||||
import static android.view.WindowLayoutParamsProto.FLAGS;
|
||||
@@ -2612,6 +2614,14 @@ public interface WindowManager extends ViewManager {
|
||||
@ActivityInfo.ColorMode
|
||||
private int mColorMode = COLOR_MODE_DEFAULT;
|
||||
|
||||
/**
|
||||
* Carries the requests about {@link WindowInsetsController.Appearance} and
|
||||
* {@link WindowInsetsController.Behavior} to the system windows which can produce insets.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final InsetsFlags insetsFlags = new InsetsFlags();
|
||||
|
||||
public LayoutParams() {
|
||||
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
type = TYPE_APPLICATION;
|
||||
@@ -2774,6 +2784,8 @@ public interface WindowManager extends ViewManager {
|
||||
TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
|
||||
out.writeInt(mColorMode);
|
||||
out.writeLong(hideTimeoutMilliseconds);
|
||||
out.writeInt(insetsFlags.appearance);
|
||||
out.writeInt(insetsFlags.behavior);
|
||||
}
|
||||
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<LayoutParams> CREATOR
|
||||
@@ -2830,6 +2842,8 @@ public interface WindowManager extends ViewManager {
|
||||
accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mColorMode = in.readInt();
|
||||
hideTimeoutMilliseconds = in.readLong();
|
||||
insetsFlags.appearance = in.readInt();
|
||||
insetsFlags.behavior = in.readInt();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"PointlessBitwiseExpression"})
|
||||
@@ -2876,6 +2890,8 @@ public interface WindowManager extends ViewManager {
|
||||
/** {@hide} */
|
||||
public static final int COLOR_MODE_CHANGED = 1 << 26;
|
||||
/** {@hide} */
|
||||
public static final int INSET_FLAGS_CHANGED = 1 << 27;
|
||||
/** {@hide} */
|
||||
public static final int EVERYTHING_CHANGED = 0xffffffff;
|
||||
|
||||
// internal buffer to backup/restore parameters under compatibility mode.
|
||||
@@ -3065,6 +3081,16 @@ public interface WindowManager extends ViewManager {
|
||||
// This can't change, it's only set at window creation time.
|
||||
hideTimeoutMilliseconds = o.hideTimeoutMilliseconds;
|
||||
|
||||
if (insetsFlags.appearance != o.insetsFlags.appearance) {
|
||||
insetsFlags.appearance = o.insetsFlags.appearance;
|
||||
changes |= INSET_FLAGS_CHANGED;
|
||||
}
|
||||
|
||||
if (insetsFlags.behavior != o.insetsFlags.behavior) {
|
||||
insetsFlags.behavior = o.insetsFlags.behavior;
|
||||
changes |= INSET_FLAGS_CHANGED;
|
||||
}
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
@@ -3212,6 +3238,17 @@ public interface WindowManager extends ViewManager {
|
||||
sb.append(prefix).append(" vsysui=").append(ViewDebug.flagsToString(
|
||||
View.class, "mSystemUiVisibility", subtreeSystemUiVisibility));
|
||||
}
|
||||
if (insetsFlags.appearance != 0) {
|
||||
sb.append(System.lineSeparator());
|
||||
sb.append(prefix).append(" apr=").append(ViewDebug.flagsToString(
|
||||
InsetsFlags.class, "appearance", insetsFlags.appearance));
|
||||
}
|
||||
if (insetsFlags.behavior != 0) {
|
||||
sb.append(System.lineSeparator());
|
||||
sb.append(prefix).append(" bhv=").append(ViewDebug.flagsToString(
|
||||
InsetsFlags.class, "behavior", insetsFlags.behavior));
|
||||
}
|
||||
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -3247,6 +3284,8 @@ public interface WindowManager extends ViewManager {
|
||||
proto.write(PRIVATE_FLAGS, privateFlags);
|
||||
proto.write(SYSTEM_UI_VISIBILITY_FLAGS, systemUiVisibility);
|
||||
proto.write(SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS, subtreeSystemUiVisibility);
|
||||
proto.write(APPEARANCE, insetsFlags.appearance);
|
||||
proto.write(BEHAVIOR, insetsFlags.behavior);
|
||||
proto.end(token);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,4 +68,6 @@ message WindowLayoutParamsProto {
|
||||
optional uint32 private_flags = 26;
|
||||
optional uint32 system_ui_visibility_flags = 27;
|
||||
optional uint32 subtree_system_ui_visibility_flags = 28;
|
||||
optional uint32 appearance = 29;
|
||||
optional uint32 behavior = 30;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user