summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTiger Huang <tigerhuang@google.com>2019-11-21 16:23:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-11-21 16:23:32 +0000
commite155ed48fae8b64b8382c4e76768738214c6ff33 (patch)
tree16ca69ca1174de79fa02412768bdf0a2117c6f6c /core/java/android
parentc80b045c0ae896a2168f72280adca54c98cfe741 (diff)
parent332793ba05e286dec2ba83bc0ccd8bb2e4162099 (diff)
Merge "Window Manager Flag Migration (6/n)"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/IWindow.aidl6
-rw-r--r--core/java/android/view/ImeInsetsSourceConsumer.java4
-rw-r--r--core/java/android/view/InsetsAnimationControlImpl.java52
-rw-r--r--core/java/android/view/InsetsController.java44
-rw-r--r--core/java/android/view/InsetsFlags.java40
-rw-r--r--core/java/android/view/InsetsSource.java8
-rw-r--r--core/java/android/view/InsetsSourceConsumer.java6
-rw-r--r--core/java/android/view/InsetsSourceControl.java6
-rw-r--r--core/java/android/view/InsetsState.java241
-rw-r--r--core/java/android/view/ViewRootImpl.java10
-rw-r--r--core/java/android/view/WindowInsets.java156
-rw-r--r--core/java/android/view/WindowInsetsAnimationControlListener.java6
-rw-r--r--core/java/android/view/WindowInsetsAnimationController.java8
-rw-r--r--core/java/android/view/WindowInsetsAnimationListener.java6
-rw-r--r--core/java/android/view/WindowInsetsController.java51
15 files changed, 316 insertions, 328 deletions
diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl
index 37b685a23066..3927ebfdb5a8 100644
--- a/core/java/android/view/IWindow.aidl
+++ b/core/java/android/view/IWindow.aidl
@@ -69,14 +69,14 @@ oneway interface IWindow {
void insetsChanged(in InsetsState insetsState);
/**
- * Called when this window retrieved control over a specified set of inset sources.
+ * Called when this window retrieved control over a specified set of insets sources.
*/
void insetsControlChanged(in InsetsState insetsState, in InsetsSourceControl[] activeControls);
/**
* Called when a set of insets source window should be shown by policy.
*
- * @param types internal inset types (WindowInsets.Type.InsetType) to show
+ * @param types internal insets types (WindowInsets.Type.InsetsType) to show
* @param fromIme true if this request originated from IME (InputMethodService).
*/
void showInsets(int types, boolean fromIme);
@@ -84,7 +84,7 @@ oneway interface IWindow {
/**
* Called when a set of insets source window should be hidden by policy.
*
- * @param types internal inset types (WindowInsets.Type.InsetType) to hide
+ * @param types internal insets types (WindowInsets.Type.InsetsType) to hide
* @param fromIme true if this request originated from IME (InputMethodService).
*/
void hideInsets(int types, boolean fromIme);
diff --git a/core/java/android/view/ImeInsetsSourceConsumer.java b/core/java/android/view/ImeInsetsSourceConsumer.java
index 3bf44ac92a58..d0694375df53 100644
--- a/core/java/android/view/ImeInsetsSourceConsumer.java
+++ b/core/java/android/view/ImeInsetsSourceConsumer.java
@@ -16,7 +16,7 @@
package android.view;
-import static android.view.InsetsState.TYPE_IME;
+import static android.view.InsetsState.ITYPE_IME;
import android.inputmethodservice.InputMethodService;
import android.os.Parcel;
@@ -46,7 +46,7 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
public ImeInsetsSourceConsumer(
InsetsState state, Supplier<Transaction> transactionSupplier,
InsetsController controller) {
- super(TYPE_IME, state, transactionSupplier, controller);
+ super(ITYPE_IME, state, transactionSupplier, controller);
}
public void onPreRendered(EditorInfo info) {
diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java
index 786dbb088e2b..3d139cd73518 100644
--- a/core/java/android/view/InsetsAnimationControlImpl.java
+++ b/core/java/android/view/InsetsAnimationControlImpl.java
@@ -16,11 +16,11 @@
package android.view;
-import static android.view.InsetsState.INSET_SIDE_BOTTOM;
-import static android.view.InsetsState.INSET_SIDE_FLOATING;
-import static android.view.InsetsState.INSET_SIDE_LEFT;
-import static android.view.InsetsState.INSET_SIDE_RIGHT;
-import static android.view.InsetsState.INSET_SIDE_TOP;
+import static android.view.InsetsState.ISIDE_BOTTOM;
+import static android.view.InsetsState.ISIDE_FLOATING;
+import static android.view.InsetsState.ISIDE_LEFT;
+import static android.view.InsetsState.ISIDE_RIGHT;
+import static android.view.InsetsState.ISIDE_TOP;
import static android.view.InsetsState.toPublicType;
import android.annotation.Nullable;
@@ -31,9 +31,9 @@ import android.util.ArraySet;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.SparseSetArray;
-import android.view.InsetsState.InsetSide;
+import android.view.InsetsState.InternalInsetsSide;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
-import android.view.WindowInsets.Type.InsetType;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowInsetsAnimationListener.InsetsAnimation;
import android.view.WindowManager.LayoutParams;
@@ -63,7 +63,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
private final Insets mShownInsets;
private final Matrix mTmpMatrix = new Matrix();
private final InsetsState mInitialInsetsState;
- private final @InsetType int mTypes;
+ private final @InsetsType int mTypes;
private final Supplier<SyncRtSurfaceTransactionApplier> mTransactionApplierSupplier;
private final InsetsController mController;
private final WindowInsetsAnimationListener.InsetsAnimation mAnimation;
@@ -77,7 +77,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
@VisibleForTesting
public InsetsAnimationControlImpl(SparseArray<InsetsSourceConsumer> consumers, Rect frame,
InsetsState state, WindowInsetsAnimationControlListener listener,
- @InsetType int types,
+ @InsetsType int types,
Supplier<SyncRtSurfaceTransactionApplier> transactionApplierSupplier,
InsetsController controller) {
mConsumers = consumers;
@@ -118,8 +118,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
}
@Override
- @InsetType
- public int getTypes() {
+ @InsetsType public int getTypes() {
return mTypes;
}
@@ -147,12 +146,11 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
}
final Insets offset = Insets.subtract(mShownInsets, mPendingInsets);
ArrayList<SurfaceParams> params = new ArrayList<>();
- updateLeashesForSide(INSET_SIDE_LEFT, offset.left, mPendingInsets.left, params, state);
- updateLeashesForSide(INSET_SIDE_TOP, offset.top, mPendingInsets.top, params, state);
- updateLeashesForSide(INSET_SIDE_RIGHT, offset.right, mPendingInsets.right, params, state);
- updateLeashesForSide(INSET_SIDE_BOTTOM, offset.bottom, mPendingInsets.bottom, params,
- state);
- updateLeashesForSide(INSET_SIDE_FLOATING, 0 /* offset */, 0 /* inset */, params, state);
+ updateLeashesForSide(ISIDE_LEFT, offset.left, mPendingInsets.left, params, state);
+ updateLeashesForSide(ISIDE_TOP, offset.top, mPendingInsets.top, params, state);
+ updateLeashesForSide(ISIDE_RIGHT, offset.right, mPendingInsets.right, params, state);
+ updateLeashesForSide(ISIDE_BOTTOM, offset.bottom, mPendingInsets.bottom, params, state);
+ updateLeashesForSide(ISIDE_FLOATING, 0 /* offset */, 0 /* inset */, params, state);
SyncRtSurfaceTransactionApplier applier = mTransactionApplierSupplier.get();
applier.scheduleApply(params.toArray(new SurfaceParams[params.size()]));
@@ -195,7 +193,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
private Insets calculateInsets(InsetsState state, Rect frame,
SparseArray<InsetsSourceConsumer> consumers, boolean shown,
- @Nullable @InsetSide SparseIntArray typeSideMap) {
+ @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
for (int i = consumers.size() - 1; i >= 0; i--) {
state.getSource(consumers.valueAt(i).getType()).setVisible(shown);
}
@@ -203,7 +201,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
}
private Insets getInsetsFromState(InsetsState state, Rect frame,
- @Nullable @InsetSide SparseIntArray typeSideMap) {
+ @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
return state.calculateInsets(frame, false /* isScreenRound */,
false /* alwaysConsumerNavBar */, null /* displayCutout */,
null /* legacyContentInsets */, null /* legacyStableInsets */,
@@ -215,7 +213,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
return Insets.max(Insets.min(insets, mShownInsets), mHiddenInsets);
}
- private void updateLeashesForSide(@InsetSide int side, int offset, int inset,
+ private void updateLeashesForSide(@InternalInsetsSide int side, int offset, int inset,
ArrayList<SurfaceParams> surfaceParams, InsetsState state) {
ArraySet<InsetsSourceConsumer> items = mSideSourceMap.get(side);
if (items == null) {
@@ -242,27 +240,27 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
if (leash != null) {
surfaceParams.add(new SurfaceParams(leash, 1f /* alpha */, mTmpMatrix,
null /* windowCrop */, 0 /* layer */, 0f /* cornerRadius*/,
- side == INSET_SIDE_FLOATING
- ? consumer.isVisible() : inset != 0 /* visible */));
+ side == ISIDE_FLOATING ? consumer.isVisible() : inset != 0 /* visible */));
}
}
}
- private void addTranslationToMatrix(@InsetSide int side, int inset, Matrix m, Rect frame) {
+ private void addTranslationToMatrix(@InternalInsetsSide int side, int inset, Matrix m,
+ Rect frame) {
switch (side) {
- case INSET_SIDE_LEFT:
+ case ISIDE_LEFT:
m.postTranslate(-inset, 0);
frame.offset(-inset, 0);
break;
- case INSET_SIDE_TOP:
+ case ISIDE_TOP:
m.postTranslate(0, -inset);
frame.offset(0, -inset);
break;
- case INSET_SIDE_RIGHT:
+ case ISIDE_RIGHT:
m.postTranslate(inset, 0);
frame.offset(inset, 0);
break;
- case INSET_SIDE_BOTTOM:
+ case ISIDE_BOTTOM:
m.postTranslate(0, inset);
frame.offset(0, inset);
break;
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index eca6dcb1daac..3c93bb7a59b2 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -16,7 +16,7 @@
package android.view;
-import static android.view.InsetsState.TYPE_IME;
+import static android.view.InsetsState.ITYPE_IME;
import static android.view.InsetsState.toPublicType;
import static android.view.WindowInsets.Type.all;
@@ -35,10 +35,10 @@ import android.util.Pair;
import android.util.Property;
import android.util.SparseArray;
import android.view.InsetsSourceConsumer.ShowResult;
-import android.view.InsetsState.InternalInsetType;
+import android.view.InsetsState.InternalInsetsType;
import android.view.SurfaceControl.Transaction;
import android.view.WindowInsets.Type;
-import android.view.WindowInsets.Type.InsetType;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
@@ -220,11 +220,11 @@ public class InsetsController implements WindowInsetsController {
}
@Override
- public void show(@InsetType int types) {
+ public void show(@InsetsType int types) {
show(types, false /* fromIme */);
}
- void show(@InsetType int types, boolean fromIme) {
+ void show(@InsetsType int types, boolean fromIme) {
// TODO: Support a ResultReceiver for IME.
// TODO(b/123718661): Make show() work for multi-session IME.
int typesReady = 0;
@@ -232,7 +232,7 @@ public class InsetsController implements WindowInsetsController {
for (int i = internalTypes.size() - 1; i >= 0; i--) {
InsetsSourceConsumer consumer = getSourceConsumer(internalTypes.valueAt(i));
if (mAnimationDirection == DIRECTION_HIDE) {
- // Only one animator (with multiple InsetType) can run at a time.
+ // Only one animator (with multiple InsetsType) can run at a time.
// previous one should be cancelled for simplicity.
cancelExistingAnimation();
} else if (consumer.isVisible()
@@ -250,11 +250,11 @@ public class InsetsController implements WindowInsetsController {
}
@Override
- public void hide(@InsetType int types) {
+ public void hide(@InsetsType int types) {
hide(types, false /* fromIme */);
}
- void hide(@InsetType int types, boolean fromIme) {
+ void hide(@InsetsType int types, boolean fromIme) {
int typesReady = 0;
final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
for (int i = internalTypes.size() - 1; i >= 0; i--) {
@@ -273,12 +273,12 @@ public class InsetsController implements WindowInsetsController {
}
@Override
- public void controlWindowInsetsAnimation(@InsetType int types,
+ public void controlWindowInsetsAnimation(@InsetsType int types,
WindowInsetsAnimationControlListener listener) {
controlWindowInsetsAnimation(types, listener, false /* fromIme */);
}
- private void controlWindowInsetsAnimation(@InsetType int types,
+ private void controlWindowInsetsAnimation(@InsetsType int types,
WindowInsetsAnimationControlListener listener, boolean fromIme) {
// If the frame of our window doesn't span the entire display, the control API makes very
// little sense, as we don't deal with negative insets. So just cancel immediately.
@@ -289,7 +289,7 @@ public class InsetsController implements WindowInsetsController {
controlAnimationUnchecked(types, listener, mFrame, fromIme);
}
- private void controlAnimationUnchecked(@InsetType int types,
+ private void controlAnimationUnchecked(@InsetsType int types,
WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme) {
if (types == 0) {
// nothing to animate.
@@ -350,7 +350,7 @@ public class InsetsController implements WindowInsetsController {
// with animation of other types.
if (mPendingTypesToShow != 0) {
// remove IME from pending because view no longer has focus.
- mPendingTypesToShow &= ~InsetsState.toPublicType(TYPE_IME);
+ mPendingTypesToShow &= ~InsetsState.toPublicType(ITYPE_IME);
}
break;
}
@@ -368,7 +368,7 @@ public class InsetsController implements WindowInsetsController {
return new Pair<>(typesReady, isReady);
}
- private int collectPendingConsumers(@InsetType int typesReady,
+ private int collectPendingConsumers(@InsetsType int typesReady,
SparseArray<InsetsSourceConsumer> consumers) {
if (mPendingTypesToShow != 0) {
typesReady |= mPendingTypesToShow;
@@ -382,7 +382,7 @@ public class InsetsController implements WindowInsetsController {
return typesReady;
}
- private void cancelExistingControllers(@InsetType int types) {
+ private void cancelExistingControllers(@InsetsType int types) {
for (int i = mAnimationControls.size() - 1; i >= 0; i--) {
InsetsAnimationControlImpl control = mAnimationControls.get(i);
if ((control.getTypes() & types) != 0) {
@@ -420,7 +420,7 @@ public class InsetsController implements WindowInsetsController {
}
@VisibleForTesting
- public @NonNull InsetsSourceConsumer getSourceConsumer(@InternalInsetType int type) {
+ public @NonNull InsetsSourceConsumer getSourceConsumer(@InternalInsetsType int type) {
InsetsSourceConsumer controller = mSourceConsumers.get(type);
if (controller != null) {
return controller;
@@ -440,14 +440,14 @@ public class InsetsController implements WindowInsetsController {
* Called when current window gains focus.
*/
public void onWindowFocusGained() {
- getSourceConsumer(TYPE_IME).onWindowFocusGained();
+ getSourceConsumer(ITYPE_IME).onWindowFocusGained();
}
/**
* Called when current window loses focus.
*/
public void onWindowFocusLost() {
- getSourceConsumer(TYPE_IME).onWindowFocusLost();
+ getSourceConsumer(ITYPE_IME).onWindowFocusLost();
}
ViewRootImpl getViewRoot() {
@@ -468,7 +468,7 @@ public class InsetsController implements WindowInsetsController {
}
private InsetsSourceConsumer createConsumerOfType(int type) {
- if (type == TYPE_IME) {
+ if (type == ITYPE_IME) {
return new ImeInsetsSourceConsumer(mState, Transaction::new, this);
} else {
return new InsetsSourceConsumer(type, mState, Transaction::new, this);
@@ -495,7 +495,7 @@ public class InsetsController implements WindowInsetsController {
}
}
- private void applyAnimation(@InsetType final int types, boolean show, boolean fromIme) {
+ private void applyAnimation(@InsetsType final int types, boolean show, boolean fromIme) {
if (types == 0) {
// nothing to animate.
return;
@@ -554,14 +554,14 @@ public class InsetsController implements WindowInsetsController {
controlAnimationUnchecked(types, listener, mState.getDisplayFrame(), fromIme);
}
- private void hideDirectly(@InsetType int types) {
+ private void hideDirectly(@InsetsType int types) {
final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
for (int i = internalTypes.size() - 1; i >= 0; i--) {
getSourceConsumer(internalTypes.valueAt(i)).hide();
}
}
- private void showDirectly(@InsetType int types) {
+ private void showDirectly(@InsetsType int types) {
final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
for (int i = internalTypes.size() - 1; i >= 0; i--) {
getSourceConsumer(internalTypes.valueAt(i)).show();
@@ -569,7 +569,7 @@ public class InsetsController implements WindowInsetsController {
}
/**
- * Cancel on-going animation to show/hide {@link InsetType}.
+ * Cancel on-going animation to show/hide {@link InsetsType}.
*/
@VisibleForTesting
public void cancelExistingAnimation() {
diff --git a/core/java/android/view/InsetsFlags.java b/core/java/android/view/InsetsFlags.java
index 6e459b22e657..385b0bf960ef 100644
--- a/core/java/android/view/InsetsFlags.java
+++ b/core/java/android/view/InsetsFlags.java
@@ -23,11 +23,11 @@ import static android.view.View.STATUS_BAR_TRANSPARENT;
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
import static android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE;
-import static android.view.WindowInsetsController.APPEARANCE_LIGHT_SIDE_BARS;
-import static android.view.WindowInsetsController.APPEARANCE_LIGHT_TOP_BAR;
+import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
+import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
-import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_SIDE_BARS;
-import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_TOP_BAR;
+import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_NAVIGATION_BARS;
+import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS;
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE;
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
@@ -43,25 +43,25 @@ public class InsetsFlags {
@ViewDebug.ExportedProperty(flagMapping = {
@ViewDebug.FlagToString(
- mask = APPEARANCE_OPAQUE_TOP_BAR,
- equals = APPEARANCE_OPAQUE_TOP_BAR,
- name = "OPAQUE_TOP_BAR"),
+ mask = APPEARANCE_OPAQUE_STATUS_BARS,
+ equals = APPEARANCE_OPAQUE_STATUS_BARS,
+ name = "OPAQUE_STATUS_BARS"),
@ViewDebug.FlagToString(
- mask = APPEARANCE_OPAQUE_SIDE_BARS,
- equals = APPEARANCE_OPAQUE_SIDE_BARS,
- name = "OPAQUE_SIDE_BARS"),
+ mask = APPEARANCE_OPAQUE_NAVIGATION_BARS,
+ equals = APPEARANCE_OPAQUE_NAVIGATION_BARS,
+ name = "OPAQUE_NAVIGATION_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"),
+ mask = APPEARANCE_LIGHT_STATUS_BARS,
+ equals = APPEARANCE_LIGHT_STATUS_BARS,
+ name = "LIGHT_STATUS_BARS"),
@ViewDebug.FlagToString(
- mask = APPEARANCE_LIGHT_SIDE_BARS,
- equals = APPEARANCE_LIGHT_SIDE_BARS,
- name = "LIGHT_SIDE_BARS")
+ mask = APPEARANCE_LIGHT_NAVIGATION_BARS,
+ equals = APPEARANCE_LIGHT_NAVIGATION_BARS,
+ name = "LIGHT_NAVIGATION_BARS")
})
public @Appearance int appearance;
@@ -88,14 +88,14 @@ public class InsetsFlags {
appearance |= convertFlag(systemUiVisibility, SYSTEM_UI_FLAG_LOW_PROFILE,
APPEARANCE_LOW_PROFILE_BARS);
appearance |= convertFlag(systemUiVisibility, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR,
- APPEARANCE_LIGHT_TOP_BAR);
+ APPEARANCE_LIGHT_STATUS_BARS);
appearance |= convertFlag(systemUiVisibility, SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR,
- APPEARANCE_LIGHT_SIDE_BARS);
+ APPEARANCE_LIGHT_NAVIGATION_BARS);
appearance |= convertNoFlag(systemUiVisibility,
- STATUS_BAR_TRANSLUCENT | STATUS_BAR_TRANSPARENT, APPEARANCE_OPAQUE_TOP_BAR);
+ STATUS_BAR_TRANSLUCENT | STATUS_BAR_TRANSPARENT, APPEARANCE_OPAQUE_STATUS_BARS);
appearance |= convertNoFlag(systemUiVisibility,
NAVIGATION_BAR_TRANSLUCENT | NAVIGATION_BAR_TRANSPARENT,
- APPEARANCE_OPAQUE_SIDE_BARS);
+ APPEARANCE_OPAQUE_NAVIGATION_BARS);
return appearance;
}
diff --git a/core/java/android/view/InsetsSource.java b/core/java/android/view/InsetsSource.java
index 16e00da82e1a..1a33ea9dd6fd 100644
--- a/core/java/android/view/InsetsSource.java
+++ b/core/java/android/view/InsetsSource.java
@@ -20,7 +20,7 @@ import android.graphics.Insets;
import android.graphics.Rect;
import android.os.Parcel;
import android.os.Parcelable;
-import android.view.InsetsState.InternalInsetType;
+import android.view.InsetsState.InternalInsetsType;
import java.io.PrintWriter;
@@ -30,7 +30,7 @@ import java.io.PrintWriter;
*/
public class InsetsSource implements Parcelable {
- private final @InternalInsetType int mType;
+ private final @InternalInsetsType int mType;
/** Frame of the source in screen coordinate space */
private final Rect mFrame;
@@ -38,7 +38,7 @@ public class InsetsSource implements Parcelable {
private final Rect mTmpFrame = new Rect();
- public InsetsSource(@InternalInsetType int type) {
+ public InsetsSource(@InternalInsetsType int type) {
mType = type;
mFrame = new Rect();
}
@@ -57,7 +57,7 @@ public class InsetsSource implements Parcelable {
mVisible = visible;
}
- public @InternalInsetType int getType() {
+ public @InternalInsetsType int getType() {
return mType;
}
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java
index 08d45a746dc4..b1caf1872de2 100644
--- a/core/java/android/view/InsetsSourceConsumer.java
+++ b/core/java/android/view/InsetsSourceConsumer.java
@@ -18,7 +18,7 @@ package android.view;
import android.annotation.IntDef;
import android.annotation.Nullable;
-import android.view.InsetsState.InternalInsetType;
+import android.view.InsetsState.InternalInsetsType;
import android.view.SurfaceControl.Transaction;
import com.android.internal.annotations.VisibleForTesting;
@@ -55,12 +55,12 @@ public class InsetsSourceConsumer {
protected final InsetsController mController;
protected boolean mVisible;
private final Supplier<Transaction> mTransactionSupplier;
- private final @InternalInsetType int mType;
+ private final @InternalInsetsType int mType;
private final InsetsState mState;
private @Nullable InsetsSourceControl mSourceControl;
private boolean mHasWindowFocus;
- public InsetsSourceConsumer(@InternalInsetType int type, InsetsState state,
+ public InsetsSourceConsumer(@InternalInsetsType int type, InsetsState state,
Supplier<Transaction> transactionSupplier, InsetsController controller) {
mType = type;
mState = state;
diff --git a/core/java/android/view/InsetsSourceControl.java b/core/java/android/view/InsetsSourceControl.java
index 4919074ec252..bcf5c7875894 100644
--- a/core/java/android/view/InsetsSourceControl.java
+++ b/core/java/android/view/InsetsSourceControl.java
@@ -20,7 +20,7 @@ import android.annotation.Nullable;
import android.graphics.Point;
import android.os.Parcel;
import android.os.Parcelable;
-import android.view.InsetsState.InternalInsetType;
+import android.view.InsetsState.InternalInsetsType;
/**
* Represents a parcelable object to allow controlling a single {@link InsetsSource}.
@@ -28,11 +28,11 @@ import android.view.InsetsState.InternalInsetType;
*/
public class InsetsSourceControl implements Parcelable {
- private final @InternalInsetType int mType;
+ private final @InternalInsetsType int mType;
private final @Nullable SurfaceControl mLeash;
private final Point mSurfacePosition;
- public InsetsSourceControl(@InternalInsetType int type, @Nullable SurfaceControl leash,
+ public InsetsSourceControl(@InternalInsetsType int type, @Nullable SurfaceControl leash,
Point surfacePosition) {
mType = type;
mLeash = leash;
diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java
index e9de3f0bb3ca..e3fed3a5dce3 100644
--- a/core/java/android/view/InsetsState.java
+++ b/core/java/android/view/InsetsState.java
@@ -34,7 +34,7 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.SparseIntArray;
import android.view.WindowInsets.Type;
-import android.view.WindowInsets.Type.InsetType;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowManager.LayoutParams;
import java.io.PrintWriter;
@@ -54,71 +54,59 @@ public class InsetsState implements Parcelable {
* at the same time.
*/
@Retention(RetentionPolicy.SOURCE)
- @IntDef(prefix = "TYPE", value = {
- TYPE_TOP_BAR,
- TYPE_SIDE_BAR_1,
- TYPE_SIDE_BAR_2,
- TYPE_SIDE_BAR_3,
- TYPE_TOP_GESTURES,
- TYPE_BOTTOM_GESTURES,
- TYPE_LEFT_GESTURES,
- TYPE_RIGHT_GESTURES,
- TYPE_TOP_TAPPABLE_ELEMENT,
- TYPE_BOTTOM_TAPPABLE_ELEMENT,
- TYPE_IME
+ @IntDef(prefix = "ITYPE", value = {
+ ITYPE_STATUS_BAR,
+ ITYPE_NAVIGATION_BAR,
+ ITYPE_CAPTION_BAR,
+ ITYPE_TOP_GESTURES,
+ ITYPE_BOTTOM_GESTURES,
+ ITYPE_LEFT_GESTURES,
+ ITYPE_RIGHT_GESTURES,
+ ITYPE_TOP_TAPPABLE_ELEMENT,
+ ITYPE_BOTTOM_TAPPABLE_ELEMENT,
+ ITYPE_IME
})
- public @interface InternalInsetType {}
+ public @interface InternalInsetsType {}
static final int FIRST_TYPE = 0;
- /** Top bar. Can be status bar or caption in freeform windowing mode. */
- public static final int TYPE_TOP_BAR = FIRST_TYPE;
+ public static final int ITYPE_STATUS_BAR = FIRST_TYPE;
+ public static final int ITYPE_NAVIGATION_BAR = 1;
+ public static final int ITYPE_CAPTION_BAR = 2;
- /**
- * Up to 3 side bars that appear on left/right/bottom. On phones there is only one side bar
- * (the navigation bar, see {@link #TYPE_NAVIGATION_BAR}), but other form factors might have
- * multiple, like Android Auto.
- */
- public static final int TYPE_SIDE_BAR_1 = 1;
- public static final int TYPE_SIDE_BAR_2 = 2;
- public static final int TYPE_SIDE_BAR_3 = 3;
-
- public static final int TYPE_TOP_GESTURES = 4;
- public static final int TYPE_BOTTOM_GESTURES = 5;
- public static final int TYPE_LEFT_GESTURES = 6;
- public static final int TYPE_RIGHT_GESTURES = 7;
- public static final int TYPE_TOP_TAPPABLE_ELEMENT = 8;
- public static final int TYPE_BOTTOM_TAPPABLE_ELEMENT = 9;
+ public static final int ITYPE_TOP_GESTURES = 3;
+ public static final int ITYPE_BOTTOM_GESTURES = 4;
+ public static final int ITYPE_LEFT_GESTURES = 5;
+ public static final int ITYPE_RIGHT_GESTURES = 6;
+ public static final int ITYPE_TOP_TAPPABLE_ELEMENT = 7;
+ public static final int ITYPE_BOTTOM_TAPPABLE_ELEMENT = 8;
/** Input method window. */
- public static final int TYPE_IME = 10;
+ public static final int ITYPE_IME = 9;
- static final int LAST_TYPE = TYPE_IME;
+ static final int LAST_TYPE = ITYPE_IME;
// Derived types
- /** First side bar is navigation bar. */
- public static final int TYPE_NAVIGATION_BAR = TYPE_SIDE_BAR_1;
-
/** A shelf is the same as the navigation bar. */
- public static final int TYPE_SHELF = TYPE_NAVIGATION_BAR;
+ public static final int ITYPE_SHELF = ITYPE_NAVIGATION_BAR;
@Retention(RetentionPolicy.SOURCE)
- @IntDef(prefix = "INSET_SIDE", value = {
- INSET_SIDE_LEFT,
- INSET_SIDE_TOP,
- INSET_SIDE_RIGHT,
- INSET_SIDE_BOTTOM,
- INSET_SIDE_FLOATING,
- INSET_SIDE_UNKNWON
+ @IntDef(prefix = "IINSETS_SIDE", value = {
+ ISIDE_LEFT,
+ ISIDE_TOP,
+ ISIDE_RIGHT,
+ ISIDE_BOTTOM,
+ ISIDE_FLOATING,
+ ISIDE_UNKNOWN
})
- public @interface InsetSide {}
- static final int INSET_SIDE_LEFT = 0;
- static final int INSET_SIDE_TOP = 1;
- static final int INSET_SIDE_RIGHT = 2;
- static final int INSET_SIDE_BOTTOM = 3;
- static final int INSET_SIDE_FLOATING = 4;
- static final int INSET_SIDE_UNKNWON = 5;
+ public @interface InternalInsetsSide {}
+ static final int ISIDE_LEFT = 0;
+ static final int ISIDE_TOP = 1;
+ static final int ISIDE_RIGHT = 2;
+ static final int ISIDE_BOTTOM = 3;
+ static final int ISIDE_FLOATING = 4;
+ static final int ISIDE_UNKNOWN = 5;
private final ArrayMap<Integer, InsetsSource> mSources = new ArrayMap<>();
@@ -147,7 +135,7 @@ public class InsetsState implements Parcelable {
public WindowInsets calculateInsets(Rect frame, boolean isScreenRound,
boolean alwaysConsumeSystemBars, DisplayCutout cutout,
@Nullable Rect legacyContentInsets, @Nullable Rect legacyStableInsets,
- int legacySoftInputMode, @Nullable @InsetSide SparseIntArray typeSideMap) {
+ int legacySoftInputMode, @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
Insets[] typeInsetsMap = new Insets[Type.SIZE];
Insets[] typeMaxInsetsMap = new Insets[Type.SIZE];
boolean[] typeVisibilityMap = new boolean[SIZE];
@@ -165,10 +153,10 @@ public class InsetsState implements Parcelable {
}
boolean skipNonImeInImeMode = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_IME
- && source.getType() != TYPE_IME;
+ && source.getType() != ITYPE_IME;
boolean skipSystemBars = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL
- && (type == TYPE_TOP_BAR || type == TYPE_NAVIGATION_BAR);
- boolean skipIme = source.getType() == TYPE_IME
+ && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR);
+ boolean skipIme = source.getType() == ITYPE_IME
&& (legacySoftInputMode & LayoutParams.SOFT_INPUT_ADJUST_RESIZE) == 0;
boolean skipLegacyTypes = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE
&& (toPublicType(type) & Type.compatSystemInsets()) != 0;
@@ -182,7 +170,7 @@ public class InsetsState implements Parcelable {
// IME won't be reported in max insets as the size depends on the EditorInfo of the IME
// target.
- if (source.getType() != TYPE_IME) {
+ if (source.getType() != ITYPE_IME) {
processSource(source, relativeFrameMax, true /* ignoreVisibility */,
typeMaxInsetsMap, null /* typeSideMap */, null /* typeVisibilityMap */);
}
@@ -192,7 +180,7 @@ public class InsetsState implements Parcelable {
}
private void processSource(InsetsSource source, Rect relativeFrame, boolean ignoreVisibility,
- Insets[] typeInsetsMap, @Nullable @InsetSide SparseIntArray typeSideMap,
+ Insets[] typeInsetsMap, @Nullable @InternalInsetsSide SparseIntArray typeSideMap,
@Nullable boolean[] typeVisibilityMap) {
Insets insets = source.calculateInsets(relativeFrame, ignoreVisibility);
@@ -212,7 +200,7 @@ public class InsetsState implements Parcelable {
}
private void processSourceAsPublicType(InsetsSource source, Insets[] typeInsetsMap,
- @InsetSide @Nullable SparseIntArray typeSideMap,
+ @InternalInsetsSide @Nullable SparseIntArray typeSideMap,
@Nullable boolean[] typeVisibilityMap, Insets insets, int type) {
int index = indexOf(type);
Insets existing = typeInsetsMap[index];
@@ -227,8 +215,8 @@ public class InsetsState implements Parcelable {
}
if (typeSideMap != null) {
- @InsetSide int insetSide = getInsetSide(insets);
- if (insetSide != INSET_SIDE_UNKNWON) {
+ @InternalInsetsSide int insetSide = getInsetSide(insets);
+ if (insetSide != ISIDE_UNKNOWN) {
typeSideMap.put(source.getType(), insetSide);
}
}
@@ -238,26 +226,26 @@ public class InsetsState implements Parcelable {
* Retrieves the side for a certain {@code insets}. It is required that only one field l/t/r/b
* is set in order that this method returns a meaningful result.
*/
- private @InsetSide int getInsetSide(Insets insets) {
+ private @InternalInsetsSide int getInsetSide(Insets insets) {
if (Insets.NONE.equals(insets)) {
- return INSET_SIDE_FLOATING;
+ return ISIDE_FLOATING;
}
if (insets.left != 0) {
- return INSET_SIDE_LEFT;
+ return ISIDE_LEFT;
}
if (insets.top != 0) {
- return INSET_SIDE_TOP;
+ return ISIDE_TOP;
}
if (insets.right != 0) {
- return INSET_SIDE_RIGHT;
+ return ISIDE_RIGHT;
}
if (insets.bottom != 0) {
- return INSET_SIDE_BOTTOM;
+ return ISIDE_BOTTOM;
}
- return INSET_SIDE_UNKNWON;
+ return ISIDE_UNKNOWN;
}
- public InsetsSource getSource(@InternalInsetType int type) {
+ public InsetsSource getSource(@InternalInsetsType int type) {
return mSources.computeIfAbsent(type, InsetsSource::new);
}
@@ -273,19 +261,19 @@ public class InsetsState implements Parcelable {
* Modifies the state of this class to exclude a certain type to make it ready for dispatching
* to the client.
*
- * @param type The {@link InternalInsetType} of the source to remove
+ * @param type The {@link InternalInsetsType} of the source to remove
*/
- public void removeSource(@InternalInsetType int type) {
+ public void removeSource(@InternalInsetsType int type) {
mSources.remove(type);
}
/**
* A shortcut for setting the visibility of the source.
*
- * @param type The {@link InternalInsetType} of the source to set the visibility
+ * @param type The {@link InternalInsetsType} of the source to set the visibility
* @param visible {@code true} for visible
*/
- public void setSourceVisible(@InternalInsetType int type, boolean visible) {
+ public void setSourceVisible(@InternalInsetsType int type, boolean visible) {
InsetsSource source = mSources.get(type);
if (source != null) {
source.setVisible(visible);
@@ -321,62 +309,53 @@ public class InsetsState implements Parcelable {
return mSources.valueAt(index);
}
- public static @InternalInsetType ArraySet<Integer> toInternalType(@InsetType int insetTypes) {
+ public static @InternalInsetsType ArraySet<Integer> toInternalType(@InsetsType int types) {
final ArraySet<Integer> result = new ArraySet<>();
- if ((insetTypes & Type.TOP_BAR) != 0) {
- result.add(TYPE_TOP_BAR);
+ if ((types & Type.STATUS_BARS) != 0) {
+ result.add(ITYPE_STATUS_BAR);
+ }
+ if ((types & Type.NAVIGATION_BARS) != 0) {
+ result.add(ITYPE_NAVIGATION_BAR);
}
- if ((insetTypes & Type.SIDE_BARS) != 0) {
- result.add(TYPE_SIDE_BAR_1);
- result.add(TYPE_SIDE_BAR_2);
- result.add(TYPE_SIDE_BAR_3);
+ if ((types & Type.CAPTION_BAR) != 0) {
+ result.add(ITYPE_CAPTION_BAR);
}
- if ((insetTypes & Type.IME) != 0) {
- result.add(TYPE_IME);
+ if ((types & Type.IME) != 0) {
+ result.add(ITYPE_IME);
}
return result;
}
- static @InsetType int toPublicType(@InternalInsetType int type) {
+ static @Type.InsetsType int toPublicType(@InternalInsetsType int type) {
switch (type) {
- case TYPE_TOP_BAR:
- return Type.TOP_BAR;
- case TYPE_SIDE_BAR_1:
- case TYPE_SIDE_BAR_2:
- case TYPE_SIDE_BAR_3:
- return Type.SIDE_BARS;
- case TYPE_IME:
+ case ITYPE_STATUS_BAR:
+ return Type.STATUS_BARS;
+ case ITYPE_NAVIGATION_BAR:
+ return Type.NAVIGATION_BARS;
+ case ITYPE_CAPTION_BAR:
+ return Type.CAPTION_BAR;
+ case ITYPE_IME:
return Type.IME;
- case TYPE_TOP_GESTURES:
- case TYPE_BOTTOM_GESTURES:
+ case ITYPE_TOP_GESTURES:
+ case ITYPE_BOTTOM_GESTURES:
return Type.MANDATORY_SYSTEM_GESTURES;
- case TYPE_LEFT_GESTURES:
- case TYPE_RIGHT_GESTURES:
+ case ITYPE_LEFT_GESTURES:
+ case ITYPE_RIGHT_GESTURES:
return Type.SYSTEM_GESTURES;
- case TYPE_TOP_TAPPABLE_ELEMENT:
- case TYPE_BOTTOM_TAPPABLE_ELEMENT:
+ case ITYPE_TOP_TAPPABLE_ELEMENT:
+ case ITYPE_BOTTOM_TAPPABLE_ELEMENT:
return Type.TAPPABLE_ELEMENT;
default:
throw new IllegalArgumentException("Unknown type: " + type);
}
}
- public static boolean getDefaultVisibility(@InsetType int type) {
- switch (type) {
- case TYPE_TOP_BAR:
- case TYPE_SIDE_BAR_1:
- case TYPE_SIDE_BAR_2:
- case TYPE_SIDE_BAR_3:
- return true;
- case TYPE_IME:
- return false;
- default:
- return true;
- }
+ public static boolean getDefaultVisibility(@InsetsType int type) {
+ return type != ITYPE_IME;
}
- public static boolean containsType(@InternalInsetType int[] types,
- @InternalInsetType int type) {
+ public static boolean containsType(@InternalInsetsType int[] types,
+ @InternalInsetsType int type) {
if (types == null) {
return false;
}
@@ -395,30 +374,30 @@ public class InsetsState implements Parcelable {
}
}
- public static String typeToString(@InternalInsetType int type) {
+ public static String typeToString(@InternalInsetsType int type) {
switch (type) {
- case TYPE_TOP_BAR:
- return "TYPE_TOP_BAR";
- case TYPE_SIDE_BAR_1:
- return "TYPE_SIDE_BAR_1";
- case TYPE_SIDE_BAR_2:
- return "TYPE_SIDE_BAR_2";
- case TYPE_SIDE_BAR_3:
- return "TYPE_SIDE_BAR_3";
- case TYPE_TOP_GESTURES:
- return "TYPE_TOP_GESTURES";
- case TYPE_BOTTOM_GESTURES:
- return "TYPE_BOTTOM_GESTURES";
- case TYPE_LEFT_GESTURES:
- return "TYPE_LEFT_GESTURES";
- case TYPE_RIGHT_GESTURES:
- return "TYPE_RIGHT_GESTURES";
- case TYPE_TOP_TAPPABLE_ELEMENT:
- return "TYPE_TOP_TAPPABLE_ELEMENT";
- case TYPE_BOTTOM_TAPPABLE_ELEMENT:
- return "TYPE_BOTTOM_TAPPABLE_ELEMENT";
+ case ITYPE_STATUS_BAR:
+ return "ITYPE_STATUS_BAR";
+ case ITYPE_NAVIGATION_BAR:
+ return "ITYPE_NAVIGATION_BAR";
+ case ITYPE_CAPTION_BAR:
+ return "ITYPE_CAPTION_BAR";
+ case ITYPE_TOP_GESTURES:
+ return "ITYPE_TOP_GESTURES";
+ case ITYPE_BOTTOM_GESTURES:
+ return "ITYPE_BOTTOM_GESTURES";
+ case ITYPE_LEFT_GESTURES:
+ return "ITYPE_LEFT_GESTURES";
+ case ITYPE_RIGHT_GESTURES:
+ return "ITYPE_RIGHT_GESTURES";
+ case ITYPE_TOP_TAPPABLE_ELEMENT:
+ return "ITYPE_TOP_TAPPABLE_ELEMENT";
+ case ITYPE_BOTTOM_TAPPABLE_ELEMENT:
+ return "ITYPE_BOTTOM_TAPPABLE_ELEMENT";
+ case ITYPE_IME:
+ return "ITYPE_IME";
default:
- return "TYPE_UNKNOWN_" + type;
+ return "ITYPE_UNKNOWN_" + type;
}
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 2ea3b6370b1e..89b111ddfb0b 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -93,7 +93,7 @@ import android.view.SurfaceControl.Transaction;
import android.view.View.AttachInfo;
import android.view.View.FocusDirection;
import android.view.View.MeasureSpec;
-import android.view.WindowInsets.Type.InsetType;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowManager.LayoutParams.SoftInputModeFlags;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -7504,11 +7504,11 @@ public final class ViewRootImpl implements ViewParent,
mHandler.obtainMessage(MSG_INSETS_CONTROL_CHANGED, args).sendToTarget();
}
- private void showInsets(@InsetType int types, boolean fromIme) {
+ private void showInsets(@InsetsType int types, boolean fromIme) {
mHandler.obtainMessage(MSG_SHOW_INSETS, types, fromIme ? 1 : 0).sendToTarget();
}
- private void hideInsets(@InsetType int types, boolean fromIme) {
+ private void hideInsets(@InsetsType int types, boolean fromIme) {
mHandler.obtainMessage(MSG_HIDE_INSETS, types, fromIme ? 1 : 0).sendToTarget();
}
@@ -8627,7 +8627,7 @@ public final class ViewRootImpl implements ViewParent,
}
@Override
- public void showInsets(@InsetType int types, boolean fromIme) {
+ public void showInsets(@InsetsType int types, boolean fromIme) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
viewAncestor.showInsets(types, fromIme);
@@ -8635,7 +8635,7 @@ public final class ViewRootImpl implements ViewParent,
}
@Override
- public void hideInsets(@InsetType int types, boolean fromIme) {
+ public void hideInsets(@InsetsType int types, boolean fromIme) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
viewAncestor.hideInsets(types, fromIme);
diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java
index bcc6a552f569..57bd5bb8cae8 100644
--- a/core/java/android/view/WindowInsets.java
+++ b/core/java/android/view/WindowInsets.java
@@ -21,11 +21,11 @@ import static android.view.WindowInsets.Type.FIRST;
import static android.view.WindowInsets.Type.IME;
import static android.view.WindowInsets.Type.LAST;
import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES;
-import static android.view.WindowInsets.Type.SIDE_BARS;
+import static android.view.WindowInsets.Type.NAVIGATION_BARS;
import static android.view.WindowInsets.Type.SIZE;
+import static android.view.WindowInsets.Type.STATUS_BARS;
import static android.view.WindowInsets.Type.SYSTEM_GESTURES;
import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT;
-import static android.view.WindowInsets.Type.TOP_BAR;
import static android.view.WindowInsets.Type.all;
import static android.view.WindowInsets.Type.compatSystemInsets;
import static android.view.WindowInsets.Type.indexOf;
@@ -39,7 +39,7 @@ import android.content.Intent;
import android.graphics.Insets;
import android.graphics.Rect;
import android.util.SparseArray;
-import android.view.WindowInsets.Type.InsetType;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethod;
@@ -175,9 +175,9 @@ public final class WindowInsets {
/**
* @return The insets that include system bars indicated by {@code typeMask}, taken from
- * {@code typeInsetMap}.
+ * {@code typeInsetsMap}.
*/
- private static Insets getInsets(Insets[] typeInsetsMap, @InsetType int typeMask) {
+ private static Insets getInsets(Insets[] typeInsetsMap, @InsetsType int typeMask) {
Insets result = null;
for (int i = FIRST; i <= LAST; i = i << 1) {
if ((typeMask & i) == 0) {
@@ -199,7 +199,7 @@ public final class WindowInsets {
/**
* Sets all entries in {@code typeInsetsMap} that belong to {@code typeMask} to {@code insets},
*/
- private static void setInsets(Insets[] typeInsetsMap, @InsetType int typeMask, Insets insets) {
+ private static void setInsets(Insets[] typeInsetsMap, @InsetsType int typeMask, Insets insets) {
for (int i = FIRST; i <= LAST; i = i << 1) {
if ((typeMask & i) == 0) {
continue;
@@ -216,34 +216,35 @@ public final class WindowInsets {
/**
* Creates a indexOf(type) -> inset map for which the {@code insets} is just mapped to
- * {@link InsetType#topBar()} and {@link InsetType#sideBars()}, depending on the location of the
- * inset.
+ * {@link InsetsType#statusBars()} and {@link InsetsType#navigationBars()}, depending on the
+ * location of the inset.
*/
private static Insets[] createCompatTypeMap(@Nullable Rect insets) {
if (insets == null) {
return null;
}
- Insets[] typeInsetMap = new Insets[SIZE];
- assignCompatInsets(typeInsetMap, insets);
- return typeInsetMap;
+ Insets[] typeInsetsMap = new Insets[SIZE];
+ assignCompatInsets(typeInsetsMap, insets);
+ return typeInsetsMap;
}
/**
* @hide
*/
- static void assignCompatInsets(Insets[] typeInsetMap, Rect insets) {
- typeInsetMap[indexOf(TOP_BAR)] = Insets.of(0, insets.top, 0, 0);
- typeInsetMap[indexOf(SIDE_BARS)] = Insets.of(insets.left, 0, insets.right, insets.bottom);
+ static void assignCompatInsets(Insets[] typeInsetsMap, Rect insets) {
+ typeInsetsMap[indexOf(STATUS_BARS)] = Insets.of(0, insets.top, 0, 0);
+ typeInsetsMap[indexOf(NAVIGATION_BARS)] =
+ Insets.of(insets.left, 0, insets.right, insets.bottom);
}
- private static boolean[] createCompatVisibilityMap(@Nullable Insets[] typeInsetMap) {
+ private static boolean[] createCompatVisibilityMap(@Nullable Insets[] typeInsetsMap) {
boolean[] typeVisibilityMap = new boolean[SIZE];
- if (typeInsetMap == null) {
+ if (typeInsetsMap == null) {
return typeVisibilityMap;
}
for (int i = FIRST; i <= LAST; i = i << 1) {
int index = indexOf(i);
- if (!Insets.NONE.equals(typeInsetMap[index])) {
+ if (!Insets.NONE.equals(typeInsetsMap[index])) {
typeVisibilityMap[index] = true;
}
}
@@ -284,20 +285,20 @@ public final class WindowInsets {
/**
* Returns the insets of a specific set of windows causing insets, denoted by the
- * {@code typeMask} bit mask of {@link InsetType}s.
+ * {@code typeMask} bit mask of {@link InsetsType}s.
*
- * @param typeMask Bit mask of {@link InsetType}s to query the insets for.
+ * @param typeMask Bit mask of {@link InsetsType}s to query the insets for.
* @return The insets.
*
* @hide pending unhide
*/
- public Insets getInsets(@InsetType int typeMask) {
+ public Insets getInsets(@InsetsType int typeMask) {
return getInsets(mTypeInsetsMap, typeMask);
}
/**
* Returns the maximum amount of insets a specific set of windows can cause, denoted by the
- * {@code typeMask} bit mask of {@link InsetType}s.
+ * {@code typeMask} bit mask of {@link InsetsType}s.
*
* <p>The maximum insets represents the area of a a window that that <b>may</b> be partially
* or fully obscured by the system window identified by {@code type}. This value does not
@@ -305,7 +306,7 @@ public final class WindowInsets {
* normally shown, but temporarily hidden, the maximum inset will still provide the inset
* associated with the status bar being shown.</p>
*
- * @param typeMask Bit mask of {@link InsetType}s to query the insets for.
+ * @param typeMask Bit mask of {@link InsetsType}s to query the insets for.
* @return The insets.
*
* @throws IllegalArgumentException If the caller tries to query {@link Type#ime()}. Maximum
@@ -314,7 +315,7 @@ public final class WindowInsets {
* currently focused view, as well as the UI state of the IME.
* @hide pending unhide
*/
- public Insets getMaxInsets(@InsetType int typeMask) throws IllegalArgumentException {
+ public Insets getMaxInsets(@InsetsType int typeMask) throws IllegalArgumentException {
if ((typeMask & IME) != 0) {
throw new IllegalArgumentException("Unable to query the maximum insets for IME");
}
@@ -325,12 +326,12 @@ public final class WindowInsets {
* Returns whether a set of windows that may cause insets is currently visible on screen,
* regardless of whether it actually overlaps with this window.
*
- * @param typeMask Bit mask of {@link InsetType}s to query visibility status.
+ * @param typeMask Bit mask of {@link Type.InsetsType}s to query visibility status.
* @return {@code true} if and only if all windows included in {@code typeMask} are currently
* visible on screen.
* @hide pending unhide
*/
- public boolean isVisible(@InsetType int typeMask) {
+ public boolean isVisible(@InsetsType int typeMask) {
for (int i = FIRST; i <= LAST; i = i << 1) {
if ((typeMask & i) == 0) {
continue;
@@ -1010,14 +1011,14 @@ public final class WindowInsets {
*
* @see #getInsets(int)
*
- * @param typeMask The bitmask of {@link InsetType} to set the insets for.
+ * @param typeMask The bitmask of {@link InsetsType} to set the insets for.
* @param insets The insets to set.
*
* @return itself
* @hide pending unhide
*/
@NonNull
- public Builder setInsets(@InsetType int typeMask, @NonNull Insets insets) {
+ public Builder setInsets(@InsetsType int typeMask, @NonNull Insets insets) {
Preconditions.checkNotNull(insets);
WindowInsets.setInsets(mTypeInsetsMap, typeMask, insets);
mSystemInsetsConsumed = false;
@@ -1035,7 +1036,7 @@ public final class WindowInsets {
*
* @see #getMaxInsets(int)
*
- * @param typeMask The bitmask of {@link InsetType} to set the insets for.
+ * @param typeMask The bitmask of {@link InsetsType} to set the insets for.
* @param insets The insets to set.
*
* @return itself
@@ -1048,7 +1049,7 @@ public final class WindowInsets {
* @hide pending unhide
*/
@NonNull
- public Builder setMaxInsets(@InsetType int typeMask, @NonNull Insets insets)
+ public Builder setMaxInsets(@InsetsType int typeMask, @NonNull Insets insets)
throws IllegalArgumentException{
if (typeMask == IME) {
throw new IllegalArgumentException("Maximum inset not available for IME");
@@ -1065,14 +1066,14 @@ public final class WindowInsets {
*
* @see #isVisible(int)
*
- * @param typeMask The bitmask of {@link InsetType} to set the visibility for.
+ * @param typeMask The bitmask of {@link InsetsType} to set the visibility for.
* @param visible Whether to mark the windows as visible or not.
*
* @return itself
* @hide pending unhide
*/
@NonNull
- public Builder setVisible(@InsetType int typeMask, boolean visible) {
+ public Builder setVisible(@InsetsType int typeMask, boolean visible) {
for (int i = FIRST; i <= LAST; i = i << 1) {
if ((typeMask & i) == 0) {
continue;
@@ -1149,35 +1150,38 @@ public final class WindowInsets {
public static final class Type {
static final int FIRST = 1 << 0;
- static final int TOP_BAR = FIRST;
+ static final int STATUS_BARS = FIRST;
+ static final int NAVIGATION_BARS = 1 << 1;
+ static final int CAPTION_BAR = 1 << 2;
- static final int IME = 1 << 1;
- static final int SIDE_BARS = 1 << 2;
+ static final int IME = 1 << 3;
- static final int SYSTEM_GESTURES = 1 << 3;
- static final int MANDATORY_SYSTEM_GESTURES = 1 << 4;
- static final int TAPPABLE_ELEMENT = 1 << 5;
+ static final int SYSTEM_GESTURES = 1 << 4;
+ static final int MANDATORY_SYSTEM_GESTURES = 1 << 5;
+ static final int TAPPABLE_ELEMENT = 1 << 6;
- static final int LAST = 1 << 6;
- static final int SIZE = 7;
+ static final int LAST = 1 << 7;
+ static final int SIZE = 8;
static final int WINDOW_DECOR = LAST;
- static int indexOf(@InsetType int type) {
+ static int indexOf(@InsetsType int type) {
switch (type) {
- case TOP_BAR:
+ case STATUS_BARS:
return 0;
- case IME:
+ case NAVIGATION_BARS:
return 1;
- case SIDE_BARS:
+ case CAPTION_BAR:
return 2;
- case SYSTEM_GESTURES:
+ case IME:
return 3;
- case MANDATORY_SYSTEM_GESTURES:
+ case SYSTEM_GESTURES:
return 4;
- case TAPPABLE_ELEMENT:
+ case MANDATORY_SYSTEM_GESTURES:
return 5;
- case WINDOW_DECOR:
+ case TAPPABLE_ELEMENT:
return 6;
+ case WINDOW_DECOR:
+ return 7;
default:
throw new IllegalArgumentException("type needs to be >= FIRST and <= LAST,"
+ " type=" + type);
@@ -1189,42 +1193,48 @@ public final class WindowInsets {
/** @hide */
@Retention(RetentionPolicy.SOURCE)
- @IntDef(flag = true, value = { TOP_BAR, IME, SIDE_BARS, WINDOW_DECOR, SYSTEM_GESTURES,
- MANDATORY_SYSTEM_GESTURES, TAPPABLE_ELEMENT})
- public @interface InsetType {
+ @IntDef(flag = true, value = {STATUS_BARS, NAVIGATION_BARS, CAPTION_BAR, IME, WINDOW_DECOR,
+ SYSTEM_GESTURES, MANDATORY_SYSTEM_GESTURES, TAPPABLE_ELEMENT})
+ public @interface InsetsType {
}
/**
- * @return An inset type representing the top bar of a window, which can be the status
- * bar on handheld-like devices as well as a caption bar.
+ * @return An insets type representing any system bars for displaying status.
*/
- public static @InsetType int topBar() {
- return TOP_BAR;
+ public static @InsetsType int statusBars() {
+ return STATUS_BARS;
}
/**
- * @return An inset type representing the window of an {@link InputMethod}.
+ * @return An insets type representing any system bars for navigation.
*/
- public static @InsetType int ime() {
- return IME;
+ public static @InsetsType int navigationBars() {
+ return NAVIGATION_BARS;
+ }
+
+ /**
+ * @return An insets type representing the window of a caption bar.
+ */
+ public static @InsetsType int captionBar() {
+ return CAPTION_BAR;
}
/**
- * @return An inset type representing any system bars that are not {@link #topBar()}.
+ * @return An insets type representing the window of an {@link InputMethod}.
*/
- public static @InsetType int sideBars() {
- return SIDE_BARS;
+ public static @InsetsType int ime() {
+ return IME;
}
/**
- * @return An inset type representing decor that is being app-controlled.
+ * @return An insets type representing decor that is being app-controlled.
*/
- public static @InsetType int windowDecor() {
+ public static @InsetsType int windowDecor() {
return WINDOW_DECOR;
}
/**
- * Returns an inset type representing the system gesture insets.
+ * Returns an insets type representing the system gesture insets.
*
* <p>The system gesture insets represent the area of a window where system gestures have
* priority and may consume some or all touch input, e.g. due to the a system bar
@@ -1240,30 +1250,30 @@ public final class WindowInsets {
*
* @see #getSystemGestureInsets()
*/
- public static @InsetType int systemGestures() {
+ public static @InsetsType int systemGestures() {
return SYSTEM_GESTURES;
}
/**
* @see #getMandatorySystemGestureInsets
*/
- public static @InsetType int mandatorySystemGestures() {
+ public static @InsetsType int mandatorySystemGestures() {
return MANDATORY_SYSTEM_GESTURES;
}
/**
* @see #getTappableElementInsets
*/
- public static @InsetType int tappableElement() {
+ public static @InsetsType int tappableElement() {
return TAPPABLE_ELEMENT;
}
/**
- * @return All system bars. Includes {@link #topBar()} as well as {@link #sideBars()}, but
- * not {@link #ime()}.
+ * @return All system bars. Includes {@link #statusBars()} as well as
+ * {@link #navigationBars()}, but not {@link #ime()}.
*/
- public static @InsetType int systemBars() {
- return TOP_BAR | SIDE_BARS;
+ public static @InsetsType int systemBars() {
+ return STATUS_BARS | NAVIGATION_BARS;
}
/**
@@ -1271,8 +1281,8 @@ public final class WindowInsets {
* system insets.
* @hide
*/
- static @InsetType int compatSystemInsets() {
- return TOP_BAR | SIDE_BARS | IME;
+ static @InsetsType int compatSystemInsets() {
+ return STATUS_BARS | NAVIGATION_BARS | IME;
}
/**
@@ -1281,7 +1291,7 @@ public final class WindowInsets {
* TODO: Figure out if this makes sense at all, mixing e.g {@link #systemGestures()} and
* {@link #ime()} does not seem very useful.
*/
- public static @InsetType int all() {
+ public static @InsetsType int all() {
return 0xFFFFFFFF;
}
}
diff --git a/core/java/android/view/WindowInsetsAnimationControlListener.java b/core/java/android/view/WindowInsetsAnimationControlListener.java
index b27a23da61b7..33fb327121c0 100644
--- a/core/java/android/view/WindowInsetsAnimationControlListener.java
+++ b/core/java/android/view/WindowInsetsAnimationControlListener.java
@@ -17,7 +17,7 @@
package android.view;
import android.annotation.NonNull;
-import android.view.WindowInsets.Type.InsetType;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.inputmethod.EditorInfo;
/**
@@ -32,13 +32,13 @@ public interface WindowInsetsAnimationControlListener {
* window is starting up.
*
* @param controller The controller to control the inset animation.
- * @param types The {@link InsetType}s it was able to gain control over. Note that this may be
+ * @param types The {@link InsetsType}s it was able to gain control over. Note that this may be
* different than the types passed into
* {@link WindowInsetsController#controlWindowInsetsAnimation} in case the window
* wasn't able to gain the controls because it wasn't the IME target or not
* currently the window that's controlling the system bars.
*/
- void onReady(@NonNull WindowInsetsAnimationController controller, @InsetType int types);
+ void onReady(@NonNull WindowInsetsAnimationController controller, @InsetsType int types);
/**
* Called when the window no longer has control over the requested types. If it loses control
diff --git a/core/java/android/view/WindowInsetsAnimationController.java b/core/java/android/view/WindowInsetsAnimationController.java
index cf4415d2b2ba..5cbf3b852018 100644
--- a/core/java/android/view/WindowInsetsAnimationController.java
+++ b/core/java/android/view/WindowInsetsAnimationController.java
@@ -18,7 +18,7 @@ package android.view;
import android.annotation.NonNull;
import android.graphics.Insets;
-import android.view.WindowInsets.Type.InsetType;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowInsetsAnimationListener.InsetsAnimation;
/**
@@ -60,9 +60,9 @@ public interface WindowInsetsAnimationController {
@NonNull Insets getCurrentInsets();
/**
- * @return The {@link InsetType}s this object is currently controlling.
+ * @return The {@link InsetsType}s this object is currently controlling.
*/
- @InsetType int getTypes();
+ @InsetsType int getTypes();
/**
* Modifies the insets by indirectly moving the windows around in the system that are causing
@@ -94,5 +94,5 @@ public interface WindowInsetsAnimationController {
* @param shownTypes The list of windows causing insets that should remain shown after finishing
* the animation.
*/
- void finish(@InsetType int shownTypes);
+ void finish(@InsetsType int shownTypes);
}
diff --git a/core/java/android/view/WindowInsetsAnimationListener.java b/core/java/android/view/WindowInsetsAnimationListener.java
index 682ab5bfb63c..f734b4b7cb0f 100644
--- a/core/java/android/view/WindowInsetsAnimationListener.java
+++ b/core/java/android/view/WindowInsetsAnimationListener.java
@@ -61,7 +61,7 @@ public interface WindowInsetsAnimationListener {
*/
class InsetsAnimation {
- private final @WindowInsets.Type.InsetType int mTypeMask;
+ private final @WindowInsets.Type.InsetsType int mTypeMask;
private final Insets mLowerBound;
private final Insets mUpperBound;
@@ -75,9 +75,9 @@ public interface WindowInsetsAnimationListener {
}
/**
- * @return The bitmask of {@link WindowInsets.Type.InsetType}s that are animating.
+ * @return The bitmask of {@link WindowInsets.Type.InsetsType}s that are animating.
*/
- public @WindowInsets.Type.InsetType int getTypeMask() {
+ public @WindowInsets.Type.InsetsType int getTypeMask() {
return mTypeMask;
}
diff --git a/core/java/android/view/WindowInsetsController.java b/core/java/android/view/WindowInsetsController.java
index b41531988518..39e2e73f6fa8 100644
--- a/core/java/android/view/WindowInsetsController.java
+++ b/core/java/android/view/WindowInsetsController.java
@@ -21,7 +21,7 @@ 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 android.view.WindowInsets.Type.InsetsType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -35,16 +35,16 @@ import java.lang.annotation.RetentionPolicy;
public interface WindowInsetsController {
/**
- * Makes the top bars become opaque with solid dark background and light foreground.
+ * Makes status bars become opaque with solid dark background and light foreground.
* @hide
*/
- int APPEARANCE_OPAQUE_TOP_BAR = 1;
+ int APPEARANCE_OPAQUE_STATUS_BARS = 1;
/**
- * Makes the side bars become opaque with solid dark background and light foreground.
+ * Makes navigation bars become opaque with solid dark background and light foreground.
* @hide
*/
- int APPEARANCE_OPAQUE_SIDE_BARS = 1 << 1;
+ int APPEARANCE_OPAQUE_NAVIGATION_BARS = 1 << 1;
/**
* Makes items on system bars become less noticeable without changing the layout of the bars.
@@ -53,34 +53,35 @@ public interface WindowInsetsController {
int APPEARANCE_LOW_PROFILE_BARS = 1 << 2;
/**
- * Changes the foreground color for the light top bar so that the items on the bar can be read
+ * Changes the foreground color for light status bars so that the items on the bar can be read
* clearly.
*/
- int APPEARANCE_LIGHT_TOP_BAR = 1 << 3;
+ int APPEARANCE_LIGHT_STATUS_BARS = 1 << 3;
/**
- * Changes the foreground color for the light side bars so that the items on the bar can be read
- * clearly.
+ * Changes the foreground color for light navigation bars so that the items on the bar can be
+ * read clearly.
*/
- int APPEARANCE_LIGHT_SIDE_BARS = 1 << 4;
+ int APPEARANCE_LIGHT_NAVIGATION_BARS = 1 << 4;
/** Determines the appearance of system bars. */
@Retention(RetentionPolicy.SOURCE)
- @IntDef(flag = true, value = {APPEARANCE_OPAQUE_TOP_BAR, APPEARANCE_OPAQUE_SIDE_BARS,
- APPEARANCE_LOW_PROFILE_BARS, APPEARANCE_LIGHT_TOP_BAR, APPEARANCE_LIGHT_SIDE_BARS})
+ @IntDef(flag = true, value = {APPEARANCE_OPAQUE_STATUS_BARS, APPEARANCE_OPAQUE_NAVIGATION_BARS,
+ APPEARANCE_LOW_PROFILE_BARS, APPEARANCE_LIGHT_STATUS_BARS,
+ APPEARANCE_LIGHT_NAVIGATION_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)}.
+ * The default option for {@link #setSystemBarsBehavior(int)}. System bars will be forcibly
+ * shown on any user interaction on the corresponding display if navigation bars are hidden by
+ * {@link #hide(int)} or {@link WindowInsetsAnimationController#changeInsets(Insets)}.
*/
- int BEHAVIOR_SHOW_SIDE_BARS_BY_TOUCH = 0;
+ int BEHAVIOR_SHOW_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
+ * hiding navigation 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
@@ -90,7 +91,7 @@ public interface WindowInsetsController {
/**
* Option for {@link #setSystemBarsBehavior(int)}: Window would like to remain interactive when
- * hiding the side bars by calling {@link #hide(int)} or
+ * hiding navigation 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
@@ -102,7 +103,7 @@ public interface WindowInsetsController {
/** 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,
+ @IntDef(value = {BEHAVIOR_SHOW_BARS_BY_TOUCH, BEHAVIOR_SHOW_BARS_BY_SWIPE,
BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE})
@interface Behavior {
}
@@ -114,11 +115,11 @@ public interface WindowInsetsController {
* change as soon as the window gains control. The app can listen to the event by observing
* {@link View#onApplyWindowInsets} and checking visibility with {@link WindowInsets#isVisible}.
*
- * @param types A bitmask of {@link WindowInsets.Type.InsetType} specifying what windows the app
+ * @param types A bitmask of {@link InsetsType} specifying what windows the app
* would like to make appear on screen.
* @hide
*/
- void show(@InsetType int types);
+ void show(@InsetsType int types);
/**
* Makes a set of windows causing insets disappear.
@@ -127,22 +128,22 @@ public interface WindowInsetsController {
* change as soon as the window gains control. The app can listen to the event by observing
* {@link View#onApplyWindowInsets} and checking visibility with {@link WindowInsets#isVisible}.
*
- * @param types A bitmask of {@link WindowInsets.Type.InsetType} specifying what windows the app
+ * @param types A bitmask of {@link InsetsType} specifying what windows the app
* would like to make disappear.
* @hide
*/
- void hide(@InsetType int types);
+ void hide(@InsetsType int types);
/**
* Lets the application control window inset animations in a frame-by-frame manner by modifying
* the position of the windows in the system causing insets directly.
*
- * @param types The {@link InsetType}s the application has requested to control.
+ * @param types The {@link InsetsType}s the application has requested to control.
* @param listener The {@link WindowInsetsAnimationControlListener} that gets called when the
* windows are ready to be controlled, among other callbacks.
* @hide
*/
- void controlWindowInsetsAnimation(@InsetType int types,
+ void controlWindowInsetsAnimation(@InsetsType int types,
@NonNull WindowInsetsAnimationControlListener listener);
/**