Merge "Re-enable home screen rotation" into ub-launcher3-rvc-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
index 1b3610a..f6f892b 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
@@ -24,6 +24,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.view.MotionEvent;
+import android.view.View;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseDraggingActivity;
@@ -209,9 +210,11 @@
mPendingAnimation = mRecentsView.createTaskLaunchAnimation(
mTaskBeingDragged, maxDuration, Interpolators.ZOOM_IN);
- mTempCords[1] = mTaskBeingDragged.getHeight();
- dl.getDescendantCoordRelativeToSelf(mTaskBeingDragged, mTempCords);
- mEndDisplacement = dl.getHeight() - mTempCords[1];
+ // Since the thumbnail is what is filling the screen, based the end displacement on it.
+ View thumbnailView = mTaskBeingDragged.getThumbnail();
+ mTempCords[1] = orientationHandler.getSecondaryDimension(thumbnailView);
+ dl.getDescendantCoordRelativeToSelf(thumbnailView, mTempCords);
+ mEndDisplacement = secondaryLayerDimension - mTempCords[1];
}
mEndDisplacement *= verticalFactor;
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 e7202e8..3513ad5 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
@@ -31,7 +31,6 @@
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
-import android.util.Log;
import android.util.Pair;
import android.view.MotionEvent;
import android.view.View;
@@ -46,7 +45,6 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
-import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.VibratorWrapper;
import com.android.launcher3.views.FloatingIconView;
@@ -133,8 +131,7 @@
mDeviceState = deviceState;
mGestureState = gestureState;
mActivityInterface = gestureState.getActivityInterface();
- mActivityInitListener =
- mActivityInterface.createActivityInitListener(this::onActivityInit);
+ mActivityInitListener = mActivityInterface.createActivityInitListener(this::onActivityInit);
mInputConsumer = inputConsumer;
mAppWindowAnimationHelper = new AppWindowAnimationHelper(context);
mPageSpacing = context.getResources().getDimensionPixelSize(R.dimen.recents_page_spacing);
@@ -396,11 +393,15 @@
public void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask) { }
- public void initWhenReady() {
+ /**
+ * Registers a callback to run when the activity is ready.
+ * @param intent The intent that will be used to start the activity if it doesn't exist already.
+ */
+ public void initWhenReady(Intent intent) {
// Preload the plan
RecentsModel.INSTANCE.get(mContext).getTasks(null);
- mActivityInitListener.register();
+ mActivityInitListener.register(intent);
}
/**
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackSwipeHandler.java
index 46b026e..b4492d8 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackSwipeHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackSwipeHandler.java
@@ -188,10 +188,10 @@
}
@Override
- public void initWhenReady() {
+ public void initWhenReady(Intent intent) {
if (mInQuickSwitchMode) {
// Only init if we are in quickswitch mode
- super.initWhenReady();
+ super.initWhenReady(intent);
}
}
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 0fb51f3..0b5221e 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -90,7 +90,6 @@
import com.android.systemui.shared.system.InputChannelCompat.InputEventReceiver;
import com.android.systemui.shared.system.InputConsumerController;
import com.android.systemui.shared.system.InputMonitorCompat;
-import com.android.systemui.shared.system.RecentsAnimationListener;
import com.android.systemui.shared.tracing.ProtoTraceable;
import java.io.FileDescriptor;
@@ -739,12 +738,14 @@
final BaseActivityInterface<BaseDraggingActivity> activityInterface =
mOverviewComponentObserver.getActivityInterface();
+ final Intent overviewIntent = new Intent(
+ mOverviewComponentObserver.getOverviewIntentIgnoreSysUiState());
if (activityInterface.getCreatedActivity() == null) {
// Make sure that UI states will be initialized.
activityInterface.createActivityInitListener((wasVisible) -> {
AppLaunchTracker.INSTANCE.get(TouchInteractionService.this);
return false;
- }).register();
+ }).register(overviewIntent);
} else if (fromInit) {
// The activity has been created before the initialization of overview service. It is
// usually happens when booting or launcher is the top activity, so we should already
@@ -752,8 +753,7 @@
return;
}
- mTaskAnimationManager.preloadRecentsAnimation(
- mOverviewComponentObserver.getOverviewIntentIgnoreSysUiState());
+ mTaskAnimationManager.preloadRecentsAnimation(overviewIntent);
}
@Override
@@ -832,7 +832,7 @@
private BaseSwipeUpHandler createLauncherSwipeHandler(GestureState gestureState,
long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask) {
- return new LauncherSwipeHandler(this, mDeviceState, mTaskAnimationManager,
+ return new LauncherSwipeHandler(this, mDeviceState, mTaskAnimationManager,
gestureState, touchTimeMs, continuingLastGesture, mInputConsumer);
}
@@ -858,11 +858,6 @@
}
}
- public static void startRecentsActivityAsync(Intent intent, RecentsAnimationListener listener) {
- UI_HELPER_EXECUTOR.execute(() -> ActivityManagerWrapper.getInstance()
- .startRecentsActivity(intent, null, listener, null, null));
- }
-
@Override
public void onPluginConnected(OverscrollPlugin overscrollPlugin, Context context) {
mOverscrollPlugin = overscrollPlugin;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
index fe9ef2b..1f6c506 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
@@ -333,7 +333,8 @@
mTaskAnimationManager.isRecentsAnimationRunning(), isLikelyToStartNewTask);
mInteractionHandler.setGestureEndCallback(this::onInteractionGestureFinished);
mMotionPauseDetector.setOnMotionPauseListener(mInteractionHandler::onMotionPauseChanged);
- mInteractionHandler.initWhenReady();
+ Intent intent = new Intent(mInteractionHandler.getLaunchIntent());
+ mInteractionHandler.initWhenReady(intent);
if (mTaskAnimationManager.isRecentsAnimationRunning()) {
mActiveCallbacks = mTaskAnimationManager.continueRecentsAnimation(mGestureState);
@@ -341,7 +342,6 @@
mTaskAnimationManager.notifyRecentsAnimationState(mInteractionHandler);
notifyGestureStarted();
} else {
- Intent intent = mInteractionHandler.getLaunchIntent();
intent.putExtra(INTENT_EXTRA_LOG_TRACE_ID, mGestureState.getGestureId());
mActiveCallbacks = mTaskAnimationManager.startRecentsAnimation(mGestureState, intent,
mInteractionHandler);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverscrollInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverscrollInputConsumer.java
index 0a21413..c49b8f2 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverscrollInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverscrollInputConsumer.java
@@ -36,17 +36,14 @@
import com.android.launcher3.R;
import com.android.quickstep.GestureState;
import com.android.quickstep.InputConsumer;
-import com.android.quickstep.views.LauncherRecentsView;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.plugins.OverscrollPlugin;
import com.android.systemui.shared.system.InputMonitorCompat;
/**
* Input consumer for handling events to pass to an {@code OverscrollPlugin}.
- *
- * @param <T> Draggable activity subclass used by RecentsView
*/
-public class OverscrollInputConsumer<T extends BaseDraggingActivity> extends DelegateInputConsumer {
+public class OverscrollInputConsumer extends DelegateInputConsumer {
private static final String TAG = "OverscrollInputConsumer";
@@ -61,12 +58,12 @@
private final float mSquaredSlop;
- private final Context mContext;
private final GestureState mGestureState;
@Nullable
private final OverscrollPlugin mPlugin;
private final GestureDetector mGestureDetector;
+ @Nullable
private RecentsView mRecentsView;
public OverscrollInputConsumer(Context context, GestureState gestureState,
@@ -77,7 +74,6 @@
.getInteger(R.integer.assistant_gesture_corner_deg_threshold);
mFlingThresholdPx = context.getResources()
.getDimension(R.dimen.gestures_overscroll_fling_threshold);
- mContext = context;
mGestureState = gestureState;
mPlugin = plugin;
@@ -85,9 +81,6 @@
mSquaredSlop = slop * slop;
mGestureDetector = new GestureDetector(context, new FlingGestureListener());
-
- gestureState.getActivityInterface().createActivityInitListener(this::onActivityInit)
- .register();
}
@Override
@@ -95,12 +88,6 @@
return TYPE_OVERSCROLL | mDelegate.getType();
}
- private boolean onActivityInit(Boolean alreadyOnHome) {
- mRecentsView = mGestureState.getActivityInterface().getCreatedActivity().getOverviewPanel();
-
- return true;
- }
-
@Override
public void onMotionEvent(MotionEvent ev) {
switch (ev.getActionMasked()) {
@@ -191,10 +178,17 @@
}
private boolean isOverscrolled() {
+ if (mRecentsView == null) {
+ BaseDraggingActivity activity = mGestureState.getActivityInterface()
+ .getCreatedActivity();
+ if (activity != null) {
+ mRecentsView = activity.getOverviewPanel();
+ }
+ }
+
// Make sure there isn't an app to quick switch to on our right
int maxIndex = 0;
- if ((mRecentsView instanceof LauncherRecentsView)
- && ((LauncherRecentsView) mRecentsView).hasRecentsExtraCard()) {
+ if (mRecentsView != null && mRecentsView.hasRecentsExtraCard()) {
maxIndex = 1;
}
diff --git a/quickstep/res/layout/gesture_tutorial_fragment.xml b/quickstep/res/layout/gesture_tutorial_fragment.xml
index 0bc062a..69481ad 100644
--- a/quickstep/res/layout/gesture_tutorial_fragment.xml
+++ b/quickstep/res/layout/gesture_tutorial_fragment.xml
@@ -39,79 +39,58 @@
android:src="@drawable/gesture_tutorial_close_button"/>
<LinearLayout
+ android:id="@+id/gesture_tutorial_fragment_titles_container"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:layout_marginTop="70dp"
+ android:layout_alignParentTop="true"
+ android:focusable="true"
+ android:gravity="center_horizontal"
android:orientation="vertical">
- <LinearLayout
- android:id="@+id/gesture_tutorial_fragment_titles_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:focusable="true">
-
- <TextView
- android:id="@+id/gesture_tutorial_fragment_title_view"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:layout_marginStart="@dimen/gesture_tutorial_title_margin_start_end"
- android:layout_marginEnd="@dimen/gesture_tutorial_title_margin_start_end"
- style="@style/TextAppearance.BackGestureTutorial.Title"/>
-
- <TextView
- android:id="@+id/gesture_tutorial_fragment_subtitle_view"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:layout_marginTop="10dp"
- android:layout_marginStart="@dimen/gesture_tutorial_subtitle_margin_start_end"
- android:layout_marginEnd="@dimen/gesture_tutorial_subtitle_margin_start_end"
- style="@style/TextAppearance.BackGestureTutorial.Subtitle"/>
-
- </LinearLayout>
-
- <Space
+ <TextView
+ android:id="@+id/gesture_tutorial_fragment_title_view"
android:layout_width="wrap_content"
- android:layout_weight="1"
- android:layout_height="0dp"
- android:layout_marginTop="48dp"
- android:layout_gravity="center_horizontal"
- android:gravity="center_horizontal"
- android:orientation="vertical"/>
-
- <!-- android:stateListAnimator="@null" removes shadow and normal on click behavior (increase
- of elevation and shadow) which is replaced by ripple effect in android:foreground -->
- <RelativeLayout
- android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="46dp"
- android:layout_marginBottom="48dp"
- android:layout_gravity="center_horizontal">
+ android:layout_marginStart="@dimen/gesture_tutorial_title_margin_start_end"
+ android:layout_marginEnd="@dimen/gesture_tutorial_title_margin_start_end"
+ style="@style/TextAppearance.GestureTutorial.Title"/>
- <Button
- android:id="@+id/gesture_tutorial_fragment_action_button"
- android:layout_width="142dp"
- android:layout_height="49dp"
- android:layout_marginEnd="@dimen/gesture_tutorial_button_margin_start_end"
- android:layout_alignParentEnd="true"
- android:stateListAnimator="@null"
- android:background="@drawable/gesture_tutorial_action_button_background"
- android:foreground="?android:attr/selectableItemBackgroundBorderless"
- style="@style/TextAppearance.BackGestureTutorial.ButtonLabel"/>
-
- <Button
- android:id="@+id/gesture_tutorial_fragment_action_text_button"
- android:layout_width="142dp"
- android:layout_height="49dp"
- android:layout_marginStart="@dimen/gesture_tutorial_button_margin_start_end"
- android:layout_alignParentStart="true"
- android:stateListAnimator="@null"
- android:background="@null"
- android:foreground="?android:attr/selectableItemBackgroundBorderless"
- style="@style/TextAppearance.BackGestureTutorial.TextButtonLabel"/>
-
- </RelativeLayout>
+ <TextView
+ android:id="@+id/gesture_tutorial_fragment_subtitle_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:layout_marginStart="@dimen/gesture_tutorial_subtitle_margin_start_end"
+ android:layout_marginEnd="@dimen/gesture_tutorial_subtitle_margin_start_end"
+ style="@style/TextAppearance.GestureTutorial.Subtitle"/>
</LinearLayout>
+
+ <!-- android:stateListAnimator="@null" removes shadow and normal on click behavior (increase
+ of elevation and shadow) which is replaced by ripple effect in android:foreground -->
+ <Button
+ android:id="@+id/gesture_tutorial_fragment_action_button"
+ android:layout_width="142dp"
+ android:layout_height="49dp"
+ android:layout_marginEnd="@dimen/gesture_tutorial_button_margin_start_end"
+ android:layout_marginBottom="48dp"
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentBottom="true"
+ android:stateListAnimator="@null"
+ android:background="@drawable/gesture_tutorial_action_button_background"
+ android:foreground="?android:attr/selectableItemBackgroundBorderless"
+ style="@style/TextAppearance.GestureTutorial.ButtonLabel"/>
+
+ <Button
+ android:id="@+id/gesture_tutorial_fragment_action_text_button"
+ android:layout_width="142dp"
+ android:layout_height="49dp"
+ android:layout_marginStart="@dimen/gesture_tutorial_button_margin_start_end"
+ android:layout_marginBottom="48dp"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentBottom="true"
+ android:stateListAnimator="@null"
+ android:background="@null"
+ android:foreground="?android:attr/selectableItemBackgroundBorderless"
+ style="@style/TextAppearance.GestureTutorial.TextButtonLabel"/>
</RelativeLayout>
\ No newline at end of file
diff --git a/quickstep/res/values/styles.xml b/quickstep/res/values/styles.xml
index 14e054e..4915f5f 100644
--- a/quickstep/res/values/styles.xml
+++ b/quickstep/res/values/styles.xml
@@ -26,29 +26,29 @@
<item name="android:layout_height">wrap_content</item>
</style>
- <style name="TextAppearance.BackGestureTutorial"
+ <style name="TextAppearance.GestureTutorial"
parent="android:TextAppearance.Material.Body1" />
- <style name="TextAppearance.BackGestureTutorial.CallToAction"
+ <style name="TextAppearance.GestureTutorial.CallToAction"
parent="android:TextAppearance.Material.Body2" />
- <style name="TextAppearance.BackGestureTutorial.Title"
- parent="TextAppearance.BackGestureTutorial">
+ <style name="TextAppearance.GestureTutorial.Title"
+ parent="TextAppearance.GestureTutorial">
<item name="android:gravity">center</item>
<item name="android:textColor">@color/gesture_tutorial_title_color</item>
<item name="android:textSize">28sp</item>
</style>
- <style name="TextAppearance.BackGestureTutorial.Subtitle"
- parent="TextAppearance.BackGestureTutorial">
+ <style name="TextAppearance.GestureTutorial.Subtitle"
+ parent="TextAppearance.GestureTutorial">
<item name="android:gravity">center</item>
<item name="android:textColor">@color/gesture_tutorial_subtitle_color</item>
<item name="android:letterSpacing">0.03</item>
<item name="android:textSize">21sp</item>
</style>
- <style name="TextAppearance.BackGestureTutorial.ButtonLabel"
- parent="TextAppearance.BackGestureTutorial.CallToAction">
+ <style name="TextAppearance.GestureTutorial.ButtonLabel"
+ parent="TextAppearance.GestureTutorial.CallToAction">
<item name="android:gravity">center</item>
<item name="android:textColor">@color/gesture_tutorial_action_button_label_color</item>
<item name="android:letterSpacing">0.02</item>
@@ -56,8 +56,8 @@
<item name="android:textAllCaps">false</item>
</style>
- <style name="TextAppearance.BackGestureTutorial.TextButtonLabel"
- parent="TextAppearance.BackGestureTutorial.ButtonLabel">
+ <style name="TextAppearance.GestureTutorial.TextButtonLabel"
+ parent="TextAppearance.GestureTutorial.ButtonLabel">
<item name="android:textColor">@color/gesture_tutorial_primary_color</item>
</style>
diff --git a/quickstep/src/com/android/launcher3/LauncherInitListener.java b/quickstep/src/com/android/launcher3/LauncherInitListener.java
index fbd7a8a..7fb0d43 100644
--- a/quickstep/src/com/android/launcher3/LauncherInitListener.java
+++ b/quickstep/src/com/android/launcher3/LauncherInitListener.java
@@ -23,7 +23,6 @@
import android.os.CancellationSignal;
import android.os.Handler;
-import com.android.launcher3.util.ActivityTracker;
import com.android.quickstep.util.ActivityInitListener;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
@@ -45,7 +44,7 @@
}
@Override
- public boolean init(Launcher launcher, boolean alreadyOnHome) {
+ public boolean handleInit(Launcher launcher, boolean alreadyOnHome) {
if (mRemoteAnimationProvider != null) {
QuickstepAppTransitionManagerImpl appTransitionManager =
(QuickstepAppTransitionManagerImpl) launcher.getAppTransitionManager();
@@ -71,7 +70,7 @@
}, cancellationSignal);
}
launcher.deferOverlayCallbacksUntilNextResumeOrStop();
- return super.init(launcher, alreadyOnHome);
+ return super.handleInit(launcher, alreadyOnHome);
}
@Override
diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
index a30e102..70cbd82 100644
--- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
@@ -291,6 +291,15 @@
launcherContentAnimator.second.run();
}
});
+ } else {
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ mLauncher.addOnResumeCallback(() ->
+ ObjectAnimator.ofFloat(mLauncher.getDepthController(), DEPTH,
+ mLauncher.getStateManager().getState().getDepth(mLauncher)).start());
+ }
+ });
}
}
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialController.java b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
index 0f9a5d0..f0cb567 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
@@ -96,9 +96,9 @@
private void updateTitles() {
updateTitleView(mTitleTextView, getTitleStringId(),
- R.style.TextAppearance_BackGestureTutorial_Title);
+ R.style.TextAppearance_GestureTutorial_Title);
updateTitleView(mSubtitleTextView, getSubtitleStringId(),
- R.style.TextAppearance_BackGestureTutorial_Subtitle);
+ R.style.TextAppearance_GestureTutorial_Subtitle);
}
private void updateTitleView(TextView textView, @Nullable Integer stringId, int styleId) {
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
index 881587d..6346a9b 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
@@ -105,8 +105,7 @@
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
- mRootView = inflater.inflate(R.layout.gesture_tutorial_fragment,
- container, /* attachToRoot= */ false);
+ mRootView = inflater.inflate(R.layout.gesture_tutorial_fragment, container, false);
mRootView.setOnApplyWindowInsetsListener((view, insets) -> {
Insets systemInsets = insets.getInsets(WindowInsets.Type.systemBars());
mEdgeBackGestureHandler.setInsets(systemInsets.left, systemInsets.right);
diff --git a/quickstep/src/com/android/quickstep/util/ActivityInitListener.java b/quickstep/src/com/android/quickstep/util/ActivityInitListener.java
index b1c72ce..2a0fe32 100644
--- a/quickstep/src/com/android/quickstep/util/ActivityInitListener.java
+++ b/quickstep/src/com/android/quickstep/util/ActivityInitListener.java
@@ -31,6 +31,8 @@
private final BiPredicate<T, Boolean> mOnInitListener;
private final ActivityTracker<T> mActivityTracker;
+ private boolean mIsRegistered = false;
+
/**
* @param onInitListener a callback made when the activity is initialized. The callback should
* return true to continue receiving callbacks (ie. for if the activity is
@@ -43,27 +45,45 @@
}
@Override
- public boolean init(T activity, boolean alreadyOnHome) {
+ public final boolean init(T activity, boolean alreadyOnHome) {
+ if (!mIsRegistered) {
+ return false;
+ }
+ return handleInit(activity, alreadyOnHome);
+ }
+
+ protected boolean handleInit(T activity, boolean alreadyOnHome) {
return mOnInitListener.test(activity, alreadyOnHome);
}
/**
* Registers the activity-created listener. If the activity is already created, then the
* callback provided in the constructor will be called synchronously.
+ * @param intent The intent that will be used to initialize the activity, if the activity
+ * doesn't already exist. We add the callback as an extra on this intent.
*/
- public void register() {
- mActivityTracker.schedule(this);
+ public void register(Intent intent) {
+ mIsRegistered = true;
+ mActivityTracker.runCallbackWhenActivityExists(this, intent);
}
+ /**
+ * After calling this, we won't {@link #init} even when the activity is ready.
+ */
public void unregister() {
- mActivityTracker.clearReference(this);
+ mIsRegistered = false;
}
+ /**
+ * Starts the given intent with the provided animation. Unlike {@link #register(Intent)}, this
+ * method will not call {@link #init} if the activity already exists, it will only call it when
+ * we get handleIntent() for the provided intent that we're starting.
+ */
public void registerAndStartActivity(Intent intent, RemoteAnimationProvider animProvider,
Context context, Handler handler, long duration) {
- register();
+ mIsRegistered = true;
Bundle options = animProvider.toActivityOptions(handler, duration, context).toBundle();
- context.startActivity(addToIntent(new Intent((intent))), options);
+ context.startActivity(addToIntent(new Intent(intent)), options);
}
}
diff --git a/res/values-v26/styles.xml b/res/values-v26/styles.xml
index 8fb408b..d2f0802 100644
--- a/res/values-v26/styles.xml
+++ b/res/values-v26/styles.xml
@@ -20,6 +20,7 @@
<!-- Theme for the widget container. -->
<style name="WidgetContainerTheme" parent="@android:style/Theme.DeviceDefault.Settings">
<item name="android:colorPrimaryDark">#E8EAED</item>
+ <item name="android:textColorSecondary">?android:attr/textColorPrimary</item>
<item name="android:colorEdgeEffect">?android:attr/textColorSecondary</item>
</style>
<style name="WidgetContainerTheme.Dark" parent="AppTheme.Dark">
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index 814b728..7de44a3 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -40,8 +40,6 @@
import com.android.launcher3.logging.StatsLogUtils;
import com.android.launcher3.logging.StatsLogUtils.LogStateProvider;
import com.android.launcher3.logging.UserEventDispatcher;
-import com.android.launcher3.testing.TestLogging;
-import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.ViewCache;
@@ -332,7 +330,6 @@
return;
}
try {
- TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: shortcut", packageName);
getSystemService(LauncherApps.class).startShortcut(packageName, id, sourceBounds,
startActivityOptions, user);
} catch (SecurityException | IllegalStateException e) {
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index 2dc7836..f69c8ed 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -41,8 +41,6 @@
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
-import com.android.launcher3.testing.TestLogging;
-import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.util.DefaultDisplay;
@@ -173,7 +171,6 @@
startShortcutIntentSafely(intent, optsBundle, item, sourceContainer);
} else if (user == null || user.equals(Process.myUserHandle())) {
// Could be launching some bookkeeping activity
- TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: activity", intent);
startActivity(intent, optsBundle);
AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(),
Process.myUserHandle(), sourceContainer);
diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java
index 41eeb78..8eceec0 100644
--- a/src/com/android/launcher3/BaseRecyclerView.java
+++ b/src/com/android/launcher3/BaseRecyclerView.java
@@ -183,10 +183,6 @@
public void onScrollStateChanged(int state) {
super.onScrollStateChanged(state);
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "onScrollStateChanged: " + state);
- }
-
if (state == SCROLL_STATE_IDLE) {
AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext());
}
@@ -196,10 +192,6 @@
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
if (isLayoutSuppressed()) info.setScrollable(false);
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS,
- "onInitializeAccessibilityNodeInfo, scrollable: " + info.isScrollable());
- }
}
@Override
@@ -207,12 +199,8 @@
final boolean changing = frozen != isLayoutSuppressed();
super.setLayoutFrozen(frozen);
if (changing) {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "setLayoutFrozen " + frozen
- + " @ " + Log.getStackTraceString(new Throwable()));
- ActivityContext.lookupContext(getContext()).getDragLayer()
- .sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED);
- }
+ ActivityContext.lookupContext(getContext()).getDragLayer()
+ .sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED);
}
}
}
\ No newline at end of file
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 93247ab..e8e88c4 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -29,6 +29,7 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -70,7 +71,7 @@
* too aggressive.
*/
public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, OnResumeCallback,
- IconLabelDotView, DraggableView {
+ IconLabelDotView, DraggableView, Reorderable {
private static final int DISPLAY_WORKSPACE = 0;
private static final int DISPLAY_ALL_APPS = 1;
@@ -78,6 +79,8 @@
private static final int[] STATE_PRESSED = new int[] {android.R.attr.state_pressed};
+ private final PointF mTranslationForReorder = new PointF(0, 0);
+ private float mScaleForReorder = 1f;
private static final Property<BubbleTextView, Float> DOT_SCALE_PROPERTY
= new Property<BubbleTextView, Float>(Float.TYPE, "dotScale") {
@@ -672,6 +675,30 @@
return mIconSize;
}
+ public void setReorderOffset(float x, float y) {
+ mTranslationForReorder.set(x, y);
+ super.setTranslationX(x);
+ super.setTranslationY(y);
+ }
+
+ public void getReorderOffset(PointF offset) {
+ offset.set(mTranslationForReorder);
+ }
+
+ public void setReorderScale(float scale) {
+ mScaleForReorder = scale;
+ super.setScaleX(scale);
+ super.setScaleY(scale);
+ }
+
+ public float getReorderScale() {
+ return mScaleForReorder;
+ }
+
+ public View getView() {
+ return this;
+ }
+
@Override
public int getViewType() {
return DRAGGABLE_ICON;
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 99416c4..71a787f 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -33,6 +33,7 @@
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
+import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -54,7 +55,6 @@
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate;
import com.android.launcher3.anim.Interpolators;
-import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DraggableView;
import com.android.launcher3.folder.PreviewBackground;
@@ -66,7 +66,6 @@
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.views.ActivityContext;
-import com.android.launcher3.widget.LauncherAppWidgetHostView;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -99,6 +98,7 @@
// 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];
+ final PointF mTmpPointF = new PointF();
// Used to visualize / debug the Grid of the CellLayout
private static final boolean VISUALIZE_GRID = false;
@@ -136,7 +136,7 @@
private final Paint mDragOutlinePaint = new Paint();
@Thunk final ArrayMap<LayoutParams, Animator> mReorderAnimators = new ArrayMap<>();
- @Thunk final ArrayMap<View, ReorderPreviewAnimation> mShakeAnimators = new ArrayMap<>();
+ @Thunk final ArrayMap<Reorderable, ReorderPreviewAnimation> mShakeAnimators = new ArrayMap<>();
private boolean mItemPlacementDirty = false;
@@ -1868,10 +1868,11 @@
boolean skip = mode == ReorderPreviewAnimation.MODE_HINT && solution.intersectingViews
!= null && !solution.intersectingViews.contains(child);
+
LayoutParams lp = (LayoutParams) child.getLayoutParams();
- if (c != null && !skip) {
- ReorderPreviewAnimation rha = new ReorderPreviewAnimation(child, mode, lp.cellX,
- lp.cellY, c.cellX, c.cellY, c.spanX, c.spanY);
+ if (c != null && !skip && (child instanceof Reorderable)) {
+ ReorderPreviewAnimation rha = new ReorderPreviewAnimation((Reorderable) child,
+ mode, lp.cellX, lp.cellY, c.cellX, c.cellY, c.spanX, c.spanY);
rha.animate();
}
}
@@ -1893,7 +1894,7 @@
// Class which represents the reorder preview animations. These animations show that an item is
// in a temporary state, and hint at where the item will return to.
class ReorderPreviewAnimation {
- final View child;
+ final Reorderable child;
float finalDeltaX;
float finalDeltaY;
float initDeltaX;
@@ -1913,8 +1914,8 @@
float animationProgress = 0;
ValueAnimator a;
- public ReorderPreviewAnimation(View child, int mode, int cellX0, int cellY0, int cellX1,
- int cellY1, int spanX, int spanY) {
+ public ReorderPreviewAnimation(Reorderable child, int mode, int cellX0, int cellY0,
+ int cellX1, int cellY1, int spanX, int spanY) {
regionToCenterPoint(cellX0, cellY0, spanX, spanY, mTmpPoint);
final int x0 = mTmpPoint[0];
final int y0 = mTmpPoint[1];
@@ -1926,63 +1927,60 @@
this.child = child;
this.mode = mode;
+ finalDeltaX = 0;
+ finalDeltaY = 0;
- // TODO issue!
- setInitialAnimationValues(false);
- finalScale = (mChildScale - (CHILD_DIVIDEND / child.getWidth())) * initScale;
- finalDeltaX = initDeltaX;
- finalDeltaY = initDeltaY;
+ child.getReorderOffset(mTmpPointF);
+ initDeltaX = mTmpPointF.x;
+ initDeltaY = mTmpPointF.y;
+ initScale = child.getReorderScale();
+ finalScale = mChildScale - (CHILD_DIVIDEND / child.getView().getWidth()) * initScale;
+
int dir = mode == MODE_HINT ? -1 : 1;
if (dX == dY && dX == 0) {
} else {
if (dY == 0) {
- finalDeltaX += - dir * Math.signum(dX) * mReorderPreviewAnimationMagnitude;
+ finalDeltaX = -dir * Math.signum(dX) * mReorderPreviewAnimationMagnitude;
} else if (dX == 0) {
- finalDeltaY += - dir * Math.signum(dY) * mReorderPreviewAnimationMagnitude;
+ finalDeltaY = -dir * Math.signum(dY) * mReorderPreviewAnimationMagnitude;
} else {
double angle = Math.atan( (float) (dY) / dX);
- finalDeltaX += (int) (- dir * Math.signum(dX) *
- Math.abs(Math.cos(angle) * mReorderPreviewAnimationMagnitude));
- finalDeltaY += (int) (- dir * Math.signum(dY) *
- Math.abs(Math.sin(angle) * mReorderPreviewAnimationMagnitude));
+ finalDeltaX = (int) (-dir * Math.signum(dX)
+ * Math.abs(Math.cos(angle) * mReorderPreviewAnimationMagnitude));
+ finalDeltaY = (int) (-dir * Math.signum(dY)
+ * Math.abs(Math.sin(angle) * mReorderPreviewAnimationMagnitude));
}
}
}
- void setInitialAnimationValues(boolean restoreOriginalValues) {
- if (restoreOriginalValues) {
- if (child instanceof LauncherAppWidgetHostView) {
- LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) child;
- initScale = lahv.getScaleToFit();
- initDeltaX = lahv.getTranslationForCentering().x;
- initDeltaY = lahv.getTranslationForCentering().y;
- } else {
- initScale = mChildScale;
- initDeltaX = 0;
- initDeltaY = 0;
- }
- } else {
- initScale = child.getScaleX();
- initDeltaX = child.getTranslationX();
- initDeltaY = child.getTranslationY();
- }
+ void setInitialAnimationValuesToBaseline() {
+ initScale = mChildScale;
+ initDeltaX = 0;
+ initDeltaY = 0;
}
void animate() {
- boolean noMovement = (finalDeltaX == initDeltaX) && (finalDeltaY == initDeltaY);
+ boolean noMovement = (finalDeltaX == 0) && (finalDeltaY == 0);
if (mShakeAnimators.containsKey(child)) {
ReorderPreviewAnimation oldAnimation = mShakeAnimators.get(child);
- oldAnimation.cancel();
mShakeAnimators.remove(child);
+
if (noMovement) {
- completeAnimationImmediately();
+ // A previous animation for this item exists, and no new animation will exist.
+ // Finish the old animation smoothly.
+ oldAnimation.finishAnimation();
return;
+ } else {
+ // A previous animation for this item exists, and a new one will exist. Stop
+ // the old animation in its tracks, and proceed with the new one.
+ oldAnimation.cancel();
}
}
if (noMovement) {
return;
}
+
ValueAnimator va = ObjectAnimator.ofFloat(this, ANIMATION_PROGRESS, 0, 1);
a = va;
@@ -1999,7 +1997,7 @@
va.addListener(new AnimatorListenerAdapter() {
public void onAnimationRepeat(Animator animation) {
// We make sure to end only after a full period
- setInitialAnimationValues(true);
+ setInitialAnimationValuesToBaseline();
repeating = true;
}
});
@@ -2012,11 +2010,9 @@
float r1 = (mode == MODE_HINT && repeating) ? 1.0f : animationProgress;
float x = r1 * finalDeltaX + (1 - r1) * initDeltaX;
float y = r1 * finalDeltaY + (1 - r1) * initDeltaY;
- child.setTranslationX(x);
- child.setTranslationY(y);
+ child.setReorderOffset(x, y);
float s = animationProgress * finalScale + (1 - animationProgress) * initScale;
- child.setScaleX(s);
- child.setScaleY(s);
+ child.setReorderScale(s);
}
private void cancel() {
@@ -2025,27 +2021,27 @@
}
}
- @Thunk void completeAnimationImmediately() {
+ /**
+ * Smoothly returns the item to its baseline position / scale
+ */
+ @Thunk void finishAnimation() {
if (a != null) {
a.cancel();
}
- setInitialAnimationValues(true);
- a = new PropertyListBuilder()
- .scale(initScale)
- .translationX(initDeltaX)
- .translationY(initDeltaY)
- .build(child)
- .setDuration(REORDER_ANIMATION_DURATION);
- Launcher.cast(mActivity).getDragController().addFirstFrameAnimationHelper(a);
+ setInitialAnimationValuesToBaseline();
+ ValueAnimator va = ObjectAnimator.ofFloat(this, ANIMATION_PROGRESS,
+ animationProgress, 0);
+ a = va;
a.setInterpolator(DEACCEL_1_5);
+ a.setDuration(REORDER_ANIMATION_DURATION);
a.start();
}
}
private void completeAndClearReorderPreviewAnimations() {
for (ReorderPreviewAnimation a: mShakeAnimators.values()) {
- a.completeAnimationImmediately();
+ a.finishAnimation();
}
mShakeAnimators.clear();
}
diff --git a/src/com/android/launcher3/CheckLongPressHelper.java b/src/com/android/launcher3/CheckLongPressHelper.java
index ef353f9..ff405ec 100644
--- a/src/com/android/launcher3/CheckLongPressHelper.java
+++ b/src/com/android/launcher3/CheckLongPressHelper.java
@@ -113,7 +113,10 @@
}
private void triggerLongPress() {
- if ((mView.getParent() != null) && mView.hasWindowFocus() && !mHasPerformedLongPress) {
+ if ((mView.getParent() != null)
+ && mView.hasWindowFocus()
+ && (!mView.isPressed() || mListener == null)
+ && !mHasPerformedLongPress) {
boolean handled;
if (mListener != null) {
handled = mListener.onLongClick(mView);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index cb0a0b2..bf05a24 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1675,6 +1675,7 @@
private void processShortcutFromDrop(PendingAddShortcutInfo info) {
Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT).setComponent(info.componentName);
setWaitingForResult(PendingRequestArgs.forIntent(REQUEST_CREATE_SHORTCUT, intent, info));
+ TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: processShortcutFromDrop");
if (!info.activityInfo.startConfigActivity(this, REQUEST_CREATE_SHORTCUT)) {
handleActivityResult(REQUEST_CREATE_SHORTCUT, RESULT_CANCELED, null);
}
diff --git a/src/com/android/launcher3/LauncherAppWidgetHost.java b/src/com/android/launcher3/LauncherAppWidgetHost.java
index 9921f76..7ea6851 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHost.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHost.java
@@ -30,6 +30,8 @@
import android.widget.Toast;
import com.android.launcher3.model.WidgetsModel;
+import com.android.launcher3.testing.TestLogging;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.widget.DeferredAppWidgetHostView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.PendingAppWidgetHostView;
@@ -298,6 +300,7 @@
}
try {
+ TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startConfigActivity");
startAppWidgetConfigureActivityForResult(activity, widgetId, 0, requestCode, null);
} catch (ActivityNotFoundException | SecurityException e) {
Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
diff --git a/src/com/android/launcher3/Reorderable.java b/src/com/android/launcher3/Reorderable.java
new file mode 100644
index 0000000..5112eaf
--- /dev/null
+++ b/src/com/android/launcher3/Reorderable.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import android.graphics.PointF;
+import android.view.View;
+
+public interface Reorderable {
+
+ /**
+ * Set the offset related to reorder hint and "bounce" animations
+ */
+ void setReorderOffset(float x, float y);
+
+ void getReorderOffset(PointF offset);
+
+ /**
+ * Set the scale related to reorder hint and "bounce" animations
+ */
+ void setReorderScale(float scale);
+ float getReorderScale();
+
+ /**
+ * Get the com.android.view related to this object
+ */
+ View getView();
+}
diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java
index fc29a30..0648682 100644
--- a/src/com/android/launcher3/allapps/DiscoveryBounce.java
+++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java
@@ -172,8 +172,7 @@
if (withDelay) {
new Handler().postDelayed(() -> showForOverviewIfNeeded(launcher, false), DELAY_MS);
return;
- } else if (Launcher.ACTIVITY_TRACKER.hasPending()
- || AbstractFloatingView.getTopOpenView(launcher) != null) {
+ } else if (AbstractFloatingView.getTopOpenView(launcher) != null) {
// TODO: Move these checks to the top and call this method after invalidate handler.
return;
}
diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
index 737c97b..1d32d1d 100644
--- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
+++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
@@ -75,9 +75,6 @@
}
public static void sendScrollFinishedEventToTest(Context context) {
- if (TestProtocol.sDebugTracing) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "sendScrollFinishedEventToTest");
- }
final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context);
if (accessibilityManager == null) return;
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java
index 6c40b8a..0df6713 100644
--- a/src/com/android/launcher3/dragndrop/AddItemActivity.java
+++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java
@@ -170,16 +170,14 @@
}
}, null, View.DRAG_FLAG_GLOBAL);
-
- Intent homeIntent = listener.addToIntent(
- new Intent(Intent.ACTION_MAIN)
+ Intent homeIntent = new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)
.setPackage(getPackageName())
- .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
-
- Launcher.ACTIVITY_TRACKER.schedule(listener);
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ Launcher.ACTIVITY_TRACKER.runCallbackWhenActivityExists(listener, homeIntent);
startActivity(homeIntent,
- ActivityOptions.makeCustomAnimation(this, 0, android.R.anim.fade_out).toBundle());
+ ActivityOptions.makeCustomAnimation(this, 0, android.R.anim.fade_out)
+ .toBundle());
mFinishOnPause = true;
return false;
}
diff --git a/src/com/android/launcher3/dragndrop/BaseItemDragListener.java b/src/com/android/launcher3/dragndrop/BaseItemDragListener.java
index e47a16f..707fd06 100644
--- a/src/com/android/launcher3/dragndrop/BaseItemDragListener.java
+++ b/src/com/android/launcher3/dragndrop/BaseItemDragListener.java
@@ -161,7 +161,6 @@
}
protected void postCleanup() {
- Launcher.ACTIVITY_TRACKER.clearReference(this);
if (mLauncher != null) {
// Remove any drag params from the launcher intent since the drag operation is complete.
Intent newIntent = new Intent(mLauncher.getIntent());
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 4fe1d1a..12d88df 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -164,6 +164,7 @@
@Thunk final ArrayList<View> mItemsInReadingOrder = new ArrayList<View>();
private AnimatorSet mCurrentAnimator;
+ private boolean mIsAnimatingClosed = false;
protected final Launcher mLauncher;
protected DragController mDragController;
@@ -729,15 +730,24 @@
}
private void animateClosed() {
+ if (mIsAnimatingClosed) {
+ return;
+ }
if (mCurrentAnimator != null && mCurrentAnimator.isRunning()) {
mCurrentAnimator.cancel();
}
AnimatorSet a = new FolderAnimationManager(this, false /* isOpening */).getAnimator();
a.addListener(new AnimatorListenerAdapter() {
@Override
+ public void onAnimationStart(Animator animation) {
+ mIsAnimatingClosed = true;
+ }
+
+ @Override
public void onAnimationEnd(Animator animation) {
closeComplete(true);
announceAccessibilityChanges();
+ mIsAnimatingClosed = false;
}
});
startAnimation(a);
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index e29971e..96bdc2a 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -26,6 +26,7 @@
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
@@ -49,6 +50,7 @@
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.OnAlarmListener;
import com.android.launcher3.R;
+import com.android.launcher3.Reorderable;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.anim.Interpolators;
@@ -79,7 +81,7 @@
* An icon that can appear on in the workspace representing an {@link Folder}.
*/
public class FolderIcon extends FrameLayout implements FolderListener, IconLabelDotView,
- DraggableView {
+ DraggableView, Reorderable {
@Thunk ActivityContext mActivity;
@Thunk Folder mFolder;
@@ -119,6 +121,9 @@
private float mDotScale;
private Animator mDotScaleAnim;
+ private final PointF mTranslationForReorder = new PointF(0, 0);
+ private float mScaleForReorder = 1f;
+
private static final Property<FolderIcon, Float> DOT_SCALE_PROPERTY
= new Property<FolderIcon, Float>(Float.TYPE, "dotScale") {
@Override
@@ -226,16 +231,6 @@
mBackground.getBounds(outBounds);
}
- @Override
- public int getViewType() {
- return DRAGGABLE_ICON;
- }
-
- @Override
- public void getVisualDragBounds(Rect bounds) {
- getPreviewBounds(bounds);
- }
-
public float getBackgroundStrokeWidth() {
return mBackground.getStrokeWidth();
}
@@ -716,4 +711,39 @@
public void onFolderClose(int currentPage) {
mPreviewItemManager.onFolderClose(currentPage);
}
+
+
+ public void setReorderOffset(float x, float y) {
+ mTranslationForReorder.set(x, y);
+ super.setTranslationX(x);
+ super.setTranslationY(y);
+ }
+
+ public void getReorderOffset(PointF offset) {
+ offset.set(mTranslationForReorder);
+ }
+
+ public void setReorderScale(float scale) {
+ mScaleForReorder = scale;
+ super.setScaleX(scale);
+ super.setScaleY(scale);
+ }
+
+ public float getReorderScale() {
+ return mScaleForReorder;
+ }
+
+ public View getView() {
+ return this;
+ }
+
+ @Override
+ public int getViewType() {
+ return DRAGGABLE_ICON;
+ }
+
+ @Override
+ public void getVisualDragBounds(Rect bounds) {
+ getPreviewBounds(bounds);
+ }
}
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index e7449bb..82f2eb4 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -98,5 +98,4 @@
public static final String PERMANENT_DIAG_TAG = "TaplTarget";
public static final String APP_NOT_DISABLED = "b/139891609";
- public static final String NO_SCROLL_END_WIDGETS = "b/152354290";
}
diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java
index f7091fc..6abca76 100644
--- a/src/com/android/launcher3/touch/ItemClickHandler.java
+++ b/src/com/android/launcher3/touch/ItemClickHandler.java
@@ -52,6 +52,8 @@
import com.android.launcher3.model.data.PromiseAppInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.pm.InstallSessionHelper;
+import com.android.launcher3.testing.TestLogging;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.views.FloatingIconView;
import com.android.launcher3.widget.PendingAppWidgetHostView;
@@ -240,6 +242,8 @@
private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher,
@Nullable String sourceContainer) {
+ TestLogging.recordEvent(
+ TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
Intent intent;
if (item instanceof PromiseAppInfo) {
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
diff --git a/src/com/android/launcher3/util/ActivityTracker.java b/src/com/android/launcher3/util/ActivityTracker.java
index 499f655..59266b4 100644
--- a/src/com/android/launcher3/util/ActivityTracker.java
+++ b/src/com/android/launcher3/util/ActivityTracker.java
@@ -15,27 +15,23 @@
*/
package com.android.launcher3.util;
-import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
-
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
-import android.util.Log;
import androidx.annotation.Nullable;
import com.android.launcher3.BaseActivity;
-import com.android.launcher3.testing.TestProtocol;
import java.lang.ref.WeakReference;
/**
* Helper class to statically track activity creation
+ * @param <T> The activity type to track
*/
-public final class ActivityTracker<T extends BaseActivity> implements Runnable {
+public final class ActivityTracker<T extends BaseActivity> {
private WeakReference<T> mCurrentActivity = new WeakReference<>(null);
- private WeakReference<SchedulerCallback<T>> mPendingCallback = new WeakReference<>(null);
private static final String EXTRA_SCHEDULER_CALLBACK = "launcher.scheduler_callback";
@@ -51,76 +47,32 @@
}
/**
- * Schedules the callback to be notified when the activity is created.
- * @return true if the activity is already created, false otherwise
+ * Call {@link SchedulerCallback#init(BaseActivity, boolean)} when the activity is ready.
+ * If the activity is already created, this is called immediately, otherwise we add the
+ * callback as an extra on the intent, and will call init() when we get handleIntent().
+ * @param callback The callback to call init() on when the activity is ready.
+ * @param intent The intent that will be used to initialize the activity, if the activity
+ * doesn't already exist. We add the callback as an extra on this intent.
*/
- public boolean schedule(SchedulerCallback<? extends T> callback) {
- synchronized (this) {
- mPendingCallback = new WeakReference<>((SchedulerCallback<T>) callback);
- }
- if (!notifyInitIfPending()) {
- // If the activity doesn't already exist, then post and wait for the activity to start
- MAIN_EXECUTOR.execute(this);
- return false;
- }
- return true;
- }
-
- @Override
- public void run() {
- notifyInitIfPending();
- }
-
- /**
- * Notifies the pending callback if the activity is now created.
- * @return true if the activity is now created.
- */
- private boolean notifyInitIfPending() {
+ public void runCallbackWhenActivityExists(SchedulerCallback<T> callback, Intent intent) {
T activity = mCurrentActivity.get();
if (activity != null) {
- notifyInitIfPending(activity, activity.isStarted());
- return true;
+ callback.init(activity, activity.isStarted());
+ } else {
+ callback.addToIntent(intent);
}
- return false;
- }
-
- public boolean notifyInitIfPending(T activity, boolean alreadyOnHome) {
- SchedulerCallback<T> pendingCallback = mPendingCallback.get();
- if (pendingCallback != null) {
- if (!pendingCallback.init(activity, alreadyOnHome)) {
- clearReference(pendingCallback);
- }
- return true;
- }
- return false;
- }
-
- public boolean clearReference(SchedulerCallback<? extends T> handler) {
- synchronized (this) {
- if (mPendingCallback.get() == handler) {
- mPendingCallback.clear();
- return true;
- }
- return false;
- }
- }
-
- public boolean hasPending() {
- return mPendingCallback.get() != null;
}
public boolean handleCreate(T activity) {
mCurrentActivity = new WeakReference<>(activity);
- return handleIntent(activity, activity.getIntent(), false, false);
+ return handleIntent(activity, activity.getIntent(), false);
}
public boolean handleNewIntent(T activity, Intent intent) {
- return handleIntent(activity, intent, activity.isStarted(), true);
+ return handleIntent(activity, intent, activity.isStarted());
}
- private boolean handleIntent(
- T activity, Intent intent, boolean alreadyOnHome, boolean explicitIntent) {
- boolean result = false;
+ private boolean handleIntent(T activity, Intent intent, boolean alreadyOnHome) {
if (intent != null && intent.getExtras() != null) {
IBinder stateBinder = intent.getExtras().getBinder(EXTRA_SCHEDULER_CALLBACK);
if (stateBinder instanceof ObjectWrapper) {
@@ -129,19 +81,26 @@
if (!handler.init(activity, alreadyOnHome)) {
intent.getExtras().remove(EXTRA_SCHEDULER_CALLBACK);
}
- result = true;
+ return true;
}
}
- if (!result && !explicitIntent) {
- result = notifyInitIfPending(activity, alreadyOnHome);
- }
- return result;
+ return false;
}
public interface SchedulerCallback<T extends BaseActivity> {
+ /**
+ * Called when the activity is ready.
+ * @param alreadyOnHome Whether the activity is already started.
+ * @return Whether to continue receiving callbacks (i.e. if the activity is recreated).
+ */
boolean init(T activity, boolean alreadyOnHome);
+ /**
+ * Adds this callback as an extra on the intent, so we can retrieve it in handleIntent() and
+ * call {@link #init}. The intent should be used to start the activity after calling this
+ * method in order for us to get handleIntent().
+ */
default Intent addToIntent(Intent intent) {
Bundle extras = new Bundle();
extras.putBinder(EXTRA_SCHEDULER_CALLBACK, ObjectWrapper.wrap(this));
diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java
index 2fc3eaf..6915953 100644
--- a/src/com/android/launcher3/views/BaseDragLayer.java
+++ b/src/com/android/launcher3/views/BaseDragLayer.java
@@ -275,9 +275,6 @@
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "BaseDragLayer: " + ev);
- }
switch (ev.getAction()) {
case ACTION_DOWN: {
mTouchDispatchState |= TOUCH_DISPATCHING_VIEW;
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java
index 880f123..d5c3c1d 100644
--- a/src/com/android/launcher3/views/OptionsPopupView.java
+++ b/src/com/android/launcher3/views/OptionsPopupView.java
@@ -40,6 +40,8 @@
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.popup.ArrowPopup;
import com.android.launcher3.shortcuts.DeepShortcutView;
+import com.android.launcher3.testing.TestLogging;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.widget.WidgetsFullSheet;
@@ -184,6 +186,7 @@
}
public static boolean startSettings(View view) {
+ TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startSettings");
Launcher launcher = Launcher.getLauncher(view.getContext());
launcher.startActivity(new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
.setPackage(launcher.getPackageName())
diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
index 5d33f13..6f2e179 100644
--- a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
@@ -19,8 +19,6 @@
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
import android.content.res.Configuration;
-import android.graphics.PointF;
-import android.graphics.Rect;
import android.os.Handler;
import android.os.SystemClock;
import android.util.SparseBooleanArray;
@@ -40,7 +38,6 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dragndrop.DragLayer;
-import com.android.launcher3.dragndrop.DraggableView;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.util.Executors;
@@ -51,7 +48,7 @@
* {@inheritDoc}
*/
public class LauncherAppWidgetHostView extends NavigableAppWidgetHostView
- implements TouchCompleteListener, View.OnLongClickListener, DraggableView {
+ implements TouchCompleteListener, View.OnLongClickListener {
// Related to the auto-advancing of widgets
private static final long ADVANCE_INTERVAL = 20000;
@@ -73,15 +70,7 @@
private boolean mIsAutoAdvanceRegistered;
private Runnable mAutoAdvanceRunnable;
- /**
- * The scaleX and scaleY value such that the widget fits within its cellspans, scaleX = scaleY.
- */
- private float mScaleToFit = 1f;
- /**
- * The translation values to center the widget within its cellspans.
- */
- private final PointF mTranslationForCentering = new PointF(0, 0);
public LauncherAppWidgetHostView(Context context) {
super(context);
@@ -307,26 +296,6 @@
scheduleNextAdvance();
}
- public void setScaleToFit(float scale) {
- mScaleToFit = scale;
- setScaleX(scale);
- setScaleY(scale);
- }
-
- public float getScaleToFit() {
- return mScaleToFit;
- }
-
- public void setTranslationForCentering(float x, float y) {
- mTranslationForCentering.set(x, y);
- setTranslationX(x);
- setTranslationY(y);
- }
-
- public PointF getTranslationForCentering() {
- return mTranslationForCentering;
- }
-
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
@@ -357,17 +326,4 @@
}
return false;
}
-
- @Override
- public int getViewType() {
- return DRAGGABLE_WIDGET;
- }
-
- @Override
- public void getVisualDragBounds(Rect bounds) {
- int width = (int) (getMeasuredWidth() * mScaleToFit);
- int height = (int) (getMeasuredHeight() * mScaleToFit);
-
- bounds.set(0, 0 , width, height);
- }
}
diff --git a/src/com/android/launcher3/widget/NavigableAppWidgetHostView.java b/src/com/android/launcher3/widget/NavigableAppWidgetHostView.java
index 104ad77..5ea01d9 100644
--- a/src/com/android/launcher3/widget/NavigableAppWidgetHostView.java
+++ b/src/com/android/launcher3/widget/NavigableAppWidgetHostView.java
@@ -18,12 +18,14 @@
import android.appwidget.AppWidgetHostView;
import android.content.Context;
+import android.graphics.PointF;
import android.graphics.Rect;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
+import com.android.launcher3.Reorderable;
import com.android.launcher3.dragndrop.DraggableView;
import java.util.ArrayList;
@@ -32,7 +34,20 @@
* Extension of AppWidgetHostView with support for controlled keyboard navigation.
*/
public abstract class NavigableAppWidgetHostView extends AppWidgetHostView
- implements DraggableView {
+ implements DraggableView, Reorderable {
+
+ /**
+ * The scaleX and scaleY value such that the widget fits within its cellspans, scaleX = scaleY.
+ */
+ private float mScaleToFit = 1f;
+
+ /**
+ * The translation values to center the widget within its cellspans.
+ */
+ private final PointF mTranslationForCentering = new PointF(0, 0);
+
+ private final PointF mTranslationForReorder = new PointF(0, 0);
+ private float mScaleForReorder = 1f;
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mChildrenFocused;
@@ -137,6 +152,47 @@
setSelected(childIsFocused);
}
+ public void setScaleToFit(float scale) {
+ mScaleToFit = scale;
+ super.setScaleX(scale * mScaleForReorder);
+ super.setScaleY(scale * mScaleForReorder);
+ }
+
+ public float getScaleToFit() {
+ return mScaleToFit;
+ }
+
+ public View getView() {
+ return this;
+ }
+
+
+ public void setTranslationForCentering(float x, float y) {
+ mTranslationForCentering.set(x, y);
+ super.setTranslationX(x + mTranslationForReorder.x);
+ super.setTranslationY(y + mTranslationForReorder.y);
+ }
+
+ public void setReorderOffset(float x, float y) {
+ mTranslationForReorder.set(x, y);
+ super.setTranslationX(mTranslationForCentering.x + x);
+ super.setTranslationY(mTranslationForCentering.y + y);
+ }
+
+ public void getReorderOffset(PointF offset) {
+ offset.set(mTranslationForReorder);
+ }
+
+ public void setReorderScale(float scale) {
+ mScaleForReorder = scale;
+ super.setScaleX(mScaleToFit * scale);
+ super.setScaleY(mScaleToFit * scale);
+ }
+
+ public float getReorderScale() {
+ return mScaleForReorder;
+ }
+
@Override
public int getViewType() {
return DRAGGABLE_WIDGET;
@@ -144,6 +200,9 @@
@Override
public void getVisualDragBounds(Rect bounds) {
- bounds.set(0, 0 , getMeasuredWidth(), getMeasuredHeight());
+ int width = (int) (getMeasuredWidth() * mScaleToFit);
+ int height = (int) (getMeasuredHeight() * mScaleToFit);
+
+ bounds.set(0, 0 , width, height);
}
}
diff --git a/src/com/android/launcher3/widget/WidgetsFullSheet.java b/src/com/android/launcher3/widget/WidgetsFullSheet.java
index 37a30af..536b766 100644
--- a/src/com/android/launcher3/widget/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsFullSheet.java
@@ -71,14 +71,6 @@
}
- @Override
- public boolean dispatchTouchEvent(MotionEvent ev) {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "WidgetsFullSheet: " + ev);
- }
- return super.dispatchTouchEvent(ev);
- }
-
public WidgetsFullSheet(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
diff --git a/src/com/android/launcher3/widget/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/WidgetsRecyclerView.java
index 17baa27..82d4110 100644
--- a/src/com/android/launcher3/widget/WidgetsRecyclerView.java
+++ b/src/com/android/launcher3/widget/WidgetsRecyclerView.java
@@ -158,23 +158,13 @@
mScrollbar.isHitInParent(e.getX(), e.getY(), mFastScrollerOffset);
}
if (mTouchDownOnScroller) {
- final boolean result = mScrollbar.handleTouchEvent(e, mFastScrollerOffset);
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "onInterceptTouchEvent 1 " + result);
- }
- return result;
- }
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "onInterceptTouchEvent 2 false");
+ return mScrollbar.handleTouchEvent(e, mFastScrollerOffset);
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "WidgetsRecyclerView.onTouchEvent");
- }
if (mTouchDownOnScroller) {
mScrollbar.handleTouchEvent(e, mFastScrollerOffset);
}
@@ -182,31 +172,5 @@
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "onRequestDisallowInterceptTouchEvent "
- + disallowIntercept);
- }
- }
-
- @Override
- public boolean dispatchTouchEvent(MotionEvent ev) {
- final boolean result = super.dispatchTouchEvent(ev);
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "WidgetsRecyclerView: state: "
- + getScrollState()
- + " can scroll: " + getLayoutManager().canScrollVertically()
- + " result: " + result
- + " layout suppressed: " + isLayoutSuppressed()
- + " event: " + ev);
- }
- return result;
- }
-
- @Override
- public void stopNestedScroll() {
- if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
- Log.d(TestProtocol.NO_SCROLL_END_WIDGETS, "stopNestedScroll");
- }
- super.stopNestedScroll();
}
}
\ No newline at end of file
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index a7089fe..86faddb 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -162,7 +162,6 @@
mLauncher.enableDebugTracing();
// Avoid double-reporting of Launcher crashes.
mLauncher.setOnLauncherCrashed(() -> mLauncherPid = 0);
- mLauncher.disableSensorRotation();
}
protected final LauncherActivityRule mActivityMonitor = new LauncherActivityRule();
@@ -278,7 +277,6 @@
clearPackageData(mDevice.getLauncherPackageName());
mLauncher.enableDebugTracing();
mLauncherPid = mLauncher.getPid();
- mLauncher.disableSensorRotation();
}
}
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index de1ada4..57000a0 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -314,7 +314,7 @@
switchToAllApps();
allApps.freeze();
try {
- allApps.getAppIcon(APP_NAME).dragToWorkspace(false);
+ allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName());
} finally {
allApps.unfreeze();
@@ -342,7 +342,7 @@
getMenuItem(0);
final String shortcutName = menuItem.getText();
- menuItem.dragToWorkspace(false);
+ menuItem.dragToWorkspace(false, false);
mLauncher.getWorkspace().getWorkspaceAppIcon(shortcutName).launch(getAppPackageName());
} finally {
allApps.unfreeze();
diff --git a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
index 0a6579a..9d4ccff 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
@@ -94,7 +94,7 @@
WidgetConfigStartupMonitor monitor = new WidgetConfigStartupMonitor();
widgets.
getWidget(mWidgetInfo.getLabel(mTargetContext.getPackageManager())).
- dragToWorkspace(true);
+ dragToWorkspace(true, false);
// Widget id for which the config activity was opened
mWidgetId = monitor.getWidgetId();
diff --git a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
index 5e26aa6..f146db5 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
@@ -57,7 +57,7 @@
getWorkspace().
openAllWidgets().
getWidget(widgetInfo.getLabel(mTargetContext.getPackageManager())).
- dragToWorkspace(false);
+ dragToWorkspace(false, false);
assertTrue(mActivityMonitor.itemExists(
(info, view) -> info instanceof LauncherAppWidgetInfo &&
@@ -83,7 +83,7 @@
mDevice.pressHome();
mLauncher.getWorkspace().openAllWidgets()
.getWidget("com.android.launcher3.testcomponent.CustomShortcutConfigActivity")
- .dragToWorkspace(false);
+ .dragToWorkspace(false, true);
mLauncher.getWorkspace().getWorkspaceAppIcon("Shortcut")
.launch(getAppPackageName());
}
diff --git a/tests/tapl/com/android/launcher3/tapl/AppIcon.java b/tests/tapl/com/android/launcher3/tapl/AppIcon.java
index bdfd563..5de5b4a 100644
--- a/tests/tapl/com/android/launcher3/tapl/AppIcon.java
+++ b/tests/tapl/com/android/launcher3/tapl/AppIcon.java
@@ -31,7 +31,6 @@
*/
public final class AppIcon extends Launchable {
- private static final Pattern START_EVENT = Pattern.compile("start:");
private static final Pattern LONG_CLICK_EVENT = Pattern.compile("onAllAppsItemLongClick");
AppIcon(LauncherInstrumentation launcher, UiObject2 icon) {
@@ -64,6 +63,6 @@
@Override
protected void expectActivityStartEvents() {
- mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, START_EVENT);
+ mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START);
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java b/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java
index 37a7b91..a40919b 100644
--- a/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java
+++ b/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java
@@ -27,8 +27,6 @@
*/
public class AppIconMenuItem extends Launchable {
- private static final Pattern START_SHORTCUT_EVENT = Pattern.compile("start: shortcut:");
-
AppIconMenuItem(LauncherInstrumentation launcher, UiObject2 shortcut) {
super(launcher, shortcut);
}
@@ -51,6 +49,6 @@
@Override
protected void expectActivityStartEvents() {
- mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, START_SHORTCUT_EVENT);
+ mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START);
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Launchable.java b/tests/tapl/com/android/launcher3/tapl/Launchable.java
index 2922acf..df7436c 100644
--- a/tests/tapl/com/android/launcher3/tapl/Launchable.java
+++ b/tests/tapl/com/android/launcher3/tapl/Launchable.java
@@ -77,8 +77,9 @@
/**
* Drags an object to the center of homescreen.
* @param startsActivity whether it's expected to start an activity.
+ * @param isWidgetShortcut whether we drag a widget shortcut
*/
- public void dragToWorkspace(boolean startsActivity) {
+ public void dragToWorkspace(boolean startsActivity, boolean isWidgetShortcut) {
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
final Point launchableCenter = getObject().getVisibleCenter();
final Point displaySize = mLauncher.getRealDisplaySize();
@@ -93,6 +94,7 @@
displaySize.y / 2),
getLongPressIndicator(),
startsActivity,
+ isWidgetShortcut,
() -> addExpectedEventsForLongClick());
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 84eae2d..debc736 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -99,6 +99,7 @@
private static final Pattern EVENT_PILFER_POINTERS = Pattern.compile("pilferPointers");
static final Pattern EVENT_START_ACTIVITY = Pattern.compile("Activity\\.onStart");
static final Pattern EVENT_STOP_ACTIVITY = Pattern.compile("Activity\\.onStop");
+ static final Pattern EVENT_START = Pattern.compile("start:");
static final Pattern EVENT_TOUCH_DOWN_TIS = getTouchEventPatternTIS("ACTION_DOWN");
static final Pattern EVENT_TOUCH_UP_TIS = getTouchEventPatternTIS("ACTION_UP");
@@ -247,8 +248,6 @@
}
}
}
-
- disableSensorRotation();
}
public void enableCheckEventsForSuccessfulGestures() {
@@ -1265,7 +1264,7 @@
TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
- public void disableSensorRotation() {
+ private void disableSensorRotation() {
getTestInfo(TestProtocol.REQUEST_MOCK_SENSOR_ROTATION);
}
@@ -1306,6 +1305,7 @@
public Closable eventsCheck() {
Assert.assertTrue("Nested event checking", !sCheckingEvents);
+ disableSensorRotation();
sCheckingEvents = true;
mExpectedPid = getPid();
if (sEventChecker == null) sEventChecker = new LogEventChecker();
diff --git a/tests/tapl/com/android/launcher3/tapl/OptionsPopupMenuItem.java b/tests/tapl/com/android/launcher3/tapl/OptionsPopupMenuItem.java
index 63a97f4..d1268cc 100644
--- a/tests/tapl/com/android/launcher3/tapl/OptionsPopupMenuItem.java
+++ b/tests/tapl/com/android/launcher3/tapl/OptionsPopupMenuItem.java
@@ -43,6 +43,7 @@
LauncherInstrumentation.log("OptionsPopupMenuItem before click "
+ mObject.getVisibleCenter() + " in " + mLauncher.getVisibleBounds(mObject));
mLauncher.clickLauncherObject(mObject);
+ mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START);
if (!Build.MODEL.contains("Cuttlefish") ||
Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q &&
!"R".equals(Build.VERSION.CODENAME)) {
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index b3b5e32..0d91dc2 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -180,6 +180,7 @@
mLauncher.getVisibleBounds(workspace).centerY()),
"deep_shortcuts_container",
false,
+ false,
() -> mLauncher.expectEvent(
TestProtocol.SEQUENCE_MAIN, LONG_CLICK_EVENT));
verifyActiveContainer();
@@ -202,7 +203,8 @@
static void dragIconToWorkspace(
LauncherInstrumentation launcher, Launchable launchable, Point dest,
- String longPressIndicator, boolean startsActivity, Runnable expectLongClickEvents) {
+ String longPressIndicator, boolean startsActivity, boolean isWidgetShortcut,
+ Runnable expectLongClickEvents) {
LauncherInstrumentation.log("dragIconToWorkspace: begin");
final Point launchableCenter = launchable.getObject().getVisibleCenter();
final long downTime = SystemClock.uptimeMillis();
@@ -224,6 +226,9 @@
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest,
LauncherInstrumentation.GestureScope.INSIDE),
NORMAL_STATE_ORDINAL);
+ if (startsActivity || isWidgetShortcut) {
+ launcher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START);
+ }
if (startsActivity) {
launcher.expectEvent(
TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_STOP_ACTIVITY);