Window Manager Flag Migration (6/n)
Refactor the insets APIs:
- Remove top/side in the names of types
- Add a type for the caption bar
- Rename InsetSide to InternalInsetsSide which is a enumeration, so that
we can have a public @InsetsSide which is a bit-wise variable
- Fix the naming about insets: inset --> insets
Bug: 118118435
Test: atest InsetsSourceProviderTest InsetsStateControllerTest
InsetsPolicyTest WindowStateTests CommandQueueTest
RegisterStatusBarResultTest InsetsFlagsTest
LightBarControllerTest RegisterStatusBarResultTest
Change-Id: I27a066299eea9927ce61f6cb5d489ad79bca42ba
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 ((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.NAVIGATION_BARS) != 0) {
|
||||
result.add(ITYPE_NAVIGATION_BAR);
|
||||
}
|
||||
if ((insetTypes & Type.IME) != 0) {
|
||||
result.add(TYPE_IME);
|
||||
if ((types & Type.CAPTION_BAR) != 0) {
|
||||
result.add(ITYPE_CAPTION_BAR);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -7505,11 +7505,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();
|
||||
}
|
||||
|
||||
@@ -8628,7 +8628,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);
|
||||
@@ -8636,7 +8636,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);
|
||||
|
||||
@@ -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() {
|
||||
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 insets type representing the window of an {@link InputMethod}.
|
||||
*/
|
||||
public static @InsetsType int ime() {
|
||||
return IME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An inset type representing any system bars that are not {@link #topBar()}.
|
||||
* @return An insets type representing decor that is being app-controlled.
|
||||
*/
|
||||
public static @InsetType int sideBars() {
|
||||
return SIDE_BARS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An inset 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ import android.view.IWindowSession;
|
||||
import android.view.InsetsSourceControl;
|
||||
import android.view.InsetsState;
|
||||
import android.view.PointerIcon;
|
||||
import android.view.WindowInsets.Type.InsetType;
|
||||
import android.view.WindowInsets.Type.InsetsType;
|
||||
|
||||
import com.android.internal.os.IResultReceiver;
|
||||
|
||||
@@ -72,15 +72,15 @@ public class BaseIWindow extends IWindow.Stub {
|
||||
|
||||
@Override
|
||||
public void insetsControlChanged(InsetsState insetsState,
|
||||
InsetsSourceControl[] activeControls) throws RemoteException {
|
||||
InsetsSourceControl[] activeControls) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showInsets(@InsetType int types, boolean fromIme) throws RemoteException {
|
||||
public void showInsets(@InsetsType int types, boolean fromIme) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideInsets(@InsetType int types, boolean fromIme) throws RemoteException {
|
||||
public void hideInsets(@InsetsType int types, boolean fromIme) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
package android.view;
|
||||
|
||||
import static android.view.ImeInsetsSourceConsumer.areEditorsSimilar;
|
||||
import static android.view.InsetsState.TYPE_IME;
|
||||
|
||||
import static android.view.InsetsState.ITYPE_IME;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ImeInsetsSourceConsumerTest {
|
||||
|
||||
@Test
|
||||
public void testImeVisibility() {
|
||||
final InsetsSourceControl ime = new InsetsSourceControl(TYPE_IME, mLeash, new Point());
|
||||
final InsetsSourceControl ime = new InsetsSourceControl(ITYPE_IME, mLeash, new Point());
|
||||
mController.onControlsChanged(new InsetsSourceControl[] { ime });
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
|
||||
import static android.view.WindowInsets.Type.sideBars;
|
||||
import static android.view.WindowInsets.Type.navigationBars;
|
||||
import static android.view.WindowInsets.Type.systemBars;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -100,21 +100,22 @@ public class InsetsAnimationControlImplTest {
|
||||
.setName("testSurface")
|
||||
.build();
|
||||
mInsetsState = new InsetsState();
|
||||
mInsetsState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 500, 100));
|
||||
mInsetsState.getSource(TYPE_NAVIGATION_BAR).setFrame(new Rect(400, 0, 500, 500));
|
||||
InsetsSourceConsumer topConsumer = new InsetsSourceConsumer(TYPE_TOP_BAR, mInsetsState,
|
||||
mInsetsState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 500, 100));
|
||||
mInsetsState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(400, 0, 500, 500));
|
||||
InsetsSourceConsumer topConsumer = new InsetsSourceConsumer(ITYPE_STATUS_BAR, mInsetsState,
|
||||
() -> mMockTransaction, mMockController);
|
||||
topConsumer.setControl(new InsetsSourceControl(TYPE_TOP_BAR, mTopLeash, new Point(0, 0)));
|
||||
topConsumer.setControl(
|
||||
new InsetsSourceControl(ITYPE_STATUS_BAR, mTopLeash, new Point(0, 0)));
|
||||
|
||||
InsetsSourceConsumer navConsumer = new InsetsSourceConsumer(TYPE_NAVIGATION_BAR,
|
||||
InsetsSourceConsumer navConsumer = new InsetsSourceConsumer(ITYPE_NAVIGATION_BAR,
|
||||
mInsetsState, () -> mMockTransaction, mMockController);
|
||||
navConsumer.hide();
|
||||
navConsumer.setControl(new InsetsSourceControl(TYPE_NAVIGATION_BAR, mNavLeash,
|
||||
navConsumer.setControl(new InsetsSourceControl(ITYPE_NAVIGATION_BAR, mNavLeash,
|
||||
new Point(400, 0)));
|
||||
|
||||
SparseArray<InsetsSourceConsumer> consumers = new SparseArray<>();
|
||||
consumers.put(TYPE_TOP_BAR, topConsumer);
|
||||
consumers.put(TYPE_NAVIGATION_BAR, navConsumer);
|
||||
consumers.put(ITYPE_STATUS_BAR, topConsumer);
|
||||
consumers.put(ITYPE_NAVIGATION_BAR, navConsumer);
|
||||
mController = new InsetsAnimationControlImpl(consumers,
|
||||
new Rect(0, 0, 500, 500), mInsetsState, mMockListener, systemBars(),
|
||||
() -> mMockTransactionApplier, mMockController);
|
||||
@@ -149,12 +150,12 @@ public class InsetsAnimationControlImplTest {
|
||||
@Test
|
||||
public void testFinishing() {
|
||||
when(mMockController.getState()).thenReturn(mInsetsState);
|
||||
mController.finish(sideBars());
|
||||
mController.finish(navigationBars());
|
||||
mController.applyChangeInsets(mInsetsState);
|
||||
assertFalse(mInsetsState.getSource(TYPE_TOP_BAR).isVisible());
|
||||
assertTrue(mInsetsState.getSource(TYPE_NAVIGATION_BAR).isVisible());
|
||||
assertFalse(mInsetsState.getSource(ITYPE_STATUS_BAR).isVisible());
|
||||
assertTrue(mInsetsState.getSource(ITYPE_NAVIGATION_BAR).isVisible());
|
||||
assertEquals(Insets.of(0, 0, 100, 0), mController.getCurrentInsets());
|
||||
verify(mMockController).notifyFinished(eq(mController), eq(sideBars()));
|
||||
verify(mMockController).notifyFinished(eq(mController), eq(navigationBars()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,7 +167,7 @@ public class InsetsAnimationControlImplTest {
|
||||
} catch (IllegalStateException ignored) {
|
||||
}
|
||||
verify(mMockListener).onCancelled();
|
||||
mController.finish(sideBars());
|
||||
mController.finish(navigationBars());
|
||||
}
|
||||
|
||||
private void assertPosition(Matrix m, Rect original, Rect transformed) {
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import static android.view.InsetsState.TYPE_IME;
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.WindowInsets.Type.topBar;
|
||||
import static android.view.InsetsState.ITYPE_IME;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.WindowInsets.Type.statusBars;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -99,28 +99,31 @@ public class InsetsControllerTest {
|
||||
|
||||
@Test
|
||||
public void testControlsChanged() {
|
||||
InsetsSourceControl control = new InsetsSourceControl(TYPE_TOP_BAR, mLeash, new Point());
|
||||
InsetsSourceControl control =
|
||||
new InsetsSourceControl(ITYPE_STATUS_BAR, mLeash, new Point());
|
||||
mController.onControlsChanged(new InsetsSourceControl[] { control });
|
||||
assertEquals(mLeash,
|
||||
mController.getSourceConsumer(TYPE_TOP_BAR).getControl().getLeash());
|
||||
mController.getSourceConsumer(ITYPE_STATUS_BAR).getControl().getLeash());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testControlsRevoked() {
|
||||
InsetsSourceControl control = new InsetsSourceControl(TYPE_TOP_BAR, mLeash, new Point());
|
||||
InsetsSourceControl control =
|
||||
new InsetsSourceControl(ITYPE_STATUS_BAR, mLeash, new Point());
|
||||
mController.onControlsChanged(new InsetsSourceControl[] { control });
|
||||
mController.onControlsChanged(new InsetsSourceControl[0]);
|
||||
assertNull(mController.getSourceConsumer(TYPE_TOP_BAR).getControl());
|
||||
assertNull(mController.getSourceConsumer(ITYPE_STATUS_BAR).getControl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testControlsRevoked_duringAnim() {
|
||||
InsetsSourceControl control = new InsetsSourceControl(TYPE_TOP_BAR, mLeash, new Point());
|
||||
InsetsSourceControl control =
|
||||
new InsetsSourceControl(ITYPE_STATUS_BAR, mLeash, new Point());
|
||||
mController.onControlsChanged(new InsetsSourceControl[] { control });
|
||||
|
||||
WindowInsetsAnimationControlListener mockListener =
|
||||
mock(WindowInsetsAnimationControlListener.class);
|
||||
mController.controlWindowInsetsAnimation(topBar(), mockListener);
|
||||
mController.controlWindowInsetsAnimation(statusBars(), mockListener);
|
||||
verify(mockListener).onReady(any(), anyInt());
|
||||
mController.onControlsChanged(new InsetsSourceControl[0]);
|
||||
verify(mockListener).onCancelled();
|
||||
@@ -141,47 +144,47 @@ public class InsetsControllerTest {
|
||||
public void testAnimationEndState() {
|
||||
InsetsSourceControl[] controls = prepareControls();
|
||||
InsetsSourceControl navBar = controls[0];
|
||||
InsetsSourceControl topBar = controls[1];
|
||||
InsetsSourceControl statusBar = controls[1];
|
||||
InsetsSourceControl ime = controls[2];
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
mController.getSourceConsumer(TYPE_IME).onWindowFocusGained();
|
||||
mController.getSourceConsumer(ITYPE_IME).onWindowFocusGained();
|
||||
// since there is no focused view, forcefully make IME visible.
|
||||
mController.applyImeVisibility(true /* setVisible */);
|
||||
mController.show(Type.all());
|
||||
// quickly jump to final state by cancelling it.
|
||||
mController.cancelExistingAnimation();
|
||||
assertTrue(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
mController.applyImeVisibility(false /* setVisible */);
|
||||
mController.hide(Type.all());
|
||||
mController.cancelExistingAnimation();
|
||||
assertFalse(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
mController.getSourceConsumer(TYPE_IME).onWindowFocusLost();
|
||||
mController.getSourceConsumer(ITYPE_IME).onWindowFocusLost();
|
||||
});
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyImeVisibility() {
|
||||
final InsetsSourceControl ime = new InsetsSourceControl(TYPE_IME, mLeash, new Point());
|
||||
final InsetsSourceControl ime = new InsetsSourceControl(ITYPE_IME, mLeash, new Point());
|
||||
|
||||
InsetsSourceControl[] controls = new InsetsSourceControl[3];
|
||||
controls[0] = ime;
|
||||
mController.onControlsChanged(controls);
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
mController.getSourceConsumer(TYPE_IME).onWindowFocusGained();
|
||||
mController.getSourceConsumer(ITYPE_IME).onWindowFocusGained();
|
||||
mController.applyImeVisibility(true);
|
||||
mController.cancelExistingAnimation();
|
||||
assertTrue(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
mController.applyImeVisibility(false);
|
||||
mController.cancelExistingAnimation();
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
mController.getSourceConsumer(TYPE_IME).onWindowFocusLost();
|
||||
mController.getSourceConsumer(ITYPE_IME).onWindowFocusLost();
|
||||
});
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
}
|
||||
@@ -190,23 +193,23 @@ public class InsetsControllerTest {
|
||||
public void testShowHideSelectively() {
|
||||
InsetsSourceControl[] controls = prepareControls();
|
||||
InsetsSourceControl navBar = controls[0];
|
||||
InsetsSourceControl topBar = controls[1];
|
||||
InsetsSourceControl statusBar = controls[1];
|
||||
InsetsSourceControl ime = controls[2];
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
int types = Type.sideBars() | Type.systemBars();
|
||||
int types = Type.navigationBars() | Type.systemBars();
|
||||
// test show select types.
|
||||
mController.show(types);
|
||||
mController.cancelExistingAnimation();
|
||||
assertTrue(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
// test hide all
|
||||
mController.hide(types);
|
||||
mController.cancelExistingAnimation();
|
||||
assertFalse(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
});
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
@@ -216,36 +219,36 @@ public class InsetsControllerTest {
|
||||
public void testShowHideSingle() {
|
||||
InsetsSourceControl[] controls = prepareControls();
|
||||
InsetsSourceControl navBar = controls[0];
|
||||
InsetsSourceControl topBar = controls[1];
|
||||
InsetsSourceControl statusBar = controls[1];
|
||||
InsetsSourceControl ime = controls[2];
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
int types = Type.sideBars() | Type.systemBars();
|
||||
int types = Type.navigationBars() | Type.systemBars();
|
||||
// test show select types.
|
||||
mController.show(types);
|
||||
mController.cancelExistingAnimation();
|
||||
assertTrue(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
// test hide all
|
||||
mController.hide(Type.all());
|
||||
mController.cancelExistingAnimation();
|
||||
assertFalse(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
// test single show
|
||||
mController.show(Type.sideBars());
|
||||
mController.show(Type.navigationBars());
|
||||
mController.cancelExistingAnimation();
|
||||
assertTrue(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
// test single hide
|
||||
mController.hide(Type.sideBars());
|
||||
mController.hide(Type.navigationBars());
|
||||
assertFalse(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
});
|
||||
@@ -256,38 +259,38 @@ public class InsetsControllerTest {
|
||||
public void testShowHideMultiple() {
|
||||
InsetsSourceControl[] controls = prepareControls();
|
||||
InsetsSourceControl navBar = controls[0];
|
||||
InsetsSourceControl topBar = controls[1];
|
||||
InsetsSourceControl statusBar = controls[1];
|
||||
InsetsSourceControl ime = controls[2];
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
// start two animations and see if previous is cancelled and final state is reached.
|
||||
mController.show(Type.sideBars());
|
||||
mController.show(Type.navigationBars());
|
||||
mController.show(Type.systemBars());
|
||||
mController.cancelExistingAnimation();
|
||||
assertTrue(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
mController.hide(Type.sideBars());
|
||||
mController.hide(Type.navigationBars());
|
||||
mController.hide(Type.systemBars());
|
||||
mController.cancelExistingAnimation();
|
||||
assertFalse(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
int types = Type.sideBars() | Type.systemBars();
|
||||
int types = Type.navigationBars() | Type.systemBars();
|
||||
// show two at a time and hide one by one.
|
||||
mController.show(types);
|
||||
mController.hide(Type.sideBars());
|
||||
mController.hide(Type.navigationBars());
|
||||
mController.cancelExistingAnimation();
|
||||
assertFalse(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
mController.hide(Type.systemBars());
|
||||
mController.cancelExistingAnimation();
|
||||
assertFalse(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
});
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
@@ -297,23 +300,23 @@ public class InsetsControllerTest {
|
||||
public void testShowMultipleHideOneByOne() {
|
||||
InsetsSourceControl[] controls = prepareControls();
|
||||
InsetsSourceControl navBar = controls[0];
|
||||
InsetsSourceControl topBar = controls[1];
|
||||
InsetsSourceControl statusBar = controls[1];
|
||||
InsetsSourceControl ime = controls[2];
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
int types = Type.sideBars() | Type.systemBars();
|
||||
int types = Type.navigationBars() | Type.systemBars();
|
||||
// show two at a time and hide one by one.
|
||||
mController.show(types);
|
||||
mController.hide(Type.sideBars());
|
||||
mController.hide(Type.navigationBars());
|
||||
mController.cancelExistingAnimation();
|
||||
assertFalse(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertTrue(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
|
||||
mController.hide(Type.systemBars());
|
||||
mController.cancelExistingAnimation();
|
||||
assertFalse(mController.getSourceConsumer(navBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(topBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(statusBar.getType()).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ime.getType()).isVisible());
|
||||
});
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
@@ -321,13 +324,14 @@ public class InsetsControllerTest {
|
||||
|
||||
@Test
|
||||
public void testAnimationEndState_controller() throws Exception {
|
||||
InsetsSourceControl control = new InsetsSourceControl(TYPE_TOP_BAR, mLeash, new Point());
|
||||
InsetsSourceControl control =
|
||||
new InsetsSourceControl(ITYPE_STATUS_BAR, mLeash, new Point());
|
||||
mController.onControlsChanged(new InsetsSourceControl[] { control });
|
||||
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
WindowInsetsAnimationControlListener mockListener =
|
||||
mock(WindowInsetsAnimationControlListener.class);
|
||||
mController.controlWindowInsetsAnimation(topBar(), mockListener);
|
||||
mController.controlWindowInsetsAnimation(statusBars(), mockListener);
|
||||
|
||||
ArgumentCaptor<WindowInsetsAnimationController> controllerCaptor =
|
||||
ArgumentCaptor.forClass(WindowInsetsAnimationController.class);
|
||||
@@ -336,7 +340,7 @@ public class InsetsControllerTest {
|
||||
});
|
||||
waitUntilNextFrame();
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
|
||||
assertFalse(mController.getSourceConsumer(TYPE_TOP_BAR).isVisible());
|
||||
assertFalse(mController.getSourceConsumer(ITYPE_STATUS_BAR).isVisible());
|
||||
});
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||
}
|
||||
@@ -349,15 +353,15 @@ public class InsetsControllerTest {
|
||||
}
|
||||
|
||||
private InsetsSourceControl[] prepareControls() {
|
||||
final InsetsSourceControl navBar = new InsetsSourceControl(TYPE_NAVIGATION_BAR, mLeash,
|
||||
final InsetsSourceControl navBar = new InsetsSourceControl(ITYPE_NAVIGATION_BAR, mLeash,
|
||||
new Point());
|
||||
final InsetsSourceControl topBar = new InsetsSourceControl(TYPE_TOP_BAR, mLeash,
|
||||
final InsetsSourceControl statusBar = new InsetsSourceControl(ITYPE_STATUS_BAR, mLeash,
|
||||
new Point());
|
||||
final InsetsSourceControl ime = new InsetsSourceControl(TYPE_IME, mLeash, new Point());
|
||||
final InsetsSourceControl ime = new InsetsSourceControl(ITYPE_IME, mLeash, new Point());
|
||||
|
||||
InsetsSourceControl[] controls = new InsetsSourceControl[3];
|
||||
controls[0] = navBar;
|
||||
controls[1] = topBar;
|
||||
controls[1] = statusBar;
|
||||
controls[2] = ime;
|
||||
mController.onControlsChanged(controls);
|
||||
return controls;
|
||||
|
||||
@@ -25,11 +25,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 org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -57,11 +57,12 @@ public class InsetsFlagsTest {
|
||||
@Test
|
||||
public void testGetAppearance() {
|
||||
assertContainsAppearance(APPEARANCE_LOW_PROFILE_BARS, SYSTEM_UI_FLAG_LOW_PROFILE);
|
||||
assertContainsAppearance(APPEARANCE_LIGHT_TOP_BAR, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
assertContainsAppearance(APPEARANCE_LIGHT_SIDE_BARS, SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
assertContainsAppearance(APPEARANCE_OPAQUE_TOP_BAR,
|
||||
assertContainsAppearance(APPEARANCE_LIGHT_STATUS_BARS, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
assertContainsAppearance(APPEARANCE_LIGHT_NAVIGATION_BARS,
|
||||
SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
assertContainsAppearance(APPEARANCE_OPAQUE_STATUS_BARS,
|
||||
0xffffffff & ~(STATUS_BAR_TRANSLUCENT | STATUS_BAR_TRANSPARENT));
|
||||
assertContainsAppearance(APPEARANCE_OPAQUE_SIDE_BARS,
|
||||
assertContainsAppearance(APPEARANCE_OPAQUE_NAVIGATION_BARS,
|
||||
0xffffffff & ~(NAVIGATION_BAR_TRANSLUCENT | NAVIGATION_BAR_TRANSPARENT));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
@@ -82,15 +82,15 @@ public class InsetsSourceConsumerTest {
|
||||
// activity isn't running, lets ignore BadTokenException.
|
||||
}
|
||||
InsetsState state = new InsetsState();
|
||||
mSpyInsetsSource = Mockito.spy(new InsetsSource(TYPE_TOP_BAR));
|
||||
mSpyInsetsSource = Mockito.spy(new InsetsSource(ITYPE_STATUS_BAR));
|
||||
state.addSource(mSpyInsetsSource);
|
||||
|
||||
mConsumer = new InsetsSourceConsumer(TYPE_TOP_BAR, state,
|
||||
mConsumer = new InsetsSourceConsumer(ITYPE_STATUS_BAR, state,
|
||||
() -> mMockTransaction, new InsetsController(viewRootImpl));
|
||||
});
|
||||
instrumentation.waitForIdleSync();
|
||||
|
||||
mConsumer.setControl(new InsetsSourceControl(TYPE_TOP_BAR, mLeash, new Point()));
|
||||
mConsumer.setControl(new InsetsSourceControl(ITYPE_STATUS_BAR, mLeash, new Point()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,7 +113,7 @@ public class InsetsSourceConsumerTest {
|
||||
reset(mMockTransaction);
|
||||
mConsumer.hide();
|
||||
verifyZeroInteractions(mMockTransaction);
|
||||
mConsumer.setControl(new InsetsSourceControl(TYPE_TOP_BAR, mLeash, new Point()));
|
||||
mConsumer.setControl(new InsetsSourceControl(ITYPE_STATUS_BAR, mLeash, new Point()));
|
||||
verify(mMockTransaction).hide(eq(mLeash));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.junit.runner.RunWith;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class InsetsSourceTest {
|
||||
|
||||
private InsetsSource mSource = new InsetsSource(TYPE_NAVIGATION_BAR);
|
||||
private InsetsSource mSource = new InsetsSource(ITYPE_NAVIGATION_BAR);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import static android.view.InsetsState.INSET_SIDE_BOTTOM;
|
||||
import static android.view.InsetsState.INSET_SIDE_TOP;
|
||||
import static android.view.InsetsState.TYPE_IME;
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.TYPE_SIDE_BAR_1;
|
||||
import static android.view.InsetsState.TYPE_SIDE_BAR_2;
|
||||
import static android.view.InsetsState.TYPE_SIDE_BAR_3;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ISIDE_BOTTOM;
|
||||
import static android.view.InsetsState.ISIDE_TOP;
|
||||
import static android.view.InsetsState.ITYPE_CAPTION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_IME;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.WindowInsets.Type.ime;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
|
||||
|
||||
@@ -65,18 +63,18 @@ public class InsetsStateTest {
|
||||
public void testCalculateInsets() throws Exception {
|
||||
try (final InsetsModeSession session =
|
||||
new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
|
||||
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(TYPE_TOP_BAR).setVisible(true);
|
||||
mState.getSource(TYPE_IME).setFrame(new Rect(0, 200, 100, 300));
|
||||
mState.getSource(TYPE_IME).setVisible(true);
|
||||
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
|
||||
mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
|
||||
mState.getSource(ITYPE_IME).setVisible(true);
|
||||
SparseIntArray typeSideMap = new SparseIntArray();
|
||||
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
|
||||
DisplayCutout.NO_CUTOUT, null, null, SOFT_INPUT_ADJUST_RESIZE, typeSideMap);
|
||||
assertEquals(Insets.of(0, 100, 0, 100), insets.getSystemWindowInsets());
|
||||
assertEquals(Insets.of(0, 100, 0, 100), insets.getInsets(Type.all()));
|
||||
assertEquals(INSET_SIDE_TOP, typeSideMap.get(TYPE_TOP_BAR));
|
||||
assertEquals(INSET_SIDE_BOTTOM, typeSideMap.get(TYPE_IME));
|
||||
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.topBar()));
|
||||
assertEquals(ISIDE_TOP, typeSideMap.get(ITYPE_STATUS_BAR));
|
||||
assertEquals(ISIDE_BOTTOM, typeSideMap.get(ITYPE_IME));
|
||||
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.statusBars()));
|
||||
assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(Type.ime()));
|
||||
}
|
||||
}
|
||||
@@ -85,17 +83,17 @@ public class InsetsStateTest {
|
||||
public void testCalculateInsets_imeAndNav() throws Exception{
|
||||
try (final InsetsModeSession session =
|
||||
new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
|
||||
mState.getSource(TYPE_NAVIGATION_BAR).setFrame(new Rect(0, 200, 100, 300));
|
||||
mState.getSource(TYPE_NAVIGATION_BAR).setVisible(true);
|
||||
mState.getSource(TYPE_IME).setFrame(new Rect(0, 100, 100, 300));
|
||||
mState.getSource(TYPE_IME).setVisible(true);
|
||||
mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(0, 200, 100, 300));
|
||||
mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
|
||||
mState.getSource(ITYPE_IME).setFrame(new Rect(0, 100, 100, 300));
|
||||
mState.getSource(ITYPE_IME).setVisible(true);
|
||||
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
|
||||
DisplayCutout.NO_CUTOUT, null, null, SOFT_INPUT_ADJUST_RESIZE, null);
|
||||
assertEquals(100, insets.getStableInsetBottom());
|
||||
assertEquals(Insets.of(0, 0, 0, 100), insets.getMaxInsets(Type.systemBars()));
|
||||
assertEquals(Insets.of(0, 0, 0, 200), insets.getSystemWindowInsets());
|
||||
assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(Type.all()));
|
||||
assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(Type.sideBars()));
|
||||
assertEquals(Insets.of(0, 0, 0, 100), insets.getInsets(Type.navigationBars()));
|
||||
assertEquals(Insets.of(0, 0, 0, 200), insets.getInsets(Type.ime()));
|
||||
}
|
||||
}
|
||||
@@ -104,24 +102,24 @@ public class InsetsStateTest {
|
||||
public void testCalculateInsets_navRightStatusTop() throws Exception {
|
||||
try (final InsetsModeSession session =
|
||||
new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) {
|
||||
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(TYPE_TOP_BAR).setVisible(true);
|
||||
mState.getSource(TYPE_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
|
||||
mState.getSource(TYPE_NAVIGATION_BAR).setVisible(true);
|
||||
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
|
||||
mState.getSource(ITYPE_NAVIGATION_BAR).setFrame(new Rect(80, 0, 100, 300));
|
||||
mState.getSource(ITYPE_NAVIGATION_BAR).setVisible(true);
|
||||
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
|
||||
DisplayCutout.NO_CUTOUT, null, null, 0, null);
|
||||
assertEquals(Insets.of(0, 100, 20, 0), insets.getSystemWindowInsets());
|
||||
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.topBar()));
|
||||
assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.sideBars()));
|
||||
assertEquals(Insets.of(0, 100, 0, 0), insets.getInsets(Type.statusBars()));
|
||||
assertEquals(Insets.of(0, 0, 20, 0), insets.getInsets(Type.navigationBars()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateInsets_imeIgnoredWithoutAdjustResize() {
|
||||
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(TYPE_TOP_BAR).setVisible(true);
|
||||
mState.getSource(TYPE_IME).setFrame(new Rect(0, 200, 100, 300));
|
||||
mState.getSource(TYPE_IME).setVisible(true);
|
||||
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
|
||||
mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
|
||||
mState.getSource(ITYPE_IME).setVisible(true);
|
||||
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
|
||||
DisplayCutout.NO_CUTOUT, null, null, 0, null);
|
||||
assertEquals(0, insets.getSystemWindowInsetBottom());
|
||||
@@ -130,11 +128,11 @@ public class InsetsStateTest {
|
||||
|
||||
@Test
|
||||
public void testStripForDispatch() {
|
||||
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(TYPE_TOP_BAR).setVisible(true);
|
||||
mState.getSource(TYPE_IME).setFrame(new Rect(0, 200, 100, 300));
|
||||
mState.getSource(TYPE_IME).setVisible(true);
|
||||
mState.removeSource(TYPE_IME);
|
||||
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_STATUS_BAR).setVisible(true);
|
||||
mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300));
|
||||
mState.getSource(ITYPE_IME).setVisible(true);
|
||||
mState.removeSource(ITYPE_IME);
|
||||
WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false,
|
||||
DisplayCutout.NO_CUTOUT, null, null, SOFT_INPUT_ADJUST_RESIZE, null);
|
||||
assertEquals(0, insets.getSystemWindowInsetBottom());
|
||||
@@ -142,32 +140,32 @@ public class InsetsStateTest {
|
||||
|
||||
@Test
|
||||
public void testEquals_differentRect() {
|
||||
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState2.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 10, 10));
|
||||
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState2.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 10, 10));
|
||||
assertNotEqualsAndHashCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals_differentSource() {
|
||||
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState2.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState2.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
assertNotEqualsAndHashCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals_sameButDifferentInsertOrder() {
|
||||
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState2.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState2.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState2.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState2.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
assertEqualsAndHashCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals_visibility() {
|
||||
mState.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(TYPE_IME).setVisible(true);
|
||||
mState2.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_IME).setVisible(true);
|
||||
mState2.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
assertNotEqualsAndHashCode();
|
||||
}
|
||||
|
||||
@@ -187,9 +185,9 @@ public class InsetsStateTest {
|
||||
|
||||
@Test
|
||||
public void testParcelUnparcel() {
|
||||
mState.getSource(TYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(TYPE_IME).setVisible(true);
|
||||
mState.getSource(TYPE_TOP_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_IME).setFrame(new Rect(0, 0, 100, 100));
|
||||
mState.getSource(ITYPE_IME).setVisible(true);
|
||||
mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100));
|
||||
Parcel p = Parcel.obtain();
|
||||
mState.writeToParcel(p, 0 /* flags */);
|
||||
p.setDataPosition(0);
|
||||
@@ -200,11 +198,10 @@ public class InsetsStateTest {
|
||||
|
||||
@Test
|
||||
public void testGetDefaultVisibility() {
|
||||
assertTrue(InsetsState.getDefaultVisibility(TYPE_TOP_BAR));
|
||||
assertTrue(InsetsState.getDefaultVisibility(TYPE_SIDE_BAR_1));
|
||||
assertTrue(InsetsState.getDefaultVisibility(TYPE_SIDE_BAR_2));
|
||||
assertTrue(InsetsState.getDefaultVisibility(TYPE_SIDE_BAR_3));
|
||||
assertFalse(InsetsState.getDefaultVisibility(TYPE_IME));
|
||||
assertTrue(InsetsState.getDefaultVisibility(ITYPE_STATUS_BAR));
|
||||
assertTrue(InsetsState.getDefaultVisibility(ITYPE_NAVIGATION_BAR));
|
||||
assertTrue(InsetsState.getDefaultVisibility(ITYPE_CAPTION_BAR));
|
||||
assertFalse(InsetsState.getDefaultVisibility(ITYPE_IME));
|
||||
}
|
||||
|
||||
private void assertEqualsAndHashCode() {
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
package android.view;
|
||||
|
||||
import static android.view.WindowInsets.Type.ime;
|
||||
import static android.view.WindowInsets.Type.sideBars;
|
||||
import static android.view.WindowInsets.Type.topBar;
|
||||
import static android.view.WindowInsets.Type.navigationBars;
|
||||
import static android.view.WindowInsets.Type.statusBars;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -59,7 +60,7 @@ public class WindowInsetsTest {
|
||||
@Test
|
||||
public void typeMap() {
|
||||
Builder b = new WindowInsets.Builder();
|
||||
b.setInsets(sideBars(), Insets.of(0, 0, 0, 100));
|
||||
b.setInsets(navigationBars(), Insets.of(0, 0, 0, 100));
|
||||
b.setInsets(ime(), Insets.of(0, 0, 0, 300));
|
||||
WindowInsets insets = b.build();
|
||||
assertEquals(300, insets.getSystemWindowInsets().bottom);
|
||||
@@ -71,22 +72,22 @@ public class WindowInsetsTest {
|
||||
Builder b = new WindowInsets.Builder();
|
||||
b.setSystemWindowInsets(Insets.of(0, 50, 30, 10));
|
||||
WindowInsets insets = b.build();
|
||||
assertEquals(Insets.of(0, 50, 0, 0), insets.getInsets(topBar()));
|
||||
assertEquals(Insets.of(0, 0, 30, 10), insets.getInsets(sideBars()));
|
||||
assertEquals(Insets.of(0, 50, 0, 0), insets.getInsets(statusBars()));
|
||||
assertEquals(Insets.of(0, 0, 30, 10), insets.getInsets(navigationBars()));
|
||||
}
|
||||
|
||||
// TODO: Move this to CTS once API made public
|
||||
@Test
|
||||
public void visibility() {
|
||||
Builder b = new WindowInsets.Builder();
|
||||
b.setInsets(sideBars(), Insets.of(0, 0, 0, 100));
|
||||
b.setInsets(navigationBars(), Insets.of(0, 0, 0, 100));
|
||||
b.setInsets(ime(), Insets.of(0, 0, 0, 300));
|
||||
b.setVisible(sideBars(), true);
|
||||
b.setVisible(navigationBars(), true);
|
||||
b.setVisible(ime(), true);
|
||||
WindowInsets insets = b.build();
|
||||
assertTrue(insets.isVisible(sideBars()));
|
||||
assertTrue(insets.isVisible(sideBars() | ime()));
|
||||
assertFalse(insets.isVisible(sideBars() | topBar()));
|
||||
assertTrue(insets.isVisible(navigationBars()));
|
||||
assertTrue(insets.isVisible(navigationBars() | ime()));
|
||||
assertFalse(insets.isVisible(navigationBars() | statusBars()));
|
||||
}
|
||||
|
||||
// TODO: Move this to CTS once API made public
|
||||
|
||||
@@ -42,7 +42,7 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
import android.view.InsetsState.InternalInsetType;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.WindowInsetsController.Appearance;
|
||||
|
||||
import com.android.internal.os.SomeArgs;
|
||||
@@ -284,12 +284,12 @@ public class CommandQueue extends IStatusBar.Stub implements CallbackController<
|
||||
/**
|
||||
* @see IStatusBar#showTransient(int, int[]).
|
||||
*/
|
||||
default void showTransient(int displayId, @InternalInsetType int[] types) { }
|
||||
default void showTransient(int displayId, @InternalInsetsType int[] types) { }
|
||||
|
||||
/**
|
||||
* @see IStatusBar#abortTransient(int, int[]).
|
||||
*/
|
||||
default void abortTransient(int displayId, @InternalInsetType int[] types) { }
|
||||
default void abortTransient(int displayId, @InternalInsetsType int[] types) { }
|
||||
|
||||
/**
|
||||
* @see IStatusBar#topAppWindowChanged(int, boolean, boolean).
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
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 com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT;
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
|
||||
@@ -123,10 +123,10 @@ public class LightBarController implements BatteryController.BatteryStateChangeC
|
||||
void onNavigationBarAppearanceChanged(@Appearance int appearance, boolean nbModeChanged,
|
||||
int navigationBarMode, boolean navbarColorManagedByIme) {
|
||||
int diff = appearance ^ mAppearance;
|
||||
if ((diff & APPEARANCE_LIGHT_SIDE_BARS) != 0 || nbModeChanged) {
|
||||
if ((diff & APPEARANCE_LIGHT_NAVIGATION_BARS) != 0 || nbModeChanged) {
|
||||
final boolean last = mNavigationLight;
|
||||
mHasLightNavigationBar = isLight(appearance, navigationBarMode,
|
||||
APPEARANCE_LIGHT_SIDE_BARS);
|
||||
APPEARANCE_LIGHT_NAVIGATION_BARS);
|
||||
mNavigationLight = mHasLightNavigationBar
|
||||
&& (mDirectReplying && mNavbarColorManagedByIme || !mForceDarkForScrim)
|
||||
&& !mQsCustomizing;
|
||||
@@ -140,7 +140,7 @@ public class LightBarController implements BatteryController.BatteryStateChangeC
|
||||
}
|
||||
|
||||
void onNavigationBarModeChanged(int newBarMode) {
|
||||
mHasLightNavigationBar = isLight(mAppearance, newBarMode, APPEARANCE_LIGHT_SIDE_BARS);
|
||||
mHasLightNavigationBar = isLight(mAppearance, newBarMode, APPEARANCE_LIGHT_NAVIGATION_BARS);
|
||||
}
|
||||
|
||||
private void reevaluate() {
|
||||
@@ -206,7 +206,7 @@ public class LightBarController implements BatteryController.BatteryStateChangeC
|
||||
|
||||
for (int i = 0; i < numStacks; i++) {
|
||||
if (isLight(mAppearanceRegions[i].getAppearance(), mStatusBarMode,
|
||||
APPEARANCE_LIGHT_TOP_BAR)) {
|
||||
APPEARANCE_LIGHT_STATUS_BARS)) {
|
||||
numLightStacks++;
|
||||
indexLightStack = i;
|
||||
}
|
||||
@@ -252,7 +252,7 @@ public class LightBarController implements BatteryController.BatteryStateChangeC
|
||||
final int numStacks = mAppearanceRegions.length;
|
||||
for (int i = 0; i < numStacks; i++) {
|
||||
final boolean isLight = isLight(mAppearanceRegions[i].getAppearance(), mStatusBarMode,
|
||||
APPEARANCE_LIGHT_TOP_BAR);
|
||||
APPEARANCE_LIGHT_STATUS_BARS);
|
||||
pw.print(" stack #"); pw.print(i); pw.print(": ");
|
||||
pw.print(mAppearanceRegions[i].toString()); pw.print(" isLight="); pw.println(isLight);
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
|
||||
import static android.app.StatusBarManager.WindowType;
|
||||
import static android.app.StatusBarManager.WindowVisibleState;
|
||||
import static android.app.StatusBarManager.windowStateToString;
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.containsType;
|
||||
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_NAVIGATION_BARS;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
|
||||
@@ -69,7 +69,7 @@ import android.telecom.TelecomManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.InsetsState.InternalInsetType;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
@@ -565,11 +565,11 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTransient(int displayId, @InternalInsetType int[] types) {
|
||||
public void showTransient(int displayId, @InternalInsetsType int[] types) {
|
||||
if (displayId != mDisplayId) {
|
||||
return;
|
||||
}
|
||||
if (!containsType(types, TYPE_NAVIGATION_BAR)) {
|
||||
if (!containsType(types, ITYPE_NAVIGATION_BAR)) {
|
||||
return;
|
||||
}
|
||||
if (!mTransientShown) {
|
||||
@@ -579,11 +579,11 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abortTransient(int displayId, @InternalInsetType int[] types) {
|
||||
public void abortTransient(int displayId, @InternalInsetsType int[] types) {
|
||||
if (displayId != mDisplayId) {
|
||||
return;
|
||||
}
|
||||
if (!containsType(types, TYPE_NAVIGATION_BAR)) {
|
||||
if (!containsType(types, ITYPE_NAVIGATION_BAR)) {
|
||||
return;
|
||||
}
|
||||
clearTransient();
|
||||
@@ -625,14 +625,14 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
}
|
||||
|
||||
private static @TransitionMode int barMode(boolean isTransient, int appearance) {
|
||||
final int lightsOutOpaque = APPEARANCE_LOW_PROFILE_BARS | APPEARANCE_OPAQUE_SIDE_BARS;
|
||||
final int lightsOutOpaque = APPEARANCE_LOW_PROFILE_BARS | APPEARANCE_OPAQUE_NAVIGATION_BARS;
|
||||
if (isTransient) {
|
||||
return MODE_SEMI_TRANSPARENT;
|
||||
} else if ((appearance & lightsOutOpaque) == lightsOutOpaque) {
|
||||
return MODE_LIGHTS_OUT;
|
||||
} else if ((appearance & APPEARANCE_LOW_PROFILE_BARS) != 0) {
|
||||
return MODE_LIGHTS_OUT_TRANSPARENT;
|
||||
} else if ((appearance & APPEARANCE_OPAQUE_SIDE_BARS) != 0) {
|
||||
} else if ((appearance & APPEARANCE_OPAQUE_NAVIGATION_BARS) != 0) {
|
||||
return MODE_OPAQUE;
|
||||
} else {
|
||||
return MODE_TRANSPARENT;
|
||||
|
||||
@@ -24,10 +24,10 @@ import static android.app.StatusBarManager.WindowType;
|
||||
import static android.app.StatusBarManager.WindowVisibleState;
|
||||
import static android.app.StatusBarManager.windowStateToString;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.InsetsState.containsType;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_TOP_BAR;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS;
|
||||
|
||||
import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
|
||||
import static com.android.systemui.Dependency.BG_HANDLER;
|
||||
@@ -102,7 +102,7 @@ import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.view.Display;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.InsetsState.InternalInsetType;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.RemoteAnimationAdapter;
|
||||
@@ -836,7 +836,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
// Set up the initial notification state. This needs to happen before CommandQueue.disable()
|
||||
setUpPresenter();
|
||||
|
||||
if (containsType(result.mTransientBarTypes, TYPE_TOP_BAR)) {
|
||||
if (containsType(result.mTransientBarTypes, ITYPE_STATUS_BAR)) {
|
||||
showTransientUnchecked();
|
||||
}
|
||||
onSystemBarAppearanceChanged(mDisplayId, result.mAppearance, result.mAppearanceRegions,
|
||||
@@ -2245,11 +2245,11 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTransient(int displayId, @InternalInsetType int[] types) {
|
||||
public void showTransient(int displayId, @InternalInsetsType int[] types) {
|
||||
if (displayId != mDisplayId) {
|
||||
return;
|
||||
}
|
||||
if (!containsType(types, TYPE_TOP_BAR)) {
|
||||
if (!containsType(types, ITYPE_STATUS_BAR)) {
|
||||
return;
|
||||
}
|
||||
showTransientUnchecked();
|
||||
@@ -2264,11 +2264,11 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abortTransient(int displayId, @InternalInsetType int[] types) {
|
||||
public void abortTransient(int displayId, @InternalInsetsType int[] types) {
|
||||
if (displayId != mDisplayId) {
|
||||
return;
|
||||
}
|
||||
if (!containsType(types, TYPE_TOP_BAR)) {
|
||||
if (!containsType(types, ITYPE_STATUS_BAR)) {
|
||||
return;
|
||||
}
|
||||
clearTransient();
|
||||
@@ -2299,14 +2299,14 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
|
||||
private static @TransitionMode int barMode(boolean isTransient, int appearance) {
|
||||
final int lightsOutOpaque = APPEARANCE_LOW_PROFILE_BARS | APPEARANCE_OPAQUE_TOP_BAR;
|
||||
final int lightsOutOpaque = APPEARANCE_LOW_PROFILE_BARS | APPEARANCE_OPAQUE_STATUS_BARS;
|
||||
if (isTransient) {
|
||||
return MODE_SEMI_TRANSPARENT;
|
||||
} else if ((appearance & lightsOutOpaque) == lightsOutOpaque) {
|
||||
return MODE_LIGHTS_OUT;
|
||||
} else if ((appearance & APPEARANCE_LOW_PROFILE_BARS) != 0) {
|
||||
return MODE_LIGHTS_OUT_TRANSPARENT;
|
||||
} else if ((appearance & APPEARANCE_OPAQUE_TOP_BAR) != 0) {
|
||||
} else if ((appearance & APPEARANCE_OPAQUE_STATUS_BARS) != 0) {
|
||||
return MODE_OPAQUE;
|
||||
} else {
|
||||
return MODE_TRANSPARENT;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
package com.android.systemui.statusbar;
|
||||
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
@@ -136,7 +136,7 @@ public class CommandQueueTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testShowTransient() {
|
||||
int[] types = new int[]{ TYPE_TOP_BAR, TYPE_NAVIGATION_BAR };
|
||||
int[] types = new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR};
|
||||
mCommandQueue.showTransient(DEFAULT_DISPLAY, types);
|
||||
waitForIdleSync();
|
||||
verify(mCallbacks).showTransient(eq(DEFAULT_DISPLAY), eq(types));
|
||||
@@ -144,7 +144,7 @@ public class CommandQueueTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testShowTransientForSecondaryDisplay() {
|
||||
int[] types = new int[]{ TYPE_TOP_BAR, TYPE_NAVIGATION_BAR };
|
||||
int[] types = new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR};
|
||||
mCommandQueue.showTransient(SECONDARY_DISPLAY, types);
|
||||
waitForIdleSync();
|
||||
verify(mCallbacks).showTransient(eq(SECONDARY_DISPLAY), eq(types));
|
||||
@@ -152,7 +152,7 @@ public class CommandQueueTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testAbortTransient() {
|
||||
int[] types = new int[]{ TYPE_TOP_BAR, TYPE_NAVIGATION_BAR };
|
||||
int[] types = new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR};
|
||||
mCommandQueue.abortTransient(DEFAULT_DISPLAY, types);
|
||||
waitForIdleSync();
|
||||
verify(mCallbacks).abortTransient(eq(DEFAULT_DISPLAY), eq(types));
|
||||
@@ -160,7 +160,7 @@ public class CommandQueueTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testAbortTransientForSecondaryDisplay() {
|
||||
int[] types = new int[]{ TYPE_TOP_BAR, TYPE_NAVIGATION_BAR };
|
||||
int[] types = new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR};
|
||||
mCommandQueue.abortTransient(SECONDARY_DISPLAY, types);
|
||||
waitForIdleSync();
|
||||
verify(mCallbacks).abortTransient(eq(SECONDARY_DISPLAY), eq(types));
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_TOP_BAR;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
|
||||
|
||||
@@ -64,8 +64,8 @@ public class LightBarControllerTest extends SysuiTestCase {
|
||||
final Rect firstBounds = new Rect(0, 0, 1, 1);
|
||||
final Rect secondBounds = new Rect(1, 0, 2, 1);
|
||||
final AppearanceRegion[] appearanceRegions = new AppearanceRegion[]{
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_TOP_BAR, firstBounds),
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_TOP_BAR, secondBounds)
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, firstBounds),
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, secondBounds)
|
||||
};
|
||||
mLightBarController.onStatusBarAppearanceChanged(
|
||||
appearanceRegions, true /* sbModeChanged */, MODE_TRANSPARENT,
|
||||
@@ -79,7 +79,7 @@ public class LightBarControllerTest extends SysuiTestCase {
|
||||
final Rect firstBounds = new Rect(0, 0, 1, 1);
|
||||
final Rect secondBounds = new Rect(1, 0, 2, 1);
|
||||
final AppearanceRegion[] appearanceRegions = new AppearanceRegion[]{
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_TOP_BAR, firstBounds),
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, firstBounds),
|
||||
new AppearanceRegion(0 /* appearance */, secondBounds)
|
||||
};
|
||||
mLightBarController.onStatusBarAppearanceChanged(
|
||||
@@ -95,7 +95,7 @@ public class LightBarControllerTest extends SysuiTestCase {
|
||||
final Rect secondBounds = new Rect(1, 0, 2, 1);
|
||||
final AppearanceRegion[] appearanceRegions = new AppearanceRegion[]{
|
||||
new AppearanceRegion(0 /* appearance */, firstBounds),
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_TOP_BAR, secondBounds)
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, secondBounds)
|
||||
};
|
||||
mLightBarController.onStatusBarAppearanceChanged(
|
||||
appearanceRegions, true /* sbModeChanged */, MODE_TRANSPARENT,
|
||||
@@ -121,7 +121,7 @@ public class LightBarControllerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testOnStatusBarAppearanceChanged_singleStack_light() {
|
||||
final AppearanceRegion[] appearanceRegions = new AppearanceRegion[]{
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_TOP_BAR, new Rect(0, 0, 1, 1))
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, new Rect(0, 0, 1, 1))
|
||||
};
|
||||
mLightBarController.onStatusBarAppearanceChanged(
|
||||
appearanceRegions, true /* sbModeChanged */, MODE_TRANSPARENT,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.server.statusbar;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.InsetsState.InternalInsetType;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.WindowInsetsController.Appearance;
|
||||
|
||||
import com.android.internal.view.AppearanceRegion;
|
||||
@@ -119,8 +119,8 @@ public interface StatusBarManagerInternal {
|
||||
AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme);
|
||||
|
||||
/** @see com.android.internal.statusbar.IStatusBar#showTransient */
|
||||
void showTransient(int displayId, @InternalInsetType int[] types);
|
||||
void showTransient(int displayId, @InternalInsetsType int[] types);
|
||||
|
||||
/** @see com.android.internal.statusbar.IStatusBar#abortTransient */
|
||||
void abortTransient(int displayId, @InternalInsetType int[] types);
|
||||
void abortTransient(int displayId, @InternalInsetsType int[] types);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ import android.util.ArraySet;
|
||||
import android.util.Pair;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.view.InsetsState.InternalInsetType;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.WindowInsetsController.Appearance;
|
||||
|
||||
import com.android.internal.R;
|
||||
@@ -482,7 +482,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTransient(int displayId, @InternalInsetType int[] types) {
|
||||
public void showTransient(int displayId, @InternalInsetsType int[] types) {
|
||||
getUiState(displayId).showTransient(types);
|
||||
if (mBar != null) {
|
||||
try {
|
||||
@@ -492,7 +492,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abortTransient(int displayId, @InternalInsetType int[] types) {
|
||||
public void abortTransient(int displayId, @InternalInsetsType int[] types) {
|
||||
getUiState(displayId).clearTransient(types);
|
||||
if (mBar != null) {
|
||||
try {
|
||||
@@ -966,13 +966,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showTransient(@InternalInsetType int[] types) {
|
||||
private void showTransient(@InternalInsetsType int[] types) {
|
||||
for (int type : types) {
|
||||
mTransientBarTypes.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearTransient(@InternalInsetType int[] types) {
|
||||
private void clearTransient(@InternalInsetsType int[] types) {
|
||||
for (int type : types) {
|
||||
mTransientBarTypes.remove(type);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.Display.FLAG_PRIVATE;
|
||||
import static android.view.Display.FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
|
||||
import static android.view.Display.INVALID_DISPLAY;
|
||||
import static android.view.InsetsState.TYPE_IME;
|
||||
import static android.view.InsetsState.TYPE_LEFT_GESTURES;
|
||||
import static android.view.InsetsState.TYPE_RIGHT_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_IME;
|
||||
import static android.view.InsetsState.ITYPE_LEFT_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_RIGHT_GESTURES;
|
||||
import static android.view.Surface.ROTATION_0;
|
||||
import static android.view.Surface.ROTATION_180;
|
||||
import static android.view.Surface.ROTATION_270;
|
||||
@@ -179,7 +179,7 @@ import android.view.ISystemGestureExclusionListener;
|
||||
import android.view.InputChannel;
|
||||
import android.view.InputDevice;
|
||||
import android.view.InputWindowHandle;
|
||||
import android.view.InsetsState.InternalInsetType;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.MagnificationSpec;
|
||||
import android.view.RemoteAnimationDefinition;
|
||||
import android.view.Surface;
|
||||
@@ -1101,7 +1101,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
||||
* @param frameProvider Function to compute the frame, or {@code null} if the just the frame of
|
||||
* the window should be taken.
|
||||
*/
|
||||
void setInsetProvider(@InternalInsetType int type, WindowState win,
|
||||
void setInsetProvider(@InternalInsetsType int type, WindowState win,
|
||||
@Nullable TriConsumer<DisplayFrames, WindowState, Rect> frameProvider) {
|
||||
mInsetsStateController.getSourceProvider(type).setWindow(win, frameProvider);
|
||||
}
|
||||
@@ -3096,7 +3096,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
||||
mInputMethodWindow.getDisplayId());
|
||||
}
|
||||
computeImeTarget(true /* updateImeTarget */);
|
||||
mInsetsStateController.getSourceProvider(TYPE_IME).setWindow(win,
|
||||
mInsetsStateController.getSourceProvider(ITYPE_IME).setWindow(win,
|
||||
null /* frameProvider */);
|
||||
}
|
||||
|
||||
@@ -5008,9 +5008,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
||||
final Region unhandled = Region.obtain();
|
||||
unhandled.set(0, 0, mDisplayFrames.mDisplayWidth, mDisplayFrames.mDisplayHeight);
|
||||
|
||||
final Rect leftEdge = mInsetsStateController.getSourceProvider(TYPE_LEFT_GESTURES)
|
||||
final Rect leftEdge = mInsetsStateController.getSourceProvider(ITYPE_LEFT_GESTURES)
|
||||
.getSource().getFrame();
|
||||
final Rect rightEdge = mInsetsStateController.getSourceProvider(TYPE_RIGHT_GESTURES)
|
||||
final Rect rightEdge = mInsetsStateController.getSourceProvider(ITYPE_RIGHT_GESTURES)
|
||||
.getSource().getFrame();
|
||||
|
||||
final Region touchableRegion = Region.obtain();
|
||||
|
||||
@@ -25,14 +25,19 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECOND
|
||||
import static android.content.res.Configuration.UI_MODE_TYPE_CAR;
|
||||
import static android.content.res.Configuration.UI_MODE_TYPE_MASK;
|
||||
import static android.view.Display.TYPE_BUILT_IN;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.TYPE_TOP_GESTURES;
|
||||
import static android.view.InsetsState.TYPE_TOP_TAPPABLE_ELEMENT;
|
||||
import static android.view.InsetsState.ITYPE_BOTTOM_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
|
||||
import static android.view.InsetsState.ITYPE_LEFT_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_RIGHT_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.InsetsState.ITYPE_TOP_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_TOP_TAPPABLE_ELEMENT;
|
||||
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_TOP_BAR;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE;
|
||||
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
|
||||
import static android.view.WindowManager.INPUT_CONSUMER_NAVIGATION;
|
||||
@@ -144,8 +149,7 @@ import android.view.InputDevice;
|
||||
import android.view.InputEvent;
|
||||
import android.view.InputEventReceiver;
|
||||
import android.view.InsetsFlags;
|
||||
import android.view.InsetsState;
|
||||
import android.view.InsetsState.InternalInsetType;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.PointerIcon;
|
||||
import android.view.Surface;
|
||||
@@ -970,36 +974,36 @@ public class DisplayPolicy {
|
||||
rect.top = 0;
|
||||
rect.bottom = getStatusBarHeight(displayFrames);
|
||||
};
|
||||
mDisplayContent.setInsetProvider(TYPE_TOP_BAR, win, frameProvider);
|
||||
mDisplayContent.setInsetProvider(TYPE_TOP_GESTURES, win, frameProvider);
|
||||
mDisplayContent.setInsetProvider(TYPE_TOP_TAPPABLE_ELEMENT, win, frameProvider);
|
||||
mDisplayContent.setInsetProvider(ITYPE_STATUS_BAR, win, frameProvider);
|
||||
mDisplayContent.setInsetProvider(ITYPE_TOP_GESTURES, win, frameProvider);
|
||||
mDisplayContent.setInsetProvider(ITYPE_TOP_TAPPABLE_ELEMENT, win, frameProvider);
|
||||
break;
|
||||
case TYPE_NAVIGATION_BAR:
|
||||
mNavigationBar = win;
|
||||
mNavigationBarController.setWindow(win);
|
||||
mNavigationBarController.setOnBarVisibilityChangedListener(
|
||||
mNavBarVisibilityListener, true);
|
||||
mDisplayContent.setInsetProvider(InsetsState.TYPE_NAVIGATION_BAR,
|
||||
mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR,
|
||||
win, null /* frameProvider */);
|
||||
mDisplayContent.setInsetProvider(InsetsState.TYPE_BOTTOM_GESTURES, win,
|
||||
mDisplayContent.setInsetProvider(ITYPE_BOTTOM_GESTURES, win,
|
||||
(displayFrames, windowState, inOutFrame) -> {
|
||||
inOutFrame.top -= mBottomGestureAdditionalInset;
|
||||
});
|
||||
mDisplayContent.setInsetProvider(InsetsState.TYPE_LEFT_GESTURES, win,
|
||||
mDisplayContent.setInsetProvider(ITYPE_LEFT_GESTURES, win,
|
||||
(displayFrames, windowState, inOutFrame) -> {
|
||||
inOutFrame.left = 0;
|
||||
inOutFrame.top = 0;
|
||||
inOutFrame.bottom = displayFrames.mDisplayHeight;
|
||||
inOutFrame.right = displayFrames.mUnrestricted.left + mSideGestureInset;
|
||||
});
|
||||
mDisplayContent.setInsetProvider(InsetsState.TYPE_RIGHT_GESTURES, win,
|
||||
mDisplayContent.setInsetProvider(ITYPE_RIGHT_GESTURES, win,
|
||||
(displayFrames, windowState, inOutFrame) -> {
|
||||
inOutFrame.left = displayFrames.mUnrestricted.right - mSideGestureInset;
|
||||
inOutFrame.top = 0;
|
||||
inOutFrame.bottom = displayFrames.mDisplayHeight;
|
||||
inOutFrame.right = displayFrames.mDisplayWidth;
|
||||
});
|
||||
mDisplayContent.setInsetProvider(InsetsState.TYPE_BOTTOM_TAPPABLE_ELEMENT, win,
|
||||
mDisplayContent.setInsetProvider(ITYPE_BOTTOM_TAPPABLE_ELEMENT, win,
|
||||
(displayFrames, windowState, inOutFrame) -> {
|
||||
if ((windowState.getAttrs().flags & FLAG_NOT_TOUCHABLE) != 0
|
||||
|| mNavigationBarLetsThroughTaps) {
|
||||
@@ -1024,11 +1028,11 @@ public class DisplayPolicy {
|
||||
if (mDisplayContent.isDefaultDisplay) {
|
||||
mService.mPolicy.setKeyguardCandidateLw(null);
|
||||
}
|
||||
mDisplayContent.setInsetProvider(TYPE_TOP_BAR, null, null);
|
||||
mDisplayContent.setInsetProvider(ITYPE_STATUS_BAR, null, null);
|
||||
} else if (mNavigationBar == win) {
|
||||
mNavigationBar = null;
|
||||
mNavigationBarController.setWindow(null);
|
||||
mDisplayContent.setInsetProvider(InsetsState.TYPE_NAVIGATION_BAR, null, null);
|
||||
mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, null, null);
|
||||
}
|
||||
if (mLastFocusedWindow == win) {
|
||||
mLastFocusedWindow = null;
|
||||
@@ -2955,7 +2959,7 @@ public class DisplayPolicy {
|
||||
}
|
||||
if (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL) {
|
||||
if (swipeTarget == mNavigationBar
|
||||
&& !getInsetsPolicy().isHidden(InsetsState.TYPE_NAVIGATION_BAR)) {
|
||||
&& !getInsetsPolicy().isHidden(ITYPE_NAVIGATION_BAR)) {
|
||||
// Don't show status bar when swiping on already visible navigation bar
|
||||
return;
|
||||
}
|
||||
@@ -2966,7 +2970,7 @@ public class DisplayPolicy {
|
||||
}
|
||||
if (controlTarget.canShowTransient()) {
|
||||
mDisplayContent.getInsetsPolicy().showTransient(IntArray.wrap(
|
||||
new int[]{TYPE_TOP_BAR, InsetsState.TYPE_NAVIGATION_BAR}));
|
||||
new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR}));
|
||||
} else {
|
||||
controlTarget.showInsets(WindowInsets.Type.systemBars(), false);
|
||||
}
|
||||
@@ -3080,9 +3084,9 @@ public class DisplayPolicy {
|
||||
final boolean isFullscreen = (visibility & (View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)) != 0
|
||||
|| (PolicyControl.getWindowFlags(win, win.mAttrs) & FLAG_FULLSCREEN) != 0
|
||||
|| (mStatusBar != null && insetsPolicy.isHidden(TYPE_TOP_BAR))
|
||||
|| (mStatusBar != null && insetsPolicy.isHidden(ITYPE_STATUS_BAR))
|
||||
|| (mNavigationBar != null && insetsPolicy.isHidden(
|
||||
InsetsState.TYPE_NAVIGATION_BAR));
|
||||
ITYPE_NAVIGATION_BAR));
|
||||
final int behavior = win.mAttrs.insetsFlags.behavior;
|
||||
final boolean isImmersive = (visibility & (View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)) != 0
|
||||
@@ -3149,15 +3153,15 @@ public class DisplayPolicy {
|
||||
private static Pair<int[], int[]> getTransientState(int vis, int oldVis) {
|
||||
final IntArray typesToShow = new IntArray(0);
|
||||
final IntArray typesToAbort = new IntArray(0);
|
||||
updateTransientState(vis, oldVis, View.STATUS_BAR_TRANSIENT, TYPE_TOP_BAR, typesToShow,
|
||||
updateTransientState(vis, oldVis, View.STATUS_BAR_TRANSIENT, ITYPE_STATUS_BAR, typesToShow,
|
||||
typesToAbort);
|
||||
updateTransientState(vis, oldVis, View.NAVIGATION_BAR_TRANSIENT,
|
||||
InsetsState.TYPE_NAVIGATION_BAR, typesToShow, typesToAbort);
|
||||
ITYPE_NAVIGATION_BAR, typesToShow, typesToAbort);
|
||||
return Pair.create(typesToShow.toArray(), typesToAbort.toArray());
|
||||
}
|
||||
|
||||
private static void updateTransientState(int vis, int oldVis, int transientFlag,
|
||||
@InternalInsetType int type, IntArray typesToShow, IntArray typesToAbort) {
|
||||
@InternalInsetsType int type, IntArray typesToShow, IntArray typesToAbort) {
|
||||
final boolean wasTransient = (oldVis & transientFlag) != 0;
|
||||
final boolean isTransient = (vis & transientFlag) != 0;
|
||||
if (!wasTransient && isTransient) {
|
||||
@@ -3174,14 +3178,14 @@ public class DisplayPolicy {
|
||||
if (statusColorWin != null && (statusColorWin == opaque || onKeyguard)) {
|
||||
// If the top fullscreen-or-dimming window is also the top fullscreen, respect
|
||||
// its light flag.
|
||||
appearance &= ~APPEARANCE_LIGHT_TOP_BAR;
|
||||
appearance &= ~APPEARANCE_LIGHT_STATUS_BARS;
|
||||
final int legacyAppearance = InsetsFlags.getAppearance(
|
||||
PolicyControl.getSystemUiVisibility(statusColorWin, null));
|
||||
appearance |= (statusColorWin.mAttrs.insetsFlags.appearance | legacyAppearance)
|
||||
& APPEARANCE_LIGHT_TOP_BAR;
|
||||
& APPEARANCE_LIGHT_STATUS_BARS;
|
||||
} else if (statusColorWin != null && statusColorWin.isDimming()) {
|
||||
// Otherwise if it's dimming, clear the light flag.
|
||||
appearance &= ~APPEARANCE_LIGHT_TOP_BAR;
|
||||
appearance &= ~APPEARANCE_LIGHT_STATUS_BARS;
|
||||
}
|
||||
return appearance;
|
||||
}
|
||||
@@ -3508,7 +3512,7 @@ public class DisplayPolicy {
|
||||
if (!isNavBarEmpty(mLastSystemUiFlags)) {
|
||||
mNavigationBarController.showTransient();
|
||||
mDisplayContent.getInsetsPolicy().showTransient(IntArray.wrap(
|
||||
new int[] {InsetsState.TYPE_NAVIGATION_BAR}));
|
||||
new int[] {ITYPE_NAVIGATION_BAR}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.server.wm;
|
||||
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.view.WindowInsets.Type.InsetType;
|
||||
import android.view.WindowInsets.Type.InsetsType;
|
||||
|
||||
/**
|
||||
* Generalization of an object that can control insets state.
|
||||
@@ -31,7 +31,7 @@ interface InsetsControlTarget {
|
||||
* @param types to specify which types of insets source window should be shown.
|
||||
* @param fromIme {@code true} if IME show request originated from {@link InputMethodService}.
|
||||
*/
|
||||
default void showInsets(@InsetType int types, boolean fromIme) {
|
||||
default void showInsets(@InsetsType int types, boolean fromIme) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ interface InsetsControlTarget {
|
||||
* @param types to specify which types of insets source window should be hidden.
|
||||
* @param fromIme {@code true} if IME hide request originated from {@link InputMethodService}.
|
||||
*/
|
||||
default void hideInsets(@InsetType int types, boolean fromIme) {
|
||||
default void hideInsets(@InsetsType int types, boolean fromIme) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,8 +20,8 @@ import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
|
||||
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION;
|
||||
@@ -30,7 +30,7 @@ import android.annotation.Nullable;
|
||||
import android.app.StatusBarManager;
|
||||
import android.util.IntArray;
|
||||
import android.view.InsetsState;
|
||||
import android.view.InsetsState.InternalInsetType;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.ViewRootImpl;
|
||||
|
||||
/**
|
||||
@@ -66,13 +66,13 @@ class InsetsPolicy {
|
||||
}
|
||||
mTopBar.setVisible(focusedWin == null
|
||||
|| focusedWin != getTopControlTarget(focusedWin)
|
||||
|| focusedWin.getClientInsetsState().getSource(TYPE_TOP_BAR).isVisible());
|
||||
|| focusedWin.getClientInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
|
||||
mNavBar.setVisible(focusedWin == null
|
||||
|| focusedWin != getNavControlTarget(focusedWin)
|
||||
|| focusedWin.getClientInsetsState().getSource(TYPE_NAVIGATION_BAR).isVisible());
|
||||
|| focusedWin.getClientInsetsState().getSource(ITYPE_NAVIGATION_BAR).isVisible());
|
||||
}
|
||||
|
||||
boolean isHidden(@InternalInsetType int type) {
|
||||
boolean isHidden(@InternalInsetsType int type) {
|
||||
final InsetsSourceProvider provider = mStateController.peekSourceProvider(type);
|
||||
return provider != null && provider.hasWindow() && !provider.getSource().isVisible();
|
||||
}
|
||||
@@ -131,10 +131,10 @@ class InsetsPolicy {
|
||||
return;
|
||||
}
|
||||
if (windowState == getTopControlTarget(mFocusedWin)) {
|
||||
mTopBar.setVisible(state.getSource(TYPE_TOP_BAR).isVisible());
|
||||
mTopBar.setVisible(state.getSource(ITYPE_STATUS_BAR).isVisible());
|
||||
}
|
||||
if (windowState == getNavControlTarget(mFocusedWin)) {
|
||||
mNavBar.setVisible(state.getSource(TYPE_NAVIGATION_BAR).isVisible());
|
||||
mNavBar.setVisible(state.getSource(ITYPE_NAVIGATION_BAR).isVisible());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,21 +165,21 @@ class InsetsPolicy {
|
||||
}
|
||||
|
||||
private @Nullable InsetsControlTarget getFakeTopControlTarget(@Nullable WindowState focused) {
|
||||
if (mShowingTransientTypes.indexOf(TYPE_TOP_BAR) != -1) {
|
||||
if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) {
|
||||
return focused;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private @Nullable InsetsControlTarget getFakeNavControlTarget(@Nullable WindowState focused) {
|
||||
if (mShowingTransientTypes.indexOf(TYPE_NAVIGATION_BAR) != -1) {
|
||||
if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1) {
|
||||
return focused;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private @Nullable InsetsControlTarget getTopControlTarget(@Nullable WindowState focusedWin) {
|
||||
if (mShowingTransientTypes.indexOf(TYPE_TOP_BAR) != -1) {
|
||||
if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) {
|
||||
return mTransientControlTarget;
|
||||
}
|
||||
if (areSystemBarsForciblyVisible() || isStatusBarForciblyVisible()) {
|
||||
@@ -189,7 +189,7 @@ class InsetsPolicy {
|
||||
}
|
||||
|
||||
private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin) {
|
||||
if (mShowingTransientTypes.indexOf(TYPE_NAVIGATION_BAR) != -1) {
|
||||
if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1) {
|
||||
return mTransientControlTarget;
|
||||
}
|
||||
if (areSystemBarsForciblyVisible() || isNavBarForciblyVisible()) {
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.view.InsetsState.TYPE_IME;
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_IME;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
|
||||
@@ -81,9 +81,9 @@ class InsetsSourceProvider {
|
||||
new Point());
|
||||
|
||||
final int type = source.getType();
|
||||
if (type == TYPE_TOP_BAR || type == TYPE_NAVIGATION_BAR) {
|
||||
if (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR) {
|
||||
mControllable = sNewInsetsMode == NEW_INSETS_MODE_FULL;
|
||||
} else if (type == TYPE_IME) {
|
||||
} else if (type == ITYPE_IME) {
|
||||
mControllable = sNewInsetsMode >= NEW_INSETS_MODE_IME;
|
||||
} else {
|
||||
mControllable = false;
|
||||
@@ -256,7 +256,7 @@ class InsetsSourceProvider {
|
||||
OnAnimationFinishedCallback finishCallback) {
|
||||
// TODO(b/118118435): We can remove the type check when implementing the transient bar
|
||||
// animation.
|
||||
if (mSource.getType() == TYPE_IME) {
|
||||
if (mSource.getType() == ITYPE_IME) {
|
||||
// TODO: use 0 alpha and remove t.hide() once b/138459974 is fixed.
|
||||
t.setAlpha(animationLeash, 1 /* alpha */);
|
||||
t.hide(animationLeash);
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.view.InsetsState.TYPE_IME;
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_IME;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
|
||||
import static android.view.ViewRootImpl.sNewInsetsMode;
|
||||
|
||||
@@ -30,7 +30,7 @@ import android.util.SparseArray;
|
||||
import android.view.InsetsSource;
|
||||
import android.view.InsetsSourceControl;
|
||||
import android.view.InsetsState;
|
||||
import android.view.InsetsState.InternalInsetType;
|
||||
import android.view.InsetsState.InternalInsetsType;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
@@ -84,9 +84,9 @@ class InsetsStateController {
|
||||
state.removeSource(type);
|
||||
|
||||
// Navigation bar doesn't get influenced by anything else
|
||||
if (type == TYPE_NAVIGATION_BAR) {
|
||||
state.removeSource(TYPE_IME);
|
||||
state.removeSource(TYPE_TOP_BAR);
|
||||
if (type == ITYPE_NAVIGATION_BAR) {
|
||||
state.removeSource(ITYPE_IME);
|
||||
state.removeSource(ITYPE_STATUS_BAR);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
@@ -107,8 +107,8 @@ class InsetsStateController {
|
||||
/**
|
||||
* @return The provider of a specific type.
|
||||
*/
|
||||
InsetsSourceProvider getSourceProvider(@InternalInsetType int type) {
|
||||
if (type == TYPE_IME) {
|
||||
InsetsSourceProvider getSourceProvider(@InternalInsetsType int type) {
|
||||
if (type == ITYPE_IME) {
|
||||
return mProviders.computeIfAbsent(type,
|
||||
key -> new ImeInsetsSourceProvider(
|
||||
mState.getSource(key), this, mDisplayContent));
|
||||
@@ -119,13 +119,13 @@ class InsetsStateController {
|
||||
}
|
||||
|
||||
ImeInsetsSourceProvider getImeSourceProvider() {
|
||||
return (ImeInsetsSourceProvider) getSourceProvider(TYPE_IME);
|
||||
return (ImeInsetsSourceProvider) getSourceProvider(ITYPE_IME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The provider of a specific type or null if we don't have it.
|
||||
*/
|
||||
@Nullable InsetsSourceProvider peekSourceProvider(@InternalInsetType int type) {
|
||||
@Nullable InsetsSourceProvider peekSourceProvider(@InternalInsetsType int type) {
|
||||
return mProviders.get(type);
|
||||
}
|
||||
|
||||
@@ -159,12 +159,12 @@ class InsetsStateController {
|
||||
}
|
||||
}
|
||||
|
||||
boolean isFakeTarget(@InternalInsetType int type, InsetsControlTarget target) {
|
||||
boolean isFakeTarget(@InternalInsetsType int type, InsetsControlTarget target) {
|
||||
return mTypeFakeControlTargetMap.get(type) == target;
|
||||
}
|
||||
|
||||
void onImeTargetChanged(@Nullable InsetsControlTarget imeTarget) {
|
||||
onControlChanged(TYPE_IME, imeTarget);
|
||||
onControlChanged(ITYPE_IME, imeTarget);
|
||||
notifyPendingInsetsControlChanged();
|
||||
}
|
||||
|
||||
@@ -180,10 +180,10 @@ class InsetsStateController {
|
||||
@Nullable InsetsControlTarget fakeTopControlling,
|
||||
@Nullable InsetsControlTarget navControlling,
|
||||
@Nullable InsetsControlTarget fakeNavControlling) {
|
||||
onControlChanged(TYPE_TOP_BAR, topControlling);
|
||||
onControlChanged(TYPE_NAVIGATION_BAR, navControlling);
|
||||
onControlFakeTargetChanged(TYPE_TOP_BAR, fakeTopControlling);
|
||||
onControlFakeTargetChanged(TYPE_NAVIGATION_BAR, fakeNavControlling);
|
||||
onControlChanged(ITYPE_STATUS_BAR, topControlling);
|
||||
onControlChanged(ITYPE_NAVIGATION_BAR, navControlling);
|
||||
onControlFakeTargetChanged(ITYPE_STATUS_BAR, fakeTopControlling);
|
||||
onControlFakeTargetChanged(ITYPE_NAVIGATION_BAR, fakeNavControlling);
|
||||
notifyPendingInsetsControlChanged();
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class InsetsStateController {
|
||||
false /* fake */);
|
||||
}
|
||||
|
||||
private void onControlChanged(@InternalInsetType int type,
|
||||
private void onControlChanged(@InternalInsetsType int type,
|
||||
@Nullable InsetsControlTarget target) {
|
||||
final InsetsControlTarget previous = mTypeControlTargetMap.get(type);
|
||||
if (target == previous) {
|
||||
@@ -223,7 +223,7 @@ class InsetsStateController {
|
||||
* showing/hiding. For example, when the transient bars are showing, and the fake target
|
||||
* requests to show system bars, the transient state will be aborted.
|
||||
*/
|
||||
void onControlFakeTargetChanged(@InternalInsetType int type,
|
||||
void onControlFakeTargetChanged(@InternalInsetsType int type,
|
||||
@Nullable InsetsControlTarget fakeTarget) {
|
||||
if (sNewInsetsMode != NEW_INSETS_MODE_FULL) {
|
||||
return;
|
||||
@@ -248,7 +248,7 @@ class InsetsStateController {
|
||||
}
|
||||
|
||||
private void removeFromControlMaps(@NonNull InsetsControlTarget target,
|
||||
@InternalInsetType int type, boolean fake) {
|
||||
@InternalInsetsType int type, boolean fake) {
|
||||
final ArrayList<Integer> array = mControlTargetTypeMap.get(target);
|
||||
if (array == null) {
|
||||
return;
|
||||
@@ -265,7 +265,7 @@ class InsetsStateController {
|
||||
}
|
||||
|
||||
private void addToControlMaps(@NonNull InsetsControlTarget target,
|
||||
@InternalInsetType int type, boolean fake) {
|
||||
@InternalInsetsType int type, boolean fake) {
|
||||
final ArrayList<Integer> array = mControlTargetTypeMap.computeIfAbsent(target,
|
||||
key -> new ArrayList<>());
|
||||
array.add(type);
|
||||
|
||||
@@ -200,7 +200,7 @@ import android.view.SurfaceSession;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowInfo;
|
||||
import android.view.WindowInsets.Type.InsetType;
|
||||
import android.view.WindowInsets.Type.InsetsType;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
@@ -3355,7 +3355,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showInsets(@InsetType int types, boolean fromIme) {
|
||||
public void showInsets(@InsetsType int types, boolean fromIme) {
|
||||
try {
|
||||
mClient.showInsets(types, fromIme);
|
||||
} catch (RemoteException e) {
|
||||
@@ -3364,7 +3364,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideInsets(@InsetType int types, boolean fromIme) {
|
||||
public void hideInsets(@InsetsType int types, boolean fromIme) {
|
||||
try {
|
||||
mClient.hideInsets(types, fromIme);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -19,7 +19,8 @@ package com.android.server.wm;
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
|
||||
@@ -67,7 +68,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testControlsForDispatch_regular() {
|
||||
addWindow(TYPE_STATUS_BAR, "topBar");
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar");
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar");
|
||||
|
||||
final InsetsSourceControl[] controls = addAppWindowAndGetControlsForDispatch();
|
||||
@@ -79,7 +80,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testControlsForDispatch_dockedStackVisible() {
|
||||
addWindow(TYPE_STATUS_BAR, "topBar");
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar");
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar");
|
||||
|
||||
final WindowState win = createWindowOnStack(null, WINDOWING_MODE_SPLIT_SCREEN_PRIMARY,
|
||||
@@ -92,7 +93,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testControlsForDispatch_freeformStackVisible() {
|
||||
addWindow(TYPE_STATUS_BAR, "topBar");
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar");
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar");
|
||||
|
||||
final WindowState win = createWindowOnStack(null, WINDOWING_MODE_FREEFORM,
|
||||
@@ -105,7 +106,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testControlsForDispatch_dockedDividerControllerResizing() {
|
||||
addWindow(TYPE_STATUS_BAR, "topBar");
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar");
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar");
|
||||
mDisplayContent.getDockedDividerController().setResizing(true);
|
||||
|
||||
@@ -117,7 +118,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testControlsForDispatch_keyguard() {
|
||||
addWindow(TYPE_STATUS_BAR, "topBar").mAttrs.privateFlags |= PRIVATE_FLAG_KEYGUARD;
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar").mAttrs.privateFlags |= PRIVATE_FLAG_KEYGUARD;
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar");
|
||||
|
||||
final InsetsSourceControl[] controls = addAppWindowAndGetControlsForDispatch();
|
||||
@@ -130,7 +131,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
// TODO: adjust this test if we pretend to the app that it's still able to control it.
|
||||
@Test
|
||||
public void testControlsForDispatch_forceStatusBarVisibleTransparent() {
|
||||
addWindow(TYPE_STATUS_BAR, "topBar").mAttrs.privateFlags |=
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar").mAttrs.privateFlags |=
|
||||
PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT;
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar");
|
||||
|
||||
@@ -143,7 +144,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testControlsForDispatch_statusBarForceShowNavigation() {
|
||||
addWindow(TYPE_STATUS_BAR, "topBar").mAttrs.privateFlags |=
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar").mAttrs.privateFlags |=
|
||||
PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION;
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar");
|
||||
|
||||
@@ -156,7 +157,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testShowTransientBars_bothCanBeTransient_appGetsBothFakeControls() {
|
||||
addWindow(TYPE_STATUS_BAR, "topBar")
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar")
|
||||
.getControllableInsetProvider().getSource().setVisible(false);
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar")
|
||||
.getControllableInsetProvider().getSource().setVisible(false);
|
||||
@@ -165,7 +166,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
final InsetsPolicy policy = mDisplayContent.getInsetsPolicy();
|
||||
policy.updateBarControlTarget(app);
|
||||
policy.showTransient(
|
||||
IntArray.wrap(new int[]{TYPE_TOP_BAR, InsetsState.TYPE_NAVIGATION_BAR}));
|
||||
IntArray.wrap(new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR}));
|
||||
final InsetsSourceControl[] controls =
|
||||
mDisplayContent.getInsetsStateController().getControlsForDispatch(app);
|
||||
|
||||
@@ -182,7 +183,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
// being cleared by InsetsSourceProvider.updateVisibility.
|
||||
final WindowState app = addWindow(TYPE_APPLICATION, "app");
|
||||
|
||||
addWindow(TYPE_STATUS_BAR, "topBar")
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar")
|
||||
.getControllableInsetProvider().getSource().setVisible(false);
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar")
|
||||
.getControllableInsetProvider().getSource().setVisible(true);
|
||||
@@ -190,7 +191,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
final InsetsPolicy policy = mDisplayContent.getInsetsPolicy();
|
||||
policy.updateBarControlTarget(app);
|
||||
policy.showTransient(
|
||||
IntArray.wrap(new int[]{TYPE_TOP_BAR, InsetsState.TYPE_NAVIGATION_BAR}));
|
||||
IntArray.wrap(new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR}));
|
||||
final InsetsSourceControl[] controls =
|
||||
mDisplayContent.getInsetsStateController().getControlsForDispatch(app);
|
||||
|
||||
@@ -199,7 +200,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
assertEquals(2, controls.length);
|
||||
for (int i = controls.length - 1; i >= 0; i--) {
|
||||
final InsetsSourceControl control = controls[i];
|
||||
if (control.getType() == TYPE_TOP_BAR) {
|
||||
if (control.getType() == ITYPE_STATUS_BAR) {
|
||||
assertNull(controls[i].getLeash());
|
||||
} else {
|
||||
assertNotNull(controls[i].getLeash());
|
||||
@@ -209,7 +210,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testAbortTransientBars_bothCanBeAborted_appGetsBothRealControls() {
|
||||
addWindow(TYPE_STATUS_BAR, "topBar")
|
||||
addWindow(TYPE_STATUS_BAR, "statusBar")
|
||||
.getControllableInsetProvider().getSource().setVisible(false);
|
||||
addWindow(TYPE_NAVIGATION_BAR, "navBar")
|
||||
.getControllableInsetProvider().getSource().setVisible(false);
|
||||
@@ -218,7 +219,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
final InsetsPolicy policy = mDisplayContent.getInsetsPolicy();
|
||||
policy.updateBarControlTarget(app);
|
||||
policy.showTransient(
|
||||
IntArray.wrap(new int[]{TYPE_TOP_BAR, InsetsState.TYPE_NAVIGATION_BAR}));
|
||||
IntArray.wrap(new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR}));
|
||||
InsetsSourceControl[] controls =
|
||||
mDisplayContent.getInsetsStateController().getControlsForDispatch(app);
|
||||
|
||||
@@ -229,8 +230,8 @@ public class InsetsPolicyTest extends WindowTestsBase {
|
||||
}
|
||||
|
||||
final InsetsState state = policy.getInsetsForDispatch(app);
|
||||
state.setSourceVisible(TYPE_TOP_BAR, true);
|
||||
state.setSourceVisible(InsetsState.TYPE_NAVIGATION_BAR, true);
|
||||
state.setSourceVisible(ITYPE_STATUS_BAR, true);
|
||||
state.setSourceVisible(ITYPE_NAVIGATION_BAR, true);
|
||||
policy.onInsetsModified(app, state);
|
||||
|
||||
controls = mDisplayContent.getInsetsStateController().getControlsForDispatch(app);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -42,7 +42,7 @@ import org.junit.runner.RunWith;
|
||||
@RunWith(WindowTestRunner.class)
|
||||
public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
|
||||
private InsetsSource mSource = new InsetsSource(TYPE_TOP_BAR);
|
||||
private InsetsSource mSource = new InsetsSource(ITYPE_STATUS_BAR);
|
||||
private InsetsSourceProvider mProvider;
|
||||
|
||||
@Before
|
||||
@@ -54,10 +54,10 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testPostLayout() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
topBar.getFrameLw().set(0, 0, 500, 100);
|
||||
topBar.mHasSurface = true;
|
||||
mProvider.setWindow(topBar, null);
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
statusBar.getFrameLw().set(0, 0, 500, 100);
|
||||
statusBar.mHasSurface = true;
|
||||
mProvider.setWindow(statusBar, null);
|
||||
mProvider.onPostLayout();
|
||||
assertEquals(new Rect(0, 0, 500, 100), mProvider.getSource().getFrame());
|
||||
assertEquals(Insets.of(0, 100, 0, 0),
|
||||
@@ -67,9 +67,9 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testPostLayout_invisible() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
topBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(topBar, null);
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
statusBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(statusBar, null);
|
||||
mProvider.onPostLayout();
|
||||
assertEquals(Insets.NONE, mProvider.getSource().calculateInsets(new Rect(0, 0, 500, 500),
|
||||
false /* ignoreVisibility */));
|
||||
@@ -77,9 +77,9 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testPostLayout_frameProvider() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
topBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(topBar,
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
statusBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(statusBar,
|
||||
(displayFrames, windowState, rect) -> {
|
||||
rect.set(10, 10, 20, 20);
|
||||
});
|
||||
@@ -89,10 +89,10 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testUpdateControlForTarget() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState target = createWindow(null, TYPE_APPLICATION, "target");
|
||||
topBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(topBar, null);
|
||||
statusBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(statusBar, null);
|
||||
mProvider.updateControlForTarget(target, false /* force */);
|
||||
assertNotNull(mProvider.getControl(target));
|
||||
mProvider.updateControlForTarget(null, false /* force */);
|
||||
@@ -101,10 +101,10 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testUpdateControlForFakeTarget() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState target = createWindow(null, TYPE_APPLICATION, "target");
|
||||
topBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(topBar, null);
|
||||
statusBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(statusBar, null);
|
||||
mProvider.updateControlForFakeTarget(target);
|
||||
assertNotNull(mProvider.getControl(target));
|
||||
assertNull(mProvider.getControl(target).getLeash());
|
||||
@@ -114,26 +114,26 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testInsetsModified() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState target = createWindow(null, TYPE_APPLICATION, "target");
|
||||
topBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(topBar, null);
|
||||
statusBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(statusBar, null);
|
||||
mProvider.updateControlForTarget(target, false /* force */);
|
||||
InsetsState state = new InsetsState();
|
||||
state.getSource(TYPE_TOP_BAR).setVisible(false);
|
||||
mProvider.onInsetsModified(target, state.getSource(TYPE_TOP_BAR));
|
||||
state.getSource(ITYPE_STATUS_BAR).setVisible(false);
|
||||
mProvider.onInsetsModified(target, state.getSource(ITYPE_STATUS_BAR));
|
||||
assertFalse(mSource.isVisible());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsetsModified_noControl() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState target = createWindow(null, TYPE_APPLICATION, "target");
|
||||
topBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(topBar, null);
|
||||
statusBar.getFrameLw().set(0, 0, 500, 100);
|
||||
mProvider.setWindow(statusBar, null);
|
||||
InsetsState state = new InsetsState();
|
||||
state.getSource(TYPE_TOP_BAR).setVisible(false);
|
||||
mProvider.onInsetsModified(target, state.getSource(TYPE_TOP_BAR));
|
||||
state.getSource(ITYPE_STATUS_BAR).setVisible(false);
|
||||
mProvider.onInsetsModified(target, state.getSource(ITYPE_STATUS_BAR));
|
||||
assertTrue(mSource.isVisible());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.view.InsetsState.TYPE_IME;
|
||||
import static android.view.InsetsState.TYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_IME;
|
||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||
|
||||
@@ -63,44 +63,44 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
@Test
|
||||
@FlakyTest(bugId = 131005232)
|
||||
public void testStripForDispatch_notOwn() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
|
||||
getController().getSourceProvider(TYPE_TOP_BAR).setWindow(topBar, null);
|
||||
topBar.setControllableInsetProvider(getController().getSourceProvider(TYPE_TOP_BAR));
|
||||
assertNotNull(getController().getInsetsForDispatch(app).getSource(TYPE_TOP_BAR));
|
||||
getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null);
|
||||
statusBar.setControllableInsetProvider(getController().getSourceProvider(ITYPE_STATUS_BAR));
|
||||
assertNotNull(getController().getInsetsForDispatch(app).getSource(ITYPE_STATUS_BAR));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStripForDispatch_own() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
mDisplayContent.getInsetsStateController().getSourceProvider(TYPE_TOP_BAR)
|
||||
.setWindow(topBar, null);
|
||||
topBar.setControllableInsetProvider(getController().getSourceProvider(TYPE_TOP_BAR));
|
||||
final InsetsState state = getController().getInsetsForDispatch(topBar);
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_STATUS_BAR)
|
||||
.setWindow(statusBar, null);
|
||||
statusBar.setControllableInsetProvider(getController().getSourceProvider(ITYPE_STATUS_BAR));
|
||||
final InsetsState state = getController().getInsetsForDispatch(statusBar);
|
||||
for (int i = state.getSourcesCount() - 1; i >= 0; i--) {
|
||||
final InsetsSource source = state.sourceAt(i);
|
||||
assertNotEquals(TYPE_TOP_BAR, source.getType());
|
||||
assertNotEquals(ITYPE_STATUS_BAR, source.getType());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStripForDispatch_navBar() {
|
||||
final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar");
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState ime = createWindow(null, TYPE_APPLICATION, "ime");
|
||||
getController().getSourceProvider(TYPE_TOP_BAR).setWindow(topBar, null);
|
||||
getController().getSourceProvider(TYPE_NAVIGATION_BAR).setWindow(navBar, null);
|
||||
getController().getSourceProvider(TYPE_IME).setWindow(ime, null);
|
||||
getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null);
|
||||
getController().getSourceProvider(ITYPE_NAVIGATION_BAR).setWindow(navBar, null);
|
||||
getController().getSourceProvider(ITYPE_IME).setWindow(ime, null);
|
||||
assertEquals(0, getController().getInsetsForDispatch(navBar).getSourcesCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBarControllingWinChanged() {
|
||||
final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar");
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
|
||||
getController().getSourceProvider(TYPE_TOP_BAR).setWindow(topBar, null);
|
||||
getController().getSourceProvider(TYPE_NAVIGATION_BAR).setWindow(navBar, null);
|
||||
getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null);
|
||||
getController().getSourceProvider(ITYPE_NAVIGATION_BAR).setWindow(navBar, null);
|
||||
getController().onBarControlTargetChanged(app, null, app, null);
|
||||
InsetsSourceControl[] controls = getController().getControlsForDispatch(app);
|
||||
assertEquals(2, controls.length);
|
||||
@@ -108,9 +108,9 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testControlRevoked() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
|
||||
getController().getSourceProvider(TYPE_TOP_BAR).setWindow(topBar, null);
|
||||
getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null);
|
||||
getController().onBarControlTargetChanged(app, null, null, null);
|
||||
assertNotNull(getController().getControlsForDispatch(app));
|
||||
getController().onBarControlTargetChanged(null, null, null, null);
|
||||
@@ -120,12 +120,12 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
@FlakyTest(bugId = 124088319)
|
||||
@Test
|
||||
public void testControlRevoked_animation() {
|
||||
final WindowState topBar = createWindow(null, TYPE_APPLICATION, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
|
||||
getController().getSourceProvider(TYPE_TOP_BAR).setWindow(topBar, null);
|
||||
getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null);
|
||||
getController().onBarControlTargetChanged(app, null, null, null);
|
||||
assertNotNull(getController().getControlsForDispatch(app));
|
||||
topBar.cancelAnimation();
|
||||
statusBar.cancelAnimation();
|
||||
assertNull(getController().getControlsForDispatch(app));
|
||||
}
|
||||
|
||||
|
||||
@@ -83,10 +83,11 @@ public class RootWindowContainerTests extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testIsAnyNonToastWindowVisibleForUid_aFewNonToastButNoneVisible() {
|
||||
final WindowState topBar = createWindow(null, TYPE_STATUS_BAR, "topBar", FAKE_CALLING_UID);
|
||||
final WindowState statusBar =
|
||||
createWindow(null, TYPE_STATUS_BAR, "statusBar", FAKE_CALLING_UID);
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app", FAKE_CALLING_UID);
|
||||
|
||||
assertFalse(topBar.isVisibleNow());
|
||||
assertFalse(statusBar.isVisibleNow());
|
||||
assertFalse(app.isVisibleNow());
|
||||
assertFalse(mWm.mRoot.isAnyNonToastWindowVisibleForUid(FAKE_CALLING_UID));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
|
||||
import static android.hardware.camera2.params.OutputConfiguration.ROTATION_90;
|
||||
import static android.view.InsetsState.TYPE_TOP_BAR;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.Surface.ROTATION_0;
|
||||
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
|
||||
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
|
||||
@@ -403,18 +403,18 @@ public class WindowStateTests extends WindowTestsBase {
|
||||
|
||||
@Test
|
||||
public void testVisibleWithInsetsProvider() {
|
||||
final WindowState topBar = createWindow(null, TYPE_STATUS_BAR, "topBar");
|
||||
final WindowState statusBar = createWindow(null, TYPE_STATUS_BAR, "statusBar");
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
|
||||
topBar.mHasSurface = true;
|
||||
assertTrue(topBar.isVisible());
|
||||
mDisplayContent.getInsetsStateController().getSourceProvider(TYPE_TOP_BAR)
|
||||
.setWindow(topBar, null /* frameProvider */);
|
||||
statusBar.mHasSurface = true;
|
||||
assertTrue(statusBar.isVisible());
|
||||
mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_STATUS_BAR)
|
||||
.setWindow(statusBar, null /* frameProvider */);
|
||||
mDisplayContent.getInsetsStateController().onBarControlTargetChanged(
|
||||
app, null /* fakeTopControlling */, app, null /* fakeNavControlling */);
|
||||
mDisplayContent.getInsetsStateController().getSourceProvider(TYPE_TOP_BAR)
|
||||
.onInsetsModified(app, new InsetsSource(TYPE_TOP_BAR));
|
||||
mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_STATUS_BAR)
|
||||
.onInsetsModified(app, new InsetsSource(ITYPE_STATUS_BAR));
|
||||
waitUntilHandlersIdle();
|
||||
assertFalse(topBar.isVisible());
|
||||
assertFalse(statusBar.isVisible());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user