Merge "Refactor Utilities#isTablet to Utilities#isLargeScreen" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
45b4cad82c
@@ -62,7 +62,7 @@ public class PreviewPositionHelper {
|
||||
*/
|
||||
public void updateThumbnailMatrix(Rect thumbnailBounds, ThumbnailData thumbnailData,
|
||||
int canvasWidth, int canvasHeight, int screenWidthPx, int screenHeightPx,
|
||||
int taskbarSize, boolean isTablet,
|
||||
int taskbarSize, boolean isLargeScreen,
|
||||
int currentRotation, boolean isRtl) {
|
||||
boolean isRotated = false;
|
||||
boolean isOrientationDifferent;
|
||||
@@ -95,7 +95,7 @@ public class PreviewPositionHelper {
|
||||
canvasScreenRatio = (float) canvasWidth / screenWidthPx;
|
||||
}
|
||||
scaledTaskbarSize = taskbarSize * canvasScreenRatio;
|
||||
thumbnailClipHint.bottom = isTablet ? scaledTaskbarSize : 0;
|
||||
thumbnailClipHint.bottom = isLargeScreen ? scaledTaskbarSize : 0;
|
||||
|
||||
float scale = thumbnailData.scale;
|
||||
final float thumbnailScale;
|
||||
@@ -103,7 +103,7 @@ public class PreviewPositionHelper {
|
||||
// Landscape vs portrait change.
|
||||
// Note: Disable rotation in grid layout.
|
||||
boolean windowingModeSupportsRotation =
|
||||
thumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN && !isTablet;
|
||||
thumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN && !isLargeScreen;
|
||||
isOrientationDifferent = isOrientationChange(deltaRotate)
|
||||
&& windowingModeSupportsRotation;
|
||||
if (canvasWidth == 0 || canvasHeight == 0 || scale == 0) {
|
||||
|
||||
@@ -137,7 +137,7 @@ public class Utilities {
|
||||
|
||||
/** @return whether or not {@param context} represents that of a large screen device or not */
|
||||
@TargetApi(Build.VERSION_CODES.R)
|
||||
public static boolean isTablet(Context context) {
|
||||
public static boolean isLargeScreen(Context context) {
|
||||
final WindowManager windowManager = context.getSystemService(WindowManager.class);
|
||||
final Rect bounds = windowManager.getCurrentWindowMetrics().getBounds();
|
||||
|
||||
|
||||
@@ -129,8 +129,8 @@ final class WirelessChargingLayout extends FrameLayout {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(textSizeAnimator, textOpacityAnimator, textFadeAnimator);
|
||||
|
||||
// For tablet docking animation, we don't play the background scrim.
|
||||
if (!Utilities.isTablet(context)) {
|
||||
// For large screens docking animation, we don't play the background scrim.
|
||||
if (!Utilities.isLargeScreen(context)) {
|
||||
ValueAnimator scrimFadeInAnimator = ObjectAnimator.ofArgb(this,
|
||||
"backgroundColor", Color.TRANSPARENT, SCRIM_COLOR);
|
||||
scrimFadeInAnimator.setDuration(SCRIM_FADE_DURATION);
|
||||
|
||||
@@ -950,9 +950,9 @@ class KeyguardUnlockAnimationController @Inject constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
// We don't do the shared element on tablets because they're large and the smartspace has to
|
||||
// fly across large distances, which is distracting.
|
||||
if (Utilities.isTablet(context)) {
|
||||
// We don't do the shared element on large screens because the smartspace has to fly across
|
||||
// large distances, which is distracting.
|
||||
if (Utilities.isLargeScreen(context)) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.android.systemui.R
|
||||
import com.android.systemui.mediaprojection.appselector.data.RecentTask
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData
|
||||
import com.android.systemui.shared.recents.utilities.PreviewPositionHelper
|
||||
import com.android.systemui.shared.recents.utilities.Utilities.isTablet
|
||||
import com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen
|
||||
|
||||
/**
|
||||
* Custom view that shows a thumbnail preview of one recent task based on [ThumbnailData].
|
||||
@@ -150,9 +150,9 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
val displayWidthPx = windowMetrics.bounds.width()
|
||||
val displayHeightPx = windowMetrics.bounds.height()
|
||||
val isRtl = layoutDirection == LAYOUT_DIRECTION_RTL
|
||||
val isTablet = isTablet(context)
|
||||
val isLargeScreen = isLargeScreen(context)
|
||||
val taskbarSize =
|
||||
if (isTablet) {
|
||||
if (isLargeScreen) {
|
||||
resources.getDimensionPixelSize(AndroidR.dimen.taskbar_frame_height)
|
||||
} else {
|
||||
0
|
||||
@@ -166,7 +166,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
displayWidthPx,
|
||||
displayHeightPx,
|
||||
taskbarSize,
|
||||
isTablet,
|
||||
isLargeScreen,
|
||||
currentRotation,
|
||||
isRtl
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.view.WindowManager
|
||||
import com.android.internal.R as AndroidR
|
||||
import com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelectorScope
|
||||
import com.android.systemui.mediaprojection.appselector.view.TaskPreviewSizeProvider.TaskPreviewSizeListener
|
||||
import com.android.systemui.shared.recents.utilities.Utilities.isTablet
|
||||
import com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen
|
||||
import com.android.systemui.statusbar.policy.CallbackController
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener
|
||||
@@ -61,8 +61,8 @@ constructor(
|
||||
val width = windowMetrics.bounds.width()
|
||||
var height = maximumWindowHeight
|
||||
|
||||
val isTablet = isTablet(context)
|
||||
if (isTablet) {
|
||||
val isLargeScreen = isLargeScreen(context)
|
||||
if (isLargeScreen) {
|
||||
val taskbarSize =
|
||||
context.resources.getDimensionPixelSize(AndroidR.dimen.taskbar_frame_height)
|
||||
height -= taskbarSize
|
||||
|
||||
@@ -37,7 +37,7 @@ import static com.android.internal.accessibility.common.ShortcutConstants.CHOOSE
|
||||
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.HOME_BUTTON_LONG_PRESS_DURATION_MS;
|
||||
import static com.android.systemui.navigationbar.NavBarHelper.transitionMode;
|
||||
import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
|
||||
import static com.android.systemui.shared.recents.utilities.Utilities.isTablet;
|
||||
import static com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY;
|
||||
@@ -1724,7 +1724,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
|
||||
|
||||
private void setNavigationIconHints(int hints) {
|
||||
if (hints == mNavigationIconHints) return;
|
||||
if (!isTablet(mContext)) {
|
||||
if (!isLargeScreen(mContext)) {
|
||||
// All IME functions handled by launcher via Sysui flags for large screen
|
||||
final boolean newBackAlt = (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
|
||||
final boolean oldBackAlt =
|
||||
|
||||
@@ -21,7 +21,7 @@ import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_GESTURE
|
||||
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR;
|
||||
|
||||
import static com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler.DEBUG_MISSING_GESTURE_TAG;
|
||||
import static com.android.systemui.shared.recents.utilities.Utilities.isTablet;
|
||||
import static com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
@@ -91,7 +91,7 @@ public class NavigationBarController implements
|
||||
private final DisplayManager mDisplayManager;
|
||||
private final TaskbarDelegate mTaskbarDelegate;
|
||||
private int mNavMode;
|
||||
@VisibleForTesting boolean mIsTablet;
|
||||
@VisibleForTesting boolean mIsLargeScreen;
|
||||
|
||||
/** A displayId - nav bar maps. */
|
||||
@VisibleForTesting
|
||||
@@ -138,16 +138,16 @@ public class NavigationBarController implements
|
||||
navBarHelper, navigationModeController, sysUiFlagsContainer,
|
||||
dumpManager, autoHideController, lightBarController, pipOptional,
|
||||
backAnimation.orElse(null), taskStackChangeListeners);
|
||||
mIsTablet = isTablet(mContext);
|
||||
mIsLargeScreen = isLargeScreen(mContext);
|
||||
dumpManager.registerDumpable(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigChanged(Configuration newConfig) {
|
||||
boolean isOldConfigTablet = mIsTablet;
|
||||
mIsTablet = isTablet(mContext);
|
||||
boolean isOldConfigLargeScreen = mIsLargeScreen;
|
||||
mIsLargeScreen = isLargeScreen(mContext);
|
||||
boolean willApplyConfig = mConfigChanges.applyNewConfig(mContext.getResources());
|
||||
boolean largeScreenChanged = mIsTablet != isOldConfigTablet;
|
||||
boolean largeScreenChanged = mIsLargeScreen != isOldConfigLargeScreen;
|
||||
// TODO(b/243765256): Disable this logging once b/243765256 is fixed.
|
||||
Log.i(DEBUG_MISSING_GESTURE_TAG, "NavbarController: newConfig=" + newConfig
|
||||
+ " mTaskbarDelegate initialized=" + mTaskbarDelegate.isInitialized()
|
||||
@@ -235,8 +235,9 @@ public class NavigationBarController implements
|
||||
|
||||
/** @return {@code true} if taskbar is enabled, false otherwise */
|
||||
private boolean initializeTaskbarIfNecessary() {
|
||||
// Enable for tablet or (phone AND flag is set); assuming phone = !mIsTablet
|
||||
boolean taskbarEnabled = mIsTablet || mFeatureFlags.isEnabled(Flags.HIDE_NAVBAR_WINDOW);
|
||||
// Enable for large screens or (phone AND flag is set); assuming phone = !mIsLargeScreen
|
||||
boolean taskbarEnabled = mIsLargeScreen || mFeatureFlags.isEnabled(
|
||||
Flags.HIDE_NAVBAR_WINDOW);
|
||||
|
||||
if (taskbarEnabled) {
|
||||
Trace.beginSection("NavigationBarController#initializeTaskbarIfNecessary");
|
||||
@@ -258,7 +259,7 @@ public class NavigationBarController implements
|
||||
@Override
|
||||
public void onDisplayReady(int displayId) {
|
||||
Display display = mDisplayManager.getDisplay(displayId);
|
||||
mIsTablet = isTablet(mContext);
|
||||
mIsLargeScreen = isLargeScreen(mContext);
|
||||
createNavigationBar(display, null /* savedState */, null /* result */);
|
||||
}
|
||||
|
||||
@@ -470,7 +471,7 @@ public class NavigationBarController implements
|
||||
|
||||
@Override
|
||||
public void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
|
||||
pw.println("mIsTablet=" + mIsTablet);
|
||||
pw.println("mIsLargeScreen=" + mIsLargeScreen);
|
||||
pw.println("mNavMode=" + mNavMode);
|
||||
for (int i = 0; i < mNavigationBars.size(); i++) {
|
||||
if (i > 0) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.systemui.recents;
|
||||
|
||||
import static com.android.systemui.shared.recents.utilities.Utilities.isTablet;
|
||||
import static com.android.systemui.shared.recents.utilities.Utilities.isLargeScreen;
|
||||
import static com.android.systemui.util.leak.RotationUtils.ROTATION_LANDSCAPE;
|
||||
import static com.android.systemui.util.leak.RotationUtils.ROTATION_NONE;
|
||||
import static com.android.systemui.util.leak.RotationUtils.ROTATION_SEASCAPE;
|
||||
@@ -265,7 +265,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
|
||||
.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
|
||||
View buttons = mLayout.findViewById(R.id.screen_pinning_buttons);
|
||||
if (!QuickStepContract.isGesturalMode(mNavBarMode)
|
||||
&& hasSoftNavigationBar(mContext.getDisplayId()) && !isTablet(mContext)) {
|
||||
&& hasSoftNavigationBar(mContext.getDisplayId()) && !isLargeScreen(mContext)) {
|
||||
buttons.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
|
||||
swapChildrenIfRtlAndVertical(buttons);
|
||||
} else {
|
||||
|
||||
@@ -143,8 +143,8 @@ public class NavigationBarControllerTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testCreateNavigationBarsIncludeDefaultTrue() {
|
||||
// Tablets may be using taskbar and the logic is different
|
||||
mNavigationBarController.mIsTablet = false;
|
||||
// Large screens may be using taskbar and the logic is different
|
||||
mNavigationBarController.mIsLargeScreen = false;
|
||||
doNothing().when(mNavigationBarController).createNavigationBar(any(), any(), any());
|
||||
|
||||
mNavigationBarController.createNavigationBars(true, null);
|
||||
@@ -292,7 +292,7 @@ public class NavigationBarControllerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testConfigurationChange_taskbarNotInitialized() {
|
||||
Configuration configuration = mContext.getResources().getConfiguration();
|
||||
when(Utilities.isTablet(any())).thenReturn(true);
|
||||
when(Utilities.isLargeScreen(any())).thenReturn(true);
|
||||
mNavigationBarController.onConfigChanged(configuration);
|
||||
verify(mTaskbarDelegate, never()).onConfigurationChanged(configuration);
|
||||
}
|
||||
@@ -300,7 +300,7 @@ public class NavigationBarControllerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testConfigurationChange_taskbarInitialized() {
|
||||
Configuration configuration = mContext.getResources().getConfiguration();
|
||||
when(Utilities.isTablet(any())).thenReturn(true);
|
||||
when(Utilities.isLargeScreen(any())).thenReturn(true);
|
||||
when(mTaskbarDelegate.isInitialized()).thenReturn(true);
|
||||
mNavigationBarController.onConfigChanged(configuration);
|
||||
verify(mTaskbarDelegate, times(1)).onConfigurationChanged(configuration);
|
||||
|
||||
Reference in New Issue
Block a user