Merge "Add sdk check to recyclerviewfastscroller" into sc-dev
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 36322ce..26d407f 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -214,8 +214,9 @@
}
};
+ // Pairs of window starting type and starting window background color for starting tasks
// Will never be larger than MAX_NUM_TASKS
- private LinkedHashMap<Integer, Integer> mTypeForTaskId;
+ private LinkedHashMap<Integer, Pair<Integer, Integer>> mTaskStartParams;
public QuickstepTransitionManager(Context context) {
mLauncher = Launcher.cast(Launcher.getLauncher(context));
@@ -232,9 +233,9 @@
mLauncher.addOnDeviceProfileChangeListener(this);
if (supportsSSplashScreen()) {
- mTypeForTaskId = new LinkedHashMap<Integer, Integer>(MAX_NUM_TASKS) {
+ mTaskStartParams = new LinkedHashMap<Integer, Pair<Integer, Integer>>(MAX_NUM_TASKS) {
@Override
- protected boolean removeEldestEntry(Entry<Integer, Integer> entry) {
+ protected boolean removeEldestEntry(Entry<Integer, Pair<Integer, Integer>> entry) {
return size() > MAX_NUM_TASKS;
}
};
@@ -420,15 +421,6 @@
return bounds;
}
- private int getOpeningTaskId(RemoteAnimationTargetCompat[] appTargets) {
- for (RemoteAnimationTargetCompat target : appTargets) {
- if (target.mode == MODE_OPENING) {
- return target.taskId;
- }
- }
- return -1;
- }
-
public void setRemoteAnimationProvider(final RemoteAnimationProvider animationProvider,
CancellationSignal cancellationSignal) {
mRemoteAnimationProvider = animationProvider;
@@ -595,10 +587,12 @@
final boolean hasSplashScreen;
if (supportsSSplashScreen()) {
- int taskId = getOpeningTaskId(appTargets);
- int type = mTypeForTaskId.getOrDefault(taskId, STARTING_WINDOW_TYPE_NONE);
- mTypeForTaskId.remove(taskId);
- hasSplashScreen = type == STARTING_WINDOW_TYPE_SPLASH_SCREEN;
+ int taskId = openingTargets.getFirstAppTargetTaskId();
+ Pair<Integer, Integer> defaultParams = Pair.create(STARTING_WINDOW_TYPE_NONE, 0);
+ Pair<Integer, Integer> taskParams =
+ mTaskStartParams.getOrDefault(taskId, defaultParams);
+ mTaskStartParams.remove(taskId);
+ hasSplashScreen = taskParams.first == STARTING_WINDOW_TYPE_SPLASH_SCREEN;
} else {
hasSplashScreen = false;
}
@@ -799,18 +793,30 @@
final RectF widgetBackgroundBounds = new RectF();
final Rect appWindowCrop = new Rect();
final Matrix matrix = new Matrix();
+ RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets,
+ wallpaperTargets, nonAppTargets, MODE_OPENING);
+
+ RemoteAnimationTargetCompat openingTarget = openingTargets.getFirstAppTarget();
+ int fallbackBackgroundColor = 0;
+ if (openingTarget != null && supportsSSplashScreen()) {
+ fallbackBackgroundColor = mTaskStartParams.containsKey(openingTarget.taskId)
+ ? mTaskStartParams.get(openingTarget.taskId).second : 0;
+ mTaskStartParams.remove(openingTarget.taskId);
+ }
+ if (fallbackBackgroundColor == 0) {
+ fallbackBackgroundColor =
+ FloatingWidgetView.getDefaultBackgroundColor(mLauncher, openingTarget);
+ }
final float finalWindowRadius = mDeviceProfile.isMultiWindowMode
? 0 : getWindowCornerRadius(mLauncher.getResources());
final FloatingWidgetView floatingView = FloatingWidgetView.getFloatingWidgetView(mLauncher,
v, widgetBackgroundBounds,
new Size(windowTargetBounds.width(), windowTargetBounds.height()),
- finalWindowRadius, appTargetsAreTranslucent);
+ finalWindowRadius, appTargetsAreTranslucent, fallbackBackgroundColor);
final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources())
? floatingView.getInitialCornerRadius() : 0;
- RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets,
- wallpaperTargets, nonAppTargets, MODE_OPENING);
SurfaceTransactionApplier surfaceApplier = new SurfaceTransactionApplier(floatingView);
openingTargets.addReleaseCheck(surfaceApplier);
@@ -1434,8 +1440,8 @@
}
@Override
- public void onTaskLaunching(int taskId, int supportedType) {
- mTransitionManager.mTypeForTaskId.put(taskId, supportedType);
+ public void onTaskLaunching(int taskId, int supportedType, int color) {
+ mTransitionManager.mTaskStartParams.put(taskId, Pair.create(supportedType, color));
}
}
}
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 88db274..52f34d9 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -1071,7 +1071,8 @@
}
protected abstract HomeAnimationFactory createHomeAnimationFactory(
- ArrayList<IBinder> launchCookies, long duration, boolean isTargetTranslucent);
+ ArrayList<IBinder> launchCookies, long duration, boolean isTargetTranslucent,
+ RemoteAnimationTargetCompat runningTaskTarget);
private final TaskStackChangeListener mActivityRestartListener = new TaskStackChangeListener() {
@Override
@@ -1117,7 +1118,7 @@
: new ArrayList<>();
boolean isTranslucent = runningTaskTarget != null && runningTaskTarget.isTranslucent;
HomeAnimationFactory homeAnimFactory =
- createHomeAnimationFactory(cookies, duration, isTranslucent);
+ createHomeAnimationFactory(cookies, duration, isTranslucent, runningTaskTarget);
mIsSwipingPipToHome = homeAnimFactory.supportSwipePipToHome()
&& runningTaskTarget != null
&& runningTaskTarget.taskInfo.pictureInPictureParams != null
diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
index 2d81429..7290ff6 100644
--- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
@@ -129,7 +129,8 @@
@Override
protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
- long duration, boolean isTargetTranslucent) {
+ long duration, boolean isTargetTranslucent,
+ RemoteAnimationTargetCompat runningTaskTarget) {
mActiveAnimationFactory = new FallbackHomeAnimationFactory(duration);
ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
Intent intent = new Intent(mGestureState.getHomeIntent());
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index 1bae1c5..40741e4 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -20,6 +20,9 @@
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.Utilities.boundToRange;
import static com.android.launcher3.Utilities.dpToPx;
+import static com.android.launcher3.Utilities.mapBoundToRange;
+import static com.android.launcher3.anim.Interpolators.EXAGGERATED_EASE;
+import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.PROTOTYPE_APP_CLOSE;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
@@ -65,6 +68,7 @@
import com.android.quickstep.views.TaskView;
import com.android.systemui.plugins.ResourceProvider;
import com.android.systemui.shared.system.InputConsumerController;
+import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import java.util.ArrayList;
@@ -84,7 +88,8 @@
@Override
protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
- long duration, boolean isTargetTranslucent) {
+ long duration, boolean isTargetTranslucent,
+ RemoteAnimationTargetCompat runningTaskTarget) {
if (mActivity == null) {
mStateCallback.addChangeListener(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED,
isPresent -> mRecentsView.startHome());
@@ -108,7 +113,7 @@
}
if (workspaceView instanceof LauncherAppWidgetHostView) {
return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView,
- isTargetTranslucent);
+ isTargetTranslucent, runningTaskTarget);
}
return createIconHomeAnimationFactory(workspaceView);
}
@@ -169,15 +174,19 @@
}
private HomeAnimationFactory createWidgetHomeAnimationFactory(
- LauncherAppWidgetHostView hostView, boolean isTargetTranslucent) {
-
+ LauncherAppWidgetHostView hostView, boolean isTargetTranslucent,
+ RemoteAnimationTargetCompat runningTaskTarget) {
+ final float floatingWidgetAlpha = isTargetTranslucent ? 0 : 1;
RectF backgroundLocation = new RectF();
Rect crop = new Rect();
mTaskViewSimulator.getCurrentCropRect().roundOut(crop);
Size windowSize = new Size(crop.width(), crop.height());
+ int fallbackBackgroundColor =
+ FloatingWidgetView.getDefaultBackgroundColor(mContext, runningTaskTarget);
FloatingWidgetView floatingWidgetView = FloatingWidgetView.getFloatingWidgetView(mActivity,
hostView, backgroundLocation, windowSize,
- mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent);
+ mTaskViewSimulator.getCurrentCornerRadius(), isTargetTranslucent,
+ fallbackBackgroundColor);
return new FloatingViewHomeAnimationFactory(floatingWidgetView) {
@@ -207,12 +216,20 @@
}
@Override
- public void update(@Nullable AppCloseConfig config, RectF currentRect,
- float progress, float radius) {
+ public void update(@Nullable AppCloseConfig config, RectF currentRect, float progress,
+ float radius) {
super.update(config, currentRect, progress, radius);
- floatingWidgetView.update(currentRect, 1 /* floatingWidgetAlpha */,
- config != null ? config.getFgAlpha() : 1f /* foregroundAlpha */,
- 0 /* fallbackBackgroundAlpha */, 1 - progress);
+ final float fallbackBackgroundAlpha =
+ 1 - mapBoundToRange(progress, 0.8f, 1, 0, 1, EXAGGERATED_EASE);
+ final float foregroundAlpha =
+ mapBoundToRange(progress, 0.5f, 1, 0, 1, EXAGGERATED_EASE);
+ floatingWidgetView.update(currentRect, floatingWidgetAlpha, foregroundAlpha,
+ fallbackBackgroundAlpha, 1 - progress);
+ }
+
+ @Override
+ protected float getWindowAlpha(float progress) {
+ return 1 - mapBoundToRange(progress, 0, 0.5f, 0, 1, LINEAR);
}
};
}
diff --git a/quickstep/src/com/android/quickstep/RemoteAnimationTargets.java b/quickstep/src/com/android/quickstep/RemoteAnimationTargets.java
index edc3ab2..c032889 100644
--- a/quickstep/src/com/android/quickstep/RemoteAnimationTargets.java
+++ b/quickstep/src/com/android/quickstep/RemoteAnimationTargets.java
@@ -85,6 +85,17 @@
return null;
}
+ /** Returns the first opening app target. */
+ public RemoteAnimationTargetCompat getFirstAppTarget() {
+ return apps.length > 0 ? apps[0] : null;
+ }
+
+ /** Returns the task id of the first opening app target, or -1 if none is found. */
+ public int getFirstAppTargetTaskId() {
+ RemoteAnimationTargetCompat target = getFirstAppTarget();
+ return target == null ? -1 : target.taskId;
+ }
+
public boolean isAnimatingHome() {
for (RemoteAnimationTargetCompat target : unfilteredApps) {
if (target.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
index b79e934..4495455 100644
--- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
+++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
@@ -181,6 +181,24 @@
public boolean supportSwipePipToHome() {
return false;
}
+
+ /**
+ * @param progress The progress of the animation to the home screen.
+ * @return The current alpha to set on the animating app window.
+ */
+ protected float getWindowAlpha(float progress) {
+ // Alpha interpolates between [1, 0] between progress values [start, end]
+ final float start = 0f;
+ final float end = 0.85f;
+
+ if (progress <= start) {
+ return 1f;
+ }
+ if (progress >= end) {
+ return 0f;
+ }
+ return Utilities.mapToRange(progress, start, end, 1, 0, ACCEL_1_5);
+ }
}
/**
@@ -236,24 +254,6 @@
return anim;
}
- /**
- * @param progress The progress of the animation to the home screen.
- * @return The current alpha to set on the animating app window.
- */
- protected float getWindowAlpha(float progress) {
- // Alpha interpolates between [1, 0] between progress values [start, end]
- final float start = 0f;
- final float end = 0.85f;
-
- if (progress <= start) {
- return 1f;
- }
- if (progress >= end) {
- return 0f;
- }
- return Utilities.mapToRange(progress, start, end, 1, 0, ACCEL_1_5);
- }
-
protected class SpringAnimationRunner extends AnimationSuccessListener
implements RectFSpringAnim.OnUpdateListener, BuilderProxy {
@@ -292,7 +292,7 @@
mMatrix.setRectToRect(mCropRectF, mWindowCurrentRect, ScaleToFit.FILL);
float cornerRadius = Utilities.mapRange(progress, mStartRadius, mEndRadius);
- float alpha = getWindowAlpha(progress);
+ float alpha = mAnimationFactory.getWindowAlpha(progress);
if (config != null && PROTOTYPE_APP_CLOSE.get()) {
alpha = config.getWindowAlpha();
cornerRadius = config.getCornerRadius();
diff --git a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
index c3b342b..cf523d0 100644
--- a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
@@ -29,8 +29,6 @@
import com.android.launcher3.R;
import com.android.quickstep.interaction.TutorialController.TutorialType;
-import java.util.ArrayDeque;
-import java.util.Deque;
import java.util.List;
/** Shows the gesture interactive sandbox in full screen mode. */
@@ -39,8 +37,9 @@
private static final String LOG_TAG = "GestureSandboxActivity";
private static final String KEY_TUTORIAL_STEPS = "tutorial_steps";
+ private static final String KEY_CURRENT_STEP = "current_step";
- private Deque<TutorialType> mTutorialSteps;
+ private TutorialType[] mTutorialSteps;
private TutorialType mCurrentTutorialStep;
private TutorialFragment mFragment;
@@ -55,9 +54,7 @@
Bundle args = savedInstanceState == null ? getIntent().getExtras() : savedInstanceState;
mTutorialSteps = getTutorialSteps(args);
- mCurrentStep = 1;
- mNumSteps = mTutorialSteps.size();
- mCurrentTutorialStep = mTutorialSteps.pop();
+ mCurrentTutorialStep = mTutorialSteps[mCurrentStep - 1];
mFragment = TutorialFragment.newInstance(mCurrentTutorialStep);
getSupportFragmentManager().beginTransaction()
.add(R.id.gesture_tutorial_fragment_container, mFragment)
@@ -88,12 +85,13 @@
@Override
protected void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
savedInstanceState.putStringArray(KEY_TUTORIAL_STEPS, getTutorialStepNames());
+ savedInstanceState.putInt(KEY_CURRENT_STEP, mCurrentStep);
super.onSaveInstanceState(savedInstanceState);
}
/** Returns true iff there aren't anymore tutorial types to display to the user. */
public boolean isTutorialComplete() {
- return mTutorialSteps.isEmpty();
+ return mCurrentStep >= mNumSteps;
}
public int getCurrentStep() {
@@ -121,7 +119,7 @@
mFragment.closeTutorial();
return;
}
- mCurrentTutorialStep = mTutorialSteps.pop();
+ mCurrentTutorialStep = mTutorialSteps[mCurrentStep];
mFragment = TutorialFragment.newInstance(mCurrentTutorialStep);
getSupportFragmentManager().beginTransaction()
.replace(R.id.gesture_tutorial_fragment_container, mFragment)
@@ -131,10 +129,9 @@
}
private String[] getTutorialStepNames() {
- String[] tutorialStepNames = new String[mTutorialSteps.size() + 1];
+ String[] tutorialStepNames = new String[mTutorialSteps.length];
- int i = 1;
- tutorialStepNames[0] = mCurrentTutorialStep.name();
+ int i = 0;
for (TutorialType tutorialStep : mTutorialSteps) {
tutorialStepNames[i++] = tutorialStep.name();
}
@@ -142,25 +139,28 @@
return tutorialStepNames;
}
- private Deque<TutorialType> getTutorialSteps(Bundle extras) {
- Deque<TutorialType> defaultSteps = new ArrayDeque<>();
- defaultSteps.push(TutorialType.RIGHT_EDGE_BACK_NAVIGATION);
+ private TutorialType[] getTutorialSteps(Bundle extras) {
+ TutorialType[] defaultSteps = new TutorialType[] {TutorialType.LEFT_EDGE_BACK_NAVIGATION};
if (extras == null || !extras.containsKey(KEY_TUTORIAL_STEPS)) {
return defaultSteps;
}
String[] tutorialStepNames = extras.getStringArray(KEY_TUTORIAL_STEPS);
+ int currentStep = extras.getInt(KEY_CURRENT_STEP, -1);
if (tutorialStepNames == null) {
return defaultSteps;
}
- Deque<TutorialType> tutorialSteps = new ArrayDeque<>();
- for (String tutorialStepName : tutorialStepNames) {
- tutorialSteps.addLast(TutorialType.valueOf(tutorialStepName));
+ TutorialType[] tutorialSteps = new TutorialType[tutorialStepNames.length];
+ for (int i = 0; i < tutorialStepNames.length; i++) {
+ tutorialSteps[i] = TutorialType.valueOf(tutorialStepNames[i]);
}
+ mCurrentStep = Math.max(currentStep, 1);
+ mNumSteps = tutorialSteps.length;
+
return tutorialSteps;
}
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialController.java b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
index c9da609..dfe0c72 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
@@ -58,6 +58,7 @@
private static final int FEEDBACK_ANIMATION_MS = 250;
private static final int RIPPLE_VISIBLE_MS = 300;
+ private static final int GESTURE_ANIMATION_DELAY_MS = 1500;
final TutorialFragment mTutorialFragment;
TutorialType mTutorialType;
@@ -65,6 +66,7 @@
final TextView mCloseButton;
final ViewGroup mFeedbackView;
+ final TextView mFeedbackTitleView;
final ImageView mFeedbackVideoView;
final ImageView mGestureVideoView;
final RelativeLayout mFakeLauncherView;
@@ -80,6 +82,12 @@
protected boolean mGestureCompleted = false;
+ // These runnables should be used when posting callbacks to their views and cleared from their
+ // views before posting new callbacks.
+ private final Runnable mTitleViewCallback;
+ @Nullable private Runnable mFeedbackViewCallback;
+ @Nullable private Runnable mFeedbackVideoViewCallback;
+
TutorialController(TutorialFragment tutorialFragment, TutorialType tutorialType) {
mTutorialFragment = tutorialFragment;
mTutorialType = tutorialType;
@@ -89,6 +97,8 @@
mCloseButton = rootView.findViewById(R.id.gesture_tutorial_fragment_close_button);
mCloseButton.setOnClickListener(button -> showSkipTutorialDialog());
mFeedbackView = rootView.findViewById(R.id.gesture_tutorial_fragment_feedback_view);
+ mFeedbackTitleView = mFeedbackView.findViewById(
+ R.id.gesture_tutorial_fragment_feedback_title);
mFeedbackVideoView = rootView.findViewById(R.id.gesture_tutorial_feedback_video);
mGestureVideoView = rootView.findViewById(R.id.gesture_tutorial_gesture_video);
mFakeLauncherView = rootView.findViewById(R.id.gesture_tutorial_fake_launcher_view);
@@ -103,6 +113,9 @@
mTutorialStepView =
rootView.findViewById(R.id.gesture_tutorial_fragment_feedback_tutorial_step);
mSkipTutorialDialog = createSkipTutorialDialog();
+
+ mTitleViewCallback = () -> mFeedbackTitleView.sendAccessibilityEvent(
+ AccessibilityEvent.TYPE_VIEW_FOCUSED);
}
private void showSkipTutorialDialog() {
@@ -169,7 +182,7 @@
playFeedbackVideo(tutorialAnimation, gestureAnimation, () -> {
mFeedbackView.setTranslationY(0);
title.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
- });
+ }, true);
}
}
@@ -192,15 +205,17 @@
isGestureSuccessful
? R.string.gesture_tutorial_nice : R.string.gesture_tutorial_try_again,
subtitleResId,
- isGestureSuccessful);
+ isGestureSuccessful,
+ false);
}
void showFeedback(
int titleResId,
int subtitleResId,
- boolean isGestureSuccessful) {
- TextView title = mFeedbackView.findViewById(R.id.gesture_tutorial_fragment_feedback_title);
- title.setText(titleResId);
+ boolean isGestureSuccessful,
+ boolean useGestureAnimationDelay) {
+ mFeedbackTitleView.setText(titleResId);
+ mFeedbackTitleView.removeCallbacks(mTitleViewCallback);
TextView subtitle =
mFeedbackView.findViewById(R.id.gesture_tutorial_fragment_feedback_subtitle);
subtitle.setText(subtitleResId);
@@ -221,11 +236,8 @@
.setDuration(FEEDBACK_ANIMATION_MS)
.translationY(0)
.start();
- title.postDelayed(
- () -> title.sendAccessibilityEvent(
- AccessibilityEvent.TYPE_VIEW_FOCUSED),
- FEEDBACK_ANIMATION_MS);
- });
+ mFeedbackTitleView.postDelayed(mTitleViewCallback, FEEDBACK_ANIMATION_MS);
+ }, useGestureAnimationDelay);
return;
} else {
mTutorialFragment.releaseFeedbackVideoView();
@@ -237,10 +249,7 @@
.setDuration(FEEDBACK_ANIMATION_MS)
.translationY(0)
.start();
- title.postDelayed(
- () -> title.sendAccessibilityEvent(
- AccessibilityEvent.TYPE_VIEW_FOCUSED),
- FEEDBACK_ANIMATION_MS);
+ mFeedbackTitleView.postDelayed(mTitleViewCallback, FEEDBACK_ANIMATION_MS);
}
void hideFeedback(boolean releaseFeedbackVideo) {
@@ -254,7 +263,8 @@
private void playFeedbackVideo(
@NonNull AnimatedVectorDrawable tutorialAnimation,
@NonNull AnimatedVectorDrawable gestureAnimation,
- @NonNull Runnable onStartRunnable) {
+ @NonNull Runnable onStartRunnable,
+ boolean useGestureAnimationDelay) {
if (tutorialAnimation.isRunning()) {
tutorialAnimation.reset();
@@ -270,7 +280,9 @@
gestureAnimation.stop();
}
- onStartRunnable.run();
+ if (!useGestureAnimationDelay) {
+ onStartRunnable.run();
+ }
}
@Override
@@ -284,8 +296,28 @@
}
});
- tutorialAnimation.start();
- mFeedbackVideoView.setVisibility(View.VISIBLE);
+ if (mFeedbackViewCallback != null) {
+ mFeedbackVideoView.removeCallbacks(mFeedbackViewCallback);
+ mFeedbackViewCallback = null;
+ }
+ if (mFeedbackVideoViewCallback != null) {
+ mFeedbackVideoView.removeCallbacks(mFeedbackVideoViewCallback);
+ mFeedbackVideoViewCallback = null;
+ }
+ if (useGestureAnimationDelay) {
+ mFeedbackViewCallback = onStartRunnable;
+ mFeedbackVideoViewCallback = () -> {
+ mFeedbackVideoView.setVisibility(View.VISIBLE);
+ tutorialAnimation.start();
+ };
+
+ mFeedbackVideoView.setVisibility(View.GONE);
+ mFeedbackView.post(mFeedbackViewCallback);
+ mFeedbackVideoView.postDelayed(mFeedbackVideoViewCallback, GESTURE_ANIMATION_DELAY_MS);
+ } else {
+ mFeedbackVideoView.setVisibility(View.VISIBLE);
+ tutorialAnimation.start();
+ }
}
void setRippleHotspot(float x, float y) {
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
index ec26022..da0fc66 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
@@ -170,7 +170,8 @@
Integer introTileStringResId = mTutorialController.getIntroductionTitle();
Integer introSubtitleResId = mTutorialController.getIntroductionSubtitle();
if (introTileStringResId != null && introSubtitleResId != null) {
- mTutorialController.showFeedback(introTileStringResId, introSubtitleResId, false);
+ mTutorialController.showFeedback(
+ introTileStringResId, introSubtitleResId, false, true);
mIntroductionShown = true;
}
}
@@ -252,7 +253,7 @@
@Override
public void onResume() {
super.onResume();
- if (mFragmentStopped) {
+ if (mFragmentStopped && mTutorialController != null) {
mTutorialController.showFeedback();
mFragmentStopped = false;
} else {
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialStepIndicator.java b/quickstep/src/com/android/quickstep/interaction/TutorialStepIndicator.java
index eda6158..d880d74 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialStepIndicator.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialStepIndicator.java
@@ -23,6 +23,7 @@
import android.widget.LinearLayout;
import androidx.appcompat.content.res.AppCompatResources;
+import androidx.core.graphics.ColorUtils;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -86,6 +87,8 @@
for (int i = mTotalSteps; i < getChildCount(); i++) {
removeViewAt(i);
}
+ int stepIndicatorColor = GraphicsUtils.getAttrColor(
+ getContext(), android.R.attr.textColorPrimary);
for (int i = 0; i < mTotalSteps; i++) {
Drawable pageIndicatorPillDrawable = AppCompatResources.getDrawable(
getContext(), R.drawable.tutorial_step_indicator_pill);
@@ -104,13 +107,10 @@
}
if (pageIndicatorPillDrawable != null) {
if (i < mCurrentStep) {
- pageIndicatorPillDrawable.setTint(
- GraphicsUtils.getAttrColor(getContext(),
- android.R.attr.textColorPrimary));
+ pageIndicatorPillDrawable.setTint(stepIndicatorColor);
} else {
pageIndicatorPillDrawable.setTint(
- GraphicsUtils.getAttrColor(getContext(),
- android.R.attr.textColorPrimaryInverse));
+ ColorUtils.setAlphaComponent(stepIndicatorColor, 0x22));
}
}
}
diff --git a/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java b/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java
index 9ea2369..65dba33 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java
@@ -27,7 +27,6 @@
import android.view.ViewOutlineProvider;
import android.widget.RemoteViews.RemoteViewOutlineProvider;
-import com.android.launcher3.util.Themes;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.RoundedCornerEnforcement;
@@ -62,7 +61,8 @@
setClipToOutline(true);
}
- void init(LauncherAppWidgetHostView hostView, View backgroundView, float finalRadius) {
+ void init(LauncherAppWidgetHostView hostView, View backgroundView, float finalRadius,
+ int fallbackBackgroundColor) {
mFinalRadius = finalRadius;
mSourceView = backgroundView;
mInitialOutlineRadius = getOutlineRadius(hostView, backgroundView);
@@ -81,7 +81,7 @@
setBackground(mBackgroundProperties.mDrawable);
mSourceView.setBackground(null);
} else if (mOriginalForeground == null) {
- mFallbackDrawable.setColor(Themes.getColorBackground(backgroundView.getContext()));
+ mFallbackDrawable.setColor(fallbackBackgroundColor);
setBackground(mFallbackDrawable);
mIsUsingFallback = true;
}
diff --git a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
index 0012dd8..22ce942 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
@@ -34,10 +34,12 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.util.Themes;
import com.android.launcher3.views.FloatingView;
import com.android.launcher3.views.ListenerView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.RoundedCornerEnforcement;
+import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
/** A view that mimics an App Widget through a launch animation. */
@TargetApi(Build.VERSION_CODES.S)
@@ -148,7 +150,7 @@
private void init(DragLayer dragLayer, LauncherAppWidgetHostView originalView,
RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius,
- boolean appTargetIsTranslucent) {
+ boolean appTargetIsTranslucent, int fallbackBackgroundColor) {
mAppWidgetView = originalView;
mAppWidgetView.beginDeferringUpdates();
mBackgroundPosition = widgetBackgroundPosition;
@@ -163,7 +165,8 @@
getRelativePosition(mAppWidgetBackgroundView, dragLayer, mBackgroundPosition);
getRelativePosition(mAppWidgetBackgroundView, mAppWidgetView, mBackgroundOffset);
if (!mAppTargetIsTranslucent) {
- mBackgroundView.init(mAppWidgetView, mAppWidgetBackgroundView, windowCornerRadius);
+ mBackgroundView.init(mAppWidgetView, mAppWidgetBackgroundView, windowCornerRadius,
+ fallbackBackgroundColor);
// Layout call before GhostView creation so that the overlaid view isn't clipped
layout(0, 0, windowSize.getWidth(), windowSize.getHeight());
mForegroundOverlayView = GhostView.addGhost(mAppWidgetView, this);
@@ -274,7 +277,8 @@
*/
public static FloatingWidgetView getFloatingWidgetView(Launcher launcher,
LauncherAppWidgetHostView originalView, RectF widgetBackgroundPosition,
- Size windowSize, float windowCornerRadius, boolean appTargetsAreTranslucent) {
+ Size windowSize, float windowCornerRadius, boolean appTargetsAreTranslucent,
+ int fallbackBackgroundColor) {
final DragLayer dragLayer = launcher.getDragLayer();
ViewGroup parent = (ViewGroup) dragLayer.getParent();
FloatingWidgetView floatingView =
@@ -282,11 +286,22 @@
floatingView.recycle();
floatingView.init(dragLayer, originalView, widgetBackgroundPosition, windowSize,
- windowCornerRadius, appTargetsAreTranslucent);
+ windowCornerRadius, appTargetsAreTranslucent, fallbackBackgroundColor);
parent.addView(floatingView);
return floatingView;
}
+ /**
+ * Extract a background color from a target's task description, or fall back to the given
+ * context's theme background color.
+ */
+ public static int getDefaultBackgroundColor(
+ Context context, RemoteAnimationTargetCompat target) {
+ return (target != null && target.taskInfo.taskDescription != null)
+ ? target.taskInfo.taskDescription.getBackgroundColor()
+ : Themes.getColorBackground(context);
+ }
+
private static void getRelativePosition(View descendant, View ancestor, RectF position) {
float[] points = new float[]{0, 0, descendant.getWidth(), descendant.getHeight()};
Utilities.getDescendantCoordRelativeToAncestor(descendant, ancestor, points,
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index cb9e1f3..a2d86bc 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -397,6 +397,13 @@
return mapRange(interpolator.getInterpolation(progress), toMin, toMax);
}
+ /** Bounds t between a lower and upper bound and maps the result to a range. */
+ public static float mapBoundToRange(float t, float lowerBound, float upperBound,
+ float toMin, float toMax, Interpolator interpolator) {
+ return mapToRange(boundToRange(t, lowerBound, upperBound), lowerBound, upperBound,
+ toMin, toMax, interpolator);
+ }
+
public static float getProgress(float current, float min, float max) {
return Math.abs(current - min) / Math.abs(max - min);
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 17c8edc..2e1cc58 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1922,6 +1922,11 @@
CellLayout layout = (CellLayout) cell.getParent().getParent();
layout.markCellsAsOccupiedForView(cell);
}
+ } else {
+ // When drag is cancelled, reattach content view back to its original parent.
+ if (mDragInfo.cell instanceof LauncherAppWidgetHostView) {
+ d.dragView.detachContentView(/* reattachToPreviousParent= */ true);
+ }
}
final CellLayout parent = (CellLayout) cell.getParent().getParent();
diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetHost.java b/src/com/android/launcher3/widget/LauncherAppWidgetHost.java
index d745754..6dc6971 100644
--- a/src/com/android/launcher3/widget/LauncherAppWidgetHost.java
+++ b/src/com/android/launcher3/widget/LauncherAppWidgetHost.java
@@ -25,15 +25,20 @@
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
+import android.os.Bundle;
import android.os.Handler;
import android.util.SparseArray;
import android.widget.Toast;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.BaseActivity;
+import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.model.WidgetsModel;
+import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.widget.custom.CustomWidgetManager;
@@ -292,8 +297,13 @@
activity.startActivityForResult(intent, requestCode);
}
-
- public void startConfigActivity(BaseActivity activity, int widgetId, int requestCode) {
+ /**
+ * Launches an app widget's configuration activity.
+ * @param activity The activity from which to launch the configuration activity
+ * @param widgetId The id of the bound app widget to be configured
+ * @param requestCode An optional request code to be returned with the result
+ */
+ public void startConfigActivity(BaseDraggingActivity activity, int widgetId, int requestCode) {
if (WidgetsModel.GO_DISABLE_WIDGETS) {
sendActionCancelled(activity, requestCode);
return;
@@ -301,13 +311,27 @@
try {
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startConfigActivity");
- startAppWidgetConfigureActivityForResult(activity, widgetId, 0, requestCode, null);
+ startAppWidgetConfigureActivityForResult(activity, widgetId, 0, requestCode,
+ getConfigurationActivityOptions(activity, widgetId));
} catch (ActivityNotFoundException | SecurityException e) {
Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
sendActionCancelled(activity, requestCode);
}
}
+ /**
+ * Returns an {@link android.app.ActivityOptions} bundle from the {code activity} for launching
+ * the configuration of the {@code widgetId} app widget, or null of options cannot be produced.
+ */
+ @Nullable
+ private Bundle getConfigurationActivityOptions(BaseDraggingActivity activity, int widgetId) {
+ LauncherAppWidgetHostView view = mViews.get(widgetId);
+ if (view == null) return null;
+ Object tag = view.getTag();
+ if (!(tag instanceof ItemInfo)) return null;
+ return activity.getActivityLaunchOptions(view, (ItemInfo) tag).toBundle();
+ }
+
private void sendActionCancelled(final BaseActivity activity, final int requestCode) {
new Handler().post(() -> activity.onActivityResult(requestCode, RESULT_CANCELED, null));
}
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java
index 150bd99..e89aea7 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java
@@ -298,6 +298,12 @@
scrollToPositionAndMaintainOffset(positionForPackageUserKey, topForPackageUserKey);
}
+ /** Returns the position of the currently expanded header, or empty if it's not present. */
+ public OptionalInt getSelectedHeaderPosition() {
+ if (mWidgetsContentVisiblePackageUserKey == null) return OptionalInt.empty();
+ return getPositionForPackageUserKey(mWidgetsContentVisiblePackageUserKey);
+ }
+
/**
* Returns the position of {@code key} in {@link #mVisibleEntries}, or empty if it's not
* present.
diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
index 090362b..4f4f1a3 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
@@ -53,6 +53,7 @@
private HeaderViewDimensionsProvider mHeaderViewDimensionsProvider;
private int mLastVisibleWidgetContentTableHeight = 0;
private int mWidgetHeaderHeight = 0;
+ private final int mCollapsedHeaderBottomMarginSize;
@Nullable private OnContentChangeListener mOnContentChangeListener;
public WidgetsRecyclerView(Context context) {
@@ -71,6 +72,10 @@
ActivityContext activity = ActivityContext.lookupContext(getContext());
DeviceProfile grid = activity.getDeviceProfile();
+
+ // The bottom margin used when the header is not expanded.
+ mCollapsedHeaderBottomMarginSize =
+ getResources().getDimensionPixelSize(R.dimen.widget_list_entry_bottom_margin);
}
@Override
@@ -182,10 +187,7 @@
&& mLastVisibleWidgetContentTableHeight == 0
&& view.getMeasuredHeight() > 0) {
// This assumes all header views are of the same height.
- RecyclerView.LayoutParams layoutParams =
- (RecyclerView.LayoutParams) view.getLayoutParams();
- mWidgetHeaderHeight = view.getMeasuredHeight() + layoutParams.topMargin
- + layoutParams.bottomMargin;
+ mWidgetHeaderHeight = view.getMeasuredHeight();
}
}
@@ -279,12 +281,17 @@
if (untilIndex > mAdapter.getItems().size()) {
untilIndex = mAdapter.getItems().size();
}
+ int expandedHeaderPosition = mAdapter.getSelectedHeaderPosition().orElse(-1);
int totalItemsHeight = 0;
for (int i = 0; i < untilIndex; i++) {
WidgetsListBaseEntry entry = mAdapter.getItems().get(i);
if (entry instanceof WidgetsListHeaderEntry
|| entry instanceof WidgetsListSearchHeaderEntry) {
totalItemsHeight += mWidgetHeaderHeight;
+ if (expandedHeaderPosition != i) {
+ // If the header is collapsed, include the bottom margin it will use.
+ totalItemsHeight += mCollapsedHeaderBottomMarginSize;
+ }
} else if (entry instanceof WidgetsListContentEntry) {
totalItemsHeight += mLastVisibleWidgetContentTableHeight;
} else {