Snap for 7809064 from c75cdd4d6c to tm-release

Change-Id: Iee6b33e8759c7890306bb289dd323ae07fa8c575
This commit is contained in:
Android Build Coastguard Worker
2021-10-09 05:09:30 +00:00
27 changed files with 473 additions and 575 deletions
@@ -16,8 +16,6 @@
package com.android.launcher3.taskbar;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
@@ -52,7 +50,6 @@ import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener;
import com.android.quickstep.RecentsAnimationController;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -187,8 +184,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
TaskbarStashController stashController = mControllers.taskbarStashController;
stashController.updateStateForFlag(FLAG_IN_APP, !isResumed);
stashController.applyState(duration);
SystemUiProxy.INSTANCE.get(mContext).notifyTaskbarStatus(!isResumed,
mControllers.taskbarStashController.isStashedInApp());
}
/**
@@ -286,11 +281,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
@Override
protected void onStashedInAppChanged() {
onStashedInAppChanged(mLauncher.getDeviceProfile());
if (mControllers.taskbarStashController.isStashedInApp()) {
mContext.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_LONGPRESS_HIDE);
} else {
mContext.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_LONGPRESS_SHOW);
}
}
private void onStashedInAppChanged(DeviceProfile deviceProfile) {
@@ -321,6 +321,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
mControllers.taskbarViewController.setRecentsButtonDisabled(
mControllers.navbarButtonsViewController.isRecentsDisabled());
mControllers.taskbarKeyguardController.updateStateForSysuiFlags(systemUiStateFlags);
mControllers.taskbarStashController.updateStateForSysuiFlags(systemUiStateFlags);
}
public void onRotationProposal(int rotation, boolean isValid) {
@@ -45,6 +45,9 @@ public class TaskbarModelCallbacks implements
private final TaskbarActivityContext mContext;
private final TaskbarView mContainer;
// Initialized in init.
private TaskbarControllers mControllers;
private boolean mBindInProgress = false;
public TaskbarModelCallbacks(
@@ -53,6 +56,10 @@ public class TaskbarModelCallbacks implements
mContainer = container;
}
public void init(TaskbarControllers controllers) {
mControllers = controllers;
}
@Override
public void startBinding() {
mBindInProgress = true;
@@ -161,6 +168,7 @@ public class TaskbarModelCallbacks implements
int predictionSize = mPredictedItems.size();
int predictionNextIndex = 0;
boolean isHotseatEmpty = true;
for (int i = 0; i < hotseatItemInfos.length; i++) {
hotseatItemInfos[i] = mHotseatItems.get(i);
if (hotseatItemInfos[i] == null && predictionNextIndex < predictionSize) {
@@ -168,7 +176,14 @@ public class TaskbarModelCallbacks implements
hotseatItemInfos[i].screenId = i;
predictionNextIndex++;
}
if (hotseatItemInfos[i] != null) {
isHotseatEmpty = false;
}
}
mContainer.updateHotseatItems(hotseatItemInfos);
mControllers.taskbarStashController.updateStateForFlag(
TaskbarStashController.FLAG_STASHED_IN_APP_EMPTY, isHotseatEmpty);
mControllers.taskbarStashController.applyState();
}
}
@@ -17,6 +17,10 @@ package com.android.launcher3.taskbar;
import static android.view.HapticFeedbackConstants.LONG_PRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
@@ -40,8 +44,14 @@ import java.util.function.IntPredicate;
public class TaskbarStashController {
public static final int FLAG_IN_APP = 1 << 0;
public static final int FLAG_STASHED_IN_APP = 1 << 1;
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 2;
public static final int FLAG_STASHED_IN_APP_MANUAL = 1 << 1; // long press, persisted
public static final int FLAG_STASHED_IN_APP_PINNED = 1 << 2; // app pinning
public static final int FLAG_STASHED_IN_APP_EMPTY = 1 << 3; // no hotseat icons
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 4;
// If we're in an app and any of these flags are enabled, taskbar should be stashed.
public static final int FLAGS_STASHED_IN_APP = FLAG_STASHED_IN_APP_MANUAL
| FLAG_STASHED_IN_APP_PINNED | FLAG_STASHED_IN_APP_EMPTY;
/**
* How long to stash/unstash when manually invoked via long press.
@@ -96,8 +106,6 @@ public class TaskbarStashController {
private AnimatedFloat mTaskbarStashedHandleAlpha;
private AnimatedFloat mTaskbarStashedHandleHintScale;
/** Whether the user has manually invoked taskbar stashing, which we persist. */
private boolean mIsStashedInApp;
/** Whether we are currently visually stashed (might change based on launcher state). */
private boolean mIsStashed = false;
private int mState;
@@ -107,12 +115,9 @@ public class TaskbarStashController {
// Evaluate whether the handle should be stashed
private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder(
flags -> {
if (!supportsVisualStashing()) {
return false;
}
boolean inApp = (flags & FLAG_IN_APP) != 0;
boolean stashedInApp = (flags & FLAG_STASHED_IN_APP) != 0;
boolean stashedLauncherState = (flags & FLAG_IN_STASHED_LAUNCHER_STATE) != 0;
boolean inApp = hasAnyFlag(flags, FLAG_IN_APP);
boolean stashedInApp = hasAnyFlag(flags, FLAGS_STASHED_IN_APP);
boolean stashedLauncherState = hasAnyFlag(flags, FLAG_IN_STASHED_LAUNCHER_STATE);
return (inApp && stashedInApp) || (!inApp && stashedLauncherState);
});
@@ -141,12 +146,13 @@ public class TaskbarStashController {
mTaskbarStashedHandleAlpha = stashedHandleController.getStashedHandleAlpha();
mTaskbarStashedHandleHintScale = stashedHandleController.getStashedHandleHintScale();
mIsStashedInApp = supportsManualStashing()
boolean isManuallyStashedInApp = supportsManualStashing()
&& mPrefs.getBoolean(SHARED_PREFS_STASHED_KEY, DEFAULT_STASHED_PREF);
updateStateForFlag(FLAG_STASHED_IN_APP, mIsStashedInApp);
updateStateForFlag(FLAG_STASHED_IN_APP_MANUAL, isManuallyStashedInApp);
applyState();
SystemUiProxy.INSTANCE.get(mActivity)
.notifyTaskbarStatus(/* visible */ true, /* stashed */ mIsStashedInApp);
.notifyTaskbarStatus(/* visible */ false, /* stashed */ isStashedInApp());
}
/**
@@ -178,10 +184,18 @@ public class TaskbarStashController {
}
/**
* Returns whether the user has manually stashed the taskbar in apps.
* Returns whether the taskbar should be stashed in apps (e.g. user long pressed to stash).
*/
public boolean isStashedInApp() {
return mIsStashedInApp;
return hasAnyFlag(FLAGS_STASHED_IN_APP);
}
private boolean hasAnyFlag(int flagMask) {
return hasAnyFlag(mState, flagMask);
}
private boolean hasAnyFlag(int flags, int flagMask) {
return (flags & flagMask) != 0;
}
public int getContentHeight() {
@@ -202,7 +216,7 @@ public class TaskbarStashController {
// taskbar, we use an OnLongClickListener on TaskbarView instead.
return false;
}
if (updateAndAnimateIsStashedInApp(false)) {
if (updateAndAnimateIsManuallyStashedInApp(false)) {
mControllers.taskbarActivityContext.getDragLayer().performHapticFeedback(LONG_PRESS);
return true;
}
@@ -213,25 +227,32 @@ public class TaskbarStashController {
* Updates whether we should stash the taskbar when in apps, and animates to the changed state.
* @return Whether we started an animation to either be newly stashed or unstashed.
*/
public boolean updateAndAnimateIsStashedInApp(boolean isStashedInApp) {
public boolean updateAndAnimateIsManuallyStashedInApp(boolean isManuallyStashedInApp) {
if (!supportsManualStashing()) {
return false;
}
if (mIsStashedInApp != isStashedInApp) {
mIsStashedInApp = isStashedInApp;
mPrefs.edit().putBoolean(SHARED_PREFS_STASHED_KEY, mIsStashedInApp).apply();
updateStateForFlag(FLAG_STASHED_IN_APP, mIsStashedInApp);
if (hasAnyFlag(FLAG_STASHED_IN_APP_MANUAL) != isManuallyStashedInApp) {
mPrefs.edit().putBoolean(SHARED_PREFS_STASHED_KEY, isManuallyStashedInApp).apply();
updateStateForFlag(FLAG_STASHED_IN_APP_MANUAL, isManuallyStashedInApp);
applyState();
SystemUiProxy.INSTANCE.get(mActivity)
.notifyTaskbarStatus(/* visible */ true, /* stashed */ mIsStashedInApp);
mControllers.uiController.onStashedInAppChanged();
return true;
}
return false;
}
private Animator createAnimToIsStashed(boolean isStashed, long duration) {
if (mAnimator != null) {
mAnimator.cancel();
}
mAnimator = new AnimatorSet();
if (!supportsVisualStashing()) {
// Just hide/show the icons instead of stashing into a handle.
mAnimator.play(mIconAlphaForStash.animateToValue(isStashed ? 0 : 1)
.setDuration(duration));
return mAnimator;
}
AnimatorSet fullLengthAnimatorSet = new AnimatorSet();
// Not exactly half and may overlap. See [first|second]HalfDurationScale below.
AnimatorSet firstHalfAnimatorSet = new AnimatorSet();
@@ -287,10 +308,6 @@ public class TaskbarStashController {
secondHalfAnimatorSet.setDuration((long) (duration * secondHalfDurationScale));
secondHalfAnimatorSet.setStartDelay((long) (duration * (1 - secondHalfDurationScale)));
if (mAnimator != null) {
mAnimator.cancel();
}
mAnimator = new AnimatorSet();
mAnimator.playTogether(fullLengthAnimatorSet, firstHalfAnimatorSet,
secondHalfAnimatorSet);
mAnimator.addListener(new AnimatorListenerAdapter() {
@@ -360,6 +377,13 @@ public class TaskbarStashController {
return mStatePropertyHolder.setState(mState, duration, false);
}
/** Called when some system ui state has changed. (See SYSUI_STATE_... in QuickstepContract) */
public void updateStateForSysuiFlags(int systemUiStateFlags) {
updateStateForFlag(FLAG_STASHED_IN_APP_PINNED,
hasAnyFlag(systemUiStateFlags, SYSUI_STATE_SCREEN_PINNING));
applyState();
}
/**
* Updates the proper flag to indicate whether the task bar should be stashed.
*
@@ -377,16 +401,44 @@ public class TaskbarStashController {
}
}
/**
* Called after updateStateForFlag() and applyState() have been called.
* @param changedFlags The flags that have changed.
*/
private void onStateChangeApplied(int changedFlags) {
if (hasAnyFlag(changedFlags, FLAGS_STASHED_IN_APP)) {
mControllers.uiController.onStashedInAppChanged();
}
if (hasAnyFlag(changedFlags, FLAGS_STASHED_IN_APP | FLAG_IN_APP)) {
SystemUiProxy.INSTANCE.get(mActivity)
.notifyTaskbarStatus(/* visible */ hasAnyFlag(FLAG_IN_APP),
/* stashed */ isStashedInApp());
}
if (hasAnyFlag(changedFlags, FLAG_STASHED_IN_APP_MANUAL)) {
if (hasAnyFlag(FLAG_STASHED_IN_APP_MANUAL)) {
mActivity.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_LONGPRESS_HIDE);
} else {
mActivity.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_LONGPRESS_SHOW);
}
}
}
private class StatePropertyHolder {
private final IntPredicate mStashCondition;
private boolean mIsStashed;
private int mPrevFlags;
StatePropertyHolder(IntPredicate stashCondition) {
mStashCondition = stashCondition;
}
public Animator setState(int flags, long duration, boolean start) {
if (mPrevFlags != flags) {
int changedFlags = mPrevFlags ^ flags;
onStateChangeApplied(changedFlags);
mPrevFlags = flags;
}
boolean isStashed = mStashCondition.test(flags);
if (mIsStashed != isStashed) {
mIsStashed = isStashed;
@@ -85,6 +85,8 @@ public class TaskbarViewController {
mTaskbarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarSize;
mTaskbarIconScaleForStash.updateValue(1f);
mModelCallbacks.init(controllers);
LauncherAppState.getInstance(mActivity).getModel().addCallbacksAndLoad(mModelCallbacks);
}
@@ -254,7 +256,8 @@ public class TaskbarViewController {
}
public View.OnLongClickListener getBackgroundOnLongClickListener() {
return view -> mControllers.taskbarStashController.updateAndAnimateIsStashedInApp(true);
return view -> mControllers.taskbarStashController
.updateAndAnimateIsManuallyStashedInApp(true);
}
/**
@@ -16,5 +16,5 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:color="@android:color/system_neutral2_50"
android:lStar="30" />
android:lStar="35" />
</selector>
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:color="@android:color/system_neutral2_50"
android:lStar="30" />
</selector>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:color="@android:color/system_accent2_50"
android:lStar="80" />
</selector>
+1 -1
View File
@@ -16,6 +16,6 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?attr/folderFillColor" />
<solid android:color="?attr/folderBackgroundColor" />
<corners android:radius="?android:attr/dialogCornerRadius" />
</shape>
+1 -1
View File
@@ -16,6 +16,6 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?attr/folderFillColor" />
<solid android:color="?attr/folderBackgroundColor" />
<corners android:radius="@dimen/bg_round_rect_radius" />
</shape>
+1 -1
View File
@@ -26,7 +26,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="?attr/folderFillColor"
android:background="?attr/folderBackgroundColor"
android:padding="8dp"
android:textColor="?attr/folderTextColor"
/>
+13 -15
View File
@@ -43,7 +43,8 @@
<attr name="folderDotColor" format="color" />
<attr name="folderPaginationColor" format="color" />
<attr name="folderFillColor" format="color" />
<attr name="folderPreviewColor" format="color" />
<attr name="folderBackgroundColor" format="color" />
<attr name="folderIconRadius" format="float" />
<attr name="folderIconBorderColor" format="color" />
<attr name="folderTextColor" format="color" />
@@ -72,7 +73,7 @@
<!-- BubbleTextView specific attributes. -->
<declare-styleable name="FolderIconPreview">
<attr name="folderFillColor" />
<attr name="folderPreviewColor" />
<attr name="folderIconBorderColor" />
<attr name="folderDotColor" />
</declare-styleable>
@@ -184,11 +185,9 @@
<attr name="twoPanelPortraitMinCellHeightDps" format="float" />
<!-- twoPanelPortraitMinCellHeightDps defaults to minCellWidthDps, if not specified -->
<attr name="twoPanelPortraitMinCellWidthDps" format="float" />
<!-- twoPanelLandscapeMinCellHeightDps defaults to twoPanelPortraitMinCellHeightDps,
if not specified -->
<!-- twoPanelLandscapeMinCellHeightDps defaults to minCellHeightDps, if not specified -->
<attr name="twoPanelLandscapeMinCellHeightDps" format="float" />
<!-- twoPanelLandscapeMinCellWidthDps defaults to twoPanelPortraitMinCellWidthDps,
if not specified -->
<!-- twoPanelLandscapeMinCellWidthDps defaults to minCellWidthDps, if not specified -->
<attr name="twoPanelLandscapeMinCellWidthDps" format="float" />
<!-- These border spaces are only used if GridDisplayOption#isScalable is true -->
@@ -217,15 +216,20 @@
if not specified -->
<attr name="twoPanelLandscapeBorderSpaceVerticalDps" format="float" />
<!-- allAppsCellSpacingDps defaults to borderSpaceDps, if not specified -->
<attr name="allAppsCellSpacingDps" format="float" />
<!-- The following values are only enabled if grid is supported. -->
<!-- allAppsIconSize defaults to iconSize, if not specified -->
<attr name="allAppsIconSize" format="float" />
<!-- allAppsIconTextSize defaults to iconTextSize, if not specified -->
<attr name="allAppsIconTextSize" format="float" />
<attr name="iconImageSize" format="float" />
<!-- landscapeIconSize defaults to iconImageSize, if not specified -->
<attr name="landscapeIconSize" format="float" />
<!-- twoPanelPortraitIconSize defaults to iconImageSize, if not specified -->
<attr name="twoPanelPortraitIconSize" format="float" />
<!-- twoPanelLandscapeIconSize defaults to landscapeIconSize, if not specified -->
<!-- twoPanelLandscapeIconSize defaults to iconImageSize, if not specified -->
<attr name="twoPanelLandscapeIconSize" format="float" />
<attr name="iconTextSize" format="float" />
@@ -233,7 +237,7 @@
<attr name="landscapeIconTextSize" format="float" />
<!-- twoPanelPortraitIconTextSize defaults to iconTextSize, if not specified -->
<attr name="twoPanelPortraitIconTextSize" format="float" />
<!-- twoPanelLandscapeIconTextSize defaults to landscapeIconTextSize, if not specified -->
<!-- twoPanelLandscapeIconTextSize defaults to iconTextSize, if not specified -->
<attr name="twoPanelLandscapeIconTextSize" format="float" />
<!-- If set, this display option is used to determine the default grid -->
@@ -242,12 +246,6 @@
<flag name="split_display" value="0x2" />
</attr>
<!-- The following values are only enabled if grid is supported. -->
<!-- allAppsIconSize defaults to iconSize, if not specified -->
<attr name="allAppsIconSize" format="float" />
<!-- allAppsIconTextSize defaults to iconTextSize, if not specified -->
<attr name="allAppsIconTextSize" format="float" />
<!-- Margin on left and right of the workspace when GridDisplayOption#isScalable is true -->
<attr name="horizontalMargin" format="float"/>
<!-- twoPanelLandscapeHorizontalMargin defaults to horizontalMargin if not specified -->
+3
View File
@@ -63,6 +63,9 @@
<color name="folder_background_light">#F9F9F9</color>
<color name="folder_background_dark">#464746</color>
<color name="folder_preview_light">#F9F9F9</color>
<color name="folder_preview_dark">#464746</color>
<color name="folder_dot_color">?attr/colorPrimary</color>
<color name="folder_pagination_color_light">#ff006c5f</color>
<color name="folder_pagination_color_dark">#ffbfebe3</color>
+4 -2
View File
@@ -51,7 +51,8 @@
<item name="widgetsTheme">@style/WidgetContainerTheme</item>
<item name="folderDotColor">@color/folder_dot_color</item>
<item name="folderPaginationColor">@color/folder_pagination_color_light</item>
<item name="folderFillColor">@color/folder_background_light</item>
<item name="folderPreviewColor">@color/folder_preview_light</item>
<item name="folderBackgroundColor">@color/folder_background_light</item>
<item name="folderIconBorderColor">?android:attr/colorPrimary</item>
<item name="folderTextColor">@color/workspace_text_color_dark</item>
<item name="isFolderDarkText">true</item>
@@ -110,7 +111,8 @@
<item name="widgetsTheme">@style/WidgetContainerTheme.Dark</item>
<item name="folderDotColor">@color/folder_dot_color</item>
<item name="folderPaginationColor">@color/folder_pagination_color_dark</item>
<item name="folderFillColor">@color/folder_background_dark</item>
<item name="folderPreviewColor">@color/folder_preview_dark</item>
<item name="folderBackgroundColor">@color/folder_background_dark</item>
<item name="folderIconBorderColor">?android:attr/colorPrimary</item>
<item name="folderTextColor">@color/workspace_text_color_light</item>
<item name="isFolderDarkText">false</item>
+51 -106
View File
@@ -80,6 +80,7 @@ public class DeviceProfile {
public final float aspectRatio;
public final boolean isScalableGrid;
private final int mTypeIndex;
/**
* The maximum amount of left/right workspace padding as a percentage of the screen width.
@@ -169,7 +170,7 @@ public class DeviceProfile {
public int qsbBottomMarginPx;
// All apps
public int allAppsCellSpacingPx;
public Point allAppsCellSpacePx;
public int allAppsOpenVerticalTranslate;
public int allAppsCellHeightPx;
public int allAppsCellWidthPx;
@@ -262,6 +263,20 @@ public class DeviceProfile {
mMetrics = context.getResources().getDisplayMetrics();
final Resources res = context.getResources();
if (isTwoPanels) {
if (isLandscape) {
mTypeIndex = InvariantDeviceProfile.INDEX_TWO_PANEL_LANDSCAPE;
} else {
mTypeIndex = InvariantDeviceProfile.INDEX_TWO_PANEL_PORTRAIT;
}
} else {
if (isLandscape) {
mTypeIndex = InvariantDeviceProfile.INDEX_LANDSCAPE;
} else {
mTypeIndex = InvariantDeviceProfile.INDEX_DEFAULT;
}
}
hotseatQsbHeight = res.getDimensionPixelSize(R.dimen.qsb_widget_height);
isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS
&& FeatureFlags.ENABLE_TASKBAR.get();
@@ -283,7 +298,9 @@ public class DeviceProfile {
folderContentPaddingTop = res.getDimensionPixelSize(R.dimen.folder_content_padding_top);
cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv);
allAppsCellSpacingPx = pxFromDp(inv.allAppsCellSpacing, mMetrics, 1f);
allAppsCellSpacePx = new Point(
pxFromDp(inv.borderSpaces[InvariantDeviceProfile.INDEX_ALL_APPS].x, mMetrics, 1f),
pxFromDp(inv.borderSpaces[InvariantDeviceProfile.INDEX_ALL_APPS].y, mMetrics, 1f));
cellLayoutBorderSpaceOriginalPx = new Point(cellLayoutBorderSpacePx);
folderCellLayoutBorderSpaceOriginalPx = pxFromDp(inv.folderBorderSpace, mMetrics, 1f);
folderCellLayoutBorderSpacePx = new Point(folderCellLayoutBorderSpaceOriginalPx,
@@ -339,7 +356,8 @@ public class DeviceProfile {
hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
hotseatExtraVerticalSize =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size);
updateHotseatIconSize(pxFromDp(inv.iconSize, mMetrics, 1f));
updateHotseatIconSize(
pxFromDp(inv.iconSize[InvariantDeviceProfile.INDEX_DEFAULT], mMetrics, 1f));
qsbBottomMarginOriginalPx = isScalableGrid
? res.getDimensionPixelSize(R.dimen.scalable_grid_qsb_bottom_margin)
@@ -451,22 +469,9 @@ public class DeviceProfile {
return 0;
}
int horizontalMarginPx;
if (isScalableGrid) {
if (isTwoPanels) {
if (isLandscape) {
horizontalMarginPx = pxFromDp(idp.twoPanelLandscapeHorizontalMargin, mMetrics);
} else {
horizontalMarginPx = pxFromDp(idp.twoPanelPortraitHorizontalMargin, mMetrics);
}
} else {
horizontalMarginPx = pxFromDp(idp.horizontalMargin, mMetrics);
}
} else {
horizontalMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_left_right_margin);
}
return horizontalMarginPx;
return isScalableGrid
? pxFromDp(idp.horizontalMargin[mTypeIndex], mMetrics)
: res.getDimensionPixelSize(R.dimen.dynamic_grid_left_right_margin);
}
private void updateHotseatIconSize(int hotseatIconSizePx) {
@@ -487,21 +492,8 @@ public class DeviceProfile {
return new Point(0, 0);
}
int horizontalSpacePx;
int verticalSpacePx;
if (isTwoPanels) {
if (isLandscape) {
horizontalSpacePx = pxFromDp(idp.twoPanelLandscapeBorderSpace.x, mMetrics);
verticalSpacePx = pxFromDp(idp.twoPanelLandscapeBorderSpace.y, mMetrics);
} else {
horizontalSpacePx = pxFromDp(idp.twoPanelPortraitBorderSpace.x, mMetrics);
verticalSpacePx = pxFromDp(idp.twoPanelPortraitBorderSpace.y, mMetrics);
}
} else {
horizontalSpacePx = pxFromDp(idp.borderSpace.x, mMetrics);
verticalSpacePx = pxFromDp(idp.borderSpace.y, mMetrics);
}
int horizontalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].x, mMetrics);
int verticalSpacePx = pxFromDp(idp.borderSpaces[mTypeIndex].y, mMetrics);
return new Point(horizontalSpacePx, verticalSpacePx);
}
@@ -598,7 +590,7 @@ public class DeviceProfile {
private void updateAllAppsWidth() {
if (isTwoPanels) {
int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns)
+ (allAppsCellSpacingPx * (numShownAllAppsColumns + 1));
+ (allAppsCellSpacePx.x * (numShownAllAppsColumns + 1));
allAppsLeftRightPadding = Math.max(1, (availableWidthPx - usedWidth) / 2);
} else {
allAppsLeftRightPadding =
@@ -661,26 +653,8 @@ public class DeviceProfile {
// Workspace
final boolean isVerticalLayout = isVerticalBarLayout();
float invIconSizeDp;
float invIconTextSizeSp;
if (isTwoPanels) {
if (isLandscape) {
invIconSizeDp = inv.twoPanelLandscapeIconSize;
invIconTextSizeSp = inv.twoPanelLandscapeIconTextSize;
} else {
invIconSizeDp = inv.twoPanelPortraitIconSize;
invIconTextSizeSp = inv.twoPanelPortraitIconTextSize;
}
} else {
if (isLandscape) {
invIconSizeDp = inv.landscapeIconSize;
invIconTextSizeSp = inv.landscapeIconTextSize;
} else {
invIconSizeDp = inv.iconSize;
invIconTextSizeSp = inv.iconTextSize;
}
}
float invIconSizeDp = inv.iconSize[mTypeIndex];
float invIconTextSizeSp = inv.iconTextSize[mTypeIndex];
iconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, iconScale));
iconTextSizePx = (int) (pxFromSp(invIconTextSizeSp, mMetrics) * iconScale);
@@ -689,9 +663,8 @@ public class DeviceProfile {
cellLayoutBorderSpacePx = getCellLayoutBorderSpaceScaled(inv, scale);
if (isScalableGrid) {
PointF minCellHeightAndWidth = getMinCellHeightAndWidth();
cellWidthPx = pxFromDp(minCellHeightAndWidth.x, mMetrics, scale);
cellHeightPx = pxFromDp(minCellHeightAndWidth.y, mMetrics, scale);
cellWidthPx = pxFromDp(inv.minCellSize[mTypeIndex].x, mMetrics, scale);
cellHeightPx = pxFromDp(inv.minCellSize[mTypeIndex].y, mMetrics, scale);
int cellContentHeight = iconSizePx + iconDrawablePaddingPx
+ Utilities.calculateTextHeight(iconTextSizePx);
cellYPaddingPx = Math.max(0, cellHeightPx - cellContentHeight) / 2;
@@ -715,8 +688,10 @@ public class DeviceProfile {
// All apps
if (numShownAllAppsColumns != inv.numColumns) {
allAppsIconSizePx = pxFromDp(inv.allAppsIconSize, mMetrics);
allAppsIconTextSizePx = pxFromSp(inv.allAppsIconTextSize, mMetrics);
allAppsIconSizePx =
pxFromDp(inv.iconSize[InvariantDeviceProfile.INDEX_ALL_APPS], mMetrics);
allAppsIconTextSizePx =
pxFromSp(inv.iconTextSize[InvariantDeviceProfile.INDEX_ALL_APPS], mMetrics);
allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx;
autoResizeAllAppsCells();
} else {
@@ -752,28 +727,6 @@ public class DeviceProfile {
folderIconOffsetYPx = (iconSizePx - folderIconSizePx) / 2;
}
/**
* Returns the minimum cell height and width as a pair.
*/
private PointF getMinCellHeightAndWidth() {
PointF result = new PointF();
if (isTwoPanels) {
if (isLandscape) {
result.x = inv.twoPanelLandscapeMinCellWidthDps;
result.y = inv.twoPanelLandscapeMinCellHeightDps;
} else {
result.x = inv.twoPanelPortraitMinCellWidthDps;
result.y = inv.twoPanelPortraitMinCellHeightDps;
}
} else {
result.x = inv.minCellWidth;
result.y = inv.minCellHeight;
}
return result;
}
private void updateAvailableFolderCellDimensions(Resources res) {
updateFolderCellSize(1f, res);
@@ -804,9 +757,12 @@ public class DeviceProfile {
}
private void updateFolderCellSize(float scale, Resources res) {
float invIconSizeDp = isVerticalBarLayout() ? inv.landscapeIconSize : inv.iconSize;
float invIconSizeDp = isVerticalBarLayout()
? inv.iconSize[InvariantDeviceProfile.INDEX_LANDSCAPE]
: inv.iconSize[InvariantDeviceProfile.INDEX_DEFAULT];
folderChildIconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, scale));
folderChildTextSizePx = pxFromSp(inv.iconTextSize, mMetrics, scale);
folderChildTextSizePx =
pxFromSp(inv.iconTextSize[InvariantDeviceProfile.INDEX_DEFAULT], mMetrics, scale);
folderLabelTextSizePx = (int) (folderChildTextSizePx * folderLabelTextScale);
int textHeight = Utilities.calculateTextHeight(folderChildTextSizePx);
@@ -901,7 +857,7 @@ public class DeviceProfile {
+ workspaceBottomPadding - mWorkspacePageIndicatorOverlapWorkspace;
padding.set(desiredWorkspaceHorizontalMarginPx,
(isScalableGrid ? workspaceTopPadding : edgeMarginPx),
workspaceTopPadding + (isScalableGrid ? 0 : edgeMarginPx),
desiredWorkspaceHorizontalMarginPx,
paddingBottom);
}
@@ -1094,19 +1050,10 @@ public class DeviceProfile {
writer.println(prefix + "\tisScalableGrid:" + isScalableGrid);
writer.println(prefix + "\tinv.minCellWidth:" + inv.minCellWidth + "dp");
writer.println(prefix + "\tinv.minCellHeight:" + inv.minCellHeight + "dp");
writer.println(prefix + "\tinv.twoPanelPortraitMinCellHeightDps:"
+ inv.twoPanelPortraitMinCellHeightDps + "dp");
writer.println(prefix + "\tinv.twoPanelPortraitMinCellWidthDps:"
+ inv.twoPanelPortraitMinCellWidthDps + "dp");
writer.println(prefix + "\tinv.twoPanelLandscapeMinCellHeightDps:"
+ inv.twoPanelLandscapeMinCellHeightDps + "dp");
writer.println(prefix + "\tinv.twoPanelLandscapeMinCellWidthDps:"
+ inv.twoPanelLandscapeMinCellWidthDps + "dp");
writer.println(prefix + "\tinv.numColumns: " + inv.numColumns);
writer.println(prefix + "\tinv.numRows: " + inv.numRows);
writer.println(prefix + "\tinv.numColumns:" + inv.numColumns);
writer.println(prefix + "\tinv.numRows:" + inv.numRows);
writer.println(prefix + "\tminCellSize: " + inv.minCellSize[mTypeIndex] + "dp");
writer.println(prefix + pxToDpStr("cellWidthPx", cellWidthPx));
writer.println(prefix + pxToDpStr("cellHeightPx", cellHeightPx));
@@ -1114,7 +1061,11 @@ public class DeviceProfile {
writer.println(prefix + pxToDpStr("getCellSize().x", getCellSize().x));
writer.println(prefix + pxToDpStr("getCellSize().y", getCellSize().y));
writer.println(prefix + "\tinv.iconSize:" + inv.iconSize + "dp");
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Horizontal",
cellLayoutBorderSpacePx.x));
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Vertical",
cellLayoutBorderSpacePx.y));
writer.println(prefix + pxToDpStr("iconSizePx", iconSizePx));
writer.println(prefix + pxToDpStr("iconTextSizePx", iconTextSizePx));
writer.println(prefix + pxToDpStr("iconDrawablePaddingPx", iconDrawablePaddingPx));
@@ -1132,14 +1083,6 @@ public class DeviceProfile {
writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpacePx Vertical",
folderCellLayoutBorderSpacePx.y));
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Horizontal",
cellLayoutBorderSpacePx.x));
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Vertical",
cellLayoutBorderSpacePx.y));
writer.println(prefix + pxToDpStr("desiredWorkspaceHorizontalMarginPx",
desiredWorkspaceHorizontalMarginPx));
writer.println(prefix + pxToDpStr("allAppsIconSizePx", allAppsIconSizePx));
writer.println(prefix + pxToDpStr("allAppsIconTextSizePx", allAppsIconTextSizePx));
writer.println(prefix + pxToDpStr("allAppsIconDrawablePaddingPx",
@@ -1161,6 +1104,8 @@ public class DeviceProfile {
writer.println(prefix + "\tisTaskbarPresentInApps:" + isTaskbarPresentInApps);
writer.println(prefix + pxToDpStr("taskbarSize", taskbarSize));
writer.println(prefix + pxToDpStr("desiredWorkspaceHorizontalMarginPx",
desiredWorkspaceHorizontalMarginPx));
writer.println(prefix + pxToDpStr("workspacePadding.left", workspacePadding.left));
writer.println(prefix + pxToDpStr("workspacePadding.top", workspacePadding.top));
writer.println(prefix + pxToDpStr("workspacePadding.right", workspacePadding.right));
@@ -86,6 +86,15 @@ public class InvariantDeviceProfile {
// used to offset float not being able to express extremely small weights in extreme cases.
private static final float WEIGHT_EFFICIENT = 100000f;
// Used for arrays to specify different sizes (e.g. border spaces, width/height) in different
// constraints
static final int COUNT_SIZES = 5;
static final int INDEX_DEFAULT = 0;
static final int INDEX_LANDSCAPE = 1;
static final int INDEX_TWO_PANEL_PORTRAIT = 2;
static final int INDEX_TWO_PANEL_LANDSCAPE = 3;
static final int INDEX_ALL_APPS = 4;
/**
* Number of icons per row and column in the workspace.
*/
@@ -97,36 +106,18 @@ public class InvariantDeviceProfile {
*/
public int numFolderRows;
public int numFolderColumns;
public float iconSize;
public float landscapeIconSize;
public float twoPanelPortraitIconSize;
public float twoPanelLandscapeIconSize;
public float landscapeIconTextSize;
public float twoPanelPortraitIconTextSize;
public float twoPanelLandscapeIconTextSize;
public float[] iconSize;
public float[] iconTextSize;
public int iconBitmapSize;
public int fillResIconDpi;
public float iconTextSize;
public float allAppsIconSize;
public float allAppsIconTextSize;
public float allAppsCellSpacing;
public boolean isSplitDisplay;
public float minCellHeight;
public float minCellWidth;
public float twoPanelPortraitMinCellHeightDps;
public float twoPanelPortraitMinCellWidthDps;
public float twoPanelLandscapeMinCellHeightDps;
public float twoPanelLandscapeMinCellWidthDps;
public PointF[] minCellSize;
public PointF borderSpace;
public PointF twoPanelPortraitBorderSpace;
public PointF twoPanelLandscapeBorderSpace;
public PointF[] borderSpaces;
public float folderBorderSpace;
public float horizontalMargin;
public float twoPanelLandscapeHorizontalMargin;
public float twoPanelPortraitHorizontalMargin;
public float[] horizontalMargin;
private SparseArray<TypedValue> mExtraAttrs;
@@ -221,17 +212,17 @@ public class InvariantDeviceProfile {
DisplayOption result = new DisplayOption(defaultDisplayOption.grid)
.add(myDisplayOption);
result.iconSizes[DisplayOption.INDEX_DEFAULT] =
defaultDisplayOption.iconSizes[DisplayOption.INDEX_DEFAULT];
for (int i = 1; i < DisplayOption.COUNT_SIZES; i++) {
result.iconSizes[INDEX_DEFAULT] =
defaultDisplayOption.iconSizes[INDEX_DEFAULT];
for (int i = 1; i < COUNT_SIZES; i++) {
result.iconSizes[i] = Math.min(
defaultDisplayOption.iconSizes[i], myDisplayOption.iconSizes[i]);
}
result.minCellHeight = defaultDisplayOption.minCellHeight;
result.minCellWidth = defaultDisplayOption.minCellWidth;
result.borderSpaces[DisplayOption.INDEX_ALL_APPS] =
defaultDisplayOption.borderSpaces[DisplayOption.INDEX_ALL_APPS];
System.arraycopy(defaultDisplayOption.minCellSize, 0, result.minCellSize, 0,
COUNT_SIZES);
System.arraycopy(defaultDisplayOption.borderSpaces, 0, result.borderSpaces, 0,
COUNT_SIZES);
initGrid(context, myInfo, result, false);
}
@@ -274,39 +265,18 @@ public class InvariantDeviceProfile {
mExtraAttrs = closestProfile.extraAttrs;
iconSize = displayOption.iconSizes[DisplayOption.INDEX_DEFAULT];
landscapeIconSize = displayOption.iconSizes[DisplayOption.INDEX_LANDSCAPE];
twoPanelPortraitIconSize = displayOption.iconSizes[DisplayOption.INDEX_TWO_PANEL_PORTRAIT];
twoPanelLandscapeIconSize =
displayOption.iconSizes[DisplayOption.INDEX_TWO_PANEL_LANDSCAPE];
iconBitmapSize = ResourceUtils.pxFromDp(iconSize, metrics);
iconSize = displayOption.iconSizes;
iconBitmapSize = ResourceUtils.pxFromDp(iconSize[INDEX_DEFAULT], metrics);
fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
iconTextSize = displayOption.textSizes[DisplayOption.INDEX_DEFAULT];
landscapeIconTextSize = displayOption.textSizes[DisplayOption.INDEX_LANDSCAPE];
twoPanelPortraitIconTextSize =
displayOption.textSizes[DisplayOption.INDEX_TWO_PANEL_PORTRAIT];
twoPanelLandscapeIconTextSize =
displayOption.textSizes[DisplayOption.INDEX_TWO_PANEL_LANDSCAPE];
iconTextSize = displayOption.textSizes;
minCellHeight = displayOption.minCellHeight;
minCellWidth = displayOption.minCellWidth;
twoPanelPortraitMinCellHeightDps = displayOption.twoPanelPortraitMinCellHeightDps;
twoPanelPortraitMinCellWidthDps = displayOption.twoPanelPortraitMinCellWidthDps;
twoPanelLandscapeMinCellHeightDps = displayOption.twoPanelLandscapeMinCellHeightDps;
twoPanelLandscapeMinCellWidthDps = displayOption.twoPanelLandscapeMinCellWidthDps;
minCellSize = displayOption.minCellSize;
borderSpace = displayOption.borderSpaces[DisplayOption.INDEX_DEFAULT];
twoPanelPortraitBorderSpace =
displayOption.borderSpaces[DisplayOption.INDEX_TWO_PANEL_PORTRAIT];
twoPanelLandscapeBorderSpace =
displayOption.borderSpaces[DisplayOption.INDEX_TWO_PANEL_LANDSCAPE];
allAppsCellSpacing = displayOption.borderSpaces[DisplayOption.INDEX_ALL_APPS].x;
borderSpaces = displayOption.borderSpaces;
folderBorderSpace = displayOption.folderBorderSpace;
horizontalMargin = displayOption.horizontalMargin;
twoPanelLandscapeHorizontalMargin = displayOption.twoPanelLandscapeHorizontalMargin;
twoPanelPortraitHorizontalMargin = displayOption.twoPanelPortraitHorizontalMargin;
numShownHotseatIcons = closestProfile.numHotseatIcons;
numDatabaseHotseatIcons = isSplitDisplay
@@ -316,12 +286,9 @@ public class InvariantDeviceProfile {
numDatabaseAllAppsColumns = isSplitDisplay
? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;
if (Utilities.isGridOptionsEnabled(context)) {
allAppsIconSize = displayOption.iconSizes[DisplayOption.INDEX_ALL_APPS];
allAppsIconTextSize = displayOption.textSizes[DisplayOption.INDEX_ALL_APPS];
} else {
allAppsIconSize = iconSize;
allAppsIconTextSize = iconTextSize;
if (!Utilities.isGridOptionsEnabled(context)) {
iconSize[INDEX_ALL_APPS] = iconSize[INDEX_DEFAULT];
iconTextSize[INDEX_ALL_APPS] = iconTextSize[INDEX_DEFAULT];
}
if (devicePaddingId != 0) {
@@ -566,11 +533,11 @@ public class InvariantDeviceProfile {
// Since the bitmaps are persisted, ensure that the default bitmap size is same as
// predefined size to avoid cache invalidation
out.iconSizes[DisplayOption.INDEX_DEFAULT] =
closestPoint.iconSizes[DisplayOption.INDEX_DEFAULT];
for (int i = DisplayOption.INDEX_DEFAULT + 1; i < DisplayOption.COUNT_SIZES; i++) {
out.iconSizes[INDEX_DEFAULT] =
closestPoint.iconSizes[INDEX_DEFAULT];
for (int i = INDEX_DEFAULT + 1; i < COUNT_SIZES; i++) {
out.iconSizes[i] = Math.min(out.iconSizes[i],
out.iconSizes[DisplayOption.INDEX_DEFAULT]);
out.iconSizes[INDEX_DEFAULT]);
}
return out;
@@ -724,32 +691,17 @@ public class InvariantDeviceProfile {
@VisibleForTesting
static final class DisplayOption {
static final int COUNT_SIZES = 5;
static final int INDEX_DEFAULT = 0;
static final int INDEX_LANDSCAPE = 1;
static final int INDEX_TWO_PANEL_PORTRAIT = 2;
static final int INDEX_TWO_PANEL_LANDSCAPE = 3;
static final int INDEX_ALL_APPS = 4;
public final GridOption grid;
private final float minWidthDps;
private final float minHeightDps;
private final boolean canBeDefault;
private float minCellHeight;
private float minCellWidth;
private float twoPanelPortraitMinCellHeightDps;
private float twoPanelPortraitMinCellWidthDps;
private float twoPanelLandscapeMinCellHeightDps;
private float twoPanelLandscapeMinCellWidthDps;
private final PointF[] minCellSize = new PointF[COUNT_SIZES];
private float folderBorderSpace;
private final PointF[] borderSpaces = new PointF[COUNT_SIZES];
private float horizontalMargin;
private float twoPanelLandscapeHorizontalMargin;
private float twoPanelPortraitHorizontalMargin;
private final float[] horizontalMargin = new float[COUNT_SIZES];
private final float[] iconSizes = new float[COUNT_SIZES];
private final float[] textSizes = new float[COUNT_SIZES];
@@ -766,27 +718,32 @@ public class InvariantDeviceProfile {
canBeDefault = a.getInt(R.styleable.ProfileDisplayOption_canBeDefault, 0)
== defaultFlagValue;
minCellHeight = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightDps, 0);
minCellWidth = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthDps, 0);
twoPanelPortraitMinCellHeightDps = a.getFloat(
R.styleable.ProfileDisplayOption_twoPanelPortraitMinCellHeightDps,
minCellHeight);
twoPanelPortraitMinCellWidthDps = a.getFloat(
R.styleable.ProfileDisplayOption_twoPanelPortraitMinCellWidthDps, minCellWidth);
twoPanelLandscapeMinCellHeightDps = a.getFloat(
R.styleable.ProfileDisplayOption_twoPanelLandscapeMinCellHeightDps,
twoPanelPortraitMinCellHeightDps);
twoPanelLandscapeMinCellWidthDps = a.getFloat(
R.styleable.ProfileDisplayOption_twoPanelLandscapeMinCellWidthDps,
twoPanelPortraitMinCellWidthDps);
float x;
float y;
x = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthDps, 0);
y = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightDps, 0);
minCellSize[INDEX_DEFAULT] = new PointF(x, y);
minCellSize[INDEX_LANDSCAPE] = new PointF(x, y);
minCellSize[INDEX_ALL_APPS] = new PointF(x, y);
x = a.getFloat(R.styleable.ProfileDisplayOption_twoPanelPortraitMinCellWidthDps,
minCellSize[INDEX_DEFAULT].x);
y = a.getFloat(R.styleable.ProfileDisplayOption_twoPanelPortraitMinCellHeightDps,
minCellSize[INDEX_DEFAULT].y);
minCellSize[INDEX_TWO_PANEL_PORTRAIT] = new PointF(x, y);
x = a.getFloat(R.styleable.ProfileDisplayOption_twoPanelLandscapeMinCellWidthDps,
minCellSize[INDEX_DEFAULT].x);
y = a.getFloat(R.styleable.ProfileDisplayOption_twoPanelLandscapeMinCellHeightDps,
minCellSize[INDEX_DEFAULT].y);
minCellSize[INDEX_TWO_PANEL_LANDSCAPE] = new PointF(x, y);
float borderSpace = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceDps, 0);
float twoPanelPortraitBorderSpaceDps = a.getFloat(
R.styleable.ProfileDisplayOption_twoPanelPortraitBorderSpaceDps, borderSpace);
float twoPanelLandscapeBorderSpaceDps = a.getFloat(
R.styleable.ProfileDisplayOption_twoPanelLandscapeBorderSpaceDps, borderSpace);
float x;
float y;
x = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceHorizontalDps, borderSpace);
y = a.getFloat(R.styleable.ProfileDisplayOption_borderSpaceVerticalDps, borderSpace);
@@ -827,7 +784,7 @@ public class InvariantDeviceProfile {
iconSizes[INDEX_DEFAULT]);
iconSizes[INDEX_TWO_PANEL_LANDSCAPE] =
a.getFloat(R.styleable.ProfileDisplayOption_twoPanelLandscapeIconSize,
iconSizes[INDEX_LANDSCAPE]);
iconSizes[INDEX_DEFAULT]);
textSizes[INDEX_DEFAULT] =
a.getFloat(R.styleable.ProfileDisplayOption_iconTextSize, 0);
@@ -842,15 +799,18 @@ public class InvariantDeviceProfile {
textSizes[INDEX_DEFAULT]);
textSizes[INDEX_TWO_PANEL_LANDSCAPE] =
a.getFloat(R.styleable.ProfileDisplayOption_twoPanelLandscapeIconTextSize,
textSizes[INDEX_LANDSCAPE]);
textSizes[INDEX_DEFAULT]);
horizontalMargin = a.getFloat(R.styleable.ProfileDisplayOption_horizontalMargin, 0);
twoPanelLandscapeHorizontalMargin = a.getFloat(
horizontalMargin[INDEX_DEFAULT] = a.getFloat(
R.styleable.ProfileDisplayOption_horizontalMargin, 0);
horizontalMargin[INDEX_LANDSCAPE] = horizontalMargin[INDEX_DEFAULT];
horizontalMargin[INDEX_ALL_APPS] = horizontalMargin[INDEX_DEFAULT];
horizontalMargin[INDEX_TWO_PANEL_LANDSCAPE] = a.getFloat(
R.styleable.ProfileDisplayOption_twoPanelLandscapeHorizontalMargin,
horizontalMargin);
twoPanelPortraitHorizontalMargin = a.getFloat(
horizontalMargin[INDEX_DEFAULT]);
horizontalMargin[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat(
R.styleable.ProfileDisplayOption_twoPanelPortraitHorizontalMargin,
horizontalMargin);
horizontalMargin[INDEX_DEFAULT]);
a.recycle();
}
@@ -864,12 +824,11 @@ public class InvariantDeviceProfile {
minWidthDps = 0;
minHeightDps = 0;
canBeDefault = false;
minCellHeight = 0;
minCellWidth = 0;
for (int i = 0; i < COUNT_SIZES; i++) {
iconSizes[i] = 0;
textSizes[i] = 0;
borderSpaces[i] = new PointF();
minCellSize[i] = new PointF();
}
}
@@ -877,21 +836,15 @@ public class InvariantDeviceProfile {
for (int i = 0; i < COUNT_SIZES; i++) {
iconSizes[i] *= w;
textSizes[i] *= w;
borderSpaces[i].x *= w;
borderSpaces[i].y *= w;
borderSpaces[i].x *= w;
borderSpaces[i].y *= w;
minCellSize[i].x *= w;
minCellSize[i].y *= w;
horizontalMargin[i] *= w;
}
minCellHeight *= w;
minCellWidth *= w;
twoPanelPortraitMinCellHeightDps *= w;
twoPanelPortraitMinCellWidthDps *= w;
twoPanelLandscapeMinCellHeightDps *= w;
twoPanelLandscapeMinCellWidthDps *= w;
folderBorderSpace *= w;
horizontalMargin *= w;
twoPanelLandscapeHorizontalMargin *= w;
twoPanelPortraitHorizontalMargin *= w;
return this;
}
@@ -899,21 +852,15 @@ public class InvariantDeviceProfile {
for (int i = 0; i < COUNT_SIZES; i++) {
iconSizes[i] += p.iconSizes[i];
textSizes[i] += p.textSizes[i];
borderSpaces[i].x += p.borderSpaces[i].x;
borderSpaces[i].y += p.borderSpaces[i].y;
borderSpaces[i].x += p.borderSpaces[i].x;
borderSpaces[i].y += p.borderSpaces[i].y;
minCellSize[i].x += p.minCellSize[i].x;
minCellSize[i].y += p.minCellSize[i].y;
horizontalMargin[i] += p.horizontalMargin[i];
}
minCellHeight += p.minCellHeight;
minCellWidth += p.minCellWidth;
twoPanelPortraitMinCellHeightDps += p.twoPanelPortraitMinCellHeightDps;
twoPanelPortraitMinCellWidthDps += p.twoPanelPortraitMinCellWidthDps;
twoPanelLandscapeMinCellHeightDps += p.twoPanelLandscapeMinCellHeightDps;
twoPanelLandscapeMinCellWidthDps += p.twoPanelLandscapeMinCellWidthDps;
folderBorderSpace += p.folderBorderSpace;
horizontalMargin += p.horizontalMargin;
twoPanelLandscapeHorizontalMargin += p.twoPanelLandscapeHorizontalMargin;
twoPanelPortraitHorizontalMargin += p.twoPanelPortraitHorizontalMargin;
return this;
}
}
+1 -1
View File
@@ -142,7 +142,7 @@ public class Partner {
}
if (iconSize > 0) {
inv.iconSize = iconSize;
inv.iconSize[InvariantDeviceProfile.INDEX_DEFAULT] = iconSize;
}
}
}
@@ -63,7 +63,6 @@ import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.RecyclerViewFastScroller;
@@ -482,10 +481,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
int layout = showTabs ? R.layout.all_apps_tabs : R.layout.all_apps_rv_layout;
View newView = getLayoutInflater().inflate(layout, this, false);
addView(newView, index);
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "should show tabs:" + showTabs,
new Exception());
}
if (showTabs) {
mViewPager = (AllAppsPagedView) newView;
mViewPager.initParentViews(this);
@@ -172,4 +172,8 @@ public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActiveP
private AllAppsContainerView.AdapterHolder getAH() {
return mAllApps.mAH[AllAppsContainerView.AdapterHolder.WORK];
}
public int getCurrentState() {
return mCurrentState;
}
}
@@ -258,7 +258,7 @@ public final class FeatureFlags {
"Enables widgets in Launcher preview for the Wallpaper app.");
public static final BooleanFlag QUICK_WALLPAPER_PICKER = getDebugFlag(
"QUICK_WALLPAPER_PICKER", false,
"QUICK_WALLPAPER_PICKER", true,
"Shows quick wallpaper picker in long-press menu");
public static final BooleanFlag ENABLE_BACK_SWIPE_HOME_ANIMATION = getDebugFlag(
@@ -22,7 +22,6 @@ import static com.android.launcher3.BubbleTextView.TEXT_ALPHA_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW;
import static com.android.launcher3.graphics.IconShape.getShape;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -175,15 +174,9 @@ public class FolderAnimationManager {
final float yDistance = initialY - lp.y;
// Set up the Folder background.
final int finalColor;
int folderFillColor = Themes.getAttrColor(mContext, R.attr.folderFillColor);
if (mIsOpening) {
finalColor = folderFillColor;
} else {
finalColor = mFolderBackground.getColor().getDefaultColor();
}
final int initialColor = setColorAlphaBound(
folderFillColor, mPreviewBackground.getBackgroundAlpha());
final int initialColor = Themes.getAttrColor(mContext, R.attr.folderPreviewColor);
final int finalColor = Themes.getAttrColor(mContext, R.attr.folderBackgroundColor);
mFolderBackground.mutate();
mFolderBackground.setColor(mIsOpening ? initialColor : finalColor);
@@ -66,7 +66,6 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
float mScale = 1f;
private float mColorMultiplier = 1f;
private int mBgColor;
private int mStrokeColor;
private int mDotColor;
@@ -87,7 +86,6 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
// Drawing / animation configurations
private static final float ACCEPT_SCALE_FACTOR = 1.20f;
private static final float ACCEPT_COLOR_MULTIPLIER = 1.5f;
// Expressed on a scale from 0 to 255.
private static final int BG_OPACITY = 255;
@@ -154,7 +152,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
TypedArray ta = context.getTheme().obtainStyledAttributes(R.styleable.FolderIconPreview);
mDotColor = ta.getColor(R.styleable.FolderIconPreview_folderDotColor, 0);
mStrokeColor = ta.getColor(R.styleable.FolderIconPreview_folderIconBorderColor, 0);
mBgColor = ta.getColor(R.styleable.FolderIconPreview_folderFillColor, 0);
mBgColor = ta.getColor(R.styleable.FolderIconPreview_folderPreviewColor, 0);
ta.recycle();
DeviceProfile grid = activity.getDeviceProfile();
@@ -227,8 +225,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
}
public int getBgColor() {
int alpha = (int) Math.min(MAX_BG_OPACITY, BG_OPACITY * mColorMultiplier);
return setColorAlphaBound(mBgColor, alpha);
return mBgColor;
}
public int getDotColor() {
@@ -384,14 +381,10 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
return mDrawingDelegate != null;
}
private void animateScale(float finalScale, float finalMultiplier,
final Runnable onStart, final Runnable onEnd) {
private void animateScale(float finalScale, final Runnable onStart, final Runnable onEnd) {
final float scale0 = mScale;
final float scale1 = finalScale;
final float bgMultiplier0 = mColorMultiplier;
final float bgMultiplier1 = finalMultiplier;
if (mScaleAnimator != null) {
mScaleAnimator.cancel();
}
@@ -403,7 +396,6 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
public void onAnimationUpdate(ValueAnimator animation) {
float prog = animation.getAnimatedFraction();
mScale = prog * scale1 + (1 - prog) * scale0;
mColorMultiplier = prog * bgMultiplier1 + (1 - prog) * bgMultiplier0;
invalidate();
}
});
@@ -429,8 +421,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
}
public void animateToAccept(CellLayout cl, int cellX, int cellY) {
animateScale(ACCEPT_SCALE_FACTOR, ACCEPT_COLOR_MULTIPLIER,
() -> delegateDrawing(cl, cellX, cellY), null);
animateScale(ACCEPT_SCALE_FACTOR, () -> delegateDrawing(cl, cellX, cellY), null);
}
public void animateToRest() {
@@ -440,11 +431,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
CellLayout cl = mDrawingDelegate;
int cellX = mDelegateCellX;
int cellY = mDelegateCellY;
animateScale(1f, 1f, () -> delegateDrawing(cl, cellX, cellY), this::clearDrawingDelegate);
}
public int getBackgroundAlpha() {
return (int) Math.min(MAX_BG_OPACITY, BG_OPACITY * mColorMultiplier);
animateScale(1f, () -> delegateDrawing(cl, cellX, cellY), this::clearDrawingDelegate);
}
public float getStrokeWidth() {
@@ -21,10 +21,8 @@ import android.content.Intent;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArrayMap;
import android.util.Log;
import android.util.LongSparseArray;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.SimpleBroadcastReceiver;
@@ -60,9 +58,6 @@ public class UserCache {
private void onUsersChanged(Intent intent) {
enableAndResetCache();
mUserChangeListeners.forEach(Runnable::run);
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "profile changed", new Exception());
}
}
/**
@@ -117,7 +117,6 @@ public final class TestProtocol {
public static final String REQUEST_MOCK_SENSOR_ROTATION = "mock-sensor-rotation";
public static final String PERMANENT_DIAG_TAG = "TaplTarget";
public static final String WORK_PROFILE_REMOVED = "b/159671700";
public static final String TASK_VIEW_ID_CRASH = "b/195430732";
public static final String NO_DROP_TARGET = "b/195031154";
public static final String NULL_INT_SET = "b/200572078";
@@ -262,8 +262,6 @@ public abstract class AbstractLauncherUiTest {
if (userManager != null) {
for (UserHandle userHandle : userManager.getUserProfiles()) {
if (!userHandle.isSystem()) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED,
"removing user " + userHandle.getIdentifier());
mDevice.executeShellCommand("pm remove-user " + userHandle.getIdentifier());
}
}
@@ -0,0 +1,167 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.ui;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import android.view.View;
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.allapps.AllAppsPagedView;
import com.android.launcher3.allapps.WorkAdapterProvider;
import com.android.launcher3.allapps.WorkEduCard;
import com.android.launcher3.allapps.WorkProfileManager;
import com.android.launcher3.tapl.LauncherInstrumentation;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.Objects;
public class WorkProfileTest extends AbstractLauncherUiTest {
private static final int WORK_PAGE = AllAppsContainerView.AdapterHolder.WORK;
private int mProfileUserId;
@Before
@Override
public void setUp() throws Exception {
super.setUp();
String output =
mDevice.executeShellCommand(
"pm create-user --profileOf 0 --managed TestProfile");
assertTrue("Failed to create work profile", output.startsWith("Success"));
String[] tokens = output.split("\\s+");
mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]);
mDevice.executeShellCommand("am start-user " + mProfileUserId);
}
@After
public void removeWorkProfile() throws Exception {
mDevice.executeShellCommand("pm remove-user " + mProfileUserId);
}
@After
public void resumeAppStoreUpdate() {
executeOnLauncher(launcher -> {
if (launcher == null || launcher.getAppsView() == null) {
return;
}
launcher.getAppsView().getAppsStore().disableDeferUpdates(DEFER_UPDATES_TEST);
});
}
private void waitForWorkTabSetup() {
waitForLauncherCondition("Work tab not setup", launcher -> {
if (launcher.getAppsView().getContentView() instanceof AllAppsPagedView) {
launcher.getAppsView().getAppsStore().enableDeferUpdates(DEFER_UPDATES_TEST);
return true;
}
return false;
}, LauncherInstrumentation.WAIT_TIME_MS);
}
@Test
public void workTabExists() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
waitForState("Launcher internal state didn't switch to Normal", () -> NORMAL);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS);
waitForLauncherCondition("Personal tab is missing",
launcher -> launcher.getAppsView().isPersonalTabVisible(),
LauncherInstrumentation.WAIT_TIME_MS);
waitForLauncherCondition("Work tab is missing",
launcher -> launcher.getAppsView().isWorkTabVisible(),
LauncherInstrumentation.WAIT_TIME_MS);
}
@Test
public void toggleWorks() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
waitForState("Launcher internal state didn't switch to Normal", () -> NORMAL);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS);
waitForWorkTabSetup();
executeOnLauncher(launcher -> {
AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
pagedView.setCurrentPage(WORK_PAGE);
});
WorkProfileManager manager = getFromLauncher(l -> l.getAppsView().getWorkManager());
waitForLauncherCondition("work profile initial state check failed", launcher ->
manager.getWorkModeSwitch() != null
&& manager.getCurrentState() == WorkProfileManager.STATE_ENABLED
&& manager.getWorkModeSwitch().isEnabled(),
LauncherInstrumentation.WAIT_TIME_MS);
//start work profile toggle OFF test
executeOnLauncher(l -> l.getAppsView().getWorkManager().getWorkModeSwitch().performClick());
waitForLauncherCondition("Work profile toggle OFF failed", launcher -> {
manager.reset(); // pulls current state from system
return manager.getCurrentState() == WorkProfileManager.STATE_DISABLED;
}, LauncherInstrumentation.WAIT_TIME_MS);
// start work profile toggle ON test
executeOnLauncher(l -> {
AllAppsContainerView allApps = l.getAppsView();
assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
View workPausedCard = allApps.getActiveRecyclerView().findViewHolderForAdapterPosition(
0).itemView;
workPausedCard.findViewById(R.id.enable_work_apps).performClick();
});
waitForLauncherCondition("Work profile toggle ON failed", launcher -> {
manager.reset(); // pulls current state from system
return manager.getCurrentState() == WorkProfileManager.STATE_ENABLED;
}, LauncherInstrumentation.WAIT_TIME_MS);
}
@Test
public void testEdu() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
waitForState("Launcher internal state didn't switch to Normal", () -> NORMAL);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS);
waitForWorkTabSetup();
executeOnLauncher(l -> {
l.getSharedPrefs().edit().putInt(WorkAdapterProvider.KEY_WORK_EDU_STEP, 0).commit();
((AllAppsPagedView) l.getAppsView().getContentView()).setCurrentPage(WORK_PAGE);
l.getAppsView().getWorkManager().reset();
});
waitForLauncherCondition("Work profile education not shown",
l -> l.getAppsView().getActiveRecyclerView()
.findViewHolderForAdapterPosition(0).itemView instanceof WorkEduCard,
LauncherInstrumentation.WAIT_TIME_MS);
}
}
-236
View File
@@ -1,236 +0,0 @@
/*
* Copyright 2018, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.ui;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
import android.widget.TextView;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.allapps.AllAppsPagedView;
import com.android.launcher3.allapps.WorkModeSwitch;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.views.WorkEduView;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class WorkTabTest extends AbstractLauncherUiTest {
private int mProfileUserId;
private static final int WORK_PAGE = AllAppsContainerView.AdapterHolder.WORK;
@Before
@Override
public void setUp() throws Exception {
super.setUp();
String output =
mDevice.executeShellCommand(
"pm create-user --profileOf 0 --managed TestProfile");
assertTrue("Failed to create work profile", output.startsWith("Success"));
String[] tokens = output.split("\\s+");
mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]);
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Created new user uid" + mProfileUserId);
mDevice.executeShellCommand("am start-user " + mProfileUserId);
}
@After
public void removeWorkProfile() throws Exception {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "(teardown) removing uid" + mProfileUserId,
new Exception());
mDevice.executeShellCommand("pm remove-user " + mProfileUserId);
}
@After
public void resumeAppStoreUpdate() {
executeOnLauncher(launcher -> {
if (launcher == null || launcher.getAppsView() == null) {
return;
}
launcher.getAppsView().getAppsStore().disableDeferUpdates(DEFER_UPDATES_TEST);
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "resuming AppStore updates");
});
}
@Ignore("b/182844465")
@Test
public void workTabExists() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS);
waitForLauncherCondition("Personal tab is missing",
launcher -> launcher.getAppsView().isPersonalTabVisible(), 60000);
waitForLauncherCondition("Work tab is missing",
launcher -> launcher.getAppsView().isWorkTabVisible(), 60000);
}
@Ignore("b/182844465")
@Test
public void toggleWorks() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
waitForState("Launcher internal state didn't switch to All Apps", () -> ALL_APPS);
getOnceNotNull("Apps view did not bind",
launcher -> launcher.getAppsView().getWorkModeSwitch(), 60000);
UserManager userManager = getFromLauncher(l -> l.getSystemService(UserManager.class));
assertEquals(2, userManager.getUserProfiles().size());
UserHandle workProfile = getFromLauncher(l -> {
UserHandle myHandle = Process.myUserHandle();
List<UserHandle> userProfiles = userManager.getUserProfiles();
return userProfiles.get(0) == myHandle ? userProfiles.get(1) : userProfiles.get(0);
});
waitForLauncherCondition("work profile can't be turned off",
l -> userManager.requestQuietModeEnabled(true, workProfile));
assertTrue(userManager.isQuietModeEnabled(workProfile));
executeOnLauncher(launcher -> {
WorkModeSwitch wf = launcher.getAppsView().getWorkModeSwitch();
((AllAppsPagedView) launcher.getAppsView().getContentView()).snapToPageImmediately(
AllAppsContainerView.AdapterHolder.WORK);
wf.toggle();
});
waitForLauncherCondition("Work toggle did not work",
l -> l.getSystemService(UserManager.class).isQuietModeEnabled(workProfile));
}
@Ignore("b/182844465")
@Test
public void testWorkEduFlow() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
executeOnLauncher(launcher -> launcher.getSharedPrefs().edit().remove(
WorkEduView.KEY_WORK_EDU_STEP).remove(
WorkEduView.KEY_LEGACY_WORK_EDU_SEEN).commit());
waitForLauncherCondition("Work tab not setup", launcher -> {
if (launcher.getAppsView().getContentView() instanceof AllAppsPagedView) {
launcher.getAppsView().getAppsStore().enableDeferUpdates(DEFER_UPDATES_TEST);
return true;
}
return false;
}, LauncherInstrumentation.WAIT_TIME_MS);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
WorkEduView workEduView = getEduView();
// verify personal app edu is seen first and click "next"
executeOnLauncher(l -> {
assertEquals(((TextView) workEduView.findViewById(R.id.content_text)).getText(),
l.getResources().getString(R.string.work_profile_edu_personal_apps));
workEduView.findViewById(R.id.proceed).callOnClick();
});
AtomicInteger attempt = new AtomicInteger(0);
// verify work edu is seen next
waitForLauncherCondition("Launcher did not show the next edu screen", l -> {
Log.d(TestProtocol.WORK_PROFILE_REMOVED,
"running test attempt" + attempt.getAndIncrement());
if (!(l.getAppsView().getContentView() instanceof AllAppsPagedView)) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work tab not setup. Skipping test");
return false;
}
if (((AllAppsPagedView) l.getAppsView().getContentView()).getCurrentPage()
!= WORK_PAGE) {
Log.d(TestProtocol.WORK_PROFILE_REMOVED, "Work page not highlighted");
}
return ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(
l.getResources().getString(R.string.work_profile_edu_work_apps));
});
}
@Ignore("b/182844465")
@Test
public void testWorkEduIntermittent() {
mDevice.pressHome();
waitForLauncherCondition("Launcher didn't start", Objects::nonNull);
executeOnLauncher(launcher -> launcher.getSharedPrefs().edit().remove(
WorkEduView.KEY_WORK_EDU_STEP).remove(
WorkEduView.KEY_LEGACY_WORK_EDU_SEEN).commit());
waitForLauncherCondition("Work tab not setup",
launcher -> launcher.getAppsView().getContentView() instanceof AllAppsPagedView,
60000);
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
// verify personal app edu is seen
getEduView();
// dismiss personal edu
mDevice.pressHome();
waitForState("Launcher did not go home", () -> NORMAL);
// open work tab
executeOnLauncher(launcher -> launcher.getStateManager().goToState(ALL_APPS));
waitForState("Launcher did not switch to all apps", () -> ALL_APPS);
waitForLauncherCondition("Work tab not setup",
launcher -> launcher.getAppsView().getContentView() instanceof AllAppsPagedView,
60000);
executeOnLauncher(launcher -> {
AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
pagedView.setCurrentPage(WORK_PAGE);
});
WorkEduView workEduView = getEduView();
// verify work tab edu is shown
waitForLauncherCondition("Launcher did not show the next edu screen",
l -> ((TextView) workEduView.findViewById(R.id.content_text)).getText().equals(
l.getResources().getString(R.string.work_profile_edu_work_apps)));
}
private WorkEduView getEduView() {
waitForLauncherCondition("Edu did not show", l -> {
DragLayer dragLayer = l.getDragLayer();
return dragLayer.getChildCount() > 0 && dragLayer.getChildAt(
dragLayer.getChildCount() - 1) instanceof WorkEduView;
}, 6000);
return getFromLauncher(launcher -> (WorkEduView) launcher.getDragLayer().getChildAt(
launcher.getDragLayer().getChildCount() - 1));
}
}