Merge "Migrate ENABLE_OVERVIEW_ICON_MENU to aconfig flag" into main
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index a77791f..908ec0b 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -1,4 +1,6 @@
[Hook Scripts]
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --config_xml tools/checkstyle.xml --sha ${PREUPLOAD_COMMIT}
-ktfmt_hook = ${REPO_ROOT}/external/ktfmt/ktfmt.py --check ${PREUPLOAD_FILES}
\ No newline at end of file
+ktfmt_hook = ${REPO_ROOT}/external/ktfmt/ktfmt.py --check ${PREUPLOAD_FILES}
+
+flag_hook = ${REPO_ROOT}/vendor/unbundled_google/packages/NexusLauncher/flag_check.py ${PREUPLOAD_COMMIT_MESSAGE}
diff --git a/quickstep/res/layout/taskbar.xml b/quickstep/res/layout/taskbar.xml
index 94388b4..72d7485 100644
--- a/quickstep/res/layout/taskbar.xml
+++ b/quickstep/res/layout/taskbar.xml
@@ -45,9 +45,6 @@
android:id="@+id/start_contextual_buttons"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:paddingStart="@dimen/taskbar_contextual_button_padding"
- android:paddingEnd="@dimen/taskbar_contextual_button_padding"
- android:paddingTop="@dimen/taskbar_contextual_padding_top"
android:gravity="center_vertical"
android:layout_gravity="start"/>
@@ -63,7 +60,6 @@
android:id="@+id/end_contextual_buttons"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:paddingTop="@dimen/taskbar_contextual_padding_top"
android:gravity="center_vertical"
android:layout_gravity="end"/>
</FrameLayout>
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index cca0fd4..d2be94a 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -1824,7 +1824,7 @@
StartingWindowListener startingWindowListener, RunnableList onEndCallback) {
View viewToUse = findLaunchableViewWithBackground(v);
if (viewToUse == null) {
- viewToUse = v;
+ return null;
}
// The CUJ is logged by the click handler, so we don't log it inside the animation
diff --git a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
index e8374b8..037f7a8 100644
--- a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
+++ b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java
@@ -35,9 +35,7 @@
import com.android.launcher3.R;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderView;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.Themes;
-import com.android.launcher3.views.ActivityContext;
/**
* A view which shows a horizontal divider
@@ -93,10 +91,7 @@
? R.color.all_apps_label_text_dark
: R.color.all_apps_label_text);
- OnboardingPrefs<?> onboardingPrefs = ActivityContext.lookupContext(
- getContext()).getOnboardingPrefs();
- mShowAllAppsLabel = onboardingPrefs == null || !onboardingPrefs.hasReachedMaxCount(
- ALL_APPS_VISITED_COUNT);
+ mShowAllAppsLabel = !ALL_APPS_VISITED_COUNT.hasReachedMax(context);
}
public void setup(FloatingHeaderView parent, FloatingHeaderRow[] rows, boolean tabsHidden) {
diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
index a63f9e8..baea418 100644
--- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
+++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
@@ -23,6 +23,7 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_RANKED;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.FlagDebugUtils.appendFlag;
+import static com.android.launcher3.util.OnboardingPrefs.HOTSEAT_LONGPRESS_TIP_SEEN;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -41,6 +42,7 @@
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.Hotseat;
+import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimationSuccessListener;
@@ -59,7 +61,6 @@
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.uioverrides.PredictedAppIcon;
import com.android.launcher3.uioverrides.QuickstepLauncher;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.views.Snackbar;
import java.io.PrintWriter;
@@ -104,12 +105,11 @@
if (mLauncher.getWorkspace().isSwitchingState()) return false;
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onWorkspaceItemLongClick");
- if (mEnableHotseatLongPressTipForTesting && !mLauncher.getOnboardingPrefs().getBoolean(
- OnboardingPrefs.HOTSEAT_LONGPRESS_TIP_SEEN)) {
+ if (mEnableHotseatLongPressTipForTesting && !HOTSEAT_LONGPRESS_TIP_SEEN.get(mLauncher)) {
Snackbar.show(mLauncher, R.string.hotseat_tip_gaps_filled,
R.string.hotseat_prediction_settings, null,
() -> mLauncher.startActivity(getSettingsIntent()));
- mLauncher.getOnboardingPrefs().markChecked(OnboardingPrefs.HOTSEAT_LONGPRESS_TIP_SEEN);
+ LauncherPrefs.get(mLauncher).put(HOTSEAT_LONGPRESS_TIP_SEEN, true);
mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
return true;
}
diff --git a/quickstep/src/com/android/launcher3/secondarydisplay/SecondaryDisplayPredictionsImpl.java b/quickstep/src/com/android/launcher3/secondarydisplay/SecondaryDisplayPredictionsImpl.java
index b982688..8b71f01 100644
--- a/quickstep/src/com/android/launcher3/secondarydisplay/SecondaryDisplayPredictionsImpl.java
+++ b/quickstep/src/com/android/launcher3/secondarydisplay/SecondaryDisplayPredictionsImpl.java
@@ -22,7 +22,6 @@
import com.android.launcher3.appprediction.AppsDividerView;
import com.android.launcher3.appprediction.PredictionRowView;
import com.android.launcher3.model.BgDataModel;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.views.ActivityContext;
/**
@@ -30,22 +29,21 @@
*/
@SuppressWarnings("unused")
public final class SecondaryDisplayPredictionsImpl extends SecondaryDisplayPredictions {
+
private final ActivityContext mActivityContext;
+ private final Context mContext;
public SecondaryDisplayPredictionsImpl(Context context) {
+ mContext = context;
mActivityContext = ActivityContext.lookupContext(context);
}
@Override
void updateAppDivider() {
- OnboardingPrefs<?> onboardingPrefs = mActivityContext.getOnboardingPrefs();
- if (onboardingPrefs != null) {
- mActivityContext.getAppsView().getFloatingHeaderView()
- .findFixedRowByType(AppsDividerView.class)
- .setShowAllAppsLabel(
- !onboardingPrefs.hasReachedMaxCount(ALL_APPS_VISITED_COUNT));
- onboardingPrefs.incrementEventCount(ALL_APPS_VISITED_COUNT);
- }
+ mActivityContext.getAppsView().getFloatingHeaderView()
+ .findFixedRowByType(AppsDividerView.class)
+ .setShowAllAppsLabel(!ALL_APPS_VISITED_COUNT.hasReachedMax(mContext));
+ ALL_APPS_VISITED_COUNT.increment(mContext);
}
@Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java b/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java
index 331184a..c201236 100644
--- a/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java
@@ -20,8 +20,6 @@
import android.view.LayoutInflater;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
-import com.android.launcher3.LauncherPrefs;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
@@ -34,12 +32,10 @@
protected final LayoutInflater mLayoutInflater;
private final List<OnDeviceProfileChangeListener> mDPChangeListeners = new ArrayList<>();
- private final OnboardingPrefs<BaseTaskbarContext> mOnboardingPrefs;
public BaseTaskbarContext(Context windowContext) {
super(windowContext, Themes.getActivityThemeRes(windowContext));
mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);
- mOnboardingPrefs = new OnboardingPrefs<>(this, LauncherPrefs.getPrefs(this));
}
@Override
@@ -52,11 +48,6 @@
return mDPChangeListeners;
}
- @Override
- public OnboardingPrefs<BaseTaskbarContext> getOnboardingPrefs() {
- return mOnboardingPrefs;
- }
-
/** Callback invoked when a drag is initiated within this context. */
public abstract void onDragStart();
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index 1c7d7e0..a321734 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -288,8 +288,7 @@
// Persistent features EDU tooltip.
if (!DisplayController.isTransientTaskbar(mLauncher)) {
- return !mLauncher.getOnboardingPrefs().hasReachedMaxCount(
- OnboardingPrefs.TASKBAR_EDU_TOOLTIP_STEP);
+ return !OnboardingPrefs.TASKBAR_EDU_TOOLTIP_STEP.hasReachedMax(mLauncher);
}
// Transient swipe EDU tooltip.
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 4b16019..be4426d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -471,7 +471,7 @@
/**
* @return {@code true} if A11y is showing in 3 button nav taskbar
*/
- private boolean isContextualButtonShowing() {
+ private boolean isA11yButtonPersistent() {
return mContext.isThreeButtonNav() && (mState & FLAG_A11Y_VISIBLE) != 0;
}
@@ -742,7 +742,7 @@
mA11yButton, res, isInKidsMode, isInSetup, isThreeButtonNav,
TaskbarManager.isPhoneMode(dp),
mWindowManagerProxy.getRotation(mContext));
- navButtonLayoutter.layoutButtons(dp, isContextualButtonShowing());
+ navButtonLayoutter.layoutButtons(dp, isA11yButtonPersistent());
updateNavButtonColor();
return;
}
@@ -838,7 +838,7 @@
int contextualWidth = mEndContextualContainer.getWidth();
// If contextual buttons are showing, we check if the end margin is enough for the
// contextual button to be showing - if not, move the nav buttons over a smidge
- if (isContextualButtonShowing() && navMarginEnd < contextualWidth) {
+ if (isA11yButtonPersistent() && navMarginEnd < contextualWidth) {
// Additional spacing, eat up half of space between last icon and nav button
navMarginEnd += res.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing) / 2;
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
index de4175d..0ac2019 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
@@ -67,11 +67,10 @@
@TaskbarEduTooltipStep
var tooltipStep: Int
get() {
- return activityContext.onboardingPrefs?.getCount(TASKBAR_EDU_TOOLTIP_STEP)
- ?: TOOLTIP_STEP_NONE
+ return TASKBAR_EDU_TOOLTIP_STEP.get(activityContext)
}
private set(step) {
- activityContext.onboardingPrefs?.setEventCount(step, TASKBAR_EDU_TOOLTIP_STEP)
+ TASKBAR_EDU_TOOLTIP_STEP.set(step, activityContext)
}
private var tooltip: TaskbarEduTooltip? = null
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index 858141a..8a8c3bc 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -122,7 +122,9 @@
private AnimatorPlaybackController mIconAlignControllerLazy = null;
private Runnable mOnControllerPreCreateCallback = NO_OP;
+ // Stored here as signals to determine if the mIconAlignController needs to be recreated.
private boolean mIsHotseatIconOnTopWhenAligned;
+ private boolean mIsStashed;
private final DeviceProfile.OnDeviceProfileChangeListener mDeviceProfileChangeListener =
dp -> commitRunningAppsToUI();
@@ -435,10 +437,13 @@
public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) {
boolean isHotseatIconOnTopWhenAligned =
mControllers.uiController.isHotseatIconOnTopWhenAligned();
- // When mIsHotseatIconOnTopWhenAligned changes, animation needs to be re-created.
+ boolean isStashed = mControllers.taskbarStashController.isStashed();
+ // Re-create animation when mIsHotseatIconOnTopWhenAligned or mIsStashed changes.
if (mIconAlignControllerLazy == null
- || mIsHotseatIconOnTopWhenAligned != isHotseatIconOnTopWhenAligned) {
+ || mIsHotseatIconOnTopWhenAligned != isHotseatIconOnTopWhenAligned
+ || mIsStashed != isStashed) {
mIsHotseatIconOnTopWhenAligned = isHotseatIconOnTopWhenAligned;
+ mIsStashed = isStashed;
mIconAlignControllerLazy = createIconAlignmentController(launcherDp);
}
mIconAlignControllerLazy.setPlayFraction(alignmentRatio);
@@ -505,7 +510,7 @@
|| (isTaskbarDividerView && FeatureFlags.ENABLE_TASKBAR_PINNING.get())) {
if (!isToHome
&& mIsHotseatIconOnTopWhenAligned
- && mControllers.taskbarStashController.isStashed()) {
+ && mIsStashed) {
// Prevent All Apps icon from appearing when going from hotseat to nav handle.
setter.setViewAlpha(child, 0, Interpolators.clampToProgress(LINEAR, 0f, 0f));
} else {
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
index cf5fd59..b1c5151 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
@@ -83,9 +83,8 @@
private void setUpAppDivider() {
mAppsView.getFloatingHeaderView()
.findFixedRowByType(AppsDividerView.class)
- .setShowAllAppsLabel(!mContext.getOnboardingPrefs().hasReachedMaxCount(
- ALL_APPS_VISITED_COUNT));
- mContext.getOnboardingPrefs().incrementEventCount(ALL_APPS_VISITED_COUNT);
+ .setShowAllAppsLabel(!ALL_APPS_VISITED_COUNT.hasReachedMax(mContext));
+ ALL_APPS_VISITED_COUNT.increment(mContext);
}
private void setUpTaskbarStashing() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt
index 7529508..b516d6f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt
@@ -69,4 +69,18 @@
params.gravity = Gravity.CENTER
return params;
}
+
+ open fun repositionContextualContainer(contextualContainer: ViewGroup, barAxisMargin: Int,
+ gravity: Int) {
+ val contextualContainerParams = FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
+ contextualContainerParams.apply {
+ marginStart = barAxisMargin
+ marginEnd = barAxisMargin
+ topMargin = 0
+ bottomMargin = 0
+ }
+ contextualContainerParams.gravity = gravity or Gravity.CENTER_VERTICAL
+ contextualContainer.layoutParams = contextualContainerParams
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt
index e7847f3..3f51958 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt
@@ -25,6 +25,7 @@
import android.widget.ImageView
import android.widget.LinearLayout
import com.android.launcher3.DeviceProfile
+import com.android.launcher3.R
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
import com.android.systemui.shared.rotation.RotationButton
@@ -47,7 +48,7 @@
a11yButton
) {
- override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
+ override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) {
val iconSize: Int = resources.getDimensionPixelSize(DIMEN_TASKBAR_ICON_SIZE_KIDS)
val buttonWidth: Int = resources.getDimensionPixelSize(DIMEN_TASKBAR_NAV_BUTTONS_WIDTH_KIDS)
val buttonHeight: Int =
@@ -100,15 +101,10 @@
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
- val endContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
- endContextualContainerParams.gravity = Gravity.END or Gravity.CENTER_VERTICAL
- endContextualContainer.layoutParams = endContextualContainerParams
-
- val startContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
- startContextualContainerParams.gravity = Gravity.START or Gravity.CENTER_VERTICAL
- startContextualContainer.layoutParams = startContextualContainerParams
+ val contextualMargin = resources.getDimensionPixelSize(
+ R.dimen.taskbar_contextual_button_padding)
+ repositionContextualContainer(endContextualContainer, 0, Gravity.END)
+ repositionContextualContainer(startContextualContainer, contextualMargin, Gravity.START)
if (imeSwitcher != null) {
startContextualContainer.addView(imeSwitcher)
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt
index c502cdb..6b05e9a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt
@@ -162,6 +162,6 @@
/** Lays out and provides access to the home, recents, and back buttons for various mischief */
interface NavButtonLayoutter {
- fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean)
+ fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean)
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt
index d6ea7f0..5a7bc49 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt
@@ -43,7 +43,7 @@
a11yButton
) {
- override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
+ override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) {
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt
index 54edd21..382e298 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt
@@ -48,7 +48,7 @@
a11yButton
) {
- override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
+ override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) {
// TODO(b/230395757): Polish pending, this is just to make it usable
val endStartMargins = resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size)
val taskbarDimensions = DimensionUtils.getTaskbarPhoneDimensions(dp, resources,
@@ -104,10 +104,9 @@
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
- val startContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
- startContextualContainerParams.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
- startContextualContainer.layoutParams = startContextualContainerParams
+ val contextualMargin = resources.getDimensionPixelSize(
+ R.dimen.taskbar_contextual_button_padding)
+ repositionContextualContainer(startContextualContainer, contextualMargin, Gravity.TOP)
if (imeSwitcher != null) {
startContextualContainer.addView(imeSwitcher)
@@ -121,4 +120,18 @@
rotationButton.currentView.layoutParams = getParamsToCenterView()
}
}
+
+ override fun repositionContextualContainer(contextualContainer: ViewGroup, barAxisMargin: Int,
+ gravity: Int) {
+ val contextualContainerParams = FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
+ contextualContainerParams.apply {
+ marginStart = 0
+ marginEnd = 0
+ topMargin = barAxisMargin
+ bottomMargin = barAxisMargin
+ }
+ contextualContainerParams.gravity = gravity or Gravity.CENTER_HORIZONTAL
+ contextualContainer.layoutParams = contextualContainerParams
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt
index 34df282..e1ffa4d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt
@@ -47,7 +47,7 @@
a11yButton
) {
- override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
+ override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) {
// TODO(b/230395757): Polish pending, this is just to make it usable
val taskbarDimensions =
DimensionUtils.getTaskbarPhoneDimensions(dp, resources,
@@ -102,10 +102,9 @@
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
- val endContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
- endContextualContainerParams.gravity = Gravity.END or Gravity.CENTER_VERTICAL
- endContextualContainer.layoutParams = endContextualContainerParams
+ val contextualMargin = resources.getDimensionPixelSize(
+ R.dimen.taskbar_contextual_button_padding)
+ repositionContextualContainer(endContextualContainer, contextualMargin, Gravity.END)
if (imeSwitcher != null) {
endContextualContainer.addView(imeSwitcher)
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt
index cfe1276..0368b1d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt
@@ -19,9 +19,9 @@
import android.content.res.Resources
import android.view.Gravity
import android.view.ViewGroup
-import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
+import com.android.launcher3.R
import com.android.systemui.shared.rotation.RotationButton
class PhoneSeascapeNavLayoutter(
@@ -54,10 +54,9 @@
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
- val endContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
- endContextualContainerParams.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL
- endContextualContainer.layoutParams = endContextualContainerParams
+ val contextualMargin = resources.getDimensionPixelSize(
+ R.dimen.taskbar_contextual_button_padding)
+ repositionContextualContainer(endContextualContainer, contextualMargin, Gravity.BOTTOM)
if (imeSwitcher != null) {
endContextualContainer.addView(imeSwitcher)
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt
index 36f5150..abdd32c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt
@@ -23,6 +23,7 @@
import android.widget.ImageView
import android.widget.LinearLayout
import com.android.launcher3.DeviceProfile
+import com.android.launcher3.R
import com.android.systemui.shared.rotation.RotationButton
class SetupNavLayoutter(
@@ -44,7 +45,7 @@
a11yButton
) {
- override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
+ override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) {
// Since setup wizard only has back button enabled, it looks strange to be
// end-aligned, so start-align instead.
val navButtonsLayoutParams = navButtonContainer.layoutParams as FrameLayout.LayoutParams
@@ -58,15 +59,10 @@
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
- val endContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
- endContextualContainerParams.gravity = Gravity.END or Gravity.CENTER_VERTICAL
- endContextualContainer.layoutParams = endContextualContainerParams
-
- val startContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
- startContextualContainerParams.gravity = Gravity.START or Gravity.CENTER_VERTICAL
- startContextualContainer.layoutParams = startContextualContainerParams
+ val contextualMargin = resources.getDimensionPixelSize(
+ R.dimen.taskbar_contextual_button_padding)
+ repositionContextualContainer(endContextualContainer, 0, Gravity.END)
+ repositionContextualContainer(startContextualContainer, contextualMargin, Gravity.START)
if (imeSwitcher != null) {
startContextualContainer.addView(imeSwitcher)
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt
index 58dce69..f5a4c64 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt
@@ -27,8 +27,7 @@
import com.android.systemui.shared.rotation.RotationButton
/**
- * Layoutter for rendering task bar in large screen. {@param isContextualButtonShowing} is true in
- * 3-button mode.
+ * Layoutter for rendering task bar in large screen, both in 3-button and gesture nav mode.
*/
class TaskbarNavLayoutter(
resources: Resources,
@@ -49,13 +48,13 @@
a11yButton
) {
- override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
+ override fun layoutButtons(dp: DeviceProfile, isA11yButtonPersistent: Boolean) {
// Add spacing after the end of the last nav button
var navMarginEnd = resources.getDimension(dp.inv.inlineNavButtonsEndSpacing).toInt()
val contextualWidth = endContextualContainer.width
// If contextual buttons are showing, we check if the end margin is enough for the
// contextual button to be showing - if not, move the nav buttons over a smidge
- if (isContextualButtonShowing && navMarginEnd < contextualWidth) {
+ if (isA11yButtonPersistent && navMarginEnd < contextualWidth) {
// Additional spacing, eat up half of space between last icon and nav button
navMarginEnd += resources.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing) / 2
}
@@ -92,16 +91,11 @@
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
- if (isContextualButtonShowing) {
- val endContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
- endContextualContainerParams.gravity = Gravity.END or Gravity.CENTER_VERTICAL
- endContextualContainer.layoutParams = endContextualContainerParams
-
- val startContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
- startContextualContainerParams.gravity = Gravity.START or Gravity.CENTER_VERTICAL
- startContextualContainer.layoutParams = startContextualContainerParams
+ if (!dp.isGestureMode) {
+ val contextualMargin = resources.getDimensionPixelSize(
+ R.dimen.taskbar_contextual_button_padding)
+ repositionContextualContainer(endContextualContainer, 0, Gravity.END)
+ repositionContextualContainer(startContextualContainer, contextualMargin, Gravity.START)
if (imeSwitcher != null) {
startContextualContainer.addView(imeSwitcher)
diff --git a/quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java b/quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java
index 475f465..2d32407 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/ApiWrapper.java
@@ -22,11 +22,17 @@
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.content.pm.ShortcutInfo;
+import android.graphics.drawable.ColorDrawable;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.util.ArrayMap;
import android.window.RemoteTransition;
import com.android.launcher3.Utilities;
+import com.android.launcher3.util.UserIconInfo;
import com.android.quickstep.util.FadeOutRemoteTransition;
+import java.util.List;
import java.util.Map;
/**
@@ -53,4 +59,41 @@
options.setRemoteTransition(new RemoteTransition(new FadeOutRemoteTransition()));
return options;
}
+
+ /**
+ * Returns a map of all users on the device to their corresponding UI properties
+ */
+ public static Map<UserHandle, UserIconInfo> queryAllUsers(Context context) {
+ UserManager um = context.getSystemService(UserManager.class);
+ Map<UserHandle, UserIconInfo> users = new ArrayMap<>();
+ List<UserHandle> usersActual = um.getUserProfiles();
+ if (usersActual != null) {
+ for (UserHandle user : usersActual) {
+ long serial = um.getSerialNumberForUser(user);
+
+ // Simple check to check if the provided user is work profile
+ // TODO: Migrate to a better platform API
+ NoopDrawable d = new NoopDrawable();
+ boolean isWork = (d != context.getPackageManager().getUserBadgedIcon(d, user));
+ UserIconInfo info = new UserIconInfo(
+ user,
+ isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN,
+ serial);
+ users.put(user, info);
+ }
+ }
+ return users;
+ }
+
+ private static class NoopDrawable extends ColorDrawable {
+ @Override
+ public int getIntrinsicHeight() {
+ return 1;
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return 1;
+ }
+ }
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index a71333a..7d88f05 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -61,7 +61,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
-import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
@@ -344,11 +343,6 @@
}
@Override
- protected QuickstepOnboardingPrefs createOnboardingPrefs(SharedPreferences sharedPrefs) {
- return new QuickstepOnboardingPrefs(this, sharedPrefs);
- }
-
- @Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
onStateOrResumeChanging(false /* inTransition */);
@@ -619,6 +613,7 @@
mViewCapture = SettingsAwareViewCapture.getInstance(this).startCapture(getWindow());
}
getWindow().addPrivateFlags(PRIVATE_FLAG_OPTIMIZE_MEASURE);
+ QuickstepOnboardingPrefs.setup(this);
View.setTraceLayoutSteps(TRACE_LAYOUTS);
View.setTracedRequestLayoutClassClass(TRACE_RELAYOUT_CLASS);
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
index cb65c53..5253e7a 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsFragment.java
@@ -29,6 +29,12 @@
import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
import static com.android.launcher3.uioverrides.plugins.PluginManagerWrapper.PLUGIN_CHANGED;
import static com.android.launcher3.uioverrides.plugins.PluginManagerWrapper.pluginEnabledKey;
+import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
+import static com.android.launcher3.util.OnboardingPrefs.HOME_BOUNCE_COUNT;
+import static com.android.launcher3.util.OnboardingPrefs.HOME_BOUNCE_SEEN;
+import static com.android.launcher3.util.OnboardingPrefs.HOTSEAT_DISCOVERY_TIP_COUNT;
+import static com.android.launcher3.util.OnboardingPrefs.HOTSEAT_LONGPRESS_TIP_SEEN;
+import static com.android.launcher3.util.OnboardingPrefs.TASKBAR_EDU_TOOLTIP_STEP;
import android.annotation.TargetApi;
import android.content.ComponentName;
@@ -71,12 +77,10 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.secondarydisplay.SecondaryDisplayLauncher;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.SimpleBroadcastReceiver;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@@ -384,24 +388,33 @@
private void addOnboardingPrefsCatergory() {
PreferenceCategory onboardingCategory = newCategory("Onboarding Flows");
onboardingCategory.setSummary("Reset these if you want to see the education again.");
- for (Map.Entry<String, String[]> titleAndKeys : OnboardingPrefs.ALL_PREF_KEYS.entrySet()) {
- String title = titleAndKeys.getKey();
- String[] keys = titleAndKeys.getValue();
- Preference onboardingPref = new Preference(getContext());
- onboardingPref.setTitle(title);
- onboardingPref.setSummary("Tap to reset");
- onboardingPref.setOnPreferenceClickListener(preference -> {
- SharedPreferences.Editor sharedPrefsEdit = LauncherPrefs.getPrefs(getContext())
- .edit();
- for (String key : keys) {
- sharedPrefsEdit.remove(key);
- }
- sharedPrefsEdit.apply();
- Toast.makeText(getContext(), "Reset " + title, Toast.LENGTH_SHORT).show();
- return true;
- });
- onboardingCategory.addPreference(onboardingPref);
- }
+
+ onboardingCategory.addPreference(createOnboardPref("All Apps Bounce",
+ HOME_BOUNCE_SEEN.getSharedPrefKey(), HOME_BOUNCE_COUNT.getSharedPrefKey()));
+ onboardingCategory.addPreference(createOnboardPref("Hybrid Hotseat Education",
+ HOTSEAT_DISCOVERY_TIP_COUNT.getSharedPrefKey(),
+ HOTSEAT_LONGPRESS_TIP_SEEN.getSharedPrefKey()));
+ onboardingCategory.addPreference(createOnboardPref("Taskbar Education",
+ TASKBAR_EDU_TOOLTIP_STEP.getSharedPrefKey()));
+ onboardingCategory.addPreference(createOnboardPref("All Apps Visited Count",
+ ALL_APPS_VISITED_COUNT.getSharedPrefKey()));
+ }
+
+ private Preference createOnboardPref(String title, String... keys) {
+ Preference onboardingPref = new Preference(getContext());
+ onboardingPref.setTitle(title);
+ onboardingPref.setSummary("Tap to reset");
+ onboardingPref.setOnPreferenceClickListener(preference -> {
+ SharedPreferences.Editor sharedPrefsEdit = LauncherPrefs.getPrefs(getContext())
+ .edit();
+ for (String key : keys) {
+ sharedPrefsEdit.remove(key);
+ }
+ sharedPrefsEdit.apply();
+ Toast.makeText(getContext(), "Reset " + title, Toast.LENGTH_SHORT).show();
+ return true;
+ });
+ return onboardingPref;
}
private void addAllAppsFromOverviewCatergory() {
diff --git a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java
index 1f8ddf0..406e9f4 100644
--- a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java
+++ b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java
@@ -185,6 +185,13 @@
@Override
public void onBackProgressed(BackMotionEvent backMotionEvent) {
mHandler.post(() -> {
+ LauncherBackAnimationController controller = mControllerRef.get();
+ if (controller == null
+ || controller.mLauncher == null
+ || !controller.mLauncher.isStarted()) {
+ // Skip animating back progress if Launcher isn't visible yet.
+ return;
+ }
mProgressAnimator.onBackProgressed(backMotionEvent);
});
}
@@ -294,6 +301,10 @@
SurfaceControl parent = viewRootImpl != null
? viewRootImpl.getSurfaceControl()
: null;
+ if (parent == null || !parent.isValid()) {
+ // Parent surface is not ready at the moment. Retry later.
+ return;
+ }
boolean isDarkTheme = Utilities.isDarkTheme(mLauncher);
mScrimLayer = new SurfaceControl.Builder()
.setName("Back to launcher background scrim")
@@ -326,6 +337,10 @@
if (!mBackInProgress || mBackTarget == null) {
return;
}
+ if (mScrimLayer == null) {
+ // Scrim hasn't been attached yet. Let's attach it.
+ addScrimLayer();
+ }
float screenWidth = mStartRect.width();
float screenHeight = mStartRect.height();
float width = Utilities.mapRange(progress, 1, MIN_WINDOW_SCALE) * screenWidth;
@@ -446,6 +461,9 @@
mScrimAlphaAnimator.cancel();
mScrimAlphaAnimator = null;
}
+ if (mScrimLayer != null) {
+ removeScrimLayer();
+ }
}
private void startTransitionAnimations(RectFSpringAnim springAnim, AnimatorSet anim) {
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index 3c7fbf0..38e896e 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -37,7 +37,6 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Trace;
-import android.util.Log;
import android.view.Display;
import android.view.RemoteAnimationAdapter;
import android.view.RemoteAnimationTarget;
@@ -68,7 +67,6 @@
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.taskbar.FallbackTaskbarUIController;
import com.android.launcher3.taskbar.TaskbarManager;
-import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.ActivityTracker;
import com.android.launcher3.util.RunnableList;
@@ -418,7 +416,6 @@
}
public void startHome() {
- Log.d(TestProtocol.INCORRECT_HOME_STATE, "start home from recents activity");
RecentsView recentsView = getOverviewPanel();
recentsView.switchToScreenshot(() -> recentsView.finishRecentsAnimation(true,
this::startHomeInternal));
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index 4b47209..0bc44e1 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -21,6 +21,7 @@
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.NavigationMode.NO_BUTTON;
import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS;
+import static com.android.quickstep.GestureState.STATE_END_TARGET_ANIMATION_FINISHED;
import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_INITIALIZED;
import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_STARTED;
import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.START_RECENTS_ANIMATION;
@@ -38,9 +39,7 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
-import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.util.DisplayController;
-import com.android.quickstep.TopTaskTracker.CachedTaskInfo;
import com.android.quickstep.util.ActiveGestureLog;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -154,6 +153,24 @@
mLastAppearedTaskTargets[i] = task;
}
mLastGestureState.updateLastAppearedTaskTargets(mLastAppearedTaskTargets);
+
+ if (ENABLE_SHELL_TRANSITIONS && mTargets.hasRecents
+ // The filtered (MODE_CLOSING) targets only contain 1 home activity.
+ && mTargets.apps.length == 1
+ && mTargets.apps[0].windowConfiguration.getActivityType()
+ == ACTIVITY_TYPE_HOME) {
+ // This is launching RecentsActivity on top of a 3p launcher. There are no
+ // other apps need to keep visible so finish the animating state after the
+ // enter animation of overview is done. Then 3p launcher can be stopped.
+ mLastGestureState.runOnceAtState(STATE_END_TARGET_ANIMATION_FINISHED, () -> {
+ // Only finish if the end target is RECENTS. Otherwise, if the target is
+ // NEW_TASK, startActivityFromRecents will be skipped.
+ if (mLastGestureState.getEndTarget() == RECENTS) {
+ finishRunningRecentsAnimation(false /* toHome */,
+ true /* forceFinish */, null /* forceFinishCb */);
+ }
+ });
+ }
}
@Override
@@ -181,9 +198,6 @@
RecentsView recentsView =
activityInterface.getCreatedActivity().getOverviewPanel();
if (recentsView != null) {
- Log.d(TestProtocol.INCORRECT_HOME_STATE,
- "finish recents animation on "
- + compat.taskInfo.description);
recentsView.finishRecentsAnimation(true, null);
}
return;
@@ -256,15 +270,8 @@
if (ENABLE_SHELL_TRANSITIONS) {
final ActivityOptions options = ActivityOptions.makeBasic();
- // Allowing to pause Home if Home is top activity and Recents is not Home. So when user
- // start home when recents animation is playing, the home activity can be resumed again
- // to let the transition controller collect Home activity.
- CachedTaskInfo cti = gestureState.getRunningTask();
- boolean homeIsOnTop = cti != null && cti.isHomeTask();
- if (activityInterface.allowAllAppsFromOverview()) {
- homeIsOnTop = true;
- }
- if (!homeIsOnTop) {
+ // Use regular (non-transient) launch for all apps page to control IME.
+ if (!activityInterface.allowAllAppsFromOverview()) {
options.setTransientLaunch();
}
options.setSourceInfo(ActivityOptions.SourceInfo.TYPE_RECENTS_ANIMATION, eventTime);
diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
index b3b7be4..e8adcab 100644
--- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
@@ -315,7 +315,7 @@
TaskIdAttributeContainer taskContainer) {
final TaskView taskView = taskContainer.getTaskView();
- if (!FeatureFlags.ENABLE_APP_PAIRS.get() || !taskView.containsMultipleTasks()) {
+ if (!FeatureFlags.enableAppPairs() || !taskView.containsMultipleTasks()) {
return null;
}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index f840707..b2f04b8 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -24,10 +24,12 @@
import static android.view.MotionEvent.ACTION_UP;
import static com.android.launcher3.Launcher.INTENT_ACTION_ALL_APPS_TOGGLE;
+import static com.android.launcher3.LauncherPrefs.backedUpItem;
import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent;
import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TRACKPAD_GESTURE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
+import static com.android.launcher3.util.OnboardingPrefs.HOME_BOUNCE_SEEN;
import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH;
import static com.android.quickstep.GestureState.DEFAULT_STATE;
import static com.android.quickstep.GestureState.TrackpadGestureType.getTrackpadGestureType;
@@ -60,7 +62,6 @@
import android.content.IIntentReceiver;
import android.content.IIntentSender;
import android.content.Intent;
-import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Region;
import android.graphics.drawable.Icon;
@@ -84,7 +85,9 @@
import androidx.annotation.UiThread;
import com.android.launcher3.BaseDraggingActivity;
+import com.android.launcher3.ConstantItem;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.EncryptionType;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatedFloat;
@@ -100,7 +103,6 @@
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.LockedUserState;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.ScreenOnTracker;
import com.android.launcher3.util.TraceHelper;
@@ -158,7 +160,8 @@
private static final String TAG = "TouchInteractionService";
- private static final String HAS_ENABLED_QUICKSTEP_ONCE = "launcher.has_enabled_quickstep_once";
+ private static final ConstantItem<Boolean> HAS_ENABLED_QUICKSTEP_ONCE = backedUpItem(
+ "launcher.has_enabled_quickstep_once", false, EncryptionType.ENCRYPTED);
private final TISBinder mTISBinder = new TISBinder(this);
@@ -569,12 +572,11 @@
}
// Reset home bounce seen on quick step enabled for first time
- SharedPreferences sharedPrefs = LauncherPrefs.getPrefs(this);
- if (!sharedPrefs.getBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)) {
- sharedPrefs.edit()
- .putBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)
- .putBoolean(OnboardingPrefs.HOME_BOUNCE_SEEN, false)
- .apply();
+ LauncherPrefs prefs = LauncherPrefs.get(this);
+ if (!prefs.get(HAS_ENABLED_QUICKSTEP_ONCE)) {
+ prefs.put(
+ HAS_ENABLED_QUICKSTEP_ONCE.to(true),
+ HOME_BOUNCE_SEEN.to(false));
}
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
index f9f1579..1af4bad 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
@@ -20,8 +20,6 @@
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import android.content.Context;
-import android.view.GestureDetector;
-import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
@@ -37,51 +35,36 @@
*/
public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
- private final GestureDetector mLongPressDetector;
private final NavHandleLongPressHandler mNavHandleLongPressHandler;
private final float mNavHandleWidth;
private final float mScreenWidth;
+ private final ViewConfiguration mViewConfiguration;
- // Below are only used if CUSTOM_LPNH_THRESHOLDS is enabled.
- private final float mCustomTouchSlopSquared;
- private final int mCustomLongPressTimeout;
- private final Runnable mTriggerCustomLongPress = this::triggerCustomLongPress;
- private MotionEvent mCurrentCustomDownEvent;
+ private final Runnable mTriggerLongPress = this::triggerLongPress;
+ private final float mTouchSlopSquared;
+ private final int mLongPressTimeout;
+
+ private MotionEvent mCurrentDownEvent;
public NavHandleLongPressInputConsumer(Context context, InputConsumer delegate,
InputMonitorCompat inputMonitor) {
super(delegate, inputMonitor);
+ mViewConfiguration = ViewConfiguration.get(context);
mNavHandleWidth = context.getResources().getDimensionPixelSize(
R.dimen.navigation_home_handle_width);
mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x;
- float customSlopMultiplier =
- LauncherPrefs.get(context).get(LONG_PRESS_NAV_HANDLE_SLOP_PERCENTAGE) / 100f;
- float customTouchSlop =
- ViewConfiguration.get(context).getScaledEdgeSlop() * customSlopMultiplier;
- mCustomTouchSlopSquared = customTouchSlop * customTouchSlop;
- mCustomLongPressTimeout = LauncherPrefs.get(context).get(LONG_PRESS_NAV_HANDLE_TIMEOUT_MS);
-
+ float touchSlop;
+ if (FeatureFlags.CUSTOM_LPNH_THRESHOLDS.get()) {
+ float customSlopMultiplier =
+ LauncherPrefs.get(context).get(LONG_PRESS_NAV_HANDLE_SLOP_PERCENTAGE) / 100f;
+ touchSlop = mViewConfiguration.getScaledEdgeSlop() * customSlopMultiplier;
+ mLongPressTimeout = LauncherPrefs.get(context).get(LONG_PRESS_NAV_HANDLE_TIMEOUT_MS);
+ } else {
+ touchSlop = mViewConfiguration.getScaledTouchSlop();
+ mLongPressTimeout = ViewConfiguration.getLongPressTimeout();
+ }
+ mTouchSlopSquared = touchSlop * touchSlop;
mNavHandleLongPressHandler = NavHandleLongPressHandler.newInstance(context);
-
- mLongPressDetector = new GestureDetector(context, new SimpleOnGestureListener() {
- @Override
- public void onLongPress(MotionEvent motionEvent) {
- if (isInNavBarHorizontalArea(motionEvent.getRawX())) {
- Runnable longPressRunnable = mNavHandleLongPressHandler.getLongPressRunnable();
- if (longPressRunnable != null) {
- OtherActivityInputConsumer oaic = getInputConsumerOfClass(
- OtherActivityInputConsumer.class);
- if (oaic != null) {
- oaic.setForceFinishRecentsTransitionCallback(longPressRunnable);
- setActive(motionEvent);
- } else {
- setActive(motionEvent);
- MAIN_EXECUTOR.post(longPressRunnable);
- }
- }
- }
- }
- });
}
@Override
@@ -91,30 +74,41 @@
@Override
public void onMotionEvent(MotionEvent ev) {
- if (!FeatureFlags.CUSTOM_LPNH_THRESHOLDS.get()) {
- mLongPressDetector.onTouchEvent(ev);
- } else {
- switch (ev.getAction()) {
- case MotionEvent.ACTION_DOWN -> {
- if (mCurrentCustomDownEvent != null) {
- mCurrentCustomDownEvent.recycle();
- }
- mCurrentCustomDownEvent = MotionEvent.obtain(ev);
- if (isInNavBarHorizontalArea(ev.getRawX())) {
- MAIN_EXECUTOR.getHandler().postDelayed(mTriggerCustomLongPress,
- mCustomLongPressTimeout);
- }
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN -> {
+ if (mCurrentDownEvent != null) {
+ mCurrentDownEvent.recycle();
}
- case MotionEvent.ACTION_MOVE -> {
- double touchDeltaSquared =
- Math.pow(ev.getX() - mCurrentCustomDownEvent.getX(), 2)
- + Math.pow(ev.getY() - mCurrentCustomDownEvent.getY(), 2);
- if (touchDeltaSquared > mCustomTouchSlopSquared) {
- cancelCustomLongPress();
- }
+ mCurrentDownEvent = MotionEvent.obtain(ev);
+ if (isInNavBarHorizontalArea(ev.getRawX())) {
+ MAIN_EXECUTOR.getHandler().postDelayed(mTriggerLongPress,
+ mLongPressTimeout);
}
- case MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> cancelCustomLongPress();
}
+ case MotionEvent.ACTION_MOVE -> {
+ float touchSlopSquared = mTouchSlopSquared;
+ float dx = ev.getX() - mCurrentDownEvent.getX();
+ float dy = ev.getY() - mCurrentDownEvent.getY();
+ double distanceSquared = (dx * dx) + (dy * dy);
+ // If the gesture is ambiguous then require more movement before classifying this
+ // as a NON long press gesture.
+ if (ev.getClassification() == MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE) {
+ float ambiguousGestureMultiplier =
+ mViewConfiguration.getScaledAmbiguousGestureMultiplier();
+ touchSlopSquared *= ambiguousGestureMultiplier * ambiguousGestureMultiplier;
+ }
+ if (distanceSquared > touchSlopSquared) {
+ cancelLongPress();
+ }
+ }
+ case MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> cancelLongPress();
+ }
+
+ // If the gesture is deep press then trigger long press asap
+ if (MAIN_EXECUTOR.getHandler().hasCallbacks(mTriggerLongPress)
+ && ev.getClassification() == MotionEvent.CLASSIFICATION_DEEP_PRESS) {
+ MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerLongPress);
+ MAIN_EXECUTOR.getHandler().post(mTriggerLongPress);
}
if (mState != STATE_ACTIVE) {
@@ -122,17 +116,23 @@
}
}
- private void triggerCustomLongPress() {
+ private void triggerLongPress() {
Runnable longPressRunnable = mNavHandleLongPressHandler.getLongPressRunnable();
if (longPressRunnable != null) {
- setActive(mCurrentCustomDownEvent);
-
- MAIN_EXECUTOR.post(longPressRunnable);
+ OtherActivityInputConsumer oaic = getInputConsumerOfClass(
+ OtherActivityInputConsumer.class);
+ if (oaic != null) {
+ oaic.setForceFinishRecentsTransitionCallback(longPressRunnable);
+ setActive(mCurrentDownEvent);
+ } else {
+ setActive(mCurrentDownEvent);
+ MAIN_EXECUTOR.post(longPressRunnable);
+ }
}
}
- private void cancelCustomLongPress() {
- MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerCustomLongPress);
+ private void cancelLongPress() {
+ MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerLongPress);
}
private boolean isInNavBarHorizontalArea(float x) {
diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
index b1daac4..71673f3 100644
--- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
+++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
@@ -224,6 +224,7 @@
private LauncherAtom.Slice mSlice;
private Optional<Integer> mCardinality = Optional.empty();
private int mInputType = SysUiStatsLog.LAUNCHER_UICHANGED__INPUT_TYPE__UNKNOWN;
+ private Optional<Integer> mFeatures = Optional.empty();
StatsCompatLogger(Context context, ActivityContext activityContext) {
mContext = context;
@@ -323,6 +324,12 @@
}
@Override
+ public StatsLogger withFeatures(int feature) {
+ this.mFeatures = Optional.of(feature);
+ return this;
+ }
+
+ @Override
public void log(EventEnum event) {
if (!Utilities.ATLEAST_R) {
return;
@@ -451,6 +458,7 @@
return;
}
int cardinality = mCardinality.orElseGet(() -> getCardinality(atomInfo));
+ int features = mFeatures.orElseGet(() -> getFeatures(atomInfo));
SysUiStatsLog.write(
SysUiStatsLog.LAUNCHER_EVENT,
SysUiStatsLog.LAUNCHER_UICHANGED__ACTION__DEFAULT_ACTION /* deprecated */,
@@ -477,7 +485,7 @@
atomInfo.getFolderIcon().getToLabelState().getNumber() /* toState */,
atomInfo.getFolderIcon().getLabelInfo() /* edittext */,
cardinality /* cardinality */,
- getFeatures(atomInfo) /* features */,
+ features /* features */,
getSearchAttributes(atomInfo) /* searchAttributes */,
getAttributes(atomInfo) /* attributes */,
inputType /* input_type */
diff --git a/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java b/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java
index ca686ec..80dd373 100644
--- a/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java
+++ b/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java
@@ -31,7 +31,7 @@
*/
public class ActiveGestureLog {
- private static final int MAX_GESTURES_TRACKED = 10;
+ private static final int MAX_GESTURES_TRACKED = 15;
public static final ActiveGestureLog INSTANCE = new ActiveGestureLog();
diff --git a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
index ef7d7a9..9df568e 100644
--- a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
+++ b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
@@ -22,9 +22,12 @@
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.util.NavigationMode.NO_BUTTON;
+import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
+import static com.android.launcher3.util.OnboardingPrefs.HOME_BOUNCE_COUNT;
+import static com.android.launcher3.util.OnboardingPrefs.HOME_BOUNCE_SEEN;
+import static com.android.launcher3.util.OnboardingPrefs.HOTSEAT_DISCOVERY_TIP_COUNT;
-import android.content.SharedPreferences;
-
+import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
@@ -34,30 +37,30 @@
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.quickstep.views.AllAppsEduView;
/**
- * Extends {@link OnboardingPrefs} for quickstep-specific onboarding data.
+ * Class to setup onboarding behavior for quickstep launcher
*/
-public class QuickstepOnboardingPrefs extends OnboardingPrefs<QuickstepLauncher> {
+public class QuickstepOnboardingPrefs {
- public QuickstepOnboardingPrefs(QuickstepLauncher launcher, SharedPreferences sharedPrefs) {
- super(launcher, sharedPrefs);
-
+ /**
+ * Sets up the initial onboarding behavior for the launcher
+ */
+ public static void setup(QuickstepLauncher launcher) {
StateManager<LauncherState> stateManager = launcher.getStateManager();
- if (!getBoolean(HOME_BOUNCE_SEEN)) {
+ if (!HOME_BOUNCE_SEEN.get(launcher)) {
stateManager.addStateListener(new StateListener<LauncherState>() {
@Override
public void onStateTransitionComplete(LauncherState finalState) {
boolean swipeUpEnabled =
- DisplayController.getNavigationMode(mLauncher).hasGestures;
+ DisplayController.getNavigationMode(launcher).hasGestures;
LauncherState prevState = stateManager.getLastState();
if (((swipeUpEnabled && finalState == OVERVIEW) || (!swipeUpEnabled
&& finalState == ALL_APPS && prevState == NORMAL) ||
- hasReachedMaxCount(HOME_BOUNCE_COUNT))) {
- mSharedPrefs.edit().putBoolean(HOME_BOUNCE_SEEN, true).apply();
+ HOME_BOUNCE_COUNT.hasReachedMax(launcher))) {
+ LauncherPrefs.get(launcher).put(HOME_BOUNCE_SEEN, true);
stateManager.removeStateListener(this);
}
}
@@ -65,21 +68,21 @@
}
if (!Utilities.isRunningInTestHarness()
- && !hasReachedMaxCount(HOTSEAT_DISCOVERY_TIP_COUNT)) {
+ && !HOTSEAT_DISCOVERY_TIP_COUNT.hasReachedMax(launcher)) {
stateManager.addStateListener(new StateListener<LauncherState>() {
boolean mFromAllApps = false;
@Override
public void onStateTransitionStart(LauncherState toState) {
- mFromAllApps = mLauncher.getStateManager().getCurrentStableState() == ALL_APPS;
+ mFromAllApps = launcher.getStateManager().getCurrentStableState() == ALL_APPS;
}
@Override
public void onStateTransitionComplete(LauncherState finalState) {
- HotseatPredictionController client = mLauncher.getHotseatPredictionController();
+ HotseatPredictionController client = launcher.getHotseatPredictionController();
if (mFromAllApps && finalState == NORMAL && client.hasPredictions()) {
- if (!mLauncher.getDeviceProfile().isTablet
- && incrementEventCount(HOTSEAT_DISCOVERY_TIP_COUNT)) {
+ if (!launcher.getDeviceProfile().isTablet
+ && HOTSEAT_DISCOVERY_TIP_COUNT.increment(launcher)) {
client.showEdu();
stateManager.removeStateListener(this);
}
@@ -109,7 +112,7 @@
public void onStateTransitionComplete(LauncherState finalState) {
if (finalState == NORMAL) {
if (mCount >= MAX_NUM_SWIPES_TO_TRIGGER_EDU) {
- if (getOpenView(mLauncher, TYPE_ALL_APPS_EDU) == null) {
+ if (getOpenView(launcher, TYPE_ALL_APPS_EDU) == null) {
AllAppsEduView.show(launcher);
}
mCount = 0;
@@ -124,7 +127,7 @@
}
if (finalState == ALL_APPS) {
- AllAppsEduView view = getOpenView(mLauncher, TYPE_ALL_APPS_EDU);
+ AllAppsEduView view = getOpenView(launcher, TYPE_ALL_APPS_EDU);
if (view != null) {
view.close(false);
}
@@ -133,20 +136,20 @@
});
}
- if (!hasReachedMaxCount(ALL_APPS_VISITED_COUNT)) {
- mLauncher.getStateManager().addStateListener(new StateListener<LauncherState>() {
+ if (!ALL_APPS_VISITED_COUNT.hasReachedMax(launcher)) {
+ launcher.getStateManager().addStateListener(new StateListener<LauncherState>() {
@Override
public void onStateTransitionComplete(LauncherState finalState) {
if (finalState == ALL_APPS) {
- incrementEventCount(ALL_APPS_VISITED_COUNT);
+ ALL_APPS_VISITED_COUNT.increment(launcher);
return;
}
- boolean hasReachedMaxCount = hasReachedMaxCount(ALL_APPS_VISITED_COUNT);
- mLauncher.getAppsView().getFloatingHeaderView().findFixedRowByType(
+ boolean hasReachedMaxCount = ALL_APPS_VISITED_COUNT.hasReachedMax(launcher);
+ launcher.getAppsView().getFloatingHeaderView().findFixedRowByType(
AppsDividerView.class).setShowAllAppsLabel(!hasReachedMaxCount);
if (hasReachedMaxCount) {
- mLauncher.getStateManager().removeStateListener(this);
+ launcher.getStateManager().removeStateListener(this);
}
}
});
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
index efe0540..8e3b5ec 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
@@ -17,7 +17,6 @@
package com.android.quickstep.util;
import static com.android.launcher3.Utilities.postAsyncCallback;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_DESKTOP_TO_WORKSPACE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DESKTOP_MODE_SPLIT_LEFT_TOP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DESKTOP_MODE_SPLIT_RIGHT_BOTTOM;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -92,6 +91,7 @@
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskAnimationManager;
import com.android.quickstep.TaskViewUtils;
+import com.android.quickstep.views.DesktopTaskView;
import com.android.quickstep.views.FloatingTaskView;
import com.android.quickstep.views.GroupedTaskView;
import com.android.quickstep.views.RecentsView;
@@ -815,7 +815,7 @@
@Override
public boolean onRequestSplitSelect(ActivityManager.RunningTaskInfo taskInfo,
int splitPosition, Rect taskBounds) {
- if (!ENABLE_SPLIT_FROM_DESKTOP_TO_WORKSPACE.get()) return false;
+ if (!DesktopTaskView.DESKTOP_MODE_SUPPORTED) return false;
MAIN_EXECUTOR.execute(() -> enterSplitSelect(taskInfo, splitPosition,
taskBounds));
return true;
diff --git a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java
index 0fa8a29..00b5621 100644
--- a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java
@@ -16,7 +16,6 @@
package com.android.quickstep.util;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_DESKTOP_TO_WORKSPACE;
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_FULLSCREEN_WITH_KEYBOARD_SHORTCUTS;
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
@@ -45,6 +44,7 @@
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.model.data.PackageItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
+import com.android.quickstep.views.DesktopTaskView;
import com.android.quickstep.views.FloatingTaskView;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
@@ -193,7 +193,7 @@
private boolean shouldIgnoreSecondSplitLaunch() {
return (!ENABLE_SPLIT_FROM_FULLSCREEN_WITH_KEYBOARD_SHORTCUTS.get()
&& !ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE.get()
- && !ENABLE_SPLIT_FROM_DESKTOP_TO_WORKSPACE.get())
+ && !DesktopTaskView.DESKTOP_MODE_SUPPORTED)
|| !mController.isSplitSelectActive();
}
}
diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
index 74c7780..a4a53d1 100644
--- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
+++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java
@@ -169,7 +169,9 @@
mIconLoadRequest2 = iconCache.updateIconInBackground(mSecondaryTask,
(task) -> {
setIcon(mIconView2, task.icon);
- setText(mIconView2, TaskUtils.getTitle(getContext(), task));
+ if (enableOverviewIconMenu()) {
+ setText(mIconView2, TaskUtils.getTitle(getContext(), task));
+ }
mDigitalWellBeingToast2.initialize(mSecondaryTask);
mDigitalWellBeingToast2.setSplitConfiguration(mSplitBoundsConfig);
mDigitalWellBeingToast.setSplitConfiguration(mSplitBoundsConfig);
@@ -184,7 +186,9 @@
}
if (needsUpdate(changes, FLAG_UPDATE_ICON)) {
setIcon(mIconView2, null);
- setText(mIconView2, null);
+ if (enableOverviewIconMenu()) {
+ setText(mIconView2, null);
+ }
}
}
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index ef908c5..0a195c3 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -5270,8 +5270,6 @@
cleanupRemoteTargets();
if (mRecentsAnimationController == null) {
- Log.d(TestProtocol.INCORRECT_HOME_STATE, "finish recents animation but recents "
- + "animation controller was null. returning.");
if (onFinishComplete != null) {
onFinishComplete.run();
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index da9ddeb..92b942d 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -1020,6 +1020,17 @@
mActivity.getStateManager(), recentsView,
recentsView.getDepthController());
anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ if (!recentsView.showAsGrid()) {
+ return;
+ }
+ recentsView.runActionOnRemoteHandles(
+ (Consumer<RemoteTargetHandle>) remoteTargetHandle ->
+ remoteTargetHandle
+ .getTaskViewSimulator()
+ .setDrawsBelowRecents(false));
+ }
@Override
public void onAnimationEnd(Animator animator) {
@@ -1081,7 +1092,9 @@
mIconLoadRequest = iconCache.updateIconInBackground(mTask,
(task) -> {
setIcon(mIconView, task.icon);
- setText(mIconView, TaskUtils.getTitle(getContext(), task));
+ if (enableOverviewIconMenu()) {
+ setText(mIconView, TaskUtils.getTitle(getContext(), task));
+ }
mDigitalWellBeingToast.initialize(task);
});
}
@@ -1097,7 +1110,9 @@
}
if (needsUpdate(changes, FLAG_UPDATE_ICON)) {
setIcon(mIconView, null);
- setText(mIconView, null);
+ if (enableOverviewIconMenu()) {
+ setText(mIconView, null);
+ }
}
}
}
diff --git a/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
index efc00bb..ba9ae67 100644
--- a/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
@@ -37,7 +37,6 @@
public class AbstractTaplTestsTaskbar extends AbstractQuickStepTest {
- protected static final String TEST_APP_NAME = "LauncherTestApp";
protected static final String TEST_APP_PACKAGE =
getInstrumentation().getContext().getPackageName();
protected static final String CALCULATOR_APP_PACKAGE =
diff --git a/quickstep/tests/src/com/android/quickstep/RecentsModelTest.java b/quickstep/tests/src/com/android/quickstep/RecentsModelTest.java
index c552d83..648fa93 100644
--- a/quickstep/tests/src/com/android/quickstep/RecentsModelTest.java
+++ b/quickstep/tests/src/com/android/quickstep/RecentsModelTest.java
@@ -101,11 +101,6 @@
when(mContext.getResources()).thenReturn(mResource);
}
- @After
- public void tearDown() throws Exception {
- mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW);
- }
-
@Test
@UiThreadTest
public void preloadOnHighResolutionEnabled() {
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index d9c1118..61f1f74 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -62,7 +62,6 @@
@RunWith(AndroidJUnit4.class)
public class TaplTestsQuickstep extends AbstractQuickStepTest {
- private static final String APP_NAME = "LauncherTestApp";
private static final String CALCULATOR_APP_PACKAGE =
resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);
private static final String READ_DEVICE_CONFIG_PERMISSION =
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java b/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java
index cc56faf..acbb58f 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java
@@ -29,11 +29,11 @@
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.rule.TestStabilityRule;
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
+import com.android.wm.shell.Flags;
import org.junit.After;
import org.junit.Before;
@@ -111,7 +111,7 @@
@Ignore("Enable once App Pairs flagged on. These cause memory leaks b/297135374")
public void testSaveAppPairMenuItemExistsOnSplitPair() throws Exception {
assumeTrue("App pairs feature is currently not enabled, no test needed",
- FeatureFlags.ENABLE_APP_PAIRS.get());
+ Flags.enableAppPairs());
createAndLaunchASplitPair();
@@ -127,7 +127,7 @@
@Ignore("Enable once App Pairs flagged on. These cause memory leaks b/297135374")
public void testSaveAppPairMenuItemDoesNotExistOnSingleTask() throws Exception {
assumeTrue("App pairs feature is currently not enabled, no test needed",
- FeatureFlags.ENABLE_APP_PAIRS.get());
+ Flags.enableAppPairs());
startAppFast(CALCULATOR_APP_PACKAGE);
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
index 093c45d..0e382a4 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
@@ -15,6 +15,7 @@
*/
package com.android.quickstep;
+import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.android.quickstep.TaplTestsTaskbar.TaskbarMode.PERSISTENT;
import static com.android.quickstep.TaplTestsTaskbar.TaskbarMode.TRANSIENT;
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java
index b3cec4e..fc23a05 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java
@@ -16,6 +16,7 @@
package com.android.quickstep;
import static com.android.launcher3.config.FeatureFlags.ENABLE_CURSOR_HOVER_STATES;
+import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
import androidx.test.filters.LargeTest;
diff --git a/res/drawable/encrypted_24px.xml b/res/drawable/encrypted_24px.xml
new file mode 100644
index 0000000..cf4d2df
--- /dev/null
+++ b/res/drawable/encrypted_24px.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="960"
+ android:viewportHeight="960"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M420,600L540,600L517,471Q537,461 548.5,442Q560,423 560,400Q560,367 536.5,343.5Q513,320 480,320Q447,320 423.5,343.5Q400,367 400,400Q400,423 411.5,442Q423,461 443,471L420,600ZM480,880Q341,845 250.5,720.5Q160,596 160,444L160,200L480,80L800,200L800,444Q800,596 709.5,720.5Q619,845 480,880ZM480,796Q584,763 652,664Q720,565 720,444L720,255L480,165L240,255L240,444Q240,565 308,664Q376,763 480,796ZM480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480Z"/>
+</vector>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 57163ff..4e865d0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -453,4 +453,7 @@
<string name="search_pref_screen_title_tablet">Search your tablet</string>
<!-- Failed action error message: e.g. Failed: Pause -->
<string name="remote_action_failed">Failed: <xliff:g id="what" example="Pause">%1$s</xliff:g></string>
+
+ <!-- Private space label -->
+ <string name="private_space_label">Private space</string>
</resources>
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 08e5def..91fbe53 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -117,6 +117,8 @@
// return an (x, y) value from helper functions. Do NOT use them to maintain other state.
@Thunk final int[] mTmpPoint = new int[2];
@Thunk final int[] mTempLocation = new int[2];
+
+ @Thunk final Rect mTempOnDrawCellToRect = new Rect();
final PointF mTmpPointF = new PointF();
protected GridOccupancy mOccupied;
@@ -600,23 +602,18 @@
DeviceProfile dp = mActivity.getDeviceProfile();
int paddingX = Math.min((mCellWidth - dp.iconSizePx) / 2, dp.gridVisualizationPaddingX);
int paddingY = Math.min((mCellHeight - dp.iconSizePx) / 2, dp.gridVisualizationPaddingY);
- mVisualizeGridRect.set(paddingX, paddingY,
- mCellWidth - paddingX,
- mCellHeight - paddingY);
mVisualizeGridPaint.setStrokeWidth(8);
- int paintAlpha = (int) (120 * mGridAlpha);
- mVisualizeGridPaint.setColor(ColorUtils.setAlphaComponent(mGridColor, paintAlpha));
+ // This is used for debugging purposes only
if (mVisualizeCells) {
+ int paintAlpha = (int) (120 * mGridAlpha);
+ mVisualizeGridPaint.setColor(ColorUtils.setAlphaComponent(mGridColor, paintAlpha));
for (int i = 0; i < mCountX; i++) {
for (int j = 0; j < mCountY; j++) {
- int transX = i * mCellWidth + (i * mBorderSpace.x) + getPaddingLeft()
- + paddingX;
- int transY = j * mCellHeight + (j * mBorderSpace.y) + getPaddingTop()
- + paddingY;
-
- mVisualizeGridRect.offsetTo(transX, transY);
+ cellToRect(i, j, 1, 1, mTempOnDrawCellToRect);
+ mVisualizeGridRect.set(mTempOnDrawCellToRect);
+ mVisualizeGridRect.inset(paddingX, paddingY);
mVisualizeGridPaint.setStyle(Paint.Style.FILL);
canvas.drawRoundRect(mVisualizeGridRect, mGridVisualizationRoundingRadius,
mGridVisualizationRoundingRadius, mVisualizeGridPaint);
@@ -628,25 +625,13 @@
for (int i = 0; i < mDragOutlines.length; i++) {
final float alpha = mDragOutlineAlphas[i];
if (alpha <= 0) continue;
+ CellLayoutLayoutParams params = mDragOutlines[i];
+ cellToRect(params.getCellX(), params.getCellY(), params.cellHSpan, params.cellVSpan,
+ mTempOnDrawCellToRect);
+ mVisualizeGridRect.set(mTempOnDrawCellToRect);
+ mVisualizeGridRect.inset(paddingX, paddingY);
mVisualizeGridPaint.setAlpha(255);
- int x = mDragOutlines[i].getCellX();
- int y = mDragOutlines[i].getCellY();
- int spanX = mDragOutlines[i].cellHSpan;
- int spanY = mDragOutlines[i].cellVSpan;
-
- // TODO b/194414754 clean this up, reconcile with cellToRect
- mVisualizeGridRect.set(paddingX, paddingY,
- mCellWidth * spanX + mBorderSpace.x * (spanX - 1) - paddingX,
- mCellHeight * spanY + mBorderSpace.y * (spanY - 1) - paddingY);
-
- int transX = x * mCellWidth + (x * mBorderSpace.x)
- + getPaddingLeft() + paddingX;
- int transY = y * mCellHeight + (y * mBorderSpace.y)
- + getPaddingTop() + paddingY;
-
- mVisualizeGridRect.offsetTo(transX, transY);
-
mVisualizeGridPaint.setStyle(Paint.Style.STROKE);
mVisualizeGridPaint.setColor(Color.argb((int) (alpha),
Color.red(mGridColor), Color.green(mGridColor), Color.blue(mGridColor)));
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 919ad21..4a9add4 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -206,7 +206,6 @@
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.KeyboardShortcutsDelegate;
import com.android.launcher3.util.LockedUserState;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.PendingRequestArgs;
import com.android.launcher3.util.RunnableList;
@@ -384,13 +383,9 @@
private PopupDataProvider mPopupDataProvider;
- private IntSet mSynchronouslyBoundPages = new IntSet();
- @NonNull private IntSet mPagesToBindSynchronously = new IntSet();
-
// We only want to get the SharedPreferences once since it does an FS stat each time we get
// it from the context.
private SharedPreferences mSharedPrefs;
- private OnboardingPrefs<? extends Launcher> mOnboardingPrefs;
// Activity result which needs to be processed after workspace has loaded.
private ActivityResultInfo mPendingActivityResult;
@@ -537,8 +532,6 @@
mAllAppsController = new AllAppsTransitionController(this);
mStateManager = new StateManager<>(this, NORMAL);
- mOnboardingPrefs = createOnboardingPrefs(mSharedPrefs);
-
// TODO: move the SearchConfig to SearchState when new LauncherState is created.
mBaseSearchConfig = new BaseSearchConfig();
@@ -564,7 +557,7 @@
if (savedInstanceState != null) {
int[] pageIds = savedInstanceState.getIntArray(RUNTIME_STATE_CURRENT_SCREEN_IDS);
if (pageIds != null) {
- mPagesToBindSynchronously = IntSet.wrap(pageIds);
+ mModelCallbacks.setPagesToBindSynchronously(IntSet.wrap(pageIds));
}
}
@@ -688,11 +681,6 @@
return new LauncherOverlayManager() { };
}
- protected OnboardingPrefs<? extends Launcher> createOnboardingPrefs(
- SharedPreferences sharedPrefs) {
- return new OnboardingPrefs<>(this, sharedPrefs);
- }
-
@Override
public void onPluginConnected(LauncherOverlayPlugin overlayManager, Context context) {
switchOverlay(() -> overlayManager.createOverlayManager(this));
@@ -1657,8 +1645,9 @@
@Override
public void onRestoreInstanceState(Bundle state) {
super.onRestoreInstanceState(state);
- if (mSynchronouslyBoundPages != null) {
- mSynchronouslyBoundPages.forEach(screenId -> {
+ IntSet synchronouslyBoundPages = mModelCallbacks.getSynchronouslyBoundPages();
+ if (synchronouslyBoundPages != null) {
+ synchronouslyBoundPages.forEach(screenId -> {
int pageIndex = mWorkspace.getPageIndexForScreenId(screenId);
if (pageIndex != PagedView.INVALID_PAGE) {
mWorkspace.restoreInstanceStateForChild(pageIndex);
@@ -2081,41 +2070,7 @@
@Override
public IntSet getPagesToBindSynchronously(IntArray orderedScreenIds) {
- IntSet visibleIds;
- if (!mPagesToBindSynchronously.isEmpty()) {
- visibleIds = mPagesToBindSynchronously;
- } else if (!mWorkspaceLoading) {
- visibleIds = mWorkspace.getCurrentPageScreenIds();
- } else {
- // If workspace binding is still in progress, getCurrentPageScreenIds won't be accurate,
- // and we should use mSynchronouslyBoundPages that's set during initial binding.
- visibleIds = mSynchronouslyBoundPages;
- }
- IntArray actualIds = new IntArray();
-
- IntSet result = new IntSet();
- if (visibleIds.isEmpty()) {
- return result;
- }
- for (int id : orderedScreenIds.toArray()) {
- actualIds.add(id);
- }
- int firstId = visibleIds.getArray().get(0);
- int pairId = mWorkspace.getScreenPair(firstId);
- // Double check that actual screenIds contains the visibleId, as empty screens are hidden
- // in single panel.
- if (actualIds.contains(firstId)) {
- result.add(firstId);
- if (mDeviceProfile.isTwoPanels && actualIds.contains(pairId)) {
- result.add(pairId);
- }
- } else if (LauncherAppState.getIDP(this).supportedProfiles.stream().anyMatch(
- deviceProfile -> deviceProfile.isTwoPanels) && actualIds.contains(pairId)) {
- // Add the right panel if left panel is hidden when switching display, due to empty
- // pages being hidden in single panel.
- result.add(pairId);
- }
- return result;
+ return mModelCallbacks.getPagesToBindSynchronously(orderedScreenIds);
}
/**
@@ -2617,8 +2572,8 @@
@TargetApi(Build.VERSION_CODES.S)
public void onInitialBindComplete(IntSet boundPages, RunnableList pendingTasks,
int workspaceItemCount, boolean isBindSync) {
- mSynchronouslyBoundPages = boundPages;
- mPagesToBindSynchronously = new IntSet();
+ mModelCallbacks.setSynchronouslyBoundPages(boundPages);
+ mModelCallbacks.setPagesToBindSynchronously(new IntSet());
clearPendingBinds();
ViewOnDrawExecutor executor = new ViewOnDrawExecutor(pendingTasks);
@@ -2691,7 +2646,7 @@
// Since we are just resetting the current page without user interaction,
// override the previous page so we don't log the page switch.
mWorkspace.setCurrentPage(currentPage, currentPage /* overridePrevPage */);
- mPagesToBindSynchronously = new IntSet();
+ mModelCallbacks.setPagesToBindSynchronously(new IntSet());
// Cache one page worth of icons
getViewCache().setCacheSize(R.layout.folder_application,
@@ -3268,11 +3223,7 @@
* @param pages should not be null.
*/
public void setPagesToBindSynchronously(@NonNull IntSet pages) {
- mPagesToBindSynchronously = pages;
- }
-
- public OnboardingPrefs<? extends Launcher> getOnboardingPrefs() {
- return mOnboardingPrefs;
+ mModelCallbacks.setPagesToBindSynchronously(pages);
}
@Override
diff --git a/src/com/android/launcher3/LauncherPrefs.kt b/src/com/android/launcher3/LauncherPrefs.kt
index ee2d445..9a0d02a 100644
--- a/src/com/android/launcher3/LauncherPrefs.kt
+++ b/src/com/android/launcher3/LauncherPrefs.kt
@@ -404,7 +404,6 @@
@JvmField
val WIDGETS_EDUCATION_TIP_SEEN = backedUpItem("launcher.widgets_education_tip_seen", false)
- @VisibleForTesting
@JvmStatic
fun <T> backedUpItem(
sharedPrefKey: String,
@@ -491,6 +490,8 @@
ITEMS_TO_MOVE_TO_DEVICE_PROTECTED_STORAGE.add(this)
}
}
+
+ fun get(c: Context): T = LauncherPrefs.get(c).get(this)
}
data class ContextualItem<T>(
@@ -508,6 +509,8 @@
}
return default!!
}
+
+ fun get(c: Context): T = LauncherPrefs.get(c).get(this)
}
enum class EncryptionType {
diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt
index 679f7d4..8304e96 100644
--- a/src/com/android/launcher3/ModelCallbacks.kt
+++ b/src/com/android/launcher3/ModelCallbacks.kt
@@ -8,12 +8,18 @@
import com.android.launcher3.model.data.WorkspaceItemInfo
import com.android.launcher3.popup.PopupContainerWithArrow
import com.android.launcher3.util.ComponentKey
+import com.android.launcher3.util.IntArray as LIntArray
+import com.android.launcher3.util.IntSet as LIntSet
import com.android.launcher3.util.PackageUserKey
import com.android.launcher3.util.Preconditions
import com.android.launcher3.widget.model.WidgetsListBaseEntry
import java.util.function.Predicate
class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
+
+ var synchronouslyBoundPages = LIntSet()
+ var pagesToBindSynchronously = LIntSet()
+
override fun preAddApps() {
// If there's an undo snackbar, force it to complete to ensure empty screens are removed
// before trying to add new items.
@@ -93,4 +99,40 @@
override fun bindAllWidgets(allWidgets: List<WidgetsListBaseEntry?>?) {
launcher.popupDataProvider.allWidgets = allWidgets
}
+
+ /** Returns the ids of the workspaces to bind. */
+ override fun getPagesToBindSynchronously(orderedScreenIds: LIntArray): LIntSet {
+ // If workspace binding is still in progress, getCurrentPageScreenIds won't be
+ // accurate, and we should use mSynchronouslyBoundPages that's set during initial binding.
+ val visibleIds =
+ when {
+ !pagesToBindSynchronously.isEmpty -> pagesToBindSynchronously
+ !launcher.isWorkspaceLoading -> launcher.workspace.currentPageScreenIds
+ else -> synchronouslyBoundPages
+ }
+ // Launcher IntArray has the same name as Kotlin IntArray
+ val result = LIntSet()
+ if (visibleIds.isEmpty) {
+ return result
+ }
+ val actualIds = orderedScreenIds.clone()
+ val firstId = visibleIds.first()
+ val pairId = launcher.workspace.getScreenPair(firstId)
+ // Double check that actual screenIds contains the visibleId, as empty screens are hidden
+ // in single panel.
+ if (actualIds.contains(firstId)) {
+ result.add(firstId)
+ if (launcher.deviceProfile.isTwoPanels && actualIds.contains(pairId)) {
+ result.add(pairId)
+ }
+ } else if (
+ LauncherAppState.getIDP(launcher).supportedProfiles.any(DeviceProfile::isTwoPanels) &&
+ actualIds.contains(pairId)
+ ) {
+ // Add the right panel if left panel is hidden when switching display, due to empty
+ // pages being hidden in single panel.
+ result.add(pairId)
+ }
+ return result
+ }
}
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index dabe84d..61ca95b 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -80,6 +80,7 @@
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.ItemInfo;
+import com.android.launcher3.recyclerview.AllAppsRecyclerViewPool;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
@@ -93,7 +94,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
-import java.util.stream.Stream;
/**
* All apps container view with search support for use in a dragging activity.
@@ -623,16 +623,18 @@
private static void setUpCustomRecyclerViewPool(
@NonNull AllAppsRecyclerView mainRecyclerView,
@Nullable AllAppsRecyclerView workRecyclerView,
- @NonNull RecyclerView.RecycledViewPool recycledViewPool) {
+ @NonNull AllAppsRecyclerViewPool recycledViewPool) {
if (!ENABLE_ALL_APPS_RV_PREINFLATION.get()) {
return;
}
+ final boolean hasWorkProfile = workRecyclerView != null;
+ recycledViewPool.setHasWorkProfile(hasWorkProfile);
mainRecyclerView.setRecycledViewPool(recycledViewPool);
if (workRecyclerView != null) {
workRecyclerView.setRecycledViewPool(recycledViewPool);
}
if (ALL_APPS_GONE_VISIBILITY.get()) {
- mainRecyclerView.updatePoolSize();
+ mainRecyclerView.updatePoolSize(hasWorkProfile);
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index cffddfc..b0f13ef 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -95,6 +95,10 @@
}
protected void updatePoolSize() {
+ updatePoolSize(false);
+ }
+
+ void updatePoolSize(boolean hasWorkProfile) {
DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
@@ -111,6 +115,9 @@
maxPoolSizeForAppIcons +=
PREINFLATE_ICONS_ROW_COUNT * grid.numShownAllAppsColumns + EXTRA_ICONS_COUNT;
}
+ if (hasWorkProfile) {
+ maxPoolSizeForAppIcons *= 2;
+ }
pool.setMaxRecycledViews(
AllAppsGridAdapter.VIEW_TYPE_ICON, maxPoolSizeForAppIcons);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java
index 7867f44..9f6e0fc 100644
--- a/src/com/android/launcher3/allapps/AllAppsStore.java
+++ b/src/com/android/launcher3/allapps/AllAppsStore.java
@@ -27,7 +27,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.recyclerview.widget.RecyclerView.RecycledViewPool;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.model.data.AppInfo;
@@ -110,7 +109,7 @@
}
}
- RecycledViewPool getRecyclerViewPool() {
+ AllAppsRecyclerViewPool getRecyclerViewPool() {
return mAllAppsRecyclerViewPool;
}
diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java
index df22425..1692912 100644
--- a/src/com/android/launcher3/allapps/DiscoveryBounce.java
+++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java
@@ -17,6 +17,7 @@
package com.android.launcher3.allapps;
import static com.android.launcher3.LauncherState.NORMAL;
+import static com.android.launcher3.util.OnboardingPrefs.HOME_BOUNCE_SEEN;
import android.animation.Animator;
import android.animation.AnimatorInflater;
@@ -122,9 +123,8 @@
}
private static void showForHomeIfNeeded(Launcher launcher, boolean withDelay) {
- OnboardingPrefs onboardingPrefs = launcher.getOnboardingPrefs();
if (!launcher.isInState(NORMAL)
- || onboardingPrefs.getBoolean(OnboardingPrefs.HOME_BOUNCE_SEEN)
+ || HOME_BOUNCE_SEEN.get(launcher)
|| AbstractFloatingView.getTopOpenView(launcher) != null
|| launcher.getSystemService(UserManager.class).isDemoUser()
|| Utilities.isRunningInTestHarness()) {
@@ -135,7 +135,7 @@
new Handler().postDelayed(() -> showForHomeIfNeeded(launcher, false), DELAY_MS);
return;
}
- onboardingPrefs.incrementEventCount(OnboardingPrefs.HOME_BOUNCE_COUNT);
+ OnboardingPrefs.HOME_BOUNCE_COUNT.increment(launcher);
new DiscoveryBounce(launcher).show();
}
diff --git a/src/com/android/launcher3/anim/PendingAnimation.java b/src/com/android/launcher3/anim/PendingAnimation.java
index 7316420..fd731f4 100644
--- a/src/com/android/launcher3/anim/PendingAnimation.java
+++ b/src/com/android/launcher3/anim/PendingAnimation.java
@@ -22,8 +22,10 @@
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
+import android.os.Trace;
import android.util.FloatProperty;
+import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController.Holder;
import java.util.ArrayList;
@@ -82,6 +84,15 @@
add(anim);
}
+ /** If trace is enabled, add counter to trace animation progress. */
+ public void logAnimationProgressToTrace(String counterName) {
+ if (Utilities.ATLEAST_Q && Trace.isEnabled()) {
+ super.addOnFrameListener(
+ animation -> Trace.setCounter(
+ counterName, (long) (animation.getAnimatedFraction() * 100)));
+ }
+ }
+
/**
* Creates and returns the underlying AnimatorSet
*/
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index feb84b7..5b44069 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -274,11 +274,14 @@
+ " locked. Enabling this causes a 1-time movement of certain SharedPreferences"
+ " data. Improves startup latency.");
- // TODO(Block 18): Clean up flags
+ // Aconfig migration complete for ENABLE_APP_PAIRS.
public static final BooleanFlag ENABLE_APP_PAIRS = getDebugFlag(274189428,
"ENABLE_APP_PAIRS", DISABLED,
"Enables the ability to create and save app pairs on the Home screen for easy"
+ " split screen launching.");
+ public static boolean enableAppPairs() {
+ return ENABLE_APP_PAIRS.get() || com.android.wm.shell.Flags.enableAppPairs();
+ }
// TODO(Block 19): Clean up flags
public static final BooleanFlag SCROLL_TOP_TO_RESET = getReleaseFlag(270395177,
@@ -385,10 +388,6 @@
270393453, "ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE", DISABLED,
"Enable initiating split screen from workspace to workspace.");
- public static final BooleanFlag ENABLE_SPLIT_FROM_DESKTOP_TO_WORKSPACE = getDebugFlag(
- 279586624, "ENABLE_SPLIT_FROM_DESKTOP_TO_WORKSPACE", DISABLED,
- "Enable initiating split screen from desktop mode to workspace.");
-
public static final BooleanFlag ENABLE_TRACKPAD_GESTURE = getDebugFlag(271010401,
"ENABLE_TRACKPAD_GESTURE", ENABLED, "Enables trackpad gesture.");
diff --git a/src/com/android/launcher3/icons/LauncherIcons.java b/src/com/android/launcher3/icons/LauncherIcons.java
index 57fa8a2..a15348b 100644
--- a/src/com/android/launcher3/icons/LauncherIcons.java
+++ b/src/com/android/launcher3/icons/LauncherIcons.java
@@ -20,11 +20,16 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.os.UserHandle;
+
+import androidx.annotation.NonNull;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.graphics.IconShape;
import com.android.launcher3.graphics.LauncherPreviewRenderer;
+import com.android.launcher3.pm.UserCache;
import com.android.launcher3.util.Themes;
+import com.android.launcher3.util.UserIconInfo;
/**
* Wrapper class to provide access to {@link BaseIconFactory} and also to provide pool of this class
@@ -107,6 +112,12 @@
return mMonochromeIconFactory.wrap(base);
}
+ @NonNull
+ @Override
+ protected UserIconInfo getUserInfo(@NonNull UserHandle user) {
+ return UserCache.INSTANCE.get(mContext).getUserInfo(user);
+ }
+
@Override
public void close() {
recycle();
diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java
index 4307566..632ca24 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.java
@@ -835,6 +835,13 @@
}
/**
+ * Set the features of the log message.
+ */
+ default StatsLogger withFeatures(int feature) {
+ return this;
+ }
+
+ /**
* Builds the final message and logs it as {@link EventEnum}.
*/
default void log(EventEnum event) {
diff --git a/src/com/android/launcher3/pm/UserCache.java b/src/com/android/launcher3/pm/UserCache.java
index 92822ab..e2b1286 100644
--- a/src/com/android/launcher3/pm/UserCache.java
+++ b/src/com/android/launcher3/pm/UserCache.java
@@ -17,6 +17,7 @@
package com.android.launcher3.pm;
import static com.android.launcher3.Utilities.ATLEAST_U;
+import static com.android.launcher3.uioverrides.ApiWrapper.queryAllUsers;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import android.content.Context;
@@ -24,7 +25,6 @@
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
-import android.util.ArrayMap;
import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
@@ -33,6 +33,7 @@
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.SimpleBroadcastReceiver;
+import com.android.launcher3.util.UserIconInfo;
import java.util.ArrayList;
import java.util.Collections;
@@ -65,7 +66,7 @@
private final Context mContext;
@NonNull
- private Map<UserHandle, Long> mUserToSerialMap;
+ private Map<UserHandle, UserIconInfo> mUserToSerialMap;
private UserCache(Context context) {
mContext = context;
@@ -103,7 +104,7 @@
@WorkerThread
private void updateCache() {
- mUserToSerialMap = queryAllUsers(mContext.getSystemService(UserManager.class));
+ mUserToSerialMap = queryAllUsers(mContext);
}
/**
@@ -118,19 +119,26 @@
* @see UserManager#getSerialNumberForUser(UserHandle)
*/
public long getSerialNumberForUser(UserHandle user) {
- Long serial = mUserToSerialMap.get(user);
- return serial == null ? 0 : serial;
+ return getUserInfo(user).userSerial;
+ }
+
+ /**
+ * Returns the user properties for the provided user or default values
+ */
+ @NonNull
+ public UserIconInfo getUserInfo(UserHandle user) {
+ UserIconInfo info = mUserToSerialMap.get(user);
+ return info == null ? new UserIconInfo(user, UserIconInfo.TYPE_MAIN) : info;
}
/**
* @see UserManager#getUserForSerialNumber(long)
*/
public UserHandle getUserForSerialNumber(long serialNumber) {
- Long value = serialNumber;
return mUserToSerialMap
.entrySet()
.stream()
- .filter(entry -> value.equals(entry.getValue()))
+ .filter(entry -> serialNumber == entry.getValue().userSerial)
.findFirst()
.map(Map.Entry::getKey)
.orElse(Process.myUserHandle());
@@ -142,16 +150,4 @@
public List<UserHandle> getUserProfiles() {
return List.copyOf(mUserToSerialMap.keySet());
}
-
- private static Map<UserHandle, Long> queryAllUsers(UserManager userManager) {
- Map<UserHandle, Long> users = new ArrayMap<>();
- List<UserHandle> usersActual = userManager.getUserProfiles();
- if (usersActual != null) {
- for (UserHandle user : usersActual) {
- long serial = userManager.getSerialNumberForUser(user);
- users.put(user, serial);
- }
- }
- return users;
- }
}
diff --git a/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt b/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt
index 1d71805..45174a7 100644
--- a/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt
+++ b/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt
@@ -40,6 +40,8 @@
private var future: Future<Void>? = null
+ var hasWorkProfile = false
+
/**
* Preinflate app icons. If all apps RV cannot be scrolled down, we don't need to preinflate.
*/
@@ -95,6 +97,9 @@
val grid = ActivityContext.lookupContext<T>(context).deviceProfile
targetPreinflateCount += grid.maxAllAppsRowCount * grid.numShownAllAppsColumns
}
+ if (hasWorkProfile) {
+ targetPreinflateCount *= 2
+ }
val existingPreinflateCount = getRecycledViewCount(BaseAllAppsAdapter.VIEW_TYPE_ICON)
return targetPreinflateCount - existingPreinflateCount
}
diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java
index a10c0ad..910b029 100644
--- a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java
+++ b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java
@@ -36,7 +36,6 @@
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
-import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
@@ -56,7 +55,6 @@
import com.android.launcher3.touch.ItemClickHandler.ItemClickProxy;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.IntSet;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.Themes;
@@ -82,7 +80,6 @@
private boolean mAppDrawerShown = false;
private StringCache mStringCache;
- private OnboardingPrefs<?> mOnboardingPrefs;
private boolean mBindingItems = false;
private SecondaryDisplayPredictions mSecondaryDisplayPredictions;
@@ -93,7 +90,6 @@
super.onCreate(savedInstanceState);
mModel = LauncherAppState.getInstance(this).getModel();
mDragController = new SecondaryDragController(this);
- mOnboardingPrefs = new OnboardingPrefs<>(this, LauncherPrefs.getPrefs(this));
mSecondaryDisplayPredictions = SecondaryDisplayPredictions.newInstance(this);
if (getWindow().getDecorView().isAttachedToWindow()) {
initUi();
@@ -272,11 +268,6 @@
}
@Override
- public OnboardingPrefs<?> getOnboardingPrefs() {
- return mOnboardingPrefs;
- }
-
- @Override
public void startBinding() {
mBindingItems = true;
mDragController.cancelDrag();
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index e52e878..0438e57 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -165,6 +165,11 @@
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, mDeviceProfile.isTablet);
return response;
+ case TestProtocol.REQUEST_NUM_ALL_APPS_COLUMNS:
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD,
+ mDeviceProfile.numShownAllAppsColumns);
+ return response;
+
case TestProtocol.REQUEST_IS_TWO_PANELS:
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
FOLDABLE_SINGLE_PAGE.get() ? false : mDeviceProfile.isTwoPanels);
diff --git a/src/com/android/launcher3/util/MainThreadInitializedObject.java b/src/com/android/launcher3/util/MainThreadInitializedObject.java
index 1cb9994..b966d8e 100644
--- a/src/com/android/launcher3/util/MainThreadInitializedObject.java
+++ b/src/com/android/launcher3/util/MainThreadInitializedObject.java
@@ -93,7 +93,7 @@
* Abstract Context which allows custom implementations for
* {@link MainThreadInitializedObject} providers
*/
- public static abstract class SandboxContext extends ContextWrapper {
+ public static class SandboxContext extends ContextWrapper {
private static final String TAG = "SandboxContext";
@@ -165,5 +165,14 @@
protected <T> T createObject(MainThreadInitializedObject<T> object) {
return object.mProvider.get(this);
}
+
+ /**
+ * Put a value into mObjectMap, can be used to put mocked MainThreadInitializedObject
+ * instances into SandboxContext.
+ */
+ @VisibleForTesting
+ public <T> void putObject(MainThreadInitializedObject<T> object, T value) {
+ mObjectMap.put(object, value);
+ }
}
}
diff --git a/src/com/android/launcher3/util/OnboardingPrefs.java b/src/com/android/launcher3/util/OnboardingPrefs.java
deleted file mode 100644
index f8f4b5f..0000000
--- a/src/com/android/launcher3/util/OnboardingPrefs.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2020 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.util;
-
-import android.content.SharedPreferences;
-import android.util.ArrayMap;
-
-import androidx.annotation.StringDef;
-
-import com.android.launcher3.views.ActivityContext;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * Stores and retrieves onboarding-related data via SharedPreferences.
- *
- * @param <T> Context which owns these preferences.
- */
-public class OnboardingPrefs<T extends ActivityContext> {
-
- public static final String HOME_BOUNCE_SEEN = "launcher.apps_view_shown";
- public static final String HOME_BOUNCE_COUNT = "launcher.home_bounce_count";
- public static final String HOTSEAT_DISCOVERY_TIP_COUNT = "launcher.hotseat_discovery_tip_count";
- public static final String HOTSEAT_LONGPRESS_TIP_SEEN = "launcher.hotseat_longpress_tip_seen";
- public static final String ALL_APPS_VISITED_COUNT = "launcher.all_apps_visited_count";
- public static final String TASKBAR_EDU_TOOLTIP_STEP = "launcher.taskbar_edu_tooltip_step";
- // When adding a new key, add it here as well, to be able to reset it from Developer Options.
- public static final Map<String, String[]> ALL_PREF_KEYS = Map.of(
- "All Apps Bounce", new String[] { HOME_BOUNCE_SEEN, HOME_BOUNCE_COUNT },
- "Hybrid Hotseat Education", new String[] { HOTSEAT_DISCOVERY_TIP_COUNT,
- HOTSEAT_LONGPRESS_TIP_SEEN },
- "Taskbar Education", new String[] { TASKBAR_EDU_TOOLTIP_STEP },
- "All Apps Visited Count", new String[] {ALL_APPS_VISITED_COUNT}
- );
-
- /**
- * Events that either have happened or have not (booleans).
- */
- @StringDef(value = {
- HOME_BOUNCE_SEEN,
- HOTSEAT_LONGPRESS_TIP_SEEN,
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface EventBoolKey {}
-
- /**
- * Events that occur multiple times, which we count up to a max defined in {@link #MAX_COUNTS}.
- */
- @StringDef(value = {
- HOME_BOUNCE_COUNT,
- HOTSEAT_DISCOVERY_TIP_COUNT,
- ALL_APPS_VISITED_COUNT,
- TASKBAR_EDU_TOOLTIP_STEP,
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface EventCountKey {}
-
- private static final Map<String, Integer> MAX_COUNTS;
-
- static {
- Map<String, Integer> maxCounts = new ArrayMap<>(5);
- maxCounts.put(HOME_BOUNCE_COUNT, 3);
- maxCounts.put(HOTSEAT_DISCOVERY_TIP_COUNT, 5);
- maxCounts.put(ALL_APPS_VISITED_COUNT, 20);
- maxCounts.put(TASKBAR_EDU_TOOLTIP_STEP, 2);
- MAX_COUNTS = Collections.unmodifiableMap(maxCounts);
- }
-
- protected final T mLauncher;
- protected final SharedPreferences mSharedPrefs;
-
- public OnboardingPrefs(T launcher, SharedPreferences sharedPrefs) {
- mLauncher = launcher;
- mSharedPrefs = sharedPrefs;
- }
-
- /** @return The number of times we have seen the given event. */
- public int getCount(@EventCountKey String key) {
- return mSharedPrefs.getInt(key, 0);
- }
-
- /** @return Whether we have seen this event enough times, as defined by {@link #MAX_COUNTS}. */
- public boolean hasReachedMaxCount(@EventCountKey String eventKey) {
- return hasReachedMaxCount(getCount(eventKey), eventKey);
- }
-
- private boolean hasReachedMaxCount(int count, @EventCountKey String eventKey) {
- return count >= MAX_COUNTS.get(eventKey);
- }
-
- /** @return Whether we have seen the given event. */
- public boolean getBoolean(@EventBoolKey String key) {
- return mSharedPrefs.getBoolean(key, false);
- }
-
- /**
- * Marks on-boarding preference boolean at true
- */
- public void markChecked(String flag) {
- mSharedPrefs.edit().putBoolean(flag, true).apply();
- }
-
- /**
- * Add 1 to the given event count, if we haven't already reached the max count.
- *
- * @return Whether we have now reached the max count.
- */
- public boolean incrementEventCount(@EventCountKey String eventKey) {
- int count = getCount(eventKey);
- if (hasReachedMaxCount(count, eventKey)) {
- return true;
- }
- count++;
- mSharedPrefs.edit().putInt(eventKey, count).apply();
- return hasReachedMaxCount(count, eventKey);
- }
-
- /**
- * Sets the event count to the given value.
- *
- * @return Whether we have now reached the max count.
- */
- public boolean setEventCount(int count, @EventCountKey String eventKey) {
- mSharedPrefs.edit().putInt(eventKey, count).apply();
- return hasReachedMaxCount(count, eventKey);
- }
-}
diff --git a/src/com/android/launcher3/util/OnboardingPrefs.kt b/src/com/android/launcher3/util/OnboardingPrefs.kt
new file mode 100644
index 0000000..8586c43
--- /dev/null
+++ b/src/com/android/launcher3/util/OnboardingPrefs.kt
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2020 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.util
+
+import android.content.Context
+import com.android.launcher3.LauncherPrefs
+import com.android.launcher3.LauncherPrefs.Companion.backedUpItem
+
+/** Stores and retrieves onboarding-related data via SharedPreferences. */
+object OnboardingPrefs {
+
+ data class CountedItem(
+ val sharedPrefKey: String,
+ val maxCount: Int,
+ ) {
+ private val prefItem = backedUpItem(sharedPrefKey, 0)
+
+ /** @return The number of times we have seen the given event. */
+ fun get(c: Context): Int {
+ return prefItem.get(c)
+ }
+
+ /** @return Whether we have seen this event enough times, as defined by [.MAX_COUNTS]. */
+ fun hasReachedMax(c: Context): Boolean {
+ return get(c) >= maxCount
+ }
+
+ /**
+ * Add 1 to the given event count, if we haven't already reached the max count.
+ *
+ * @return Whether we have now reached the max count.
+ */
+ fun increment(c: Context): Boolean {
+ val count = get(c)
+ if (count >= maxCount) {
+ return true
+ }
+ return set(count + 1, c)
+ }
+
+ /**
+ * Sets the event count to the given value.
+ *
+ * @return Whether we have now reached the max count.
+ */
+ fun set(count: Int, c: Context): Boolean {
+ LauncherPrefs.get(c).put(prefItem, count)
+ return count >= maxCount
+ }
+ }
+
+ @JvmField val TASKBAR_EDU_TOOLTIP_STEP = CountedItem("launcher.taskbar_edu_tooltip_step", 2)
+
+ @JvmField val HOME_BOUNCE_COUNT = CountedItem("launcher.home_bounce_count", 3)
+
+ @JvmField
+ val HOTSEAT_DISCOVERY_TIP_COUNT = CountedItem("launcher.hotseat_discovery_tip_count", 5)
+
+ @JvmField val ALL_APPS_VISITED_COUNT = CountedItem("launcher.all_apps_visited_count", 20)
+
+ @JvmField val HOME_BOUNCE_SEEN = backedUpItem("launcher.apps_view_shown", false)
+
+ @JvmField
+ val HOTSEAT_LONGPRESS_TIP_SEEN = backedUpItem("launcher.hotseat_longpress_tip_seen", false)
+}
diff --git a/src/com/android/launcher3/util/WindowBounds.java b/src/com/android/launcher3/util/WindowBounds.java
index 91480e1..ec3b642 100644
--- a/src/com/android/launcher3/util/WindowBounds.java
+++ b/src/com/android/launcher3/util/WindowBounds.java
@@ -67,7 +67,8 @@
return false;
}
WindowBounds other = (WindowBounds) obj;
- return other.bounds.equals(bounds) && other.insets.equals(insets);
+ return other.bounds.equals(bounds) && other.insets.equals(insets)
+ && other.rotationHint == rotationHint;
}
@Override
diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java
index 0d55f15..3921e12 100644
--- a/src/com/android/launcher3/views/ActivityContext.java
+++ b/src/com/android/launcher3/views/ActivityContext.java
@@ -74,7 +74,6 @@
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.util.ActivityOptionsWrapper;
-import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.RunnableList;
@@ -231,12 +230,6 @@
*/
default void applyOverwritesToLogItem(LauncherAtom.ItemInfo.Builder itemInfoBuilder) { }
- /** Onboarding preferences for any onboarding data within this context. */
- @Nullable
- default OnboardingPrefs<?> getOnboardingPrefs() {
- return null;
- }
-
/** Returns {@code true} if items are currently being bound within this context. */
default boolean isBindingItems() {
return false;
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java b/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java
index 599a591..fe5c1fd 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java
@@ -21,10 +21,16 @@
import android.content.Context;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.ShortcutInfo;
+import android.graphics.drawable.ColorDrawable;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.util.ArrayMap;
import com.android.launcher3.Utilities;
+import com.android.launcher3.util.UserIconInfo;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
/**
@@ -48,4 +54,41 @@
public static ActivityOptions createFadeOutAnimOptions(Context context) {
return ActivityOptions.makeCustomAnimation(context, 0, android.R.anim.fade_out);
}
+
+ /**
+ * Returns a map of all users on the device to their corresponding UI properties
+ */
+ public static Map<UserHandle, UserIconInfo> queryAllUsers(Context context) {
+ UserManager um = context.getSystemService(UserManager.class);
+ Map<UserHandle, UserIconInfo> users = new ArrayMap<>();
+ List<UserHandle> usersActual = um.getUserProfiles();
+ if (usersActual != null) {
+ for (UserHandle user : usersActual) {
+ long serial = um.getSerialNumberForUser(user);
+
+ // Simple check to check if the provided user is work profile
+ // TODO: Migrate to a better platform API
+ NoopDrawable d = new NoopDrawable();
+ boolean isWork = (d != context.getPackageManager().getUserBadgedIcon(d, user));
+ UserIconInfo info = new UserIconInfo(
+ user,
+ isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN,
+ serial);
+ users.put(user, info);
+ }
+ }
+ return users;
+ }
+
+ private static class NoopDrawable extends ColorDrawable {
+ @Override
+ public int getIntrinsicHeight() {
+ return 1;
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return 1;
+ }
+ }
}
diff --git a/tests/Android.bp b/tests/Android.bp
index 6b8cecb..29a45aa 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -54,6 +54,7 @@
"src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java",
"src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java",
"src/com/android/launcher3/util/LauncherLayoutBuilder.java",
+ "src/com/android/launcher3/util/TestConstants.java",
"src/com/android/launcher3/util/TestUtil.java",
"src/com/android/launcher3/util/Wait.java",
"src/com/android/launcher3/util/WidgetUtils.java",
diff --git a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java
index 54a1c08..3e80e6b 100644
--- a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java
+++ b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java
@@ -115,6 +115,7 @@
public static final String REQUEST_CLEAR_DATA = "clear-data";
public static final String REQUEST_HOTSEAT_ICON_NAMES = "get-hotseat-icon-names";
public static final String REQUEST_IS_TABLET = "is-tablet";
+ public static final String REQUEST_NUM_ALL_APPS_COLUMNS = "num-all-apps-columns";
public static final String REQUEST_IS_TWO_PANELS = "is-two-panel";
public static final String REQUEST_START_DRAG_THRESHOLD = "start-drag-threshold";
public static final String REQUEST_SHELL_DRAG_READY = "shell-drag-ready";
@@ -157,7 +158,6 @@
public static final String PERMANENT_DIAG_TAG = "TaplTarget";
public static final String TWO_TASKBAR_LONG_CLICKS = "b/262282528";
public static final String ICON_MISSING = "b/282963545";
- public static final String INCORRECT_HOME_STATE = "b/293191790";
public static final String REQUEST_EMULATE_DISPLAY = "emulate-display";
public static final String REQUEST_STOP_EMULATE_DISPLAY = "stop-emulate-display";
diff --git a/tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt b/tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
index 84fa988..0b31469 100644
--- a/tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
+++ b/tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
@@ -24,6 +24,7 @@
import androidx.test.core.app.ApplicationProvider
import com.android.launcher3.testing.shared.ResourceUtils
import com.android.launcher3.util.DisplayController
+import com.android.launcher3.util.MainThreadInitializedObject.SandboxContext
import com.android.launcher3.util.NavigationMode
import com.android.launcher3.util.WindowBounds
import com.android.launcher3.util.rule.TestStabilityRule
@@ -35,8 +36,6 @@
import java.io.StringWriter
import kotlin.math.max
import kotlin.math.min
-import org.junit.After
-import org.junit.Before
import org.junit.Rule
import org.mockito.kotlin.any
import org.mockito.kotlin.mock
@@ -50,30 +49,14 @@
* For an implementation that mocks InvariantDeviceProfile, use [FakeInvariantDeviceProfileTest]
*/
abstract class AbstractDeviceProfileTest {
- protected var context: Context? = null
+ protected lateinit var context: SandboxContext
protected open val runningContext: Context = ApplicationProvider.getApplicationContext()
private val displayController: DisplayController = mock()
private val windowManagerProxy: WindowManagerProxy = mock()
- private lateinit var originalDisplayController: DisplayController
- private lateinit var originalWindowManagerProxy: WindowManagerProxy
+ private val launcherPrefs: LauncherPrefs = mock()
@Rule @JvmField val testStabilityRule = TestStabilityRule()
- @Before
- open fun setUp() {
- val appContext: Context = ApplicationProvider.getApplicationContext()
- originalWindowManagerProxy = WindowManagerProxy.INSTANCE.get(appContext)
- originalDisplayController = DisplayController.INSTANCE.get(appContext)
- WindowManagerProxy.INSTANCE.initializeForTesting(windowManagerProxy)
- DisplayController.INSTANCE.initializeForTesting(displayController)
- }
-
- @After
- open fun tearDown() {
- WindowManagerProxy.INSTANCE.initializeForTesting(originalWindowManagerProxy)
- DisplayController.INSTANCE.initializeForTesting(originalDisplayController)
- }
-
class DeviceSpec(
val naturalSize: Pair<Int, Int>,
var densityDpi: Int,
@@ -304,8 +287,19 @@
screenHeightDp = (realBounds.bounds.height() / density).toInt()
smallestScreenWidthDp = min(screenWidthDp, screenHeightDp)
}
- context = runningContext.createConfigurationContext(config)
+ val configurationContext = runningContext.createConfigurationContext(config)
+ context =
+ SandboxContext(
+ configurationContext,
+ DisplayController.INSTANCE,
+ WindowManagerProxy.INSTANCE,
+ LauncherPrefs.INSTANCE
+ )
+ context.putObject(DisplayController.INSTANCE, displayController)
+ context.putObject(WindowManagerProxy.INSTANCE, windowManagerProxy)
+ context.putObject(LauncherPrefs.INSTANCE, launcherPrefs)
+ whenever(launcherPrefs.get(LauncherPrefs.TASKBAR_PINNING)).thenReturn(false)
val info = spy(DisplayController.Info(context, windowManagerProxy, perDisplayBoundsCache))
whenever(displayController.info).thenReturn(info)
whenever(info.isTransientTaskbar).thenReturn(isGestureMode)
diff --git a/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java b/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java
index 85cf52e..0f5d85b 100644
--- a/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java
+++ b/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java
@@ -15,7 +15,7 @@
*/
package com.android.launcher3.appiconmenu;
-import static com.android.launcher3.ui.TaplTestsLauncher3.APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
import static org.junit.Assert.assertEquals;
@@ -64,7 +64,7 @@
final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
- final AppIconMenu menu = allApps.getAppIcon(APP_NAME).openDeepShortcutMenu();
+ final AppIconMenu menu = allApps.getAppIcon(TEST_APP_NAME).openDeepShortcutMenu();
executeOnLauncher(
launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
@@ -89,9 +89,9 @@
final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
- allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
+ allApps.getAppIcon(TEST_APP_NAME).dragToWorkspace(false, false);
final AppIconMenu menu = mLauncher.getWorkspace().getWorkspaceAppIcon(
- APP_NAME).openDeepShortcutMenu();
+ TEST_APP_NAME).openDeepShortcutMenu();
executeOnLauncher(
launcher -> assertTrue("Launcher internal state didn't switch to Showing Menu",
diff --git a/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java b/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java
index 032a7b4..c5d5de8 100644
--- a/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java
+++ b/tests/src/com/android/launcher3/compat/PromiseIconUiTest.java
@@ -27,6 +27,7 @@
import com.android.launcher3.LauncherState;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.LauncherBindableItemsContainer.ItemOperator;
+import com.android.launcher3.util.rule.ViewCaptureRule;
import org.junit.After;
import org.junit.Test;
@@ -95,6 +96,7 @@
}
@Test
+ @ViewCaptureRule.MayProduceNoFrames
public void testPromiseIcon_notAddedFromIneligibleSession() throws Throwable {
final String appLabel = "Test Promise App " + UUID.randomUUID().toString();
final ItemOperator findPromiseApp = (info, view) ->
diff --git a/tests/src/com/android/launcher3/dragging/TaplDragTest.java b/tests/src/com/android/launcher3/dragging/TaplDragTest.java
index c652b98..7ec7826 100644
--- a/tests/src/com/android/launcher3/dragging/TaplDragTest.java
+++ b/tests/src/com/android/launcher3/dragging/TaplDragTest.java
@@ -15,10 +15,10 @@
*/
package com.android.launcher3.dragging;
-import static com.android.launcher3.ui.TaplTestsLauncher3.APP_NAME;
-import static com.android.launcher3.ui.TaplTestsLauncher3.GMAIL_APP_NAME;
-import static com.android.launcher3.ui.TaplTestsLauncher3.MAPS_APP_NAME;
-import static com.android.launcher3.ui.TaplTestsLauncher3.STORE_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.GMAIL_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.STORE_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
import static org.junit.Assert.assertEquals;
@@ -118,7 +118,7 @@
allApps.freeze();
try {
final HomeAppIconMenuItem menuItem = allApps
- .getAppIcon(APP_NAME)
+ .getAppIcon(TEST_APP_NAME)
.openDeepShortcutMenu()
.getMenuItem(0);
final String actualShortcutName = menuItem.getText();
@@ -147,7 +147,7 @@
final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
- allApps.getAppIcon(APP_NAME)
+ allApps.getAppIcon(TEST_APP_NAME)
.openDeepShortcutMenu()
.getMenuItem(0)
.dragToWorkspace(target.x, target.y);
@@ -194,8 +194,8 @@
final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
- allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
- mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName());
+ allApps.getAppIcon(TEST_APP_NAME).dragToWorkspace(false, false);
+ mLauncher.getWorkspace().getWorkspaceAppIcon(TEST_APP_NAME).launch(getAppPackageName());
} finally {
allApps.unfreeze();
}
@@ -222,7 +222,7 @@
final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
try {
- allApps.getAppIcon(APP_NAME).dragToWorkspace(target.x, target.y);
+ allApps.getAppIcon(TEST_APP_NAME).dragToWorkspace(target.x, target.y);
} finally {
allApps.unfreeze();
}
@@ -235,7 +235,7 @@
}
// test to move a shortcut to other cell.
- final HomeAppIcon launcherTestAppIcon = createShortcutInCenterIfNotExist(APP_NAME);
+ final HomeAppIcon launcherTestAppIcon = createShortcutInCenterIfNotExist(TEST_APP_NAME);
for (Point target : targets) {
startTime = SystemClock.uptimeMillis();
launcherTestAppIcon.dragToWorkspace(target.x, target.y);
diff --git a/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java b/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java
index 5b87a05..7027e85 100644
--- a/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java
+++ b/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java
@@ -16,11 +16,12 @@
package com.android.launcher3.dragging;
import static com.android.launcher3.testing.shared.TestProtocol.ICON_MISSING;
-import static com.android.launcher3.ui.TaplTestsLauncher3.APP_NAME;
-import static com.android.launcher3.ui.TaplTestsLauncher3.DUMMY_APP_NAME;
-import static com.android.launcher3.ui.TaplTestsLauncher3.MAPS_APP_NAME;
-import static com.android.launcher3.ui.TaplTestsLauncher3.STORE_APP_NAME;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.util.TestConstants.AppNames.DUMMY_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.GMAIL_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.STORE_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.google.common.truth.Truth.assertThat;
@@ -62,7 +63,7 @@
@Test
@PortraitLandscape
public void testDeleteFromWorkspace() {
- for (String appName : new String[]{"Gmail", "Play Store", APP_NAME}) {
+ for (String appName : new String[]{GMAIL_APP_NAME, STORE_APP_NAME, TEST_APP_NAME}) {
final HomeAppIcon homeAppIcon = createShortcutInCenterIfNotExist(appName);
Workspace workspace = mLauncher.getWorkspace().deleteAppIcon(homeAppIcon);
workspace.verifyWorkspaceAppIconIsGone(
@@ -174,9 +175,9 @@
mLauncher.getWorkspace()
.deleteAppIcon(mLauncher.getWorkspace().getHotseatAppIcon(0))
.switchToAllApps()
- .getAppIcon(APP_NAME)
+ .getAppIcon(TEST_APP_NAME)
.dragToHotseat(0);
mLauncher.getWorkspace().deleteAppIcon(
- mLauncher.getWorkspace().getHotseatAppIcon(APP_NAME));
+ mLauncher.getWorkspace().getHotseatAppIcon(TEST_APP_NAME));
}
}
diff --git a/tests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java b/tests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java
index 038c98b..fbbfb2a 100644
--- a/tests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java
+++ b/tests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java
@@ -31,6 +31,7 @@
import static org.mockito.Mockito.when;
import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.PathInterpolator;
@@ -42,6 +43,8 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
/**
@@ -56,9 +59,11 @@
@Spy
FastBitmapDrawable mFastBitmapDrawable =
spy(new FastBitmapDrawable(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888)));
+ @Mock Drawable mBadge;
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
FastBitmapDrawable.setFlagHoverEnabled(true);
when(mFastBitmapDrawable.isVisible()).thenReturn(true);
mFastBitmapDrawable.mIsPressed = false;
@@ -326,4 +331,15 @@
assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), 1f, EPSILON);
verify(mFastBitmapDrawable).invalidateSelf();
}
+
+ @Test
+ public void testUpdateBadgeAlpha() {
+ mFastBitmapDrawable.setBadge(mBadge);
+
+ mFastBitmapDrawable.setAlpha(1);
+ mFastBitmapDrawable.setAlpha(0);
+
+ verify(mBadge).setAlpha(1);
+ verify(mBadge).setAlpha(0);
+ }
}
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index f4a00e8..56a74a9 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -49,7 +49,6 @@
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.Until;
-import com.android.launcher3.Flags;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
@@ -207,16 +206,9 @@
@Rule
public SetFlagsRule mSetFlagsRule = getFlagsRule();
- // TODO(b/301555714): Remove when SetFlagsRule initializes flags to their default values.
private SetFlagsRule getFlagsRule() {
SetFlagsRule flagsRule = new SetFlagsRule();
- flagsRule.disableFlags(
- Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW,
- Flags.FLAG_ENABLE_OVERVIEW_ICON_MENU,
- Flags.FLAG_ENABLE_RESPONSIVE_WORKSPACE,
- Flags.FLAG_ENABLE_CURSOR_HOVER_STATES,
- Flags.FLAG_ENABLE_TWOLINE_ALLAPPS,
- Flags.FLAG_ENABLE_EXPANDING_PAUSE_WORK_BUTTON);
+ flagsRule.initAllFlagsToReleaseConfigDefault();
return flagsRule;
}
diff --git a/tests/src/com/android/launcher3/ui/BubbleTextViewTest.java b/tests/src/com/android/launcher3/ui/BubbleTextViewTest.java
index 6c2950c..b019414 100644
--- a/tests/src/com/android/launcher3/ui/BubbleTextViewTest.java
+++ b/tests/src/com/android/launcher3/ui/BubbleTextViewTest.java
@@ -97,9 +97,7 @@
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_TWOLINE_ALLAPPS);
- mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_CURSOR_HOVER_STATES);
- mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_OVERVIEW_ICON_MENU);
+ mSetFlagsRule.initAllFlagsToReleaseConfigDefault();
Utilities.enableRunningInTestHarnessForTests();
mContext = new ActivityContextWrapper(getApplicationContext());
mBubbleTextView = new BubbleTextView(mContext);
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 799ef5b..f2cbd92 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -23,7 +23,6 @@
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.LauncherState;
-import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import org.junit.Before;
import org.junit.Test;
@@ -32,11 +31,6 @@
@LargeTest
@RunWith(AndroidJUnit4.class)
public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
- public static final String APP_NAME = "LauncherTestApp";
- public static final String DUMMY_APP_NAME = "Aardwolf";
- public static final String MAPS_APP_NAME = "Maps";
- public static final String STORE_APP_NAME = "Play Store";
- public static final String GMAIL_APP_NAME = "Gmail";
@Before
public void setUp() throws Exception {
diff --git a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java
index d8ae99c..d776f21 100644
--- a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java
@@ -16,6 +16,7 @@
package com.android.launcher3.ui.workspace;
import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.util.TestConstants.AppNames.CHROME_APP_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -85,7 +86,8 @@
isWorkspaceScrollable(launcher)));
assertEquals("Initial workspace doesn't have the correct page", workspace.pagesPerScreen(),
workspace.getPageCount());
- workspace.verifyWorkspaceAppIconIsGone("Chrome app was found on empty workspace", "Chrome");
+ workspace.verifyWorkspaceAppIconIsGone("Chrome app was found on empty workspace",
+ CHROME_APP_NAME);
workspace.ensureWorkspaceIsScrollable();
executeOnLauncher(
@@ -96,7 +98,7 @@
launcher -> assertTrue("ensureScrollable didn't make workspace scrollable",
isWorkspaceScrollable(launcher)));
assertNotNull("ensureScrollable didn't add Chrome app",
- workspace.getWorkspaceAppIcon("Chrome"));
+ workspace.getWorkspaceAppIcon(CHROME_APP_NAME));
// Test flinging workspace.
workspace.flingBackward();
@@ -112,7 +114,7 @@
assertTrue("Launcher internal state is not Home", isInState(() -> LauncherState.NORMAL));
// Test starting a workspace app.
- final HomeAppIcon app = workspace.getWorkspaceAppIcon("Chrome");
+ final HomeAppIcon app = workspace.getWorkspaceAppIcon(CHROME_APP_NAME);
assertNotNull("No Chrome app in workspace", app);
}
diff --git a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
index 8e5e9cc..34c7707 100644
--- a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.ui.workspace;
+import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -51,7 +53,6 @@
public class ThemeIconsTest extends AbstractLauncherUiTest {
private static final String APP_NAME = "IconThemedActivity";
- private static final String SHORTCUT_APP_NAME = "LauncherTestApp";
private static final String SHORTCUT_NAME = "Shortcut 1";
@Test
@@ -81,7 +82,7 @@
allApps.freeze();
try {
- HomeAppIcon icon = allApps.getAppIcon(SHORTCUT_APP_NAME);
+ HomeAppIcon icon = allApps.getAppIcon(TEST_APP_NAME);
HomeAppIconMenuItem shortcutItem =
(HomeAppIconMenuItem) icon.openDeepShortcutMenu().getMenuItem(SHORTCUT_NAME);
shortcutItem.dragToWorkspace(false, false);
@@ -118,7 +119,7 @@
allApps.freeze();
try {
- HomeAppIcon icon = allApps.getAppIcon(SHORTCUT_APP_NAME);
+ HomeAppIcon icon = allApps.getAppIcon(TEST_APP_NAME);
HomeAppIconMenuItem shortcutItem =
(HomeAppIconMenuItem) icon.openDeepShortcutMenu().getMenuItem(SHORTCUT_NAME);
shortcutItem.dragToWorkspace(false, false);
diff --git a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
index 00e00fa..35b4883 100644
--- a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
@@ -16,6 +16,11 @@
package com.android.launcher3.ui.workspace;
+import static com.android.launcher3.util.TestConstants.AppNames.CHROME_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.MESSAGES_APP_NAME;
+import static com.android.launcher3.util.TestConstants.AppNames.STORE_APP_NAME;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -76,7 +81,7 @@
executeOnLauncher(launcher -> {
launcher.enableHotseatEdu(false);
assertPagesExist(launcher, 0, 1);
- assertItemsOnPage(launcher, 0, "Play Store", "Maps");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME, MAPS_APP_NAME);
assertPageEmpty(launcher, 1);
});
}
@@ -94,12 +99,12 @@
public void testDragIconToRightPanel() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 1);
+ workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
- assertItemsOnPage(launcher, 0, "Maps", "Play Store");
- assertItemsOnPage(launcher, 1, "Chrome");
+ assertItemsOnPage(launcher, 0, MAPS_APP_NAME, STORE_APP_NAME);
+ assertItemsOnPage(launcher, 1, CHROME_APP_NAME);
});
}
@@ -108,52 +113,52 @@
public void testSinglePageDragIconWhenMultiplePageScrollingIsPossible() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 2);
+ workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 2);
workspace.flingBackward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
- assertItemsOnPage(launcher, 2, "Chrome");
- assertItemsOnPage(launcher, 3, "Maps");
+ assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
+ assertItemsOnPage(launcher, 3, MAPS_APP_NAME);
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
- assertItemsOnPage(launcher, 2, "Chrome");
+ assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
assertPageEmpty(launcher, 3);
assertPageEmpty(launcher, 4);
- assertItemsOnPage(launcher, 5, "Maps");
+ assertItemsOnPage(launcher, 5, MAPS_APP_NAME);
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), -1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
- assertItemsOnPage(launcher, 2, "Chrome");
- assertItemsOnPage(launcher, 3, "Maps");
+ assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
+ assertItemsOnPage(launcher, 3, MAPS_APP_NAME);
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), -1);
workspace.flingForward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Chrome"), -2);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(CHROME_APP_NAME), -2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
- assertItemsOnPage(launcher, 0, "Chrome", "Play Store");
- assertItemsOnPage(launcher, 1, "Maps");
+ assertItemsOnPage(launcher, 0, CHROME_APP_NAME, STORE_APP_NAME);
+ assertItemsOnPage(launcher, 1, MAPS_APP_NAME);
});
}
@@ -162,13 +167,13 @@
public void testDragIconToPage2() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
- assertItemsOnPage(launcher, 2, "Maps");
+ assertItemsOnPage(launcher, 2, MAPS_APP_NAME);
assertPageEmpty(launcher, 3);
});
}
@@ -179,14 +184,14 @@
Workspace workspace = mLauncher.getWorkspace();
// b/299522368 sometimes the phone app is not present in the hotseat.
- workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 3);
+ workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store", "Maps");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME, MAPS_APP_NAME);
assertPageEmpty(launcher, 1);
assertPageEmpty(launcher, 2);
- assertItemsOnPage(launcher, 3, "Chrome");
+ assertItemsOnPage(launcher, 3, CHROME_APP_NAME);
});
}
@@ -195,44 +200,44 @@
public void testMultiplePageDragIcon() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getHotseatAppIcon("Messages"), 2);
+ workspace.dragIcon(workspace.getHotseatAppIcon(MESSAGES_APP_NAME), 2);
workspace.flingBackward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 5);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 5);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
- assertItemsOnPage(launcher, 2, "Messages");
+ assertItemsOnPage(launcher, 2, MESSAGES_APP_NAME);
assertPageEmpty(launcher, 3);
assertPageEmpty(launcher, 4);
- assertItemsOnPage(launcher, 5, "Maps");
+ assertItemsOnPage(launcher, 5, MAPS_APP_NAME);
});
workspace.flingBackward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Messages"), 4);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MESSAGES_APP_NAME), 4);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 4, 5, 6, 7);
- assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
assertPageEmpty(launcher, 4);
- assertItemsOnPage(launcher, 5, "Maps");
- assertItemsOnPage(launcher, 6, "Messages");
+ assertItemsOnPage(launcher, 5, MAPS_APP_NAME);
+ assertItemsOnPage(launcher, 6, MESSAGES_APP_NAME);
assertPageEmpty(launcher, 7);
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Messages"), -3);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MESSAGES_APP_NAME), -3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store");
- assertItemsOnPage(launcher, 1, "Messages");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
+ assertItemsOnPage(launcher, 1, MESSAGES_APP_NAME);
assertPageEmpty(launcher, 4);
- assertItemsOnPage(launcher, 5, "Maps");
+ assertItemsOnPage(launcher, 5, MAPS_APP_NAME);
});
}
@@ -241,38 +246,38 @@
public void testEmptyPageDoesNotGetRemovedIfPagePairIsNotEmpty() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 3);
- workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 0);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 3);
+ workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 0);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
- assertItemsOnPage(launcher, 2, "Chrome");
- assertItemsOnPage(launcher, 3, "Maps");
+ assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
+ assertItemsOnPage(launcher, 3, MAPS_APP_NAME);
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), -1);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), -1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store");
- assertItemsOnPage(launcher, 1, "Maps");
- assertItemsOnPage(launcher, 2, "Chrome");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
+ assertItemsOnPage(launcher, 1, MAPS_APP_NAME);
+ assertItemsOnPage(launcher, 2, CHROME_APP_NAME);
assertPageEmpty(launcher, 3);
});
// Move Chrome to the right panel as well, to make sure pages are not deleted whichever
// page is the empty one
workspace.flingForward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Chrome"), 1);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(CHROME_APP_NAME), 1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Play Store");
- assertItemsOnPage(launcher, 1, "Maps");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
+ assertItemsOnPage(launcher, 1, MAPS_APP_NAME);
assertPageEmpty(launcher, 2);
- assertItemsOnPage(launcher, 3, "Chrome");
+ assertItemsOnPage(launcher, 3, CHROME_APP_NAME);
});
}
@@ -281,25 +286,25 @@
public void testEmptyPagesGetRemovedIfBothPagesAreEmpty() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Play Store"), 2);
- workspace.dragIcon(workspace.getHotseatAppIcon("Chrome"), 1);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(STORE_APP_NAME), 2);
+ workspace.dragIcon(workspace.getHotseatAppIcon(CHROME_APP_NAME), 1);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3);
- assertItemsOnPage(launcher, 0, "Maps");
+ assertItemsOnPage(launcher, 0, MAPS_APP_NAME);
assertPageEmpty(launcher, 1);
- assertItemsOnPage(launcher, 2, "Play Store");
- assertItemsOnPage(launcher, 3, "Chrome");
+ assertItemsOnPage(launcher, 2, STORE_APP_NAME);
+ assertItemsOnPage(launcher, 3, CHROME_APP_NAME);
});
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Chrome"), -1);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(CHROME_APP_NAME), -1);
workspace.flingForward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Play Store"), -2);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(STORE_APP_NAME), -2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1);
- assertItemsOnPage(launcher, 0, "Play Store", "Maps");
- assertItemsOnPage(launcher, 1, "Chrome");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME, MAPS_APP_NAME);
+ assertItemsOnPage(launcher, 1, CHROME_APP_NAME);
});
}
@@ -308,28 +313,28 @@
public void testMiddleEmptyPagesGetRemoved() {
Workspace workspace = mLauncher.getWorkspace();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
- workspace.dragIcon(workspace.getHotseatAppIcon("Messages"), 3);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 2);
+ workspace.dragIcon(workspace.getHotseatAppIcon(MESSAGES_APP_NAME), 3);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 2, 3, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
- assertItemsOnPage(launcher, 2, "Maps");
+ assertItemsOnPage(launcher, 2, MAPS_APP_NAME);
assertPageEmpty(launcher, 3);
assertPageEmpty(launcher, 4);
- assertItemsOnPage(launcher, 5, "Messages");
+ assertItemsOnPage(launcher, 5, MESSAGES_APP_NAME);
});
workspace.flingBackward();
- workspace.dragIcon(workspace.getWorkspaceAppIcon("Maps"), 2);
+ workspace.dragIcon(workspace.getWorkspaceAppIcon(MAPS_APP_NAME), 2);
executeOnLauncher(launcher -> {
assertPagesExist(launcher, 0, 1, 4, 5);
- assertItemsOnPage(launcher, 0, "Play Store");
+ assertItemsOnPage(launcher, 0, STORE_APP_NAME);
assertPageEmpty(launcher, 1);
- assertItemsOnPage(launcher, 4, "Maps");
- assertItemsOnPage(launcher, 5, "Messages");
+ assertItemsOnPage(launcher, 4, MAPS_APP_NAME);
+ assertItemsOnPage(launcher, 5, MESSAGES_APP_NAME);
});
}
diff --git a/tests/src/com/android/launcher3/util/TestConstants.java b/tests/src/com/android/launcher3/util/TestConstants.java
new file mode 100644
index 0000000..6f3c63a
--- /dev/null
+++ b/tests/src/com/android/launcher3/util/TestConstants.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2023 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.util;
+
+public class TestConstants {
+ public static class AppNames {
+
+ public static final String TEST_APP_NAME = "LauncherTestApp";
+ public static final String DUMMY_APP_NAME = "Aardwolf";
+ public static final String MAPS_APP_NAME = "Maps";
+ public static final String STORE_APP_NAME = "Play Store";
+ public static final String GMAIL_APP_NAME = "Gmail";
+ public static final String CHROME_APP_NAME = "Chrome";
+ public static final String MESSAGES_APP_NAME = "Messages";
+ }
+}
diff --git a/tests/src/com/android/launcher3/util/rule/ViewCaptureRule.kt b/tests/src/com/android/launcher3/util/rule/ViewCaptureRule.kt
index ccbae4f..e70ea18 100644
--- a/tests/src/com/android/launcher3/util/rule/ViewCaptureRule.kt
+++ b/tests/src/com/android/launcher3/util/rule/ViewCaptureRule.kt
@@ -132,7 +132,9 @@
for (i in 0 until viewCaptureData!!.windowDataCount) {
frameCount += viewCaptureData!!.getWindowData(i).frameDataCount
}
- assertTrue("Empty ViewCapture data", frameCount > 0)
+
+ val mayProduceNoFrames = description.getAnnotation(MayProduceNoFrames::class.java) != null
+ assertTrue("Empty ViewCapture data", mayProduceNoFrames || frameCount > 0)
val anomalies: Map<String, String> = ViewCaptureAnalyzer.getAnomalies(viewCaptureData)
if (!anomalies.isEmpty()) {
@@ -159,4 +161,8 @@
)
}
}
+
+ @Retention(AnnotationRetention.RUNTIME)
+ @Target(AnnotationTarget.FUNCTION)
+ annotation class MayProduceNoFrames
}
diff --git a/tests/src/com/android/launcher3/util/viewcapture_analysis/PositionJumpDetector.java b/tests/src/com/android/launcher3/util/viewcapture_analysis/PositionJumpDetector.java
index a1ddcb0..5f2c68c 100644
--- a/tests/src/com/android/launcher3/util/viewcapture_analysis/PositionJumpDetector.java
+++ b/tests/src/com/android/launcher3/util/viewcapture_analysis/PositionJumpDetector.java
@@ -46,7 +46,7 @@
DRAG_LAYER + "WidgetsTwoPaneSheet|SpringRelativeLayout:id/container",
DRAG_LAYER + "WidgetsFullSheet|SpringRelativeLayout:id/container",
DRAG_LAYER + "LauncherDragView",
- RECENTS_DRAG_LAYER + "FallbackRecentsView:id/overview_panel|TaskView",
+ RECENTS_DRAG_LAYER + "FallbackRecentsView:id/overview_panel",
CONTENT + "LauncherRootView:id/launcher|FloatingIconView",
DRAG_LAYER + "FloatingTaskView",
DRAG_LAYER + "LauncherRecentsView:id/overview_panel"
diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java
index 9f8fb92..efeb5f6 100644
--- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java
+++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java
@@ -54,13 +54,13 @@
private static final int STASHED_TASKBAR_BOTTOM_EDGE_DP = 1;
private final Condition<UiDevice, Boolean> mStashedTaskbarHintScaleCondition =
- device -> mLauncher.getTestInfo(REQUEST_STASHED_TASKBAR_SCALE).getFloat(
- TestProtocol.TEST_INFO_RESPONSE_FIELD) - UNSTASHED_TASKBAR_HANDLE_HINT_SCALE
+ device -> Math.abs(mLauncher.getTestInfo(REQUEST_STASHED_TASKBAR_SCALE).getFloat(
+ TestProtocol.TEST_INFO_RESPONSE_FIELD) - UNSTASHED_TASKBAR_HANDLE_HINT_SCALE)
< 0.00001f;
private final Condition<UiDevice, Boolean> mStashedTaskbarDefaultScaleCondition =
- device -> mLauncher.getTestInfo(REQUEST_STASHED_TASKBAR_SCALE).getFloat(
- TestProtocol.TEST_INFO_RESPONSE_FIELD) - 1f < 0.00001f;
+ device -> Math.abs(mLauncher.getTestInfo(REQUEST_STASHED_TASKBAR_SCALE).getFloat(
+ TestProtocol.TEST_INFO_RESPONSE_FIELD) - 1f) < 0.00001f;
LaunchedAppState(LauncherInstrumentation launcher) {
super(launcher);
@@ -284,7 +284,8 @@
Point stashedTaskbarHintArea = new Point(mLauncher.getRealDisplaySize().x / 2,
mLauncher.getRealDisplaySize().y - 1);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_ENTER,
- new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), null);
+ new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), null,
+ InputDevice.SOURCE_MOUSE);
mLauncher.getDevice().wait(mStashedTaskbarHintScaleCondition,
LauncherInstrumentation.WAIT_TIME_MS);
@@ -296,7 +297,7 @@
mLauncher.getRealDisplaySize().y - 500);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT,
new Point(outsideStashedTaskbarHintArea.x, outsideStashedTaskbarHintArea.y),
- null);
+ null, InputDevice.SOURCE_MOUSE);
mLauncher.getDevice().wait(mStashedTaskbarDefaultScaleCondition,
LauncherInstrumentation.WAIT_TIME_MS);
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index d7f9c78..307f192 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -27,6 +27,7 @@
import static com.android.launcher3.tapl.Folder.FOLDER_CONTENT_RES_ID;
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
+import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_NUM_ALL_APPS_COLUMNS;
import android.app.ActivityManager;
import android.app.Instrumentation;
@@ -353,6 +354,11 @@
.getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
+ public int getNumAllAppsColumns() {
+ return getTestInfo(REQUEST_NUM_ALL_APPS_COLUMNS).getInt(
+ TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ }
+
public boolean isTablet() {
return getTestInfo(TestProtocol.REQUEST_IS_TABLET)
.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);