Merge "Revert regression where we no longer reverse translation for RTL" into ub-launcher3-rvc-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
index f907089..78cc2dc 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
@@ -200,6 +200,7 @@
pageId = LauncherSettings.Settings.call(mLauncher.getContentResolver(),
LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
.getInt(LauncherSettings.Settings.EXTRA_VALUE);
+ mNewScreens = IntArray.wrap(pageId);
}
for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) {
View child = mHotseat.getChildAt(i, 0);
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java
index 4213740..fa137f8 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java
@@ -33,6 +33,7 @@
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
+import com.android.launcher3.Workspace;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.UserEventDispatcher;
@@ -153,6 +154,12 @@
private void logUserAction(boolean migrated, int pageIndex) {
LauncherLogProto.Action action = new LauncherLogProto.Action();
LauncherLogProto.Target target = new LauncherLogProto.Target();
+
+ int hotseatItemsCount = mLauncher.getHotseat().getShortcutsAndWidgets().getChildCount();
+ // -1 to exclude smart space
+ int workspaceItemCount = mLauncher.getWorkspace().getScreenWithId(
+ Workspace.FIRST_SCREEN_ID).getShortcutsAndWidgets().getChildCount() - 1;
+
action.type = LauncherLogProto.Action.Type.TOUCH;
action.touch = LauncherLogProto.Action.Touch.TAP;
target.containerType = LauncherLogProto.ContainerType.TIP;
@@ -162,7 +169,7 @@
target.rank = MIGRATION_EXPERIMENT_IDENTIFIER;
// encoding migration type on pageIndex
target.pageIndex = pageIndex;
- target.cardinality = HotseatPredictionController.MAX_ITEMS_FOR_MIGRATION;
+ target.cardinality = (workspaceItemCount * 1000) + hotseatItemsCount;
LauncherLogProto.LauncherEvent event = newLauncherEvent(action, target);
UserEventDispatcher.newInstance(getContext()).dispatchUserEvent(event, null);
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
index 7c00287..077a1ad 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
@@ -31,6 +31,7 @@
import android.app.prediction.AppTargetId;
import android.content.ComponentName;
import android.os.Bundle;
+import android.os.Process;
import android.provider.DeviceConfig;
import android.util.Log;
import android.view.View;
@@ -40,6 +41,7 @@
import androidx.annotation.Nullable;
import com.android.launcher3.BubbleTextView;
+import com.android.launcher3.CellLayout;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.Hotseat;
@@ -63,6 +65,7 @@
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
+import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.shortcuts.ShortcutKey;
@@ -76,6 +79,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.OptionalInt;
import java.util.stream.IntStream;
@@ -91,9 +95,6 @@
private static final String TAG = "PredictiveHotseat";
private static final boolean DEBUG = false;
- public static final int MAX_ITEMS_FOR_MIGRATION = DeviceConfig.getInt(
- DeviceFlag.NAMESPACE_LAUNCHER, "max_homepage_items_for_migration", 5);
-
//TODO: replace this with AppTargetEvent.ACTION_UNPIN (b/144119543)
private static final int APPTARGET_ACTION_UNPIN = 4;
@@ -103,6 +104,8 @@
private static final String BUNDLE_KEY_HOTSEAT = "hotseat_apps";
private static final String BUNDLE_KEY_WORKSPACE = "workspace_apps";
+ private static final String BUNDLE_KEY_PIN_EVENTS = "pin_events";
+
private static final String PREDICTION_CLIENT = "hotseat";
private DropTarget.DragObject mDragObject;
private int mHotSeatItemsCount;
@@ -296,15 +299,45 @@
private Bundle getAppPredictionContextExtra() {
Bundle bundle = new Bundle();
+
+ //TODO: remove this way of reporting items
bundle.putParcelableArrayList(BUNDLE_KEY_HOTSEAT,
getPinnedAppTargetsInViewGroup((mHotseat.getShortcutsAndWidgets())));
bundle.putParcelableArrayList(BUNDLE_KEY_WORKSPACE, getPinnedAppTargetsInViewGroup(
mLauncher.getWorkspace().getScreenWithId(
Workspace.FIRST_SCREEN_ID).getShortcutsAndWidgets()));
+ ArrayList<AppTargetEvent> pinEvents = new ArrayList<>();
+ getPinEventsForViewGroup(pinEvents, mHotseat.getShortcutsAndWidgets(),
+ APP_LOCATION_HOTSEAT);
+ getPinEventsForViewGroup(pinEvents, mLauncher.getWorkspace().getScreenWithId(
+ Workspace.FIRST_SCREEN_ID).getShortcutsAndWidgets(), APP_LOCATION_WORKSPACE);
+ bundle.putParcelableArrayList(BUNDLE_KEY_PIN_EVENTS, pinEvents);
+
return bundle;
}
+ private ArrayList<AppTargetEvent> getPinEventsForViewGroup(ArrayList<AppTargetEvent> pinEvents,
+ ViewGroup views, String root) {
+ for (int i = 0; i < views.getChildCount(); i++) {
+ View child = views.getChildAt(i);
+ final AppTargetEvent event;
+ if (child.getTag() instanceof ItemInfo && getAppTargetFromInfo(
+ (ItemInfo) child.getTag()) != null) {
+ ItemInfo info = (ItemInfo) child.getTag();
+ event = wrapAppTargetWithLocation(getAppTargetFromInfo(info),
+ AppTargetEvent.ACTION_PIN, info);
+ } else {
+ CellLayout.LayoutParams params = (CellLayout.LayoutParams) views.getLayoutParams();
+ event = wrapAppTargetWithLocation(getBlockAppTarget(), AppTargetEvent.ACTION_PIN,
+ root, 0, params.cellX, params.cellY, params.cellHSpan, params.cellVSpan);
+ }
+ pinEvents.add(event);
+ }
+ return pinEvents;
+ }
+
+
private ArrayList<AppTarget> getPinnedAppTargetsInViewGroup(ViewGroup viewGroup) {
ArrayList<AppTarget> pinnedApps = new ArrayList<>();
for (int i = 0; i < viewGroup.getChildCount(); i++) {
@@ -606,6 +639,9 @@
if (isReady()) return;
int hotseatItemsCount = mHotseat.getShortcutsAndWidgets().getChildCount();
+ int maxItems = DeviceConfig.getInt(
+ DeviceFlag.NAMESPACE_LAUNCHER, "max_homepage_items_for_migration", 5);
+
// -1 to exclude smart space
int workspaceItemCount = mLauncher.getWorkspace().getScreenWithId(
Workspace.FIRST_SCREEN_ID).getShortcutsAndWidgets().getChildCount() - 1;
@@ -614,7 +650,7 @@
// open spots in their hotseat and have more than maxItems in their hotseat + workspace
if (hotseatItemsCount == mHotSeatItemsCount && workspaceItemCount + hotseatItemsCount
- > MAX_ITEMS_FOR_MIGRATION) {
+ > maxItems) {
mLauncher.getSharedPrefs().edit().putBoolean(HotseatEduController.KEY_HOTSEAT_EDU_SEEN,
true).apply();
@@ -626,8 +662,8 @@
// temporarily encode details in log target (go/hotseat_migration)
target.rank = 2;
- target.cardinality = MAX_ITEMS_FOR_MIGRATION;
- target.pageIndex = (workspaceItemCount * 1000) + hotseatItemsCount;
+ target.cardinality = (workspaceItemCount * 1000) + hotseatItemsCount;
+ target.pageIndex = maxItems;
LauncherLogProto.LauncherEvent event = newLauncherEvent(action, target);
UserEventDispatcher.newInstance(mLauncher).dispatchUserEvent(event, null);
@@ -689,4 +725,52 @@
return new AppTarget.Builder(new AppTargetId("app:" + cn.getPackageName()),
cn.getPackageName(), info.user).setClassName(cn.getClassName()).build();
}
+
+ private AppTarget getAppTargetFromInfo(ItemInfo info) {
+ if (info == null) return null;
+ if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET
+ && info instanceof LauncherAppWidgetInfo
+ && ((LauncherAppWidgetInfo) info).providerName != null) {
+ ComponentName cn = ((LauncherAppWidgetInfo) info).providerName;
+ return new AppTarget.Builder(new AppTargetId("widget:" + cn.getPackageName()),
+ cn.getPackageName(), info.user).setClassName(cn.getClassName()).build();
+ } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
+ && info.getTargetComponent() != null) {
+ ComponentName cn = info.getTargetComponent();
+ return new AppTarget.Builder(new AppTargetId("app:" + cn.getPackageName()),
+ cn.getPackageName(), info.user).setClassName(cn.getClassName()).build();
+ } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT
+ && info instanceof WorkspaceItemInfo) {
+ ShortcutKey shortcutKey = ShortcutKey.fromItemInfo(info);
+ //TODO: switch to using full shortcut info
+ return new AppTarget.Builder(new AppTargetId("shortcut:" + shortcutKey.getId()),
+ shortcutKey.componentName.getPackageName(), shortcutKey.user).build();
+ } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
+ return new AppTarget.Builder(new AppTargetId("folder:" + info.id),
+ mLauncher.getPackageName(), info.user).build();
+ }
+ return null;
+ }
+
+ private AppTargetEvent wrapAppTargetWithLocation(AppTarget target, int action, ItemInfo info) {
+ return wrapAppTargetWithLocation(target, action,
+ info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT
+ ? APP_LOCATION_HOTSEAT : APP_LOCATION_WORKSPACE, info.screenId, info.cellX,
+ info.cellY, info.spanX, info.spanY);
+ }
+
+ private AppTargetEvent wrapAppTargetWithLocation(AppTarget target, int action, String root,
+ int screenId, int x, int y, int spanX, int spanY) {
+ return new AppTargetEvent.Builder(target, action).setLaunchLocation(
+ String.format(Locale.ENGLISH, "%s/%d/[%d,%d]/[%d,%d]", root, screenId, x, y, spanX,
+ spanY)).build();
+ }
+
+ /**
+ * A helper method to generate an AppTarget that's used to communicate workspace layout
+ */
+ private AppTarget getBlockAppTarget() {
+ return new AppTarget.Builder(new AppTargetId("block"),
+ mLauncher.getPackageName(), Process.myUserHandle()).build();
+ }
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java
index 70880eb..8af26c6 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java
@@ -136,9 +136,11 @@
@Override
public void addSupportedAccessibilityActions(AccessibilityNodeInfo accessibilityNodeInfo) {
- accessibilityNodeInfo.addAction(
- new AccessibilityNodeInfo.AccessibilityAction(PIN_PREDICTION,
- getContext().getText(R.string.pin_prediction)));
+ if (!mIsPinned) {
+ accessibilityNodeInfo.addAction(
+ new AccessibilityNodeInfo.AccessibilityAction(PIN_PREDICTION,
+ getContext().getText(R.string.pin_prediction)));
+ }
}
@Override
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
index 85741ed..70b139d 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
@@ -197,33 +197,18 @@
}
protected void startNewTask(int successStateFlag, Consumer<Boolean> resultCallback) {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_START_FROM_RECENTS, "startNewTask1");
- }
// Launch the task user scrolled to (mRecentsView.getNextPage()).
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
// We finish recents animation inside launchTask() when live tile is enabled.
mRecentsView.getNextPageTaskView().launchTask(false /* animate */,
true /* freezeTaskList */);
} else {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_START_FROM_RECENTS, "startNewTask2");
- }
int taskId = mRecentsView.getNextPageTaskView().getTask().key.id;
mFinishingRecentsAnimationForNewTaskId = taskId;
mRecentsAnimationController.finish(true /* toRecents */, () -> {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_START_FROM_RECENTS, "onFinishComplete1");
- }
if (!mCanceled) {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_START_FROM_RECENTS, "onFinishComplete2");
- }
TaskView nextTask = mRecentsView.getTaskView(taskId);
if (nextTask != null) {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_START_FROM_RECENTS, "onFinishComplete3");
- }
nextTask.launchTask(false /* animate */, true /* freezeTaskList */,
success -> {
resultCallback.accept(success);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java
index 1bd0333..8574cf1 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java
@@ -965,9 +965,6 @@
windowAnim.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_START_FROM_RECENTS, "onAnimationSuccess");
- }
if (mRecentsAnimationController == null) {
// If the recents animation is interrupted, we still end the running
// animation (not canceled) so this is still called. In that case, we can
@@ -1191,9 +1188,6 @@
}
private void switchToScreenshot() {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_START_FROM_RECENTS, "switchToScreenshot");
- }
final int runningTaskId = mGestureState.getRunningTaskId();
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
if (mRecentsAnimationController != null) {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index 7979601..2c2feb2 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -58,7 +58,6 @@
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.model.AppLaunchTracker;
@@ -68,6 +67,7 @@
import com.android.launcher3.tracing.nano.LauncherTraceProto;
import com.android.launcher3.tracing.nano.TouchInteractionServiceProto;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
+import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.inputconsumers.AccessibilityInputConsumer;
import com.android.quickstep.inputconsumers.AssistantInputConsumer;
@@ -378,7 +378,7 @@
if (!sharedPrefs.getBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)) {
sharedPrefs.edit()
.putBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)
- .putBoolean(DiscoveryBounce.HOME_BOUNCE_SEEN, false)
+ .putBoolean(OnboardingPrefs.HOME_BOUNCE_SEEN, false)
.apply();
}
}
@@ -539,6 +539,8 @@
boolean canStartSystemGesture = mDeviceState.canStartSystemGesture();
if (!mDeviceState.isUserUnlocked()) {
+ Log.d(TAG, "User locked. Can start system gesture? " + canStartSystemGesture
+ + " sysUiFlags: " + mDeviceState.getSystemUiStateFlags());
if (canStartSystemGesture) {
// This handles apps launched in direct boot mode (e.g. dialer) as well as apps
// launched while device is locked even after exiting direct boot mode (e.g. camera).
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index b46d6f6..a18f7ba 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -849,7 +849,8 @@
final int pageCount = getPageCount();
for (int i = 0; i < pageCount; i++) {
View page = getPageAt(i);
- mScrollState.updateInterpolation(mOrientationHandler.getChildStart(page), mPageSpacing);
+ mScrollState.updateInterpolation(mOrientationHandler.getChildStartWithTranslation(page),
+ mPageSpacing);
((PageCallbacks) page).onPageScroll(mScrollState);
}
}
@@ -1236,7 +1237,7 @@
/**
* Updates linearInterpolation for the provided child position
*/
- public void updateInterpolation(int childStart, int pageSpacing) {
+ public void updateInterpolation(float childStart, int pageSpacing) {
float pageCenter = childStart + halfPageSize;
float distanceFromScreenCenter = screenCenter - pageCenter;
float distanceToReachEdge = halfScreenSize + halfPageSize + pageSpacing;
diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
index 69400b3..48e25bd 100644
--- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
@@ -17,14 +17,7 @@
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON;
-import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
-import static com.android.launcher3.LauncherState.OVERVIEW;
-import static com.android.launcher3.allapps.DiscoveryBounce.BOUNCE_MAX_COUNT;
-import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_COUNT;
-import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_SEEN;
-import static com.android.launcher3.allapps.DiscoveryBounce.SHELF_BOUNCE_COUNT;
-import static com.android.launcher3.allapps.DiscoveryBounce.SHELF_BOUNCE_SEEN;
import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;
@@ -32,6 +25,7 @@
import android.animation.ValueAnimator;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.view.View;
@@ -47,12 +41,14 @@
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.uioverrides.RecentsViewStateController;
+import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.UiThreadHelper;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
import com.android.quickstep.SystemUiProxy;
+import com.android.quickstep.util.QuickstepOnboardingPrefs;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.RemoteFadeOutAnimationListener;
import com.android.quickstep.util.ShelfPeekAnim;
@@ -86,45 +82,6 @@
super.onCreate(savedInstanceState);
SysUINavigationMode.INSTANCE.get(this).addModeChangeListener(this);
-
- if (!getSharedPrefs().getBoolean(HOME_BOUNCE_SEEN, false)) {
- getStateManager().addStateListener(new LauncherStateManager.StateListener() {
- @Override
- public void onStateTransitionStart(LauncherState toState) { }
-
- @Override
- public void onStateTransitionComplete(LauncherState finalState) {
- boolean swipeUpEnabled = SysUINavigationMode.INSTANCE
- .get(BaseQuickstepLauncher.this).getMode().hasGestures;
- LauncherState prevState = getStateManager().getLastState();
-
- if (((swipeUpEnabled && finalState == OVERVIEW) || (!swipeUpEnabled
- && finalState == ALL_APPS && prevState == NORMAL) || BOUNCE_MAX_COUNT
- <= getSharedPrefs().getInt(HOME_BOUNCE_COUNT, 0))) {
- getSharedPrefs().edit().putBoolean(HOME_BOUNCE_SEEN, true).apply();
- getStateManager().removeStateListener(this);
- }
- }
- });
- }
-
- if (!getSharedPrefs().getBoolean(SHELF_BOUNCE_SEEN, false)) {
- getStateManager().addStateListener(new LauncherStateManager.StateListener() {
- @Override
- public void onStateTransitionStart(LauncherState toState) { }
-
- @Override
- public void onStateTransitionComplete(LauncherState finalState) {
- LauncherState prevState = getStateManager().getLastState();
-
- if ((finalState == ALL_APPS && prevState == OVERVIEW) || BOUNCE_MAX_COUNT
- <= getSharedPrefs().getInt(SHELF_BOUNCE_COUNT, 0)) {
- getSharedPrefs().edit().putBoolean(SHELF_BOUNCE_SEEN, true).apply();
- getStateManager().removeStateListener(this);
- }
- }
- });
- }
}
@Override
@@ -244,6 +201,12 @@
}
@Override
+ protected OnboardingPrefs createOnboardingPrefs(SharedPreferences sharedPrefs,
+ LauncherStateManager stateManager) {
+ return new QuickstepOnboardingPrefs(this, sharedPrefs, stateManager);
+ }
+
+ @Override
protected ScaleAndTranslation getOverviewScaleAndTranslationForNormalState() {
if (SysUINavigationMode.getMode(this) == Mode.NO_BUTTON) {
PagedOrientationHandler layoutVertical =
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java
index 783978d..d1dbcfb 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java
@@ -91,9 +91,6 @@
RemoteAnimationTargetCompat[] appTargets,
RemoteAnimationTargetCompat[] wallpaperTargets,
Rect homeContentInsets, Rect minimizedHomeBounds) {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_START_FROM_RECENTS, "onAnimationStart");
- }
RecentsAnimationTargets targets = new RecentsAnimationTargets(appTargets,
wallpaperTargets, homeContentInsets, minimizedHomeBounds);
mController = new RecentsAnimationController(animationController,
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 8cb27a3..6dbf2b0 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -74,6 +74,8 @@
NavigationModeChangeListener,
DefaultDisplay.DisplayInfoChangeListener {
+ private static final String TAG = "RecentsAnimationDeviceState";
+
private final Context mContext;
private final SysUINavigationMode mSysUiNavMode;
private final DefaultDisplay mDefaultDisplay;
@@ -96,6 +98,7 @@
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_USER_UNLOCKED.equals(intent.getAction())) {
+ Log.d(TAG, "User Unlocked Broadcast Received");
mIsUserUnlocked = true;
notifyUserUnlocked();
}
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index b04a1ae..bbca568 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -53,9 +53,6 @@
@UiThread
public RecentsAnimationCallbacks startRecentsAnimation(GestureState gestureState,
Intent intent, RecentsAnimationCallbacks.RecentsAnimationListener listener) {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_START_FROM_RECENTS, "startRecentsAnimation");
- }
// Notify if recents animation is still running
if (mController != null) {
String msg = "New recents animation started before old animation completed";
diff --git a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
new file mode 100644
index 0000000..ab2484d
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java
@@ -0,0 +1,96 @@
+/*
+ * 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.quickstep.util;
+
+import static com.android.launcher3.LauncherState.ALL_APPS;
+import static com.android.launcher3.LauncherState.NORMAL;
+import static com.android.launcher3.LauncherState.OVERVIEW;
+
+import android.content.SharedPreferences;
+
+import com.android.launcher3.BaseQuickstepLauncher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.LauncherStateManager;
+import com.android.launcher3.LauncherStateManager.StateListener;
+import com.android.launcher3.util.OnboardingPrefs;
+import com.android.quickstep.SysUINavigationMode;
+
+/**
+ * Extends {@link OnboardingPrefs} for quickstep-specific onboarding data.
+ */
+public class QuickstepOnboardingPrefs extends OnboardingPrefs<BaseQuickstepLauncher> {
+
+ public QuickstepOnboardingPrefs(BaseQuickstepLauncher launcher, SharedPreferences sharedPrefs,
+ LauncherStateManager stateManager) {
+ super(launcher, sharedPrefs, stateManager);
+
+ if (!getBoolean(HOME_BOUNCE_SEEN)) {
+ mStateManager.addStateListener(new StateListener() {
+ @Override
+ public void onStateTransitionStart(LauncherState toState) { }
+
+ @Override
+ public void onStateTransitionComplete(LauncherState finalState) {
+ boolean swipeUpEnabled = SysUINavigationMode.INSTANCE
+ .get(mLauncher).getMode().hasGestures;
+ LauncherState prevState = mStateManager.getLastState();
+
+ if (((swipeUpEnabled && finalState == OVERVIEW) || (!swipeUpEnabled
+ && finalState == ALL_APPS && prevState == NORMAL) ||
+ hasReachedMaxCount(HOME_BOUNCE_COUNT))) {
+ mSharedPrefs.edit().putBoolean(HOME_BOUNCE_SEEN, true).apply();
+ mStateManager.removeStateListener(this);
+ }
+ }
+ });
+ }
+
+ if (!getBoolean(SHELF_BOUNCE_SEEN)) {
+ mStateManager.addStateListener(new StateListener() {
+ @Override
+ public void onStateTransitionStart(LauncherState toState) { }
+
+ @Override
+ public void onStateTransitionComplete(LauncherState finalState) {
+ LauncherState prevState = mStateManager.getLastState();
+
+ if ((finalState == ALL_APPS && prevState == OVERVIEW) ||
+ hasReachedMaxCount(SHELF_BOUNCE_COUNT)) {
+ mSharedPrefs.edit().putBoolean(SHELF_BOUNCE_SEEN, true).apply();
+ mStateManager.removeStateListener(this);
+ }
+ }
+ });
+ }
+
+ if (!hasReachedMaxCount(ALL_APPS_COUNT)) {
+ mStateManager.addStateListener(new StateListener() {
+ @Override
+ public void onStateTransitionStart(LauncherState toState) { }
+
+ @Override
+ public void onStateTransitionComplete(LauncherState finalState) {
+ if (finalState == ALL_APPS) {
+ if (incrementEventCount(ALL_APPS_COUNT)) {
+ mStateManager.removeStateListener(this);
+ mLauncher.getScrimView().updateDragHandleVisibility();
+ }
+ }
+ }
+ });
+ }
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java
index c2ccd90..f5498c9 100644
--- a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java
+++ b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java
@@ -43,6 +43,7 @@
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.uioverrides.states.OverviewState;
+import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ScrimView;
import com.android.quickstep.SysUINavigationMode;
@@ -75,6 +76,7 @@
private final float mRadius;
private final int mMaxScrimAlpha;
private final Paint mPaint;
+ private final OnboardingPrefs mOnboardingPrefs;
// Mid point where the alpha changes
private int mMidAlpha;
@@ -100,6 +102,7 @@
private boolean mRemainingScreenPathValid = false;
private Mode mSysUINavigationMode;
+ private boolean mIsTwoZoneSwipeModel;
public ShelfScrimView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -108,6 +111,7 @@
mEndAlpha = Color.alpha(mEndScrim);
mRadius = BOTTOM_CORNER_RADIUS_RATIO * Themes.getDialogCornerRadius(context);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mOnboardingPrefs = mLauncher.getOnboardingPrefs();
// Just assume the easiest UI for now, until we have the proper layout information.
mDrawingFlatColor = true;
@@ -140,9 +144,11 @@
// Show the shelf more quickly before reaching overview progress.
mBeforeMidProgressColorInterpolator = ACCEL_2;
mAfterMidProgressColorInterpolator = ACCEL;
+ mIsTwoZoneSwipeModel = FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get();
} else {
mBeforeMidProgressColorInterpolator = ACCEL;
mAfterMidProgressColorInterpolator = Interpolators.clampToProgress(ACCEL, 0.5f, 1f);
+ mIsTwoZoneSwipeModel = false;
}
}
@@ -236,9 +242,9 @@
@Override
protected boolean shouldDragHandleBeVisible() {
- boolean twoZoneSwipeModel = FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get()
- && SysUINavigationMode.removeShelfFromOverview(mLauncher);
- return twoZoneSwipeModel || super.shouldDragHandleBeVisible();
+ boolean needsAllAppsEdu = mIsTwoZoneSwipeModel
+ && !mOnboardingPrefs.hasReachedMaxCount(OnboardingPrefs.ALL_APPS_COUNT);
+ return needsAllAppsEdu || super.shouldDragHandleBeVisible();
}
@Override
diff --git a/res/layout/work_apps_paused.xml b/res/layout/work_apps_paused.xml
index f64b2d9..08e1c98 100644
--- a/res/layout/work_apps_paused.xml
+++ b/res/layout/work_apps_paused.xml
@@ -20,7 +20,7 @@
android:gravity="center">
<TextView
- style="@style/PrimaryMediumText"
+ style="@style/PrimaryHeadline"
android:textColor="?attr/workProfileOverlayTextColor"
android:id="@+id/work_apps_paused_title"
android:layout_width="wrap_content"
diff --git a/res/values/config.xml b/res/values/config.xml
index ef67613..0657b86 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -131,8 +131,8 @@
<item name="dismiss_task_trans_x_damping_ratio" type="dimen" format="float">0.5</item>
<item name="dismiss_task_trans_x_stiffness" type="dimen" format="float">1500</item>
- <item name="horizontal_spring_damping_ratio" type="dimen" format="float">0.75</item>
- <item name="horizontal_spring_stiffness" type="dimen" format="float">200</item>
+ <item name="horizontal_spring_damping_ratio" type="dimen" format="float">0.8</item>
+ <item name="horizontal_spring_stiffness" type="dimen" format="float">400</item>
<item name="swipe_up_rect_scale_damping_ratio" type="dimen" format="float">0.75</item>
<item name="swipe_up_rect_scale_stiffness" type="dimen" format="float">200</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ac04262..a9ce24c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -343,6 +343,10 @@
<string name="work_apps_paused_title">Work profile is paused</string>
<!--- body shown when user opens work apps tab while work apps are paused -->
<string name="work_apps_paused_body">Work apps can\’t send you notifications, use your battery, or access your location</string>
+ <!-- content description for paused work apps list -->
+ <string name="work_apps_paused_content_description">Work profile is paused. Work apps can\’t send you notifications, use your battery, or access your location</string>
+
+
<!-- A tip shown pointing at work toggle -->
<string name="work_switch_tip">Pause work apps and notifications</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index bc6ab45..fcc651b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -226,6 +226,9 @@
<style name="TextHeadline" parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle" />
<style name="PrimaryMediumText" parent="@android:style/TextAppearance.DeviceDefault.Medium"/>
+ <style name="PrimaryHeadline" parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle">
+ <item name="android:textStyle">bold</item>
+ </style>
<style name="TextTitle" parent="@android:style/TextAppearance.DeviceDefault" />
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 14638a1..f69940b 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -139,6 +139,7 @@
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
+import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.PendingRequestArgs;
@@ -300,6 +301,7 @@
// 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 mOnboardingPrefs;
// Activity result which needs to be processed after workspace has loaded.
private ActivityResultInfo mPendingActivityResult;
@@ -367,6 +369,8 @@
mAllAppsController = new AllAppsTransitionController(this);
mStateManager = new LauncherStateManager(this);
+ mOnboardingPrefs = createOnboardingPrefs(mSharedPrefs, mStateManager);
+
mAppWidgetManager = new WidgetManagerHelper(this);
mAppWidgetHost = new LauncherAppWidgetHost(this,
appWidgetId -> getWorkspace().removeWidget(appWidgetId));
@@ -458,6 +462,15 @@
return new LauncherOverlayManager() { };
}
+ protected OnboardingPrefs createOnboardingPrefs(SharedPreferences sharedPrefs,
+ LauncherStateManager stateManager) {
+ return new OnboardingPrefs<>(this, sharedPrefs, stateManager);
+ }
+
+ public OnboardingPrefs getOnboardingPrefs() {
+ return mOnboardingPrefs;
+ }
+
@Override
public void onPluginConnected(OverlayPlugin overlayManager, Context context) {
switchOverlay(() -> overlayManager.createOverlayManager(this, this));
@@ -2565,9 +2578,10 @@
writer.println(prefix + "\tmRotationHelper: " + mRotationHelper);
writer.println(prefix + "\tmAppWidgetHost.isListening: " + mAppWidgetHost.isListening());
- // Extra logging for b/116853349
+ // Extra logging for general debugging
mDragLayer.dump(prefix, writer);
mStateManager.dump(prefix, writer);
+ mPopupDataProvider.dump(prefix, writer);
try {
FileLog.flushAll(writer);
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index e36ae94..5343424 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -917,7 +917,7 @@
// Remember location of down touch
mDownMotionX = x;
mDownMotionY = y;
- mLastMotion = mOrientationHandler.getPrimaryDirection(ev, 0);
+ mDownMotionPrimary = mLastMotion = mOrientationHandler.getPrimaryDirection(ev, 0);
mLastMotionRemainder = 0;
mTotalMotion = 0;
mActivePointerId = ev.getPointerId(0);
@@ -1069,16 +1069,28 @@
}
}
+ /**
+ * Returns the amount of overscroll caused by the spring in {@link OverScroller}.
+ */
+ private int getSpringOverScroll(int amount) {
+ if (mScroller.isSpringing()) {
+ return amount < 0
+ ? mScroller.getCurrPos()
+ : Math.max(0, mScroller.getCurrPos() - mMaxScroll);
+ } else {
+ return 0;
+ }
+ }
+
protected void dampedOverScroll(int amount) {
- mSpringOverScroll = amount;
if (amount == 0) {
return;
}
int size = mOrientationHandler.getMeasuredSize(this);
int overScrollAmount = OverScroll.dampedScroll(amount, size);
- mSpringOverScroll = overScrollAmount;
if (mScroller.isSpringing()) {
+ mSpringOverScroll = getSpringOverScroll(amount);
invalidate();
return;
}
@@ -1090,8 +1102,8 @@
}
protected void overScroll(int amount) {
- mSpringOverScroll = amount;
if (mScroller.isSpringing()) {
+ mSpringOverScroll = getSpringOverScroll(amount);
invalidate();
return;
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 69faa49..a45c96c 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -645,8 +645,8 @@
if (!mIsWork || recyclerView == null) return;
boolean workDisabled = UserCache.INSTANCE.get(mLauncher).isAnyProfileQuietModeEnabled();
if (mWorkDisabled == workDisabled) return;
- recyclerView.setContentDescription(
- workDisabled ? mLauncher.getString(R.string.work_apps_paused_title) : null);
+ recyclerView.setContentDescription(workDisabled ? mLauncher.getString(
+ R.string.work_apps_paused_content_description) : null);
View overlayView = getOverlayView();
recyclerView.setItemAnimator(new DefaultItemAnimator());
if (workDisabled) {
diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java
index 0f0fc3a..fc29a30 100644
--- a/src/com/android/launcher3/allapps/DiscoveryBounce.java
+++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java
@@ -24,7 +24,6 @@
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorListenerAdapter;
-import android.content.SharedPreferences;
import android.os.Handler;
import android.os.UserManager;
import android.view.MotionEvent;
@@ -35,6 +34,7 @@
import com.android.launcher3.LauncherStateManager.StateListener;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.util.OnboardingPrefs;
/**
* Abstract base class of floating view responsible for showing discovery bounce animation
@@ -43,13 +43,6 @@
private static final long DELAY_MS = 450;
- public static final String HOME_BOUNCE_SEEN = "launcher.apps_view_shown";
- public static final String SHELF_BOUNCE_SEEN = "launcher.shelf_bounce_seen";
- public static final String HOME_BOUNCE_COUNT = "launcher.home_bounce_count";
- public static final String SHELF_BOUNCE_COUNT = "launcher.shelf_bounce_count";
-
- public static final int BOUNCE_MAX_COUNT = 3;
-
private final Launcher mLauncher;
private final Animator mDiscoBounceAnimation;
@@ -142,8 +135,9 @@
}
private static void showForHomeIfNeeded(Launcher launcher, boolean withDelay) {
+ OnboardingPrefs onboardingPrefs = launcher.getOnboardingPrefs();
if (!launcher.isInState(NORMAL)
- || launcher.getSharedPrefs().getBoolean(HOME_BOUNCE_SEEN, false)
+ || onboardingPrefs.getBoolean(OnboardingPrefs.HOME_BOUNCE_SEEN)
|| AbstractFloatingView.getTopOpenView(launcher) != null
|| launcher.getSystemService(UserManager.class).isDemoUser()
|| Utilities.IS_RUNNING_IN_TEST_HARNESS) {
@@ -154,7 +148,7 @@
new Handler().postDelayed(() -> showForHomeIfNeeded(launcher, false), DELAY_MS);
return;
}
- incrementHomeBounceCount(launcher);
+ onboardingPrefs.incrementEventCount(OnboardingPrefs.HOME_BOUNCE_COUNT);
new DiscoveryBounce(launcher, 0).show(HOTSEAT);
}
@@ -164,11 +158,12 @@
}
private static void showForOverviewIfNeeded(Launcher launcher, boolean withDelay) {
+ OnboardingPrefs onboardingPrefs = launcher.getOnboardingPrefs();
if (!launcher.isInState(OVERVIEW)
|| !launcher.hasBeenResumed()
|| launcher.isForceInvisible()
|| launcher.getDeviceProfile().isVerticalBarLayout()
- || launcher.getSharedPrefs().getBoolean(SHELF_BOUNCE_SEEN, false)
+ || onboardingPrefs.getBoolean(OnboardingPrefs.SHELF_BOUNCE_SEEN)
|| launcher.getSystemService(UserManager.class).isDemoUser()
|| Utilities.IS_RUNNING_IN_TEST_HARNESS) {
return;
@@ -182,7 +177,7 @@
// TODO: Move these checks to the top and call this method after invalidate handler.
return;
}
- incrementShelfBounceCount(launcher);
+ onboardingPrefs.incrementEventCount(OnboardingPrefs.SHELF_BOUNCE_COUNT);
new DiscoveryBounce(launcher, (1 - OVERVIEW.getVerticalProgress(launcher)))
.show(PREDICTION);
@@ -209,22 +204,4 @@
mController.setProgress(progress - mDelta);
}
}
-
- private static void incrementShelfBounceCount(Launcher launcher) {
- SharedPreferences sharedPrefs = launcher.getSharedPrefs();
- int count = sharedPrefs.getInt(SHELF_BOUNCE_COUNT, 0);
- if (count > BOUNCE_MAX_COUNT) {
- return;
- }
- sharedPrefs.edit().putInt(SHELF_BOUNCE_COUNT, count + 1).apply();
- }
-
- private static void incrementHomeBounceCount(Launcher launcher) {
- SharedPreferences sharedPrefs = launcher.getSharedPrefs();
- int count = sharedPrefs.getInt(HOME_BOUNCE_COUNT, 0);
- if (count > BOUNCE_MAX_COUNT) {
- return;
- }
- sharedPrefs.edit().putInt(HOME_BOUNCE_COUNT, count + 1).apply();
- }
}
diff --git a/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java
index 2515c24..2de425e 100644
--- a/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java
@@ -135,8 +135,8 @@
@Override
public void setActiveMarker(int activePage) {
updateTabTextColor(activePage);
- updateIndicatorPosition(activePage);
if (mContainerView != null && mLastActivePage != activePage) {
+ updateIndicatorPosition(activePage);
mContainerView.onTabChanged(activePage);
}
mLastActivePage = activePage;
diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java
index 05db18e..33262b6 100644
--- a/src/com/android/launcher3/allapps/WorkModeSwitch.java
+++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java
@@ -25,6 +25,8 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.ViewConfiguration;
import android.widget.Switch;
import com.android.launcher3.Insettable;
@@ -46,16 +48,28 @@
private Rect mInsets = new Rect();
+ private final float[] mTouch = new float[2];
+ private int mTouchSlop;
+
public WorkModeSwitch(Context context) {
super(context);
+ init();
}
public WorkModeSwitch(Context context, AttributeSet attrs) {
super(context, attrs);
+ init();
+
}
public WorkModeSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
+ init();
+ }
+
+ private void init() {
+ ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
+ mTouchSlop = viewConfiguration.getScaledTouchSlop();
}
@Override
@@ -73,7 +87,7 @@
private void setCheckedInternal(boolean checked) {
super.setChecked(checked);
- setCompoundDrawablesWithIntrinsicBounds(
+ setCompoundDrawablesRelativeWithIntrinsicBounds(
checked ? R.drawable.ic_corp : R.drawable.ic_corp_off, 0, 0, 0);
}
@@ -84,6 +98,25 @@
setEnabled(true);
}
+
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ mTouch[0] = ev.getX();
+ mTouch[1] = ev.getY();
+ } else if (ev.getActionMasked() == MotionEvent.ACTION_MOVE) {
+ if (Math.abs(mTouch[0] - ev.getX()) > mTouchSlop
+ || Math.abs(mTouch[1] - ev.getY()) > mTouchSlop) {
+ int action = ev.getAction();
+ ev.setAction(MotionEvent.ACTION_CANCEL);
+ super.onTouchEvent(ev);
+ ev.setAction(action);
+ return false;
+ }
+ }
+ return super.onTouchEvent(ev);
+ }
+
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
diff --git a/src/com/android/launcher3/dot/DotInfo.java b/src/com/android/launcher3/dot/DotInfo.java
index 4ff0539..fc180d1 100644
--- a/src/com/android/launcher3/dot/DotInfo.java
+++ b/src/com/android/launcher3/dot/DotInfo.java
@@ -16,6 +16,8 @@
package com.android.launcher3.dot;
+import androidx.annotation.NonNull;
+
import com.android.launcher3.notification.NotificationInfo;
import com.android.launcher3.notification.NotificationKeyData;
@@ -83,4 +85,10 @@
public int getNotificationCount() {
return Math.min(mTotalCount, MAX_COUNT);
}
+
+ @NonNull
+ @Override
+ public String toString() {
+ return Integer.toString(mTotalCount);
+ }
}
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 36c8ee2..331298f 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -51,6 +51,7 @@
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate;
import com.android.launcher3.dot.DotInfo;
@@ -397,6 +398,9 @@
} else if (view instanceof ImageView) {
// Only the system shortcut icon shows on a gray background header.
info.setIconAndContentDescriptionFor((ImageView) view);
+ if (Utilities.ATLEAST_OREO) {
+ view.setTooltipText(view.getContentDescription());
+ }
}
view.setTag(info);
view.setOnClickListener(info);
diff --git a/src/com/android/launcher3/popup/PopupDataProvider.java b/src/com/android/launcher3/popup/PopupDataProvider.java
index a6b9356..5a5f668 100644
--- a/src/com/android/launcher3/popup/PopupDataProvider.java
+++ b/src/com/android/launcher3/popup/PopupDataProvider.java
@@ -33,6 +33,7 @@
import com.android.launcher3.util.ShortcutUtil;
import com.android.launcher3.widget.WidgetListRowEntry;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -238,6 +239,11 @@
}).collect(Collectors.toList());
}
+ public void dump(String prefix, PrintWriter writer) {
+ writer.println(prefix + "PopupDataProvider:");
+ writer.println(prefix + "\tmPackageUserToDotInfos:" + mPackageUserToDotInfos);
+ }
+
public interface PopupDataChangeListener {
PopupDataChangeListener INSTANCE = new PopupDataChangeListener() { };
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index 3181752..015de59 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -100,5 +100,4 @@
public static final String NO_BACKGROUND_TO_OVERVIEW_TAG = "b/138251824";
public static final String APP_NOT_DISABLED = "b/139891609";
public static final String NO_SCROLL_END_WIDGETS = "b/152354290";
- public static final String NO_START_FROM_RECENTS = "b/152658211";
}
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index 6715bc1..bab5747 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -65,11 +65,11 @@
}
@Override
- public void getCurveProperties(PagedView view, Rect mInsets, CurveProperties out) {
+ public void getCurveProperties(PagedView view, Rect insets, CurveProperties out) {
out.scroll = view.getScrollY();
out.halfPageSize = view.getNormalChildHeight() / 2;
out.halfScreenSize = view.getMeasuredHeight() / 2;
- out.screenCenter = mInsets.top + view.getPaddingTop() + out.scroll + out.halfPageSize;
+ out.screenCenter = insets.top + view.getPaddingTop() + out.scroll + out.halfPageSize;
}
@Override
@@ -157,11 +157,6 @@
}
@Override
- public float getViewCenterPosition(View view) {
- return view.getTop() + view.getTranslationY();
- }
-
- @Override
public int getPrimaryScroll(View view) {
return view.getScrollY();
}
@@ -205,6 +200,11 @@
}
@Override
+ public float getChildStartWithTranslation(View view) {
+ return view.getTop() + view.getTranslationY();
+ }
+
+ @Override
public int getCenterForPage(View view, Rect insets) {
return (view.getPaddingLeft() + view.getMeasuredWidth() + insets.left
- insets.right - view.getPaddingRight()) / 2;
diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java
index 974e3f3..50606ec 100644
--- a/src/com/android/launcher3/touch/PagedOrientationHandler.java
+++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java
@@ -65,10 +65,10 @@
FloatProperty<View> getPrimaryViewTranslate();
FloatProperty<View> getSecondaryViewTranslate();
void setPrimaryAndResetSecondaryTranslate(View view, float translation);
- float getViewCenterPosition(View view);
int getPrimaryScroll(View view);
float getPrimaryScale(View view);
int getChildStart(View view);
+ float getChildStartWithTranslation(View view);
int getCenterForPage(View view, Rect insets);
int getScrollOffsetStart(View view, Rect insets);
int getScrollOffsetEnd(View view, Rect insets);
@@ -87,7 +87,7 @@
void delegateScrollTo(PagedView pagedView, int primaryScroll);
void delegateScrollBy(PagedView pagedView, int unboundedScroll, int x, int y);
void scrollerStartScroll(OverScroller scroller, int newPosition);
- void getCurveProperties(PagedView view, Rect mInsets, CurveProperties out);
+ void getCurveProperties(PagedView view, Rect insets, CurveProperties out);
boolean isGoingUp(float displacement);
/**
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index 6d903b3..245138f 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -65,11 +65,11 @@
}
@Override
- public void getCurveProperties(PagedView view, Rect mInsets, CurveProperties out) {
+ public void getCurveProperties(PagedView view, Rect insets, CurveProperties out) {
out.scroll = view.getScrollX();
out.halfPageSize = view.getNormalChildWidth() / 2;
out.halfScreenSize = view.getMeasuredWidth() / 2;
- out.screenCenter = mInsets.left + view.getPaddingLeft() + out.scroll + out.halfPageSize;
+ out.screenCenter = insets.left + view.getPaddingLeft() + out.scroll + out.halfPageSize;
}
@Override
@@ -155,11 +155,6 @@
}
@Override
- public float getViewCenterPosition(View view) {
- return view.getLeft() + view.getTranslationX();
- }
-
- @Override
public int getPrimaryScroll(View view) {
return view.getScrollX();
}
@@ -203,6 +198,11 @@
}
@Override
+ public float getChildStartWithTranslation(View view) {
+ return view.getLeft() + view.getTranslationX();
+ }
+
+ @Override
public int getCenterForPage(View view, Rect insets) {
return (view.getPaddingTop() + view.getMeasuredHeight() + insets.top
- insets.bottom - view.getPaddingBottom()) / 2;
diff --git a/src/com/android/launcher3/util/OnboardingPrefs.java b/src/com/android/launcher3/util/OnboardingPrefs.java
new file mode 100644
index 0000000..baa1eee
--- /dev/null
+++ b/src/com/android/launcher3/util/OnboardingPrefs.java
@@ -0,0 +1,115 @@
+/*
+ * 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.Launcher;
+import com.android.launcher3.LauncherStateManager;
+
+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.
+ */
+public class OnboardingPrefs<T extends Launcher> {
+
+ public static final String HOME_BOUNCE_SEEN = "launcher.apps_view_shown";
+ public static final String SHELF_BOUNCE_SEEN = "launcher.shelf_bounce_seen";
+ public static final String HOME_BOUNCE_COUNT = "launcher.home_bounce_count";
+ public static final String SHELF_BOUNCE_COUNT = "launcher.shelf_bounce_count";
+ public static final String ALL_APPS_COUNT = "launcher.all_apps_count";
+
+ /**
+ * Events that either have happened or have not (booleans).
+ */
+ @StringDef(value = {
+ HOME_BOUNCE_SEEN,
+ SHELF_BOUNCE_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,
+ SHELF_BOUNCE_COUNT,
+ ALL_APPS_COUNT,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface EventCountKey {}
+
+ private static final Map<String, Integer> MAX_COUNTS;
+ static {
+ Map<String, Integer> maxCounts = new ArrayMap<>(3);
+ maxCounts.put(HOME_BOUNCE_COUNT, 3);
+ maxCounts.put(SHELF_BOUNCE_COUNT, 3);
+ maxCounts.put(ALL_APPS_COUNT, 5);
+ MAX_COUNTS = Collections.unmodifiableMap(maxCounts);
+ }
+
+ protected final T mLauncher;
+ protected final SharedPreferences mSharedPrefs;
+ protected final LauncherStateManager mStateManager;
+
+ public OnboardingPrefs(T launcher, SharedPreferences sharedPrefs,
+ LauncherStateManager stateManager) {
+ mLauncher = launcher;
+ mSharedPrefs = sharedPrefs;
+ mStateManager = stateManager;
+ }
+
+ /** @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);
+ }
+
+ /**
+ * 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);
+ }
+}
diff --git a/src/com/android/launcher3/util/OverScroller.java b/src/com/android/launcher3/util/OverScroller.java
index 34efb12..87e6986 100644
--- a/src/com/android/launcher3/util/OverScroller.java
+++ b/src/com/android/launcher3/util/OverScroller.java
@@ -561,10 +561,11 @@
mStartTime = AnimationUtils.currentAnimationTimeMillis();
mDuration = duration;
+ if (mSpring != null) {
+ mSpring.cancel();
+ }
+
if (mState == SPRING) {
- if (mSpring != null) {
- mSpring.cancel();
- }
mSpring = new SpringAnimation(this, SPRING_PROPERTY);
ResourceProvider rp = DynamicResource.provider(mContext);
@@ -576,9 +577,9 @@
mSpring.setStartVelocity(velocity);
mSpring.animateToFinalPosition(mFinal);
mSpring.addEndListener((animation, canceled, value, velocity1) -> {
+ mSpring = null;
finish();
mState = SPLINE;
- mSpring = null;
});
}
// Unused
diff --git a/src/com/android/launcher3/util/PackageUserKey.java b/src/com/android/launcher3/util/PackageUserKey.java
index 46e7070..3a3b5a2 100644
--- a/src/com/android/launcher3/util/PackageUserKey.java
+++ b/src/com/android/launcher3/util/PackageUserKey.java
@@ -3,6 +3,7 @@
import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.launcher3.model.data.ItemInfo;
@@ -60,4 +61,10 @@
PackageUserKey otherKey = (PackageUserKey) obj;
return mPackageName.equals(otherKey.mPackageName) && mUser.equals(otherKey.mUser);
}
+
+ @NonNull
+ @Override
+ public String toString() {
+ return mPackageName + "#" + mUser;
+ }
}
diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java
index 39e1eac..442c5fd 100644
--- a/src/com/android/launcher3/views/ScrimView.java
+++ b/src/com/android/launcher3/views/ScrimView.java
@@ -82,7 +82,7 @@
* Simple scrim which draws a flat color
*/
public class ScrimView<T extends Launcher> extends View implements Insettable, OnChangeListener,
- AccessibilityStateChangeListener, StateListener {
+ AccessibilityStateChangeListener {
public static final IntProperty<ScrimView> DRAG_HANDLE_ALPHA =
new IntProperty<ScrimView>("dragHandleAlpha") {
@@ -116,6 +116,18 @@
private final AccessibilityManager mAM;
protected final int mEndScrim;
+ private final StateListener mAccessibilityLauncherStateListener = new StateListener() {
+ @Override
+ public void onStateTransitionStart(LauncherState toState) {}
+
+ @Override
+ public void onStateTransitionComplete(LauncherState finalState) {
+ setImportantForAccessibility(finalState == ALL_APPS
+ ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
+ : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
+ }
+ };
+
protected float mMaxScrimAlpha;
protected float mProgress = 1;
@@ -177,7 +189,7 @@
@Override
public void setInsets(Rect insets) {
updateDragHandleBounds();
- updateDragHandleVisibility(null);
+ updateDragHandleVisibility();
}
@Override
@@ -375,18 +387,22 @@
@Override
public void onAccessibilityStateChanged(boolean enabled) {
LauncherStateManager stateManager = mLauncher.getStateManager();
- stateManager.removeStateListener(this);
+ stateManager.removeStateListener(mAccessibilityLauncherStateListener);
if (enabled) {
- stateManager.addStateListener(this);
- handleStateChangedComplete(stateManager.getState());
+ stateManager.addStateListener(mAccessibilityLauncherStateListener);
+ mAccessibilityLauncherStateListener.onStateTransitionComplete(stateManager.getState());
} else {
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
}
+ updateDragHandleVisibility();
+ }
+
+ public void updateDragHandleVisibility() {
updateDragHandleVisibility(null);
}
- private void updateDragHandleVisibility(Drawable recycle) {
+ private void updateDragHandleVisibility(@Nullable Drawable recycle) {
boolean visible = shouldDragHandleBeVisible();
boolean wasVisible = mDragHandle != null;
if (visible != wasVisible) {
@@ -424,20 +440,6 @@
mAccessibilityHelper.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
}
- @Override
- public void onStateTransitionStart(LauncherState toState) {}
-
- @Override
- public void onStateTransitionComplete(LauncherState finalState) {
- handleStateChangedComplete(finalState);
- }
-
- private void handleStateChangedComplete(LauncherState finalState) {
- setImportantForAccessibility(finalState == ALL_APPS
- ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
- : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
- }
-
protected class AccessibilityHelper extends ExploreByTouchHelper {
private static final int DRAG_HANDLE_ID = 1;
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
index a56801f..313ea05 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -15,8 +15,8 @@
*/
package com.android.launcher3.uioverrides.states;
-import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_SEEN;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
+import static com.android.launcher3.util.OnboardingPrefs.HOME_BOUNCE_SEEN;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Launcher;
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 710ce9e..84eae2d 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -247,6 +247,8 @@
}
}
}
+
+ disableSensorRotation();
}
public void enableCheckEventsForSuccessfulGestures() {
diff --git a/tests/tapl/com/android/launcher3/tapl/LogEventChecker.java b/tests/tapl/com/android/launcher3/tapl/LogEventChecker.java
index 49901ea..78dfc36 100644
--- a/tests/tapl/com/android/launcher3/tapl/LogEventChecker.java
+++ b/tests/tapl/com/android/launcher3/tapl/LogEventChecker.java
@@ -44,6 +44,7 @@
private static final String START_PREFIX = "START_READER ";
private static final String FINISH_PREFIX = "FINISH_READER ";
+ private static final String SKIP_EVENTS_TAG = "b/153670015";
private volatile CountDownLatch mFinished;
@@ -72,6 +73,7 @@
mFinished = null;
}
mEvents.clear();
+ Log.d(SKIP_EVENTS_TAG, "Cleared events");
mExpectedEvents.clear();
mEventsCounter.drainPermits();
final String id = UUID.randomUUID().toString();
@@ -89,27 +91,30 @@
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
Runtime.getRuntime().exec(cmd).getInputStream()))) {
- for (;;) {
+ for (; ; ) {
// Skip everything before the next start command.
- for (;;) {
+ for (; ; ) {
final String event = reader.readLine();
if (event.contains(TestProtocol.TAPL_EVENTS_TAG)
&& event.contains(mStartCommand)) {
+ Log.d(SKIP_EVENTS_TAG, "Read start: " + event);
break;
}
}
// Store all actual events until the finish command.
- for (;;) {
+ for (; ; ) {
final String event = reader.readLine();
if (event.contains(TestProtocol.TAPL_EVENTS_TAG)) {
if (event.contains(mFinishCommand)) {
mFinished.countDown();
+ Log.d(SKIP_EVENTS_TAG, "Read finish: " + event);
break;
} else {
final Matcher matcher = EVENT_LOG_ENTRY.matcher(event);
if (matcher.find()) {
mEvents.add(matcher.group("sequence"), matcher.group("event"));
+ Log.d(SKIP_EVENTS_TAG, "Read event: " + event);
mEventsCounter.release();
}
}
@@ -154,6 +159,7 @@
String sequence = expectedEvents.getKey();
List<String> actual = new ArrayList<>(mEvents.getNonNull(sequence));
+ Log.d(SKIP_EVENTS_TAG, "Verifying events");
final int mismatchPosition = getMismatchPosition(expectedEvents.getValue(), actual);
hasMismatches = hasMismatches || mismatchPosition != -1;
formatSequenceWithMismatch(