Merge "Ignore touches on launcher while quick scrub is enabled" into ub-launcher3-master
diff --git a/go/res/xml/device_profiles.xml b/go/res/xml/device_profiles.xml
index 487c026..16d7e13 100644
--- a/go/res/xml/device_profiles.xml
+++ b/go/res/xml/device_profiles.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<profiles xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3" >
+<profiles xmlns:launcher="http://schemas.android.com/apk/res-auto" >
<profile
launcher:name="Go Device"
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index 18ddeee..85b40d0 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/res/layout/longpress_options_menu.xml b/quickstep/res/layout/longpress_options_menu.xml
new file mode 100644
index 0000000..9cf0fcf
--- /dev/null
+++ b/quickstep/res/layout/longpress_options_menu.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<com.android.launcher3.uioverrides.OptionsPopupView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="96dp"
+ android:background="?attr/popupColorPrimary"
+ android:elevation="@dimen/deep_shortcuts_elevation"
+ android:orientation="horizontal"
+ launcher:layout_ignoreInsets="true">
+
+ <FrameLayout
+ android:id="@+id/wallpaper_button"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="?android:attr/selectableItemBackground">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:drawablePadding="4dp"
+ android:drawableTint="?android:attr/textColorPrimary"
+ android:drawableTop="@drawable/ic_wallpaper"
+ android:fontFamily="sans-serif-condensed"
+ android:gravity="center"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp"
+ android:text="@string/wallpaper_button_text"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="12sp"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/widget_button"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="?android:attr/selectableItemBackground">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:drawablePadding="4dp"
+ android:drawableTint="?android:attr/textColorPrimary"
+ android:drawableTop="@drawable/ic_widget"
+ android:fontFamily="sans-serif-condensed"
+ android:gravity="center"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp"
+ android:text="@string/widget_button_text"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="12sp"/>
+
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/settings_button"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="?android:attr/selectableItemBackground">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:drawablePadding="4dp"
+ android:drawableTint="?android:attr/textColorPrimary"
+ android:drawableTop="@drawable/ic_setting"
+ android:fontFamily="sans-serif-condensed"
+ android:gravity="center"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp"
+ android:text="@string/settings_button_text"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="12sp"/>
+
+ </FrameLayout>
+
+</com.android.launcher3.uioverrides.OptionsPopupView>
\ No newline at end of file
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 9ef8e82..9cc7973 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -16,11 +16,14 @@
<resources>
+ <dimen name="options_menu_icon_size">24dp</dimen>
+
<dimen name="task_thumbnail_top_margin">24dp</dimen>
<dimen name="task_thumbnail_icon_size">48dp</dimen>
<dimen name="task_menu_background_radius">12dp</dimen>
<dimen name="task_corner_radius">2dp</dimen>
<dimen name="task_fade_length">20dp</dimen>
+ <dimen name="recents_page_spacing">10dp</dimen>
<dimen name="quickstep_fling_threshold_velocity">500dp</dimen>
@@ -31,6 +34,9 @@
<!-- TODO: This can be calculated using other resource values -->
<dimen name="all_apps_search_box_full_height">90dp</dimen>
- <dimen name="drag_layer_trans_y">25dp</dimen>
+ <!-- Launcher app transition -->
+ <dimen name="content_trans_y">25dp</dimen>
+ <dimen name="workspace_trans_y">80dp</dimen>
+ <dimen name="shelf_min_value">-2.857dp</dimen>
</resources>
diff --git a/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java
new file mode 100644
index 0000000..489e55b
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3;
+
+import android.animation.AnimatorSet;
+import android.os.Handler;
+
+import com.android.systemui.shared.system.RemoteAnimationRunnerCompat;
+
+import static com.android.systemui.shared.recents.utilities.Utilities.postAtFrontOfQueueAsynchronously;
+
+public abstract class LauncherAnimationRunner implements RemoteAnimationRunnerCompat {
+
+ AnimatorSet mAnimator;
+ private Launcher mLauncher;
+
+ LauncherAnimationRunner(Launcher launcher) {
+ mLauncher = launcher;
+ }
+
+ @Override
+ public void onAnimationCancelled() {
+ postAtFrontOfQueueAsynchronously(mLauncher.getWindow().getDecorView().getHandler(), () -> {
+ if (mAnimator != null) {
+ mAnimator.cancel();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
index dd05cfe..256e926 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
@@ -16,6 +16,7 @@
package com.android.launcher3;
+import static com.android.launcher3.views.AllAppsScrim.SCRIM_PROGRESS;
import static com.android.systemui.shared.recents.utilities.Utilities.getNextFrameNumber;
import static com.android.systemui.shared.recents.utilities.Utilities.getSurface;
import static com.android.systemui.shared.recents.utilities.Utilities.postAtFrontOfQueueAsynchronously;
@@ -25,10 +26,13 @@
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
@@ -38,48 +42,67 @@
import com.android.launcher3.InsettableFrameLayout.LayoutParams;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.views.AllAppsScrim;
+import com.android.systemui.shared.system.ActivityCompat;
import com.android.systemui.shared.system.ActivityOptionsCompat;
import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;
+import com.android.systemui.shared.system.RemoteAnimationDefinitionCompat;
import com.android.systemui.shared.system.RemoteAnimationRunnerCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import com.android.systemui.shared.system.TransactionCompat;
+import com.android.systemui.shared.system.WindowManagerWrapper;
/**
- * Manages the opening app animations from Launcher.
+ * Manages the opening and closing app transitions from Launcher.
*/
public class LauncherAppTransitionManager {
+ private static final String TAG = "LauncherTransition";
private static final int REFRESH_RATE_MS = 16;
+ private static final int CLOSING_TRANSITION_DURATION_MS = 350;
+
private final DragLayer mDragLayer;
private final Launcher mLauncher;
private final DeviceProfile mDeviceProfile;
- private final float mDragLayerTransY;
+ private final float mContentTransY;
+ private final float mWorkspaceTransY;
+ // The smallest y-value the shelf will reach on screen, before overshooting back down to 0.
+ private final float mShelfMinValue;
private ImageView mFloatingView;
+ private boolean mIsRtl;
public LauncherAppTransitionManager(Launcher launcher) {
mLauncher = launcher;
mDragLayer = launcher.getDragLayer();
mDeviceProfile = launcher.getDeviceProfile();
- mDragLayerTransY =
- launcher.getResources().getDimensionPixelSize(R.dimen.drag_layer_trans_y);
+ mIsRtl = Utilities.isRtl(launcher.getResources());
+
+ Resources res = launcher.getResources();
+ mContentTransY = res.getDimensionPixelSize(R.dimen.content_trans_y);
+ mWorkspaceTransY = res.getDimensionPixelSize(R.dimen.workspace_trans_y);
+ mShelfMinValue = res.getDimensionPixelSize(R.dimen.shelf_min_value);
}
+ /**
+ * @return A Bundle with remote animations that controls how the window of the opening
+ * targets are displayed.
+ */
public Bundle getActivityLauncherOptions(View v) {
- RemoteAnimationRunnerCompat runner = new RemoteAnimationRunnerCompat() {
+ RemoteAnimationRunnerCompat runner = new LauncherAnimationRunner(mLauncher) {
@Override
public void onAnimationStart(RemoteAnimationTargetCompat[] targets,
Runnable finishedCallback) {
// Post at front of queue ignoring sync barriers to make sure it gets processed
// before the next frame.
postAtFrontOfQueueAsynchronously(v.getHandler(), () -> {
- AnimatorSet both = new AnimatorSet();
- both.play(getLauncherAnimators(v));
- both.play(getAppWindowAnimators(v, targets));
- both.addListener(new AnimatorListenerAdapter() {
+ mAnimator = new AnimatorSet();
+ mAnimator.play(getLauncherAnimators(v));
+ mAnimator.play(getWindowAnimators(v, targets));
+ mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// Reset launcher to normal state
@@ -96,51 +119,62 @@
finishedCallback.run();
}
});
- both.start();
+ mAnimator.start();
// Because t=0 has the app icon in its original spot, we can skip the first
// frame and have the same movement one frame earlier.
- both.setCurrentPlayTime(REFRESH_RATE_MS);
+ mAnimator.setCurrentPlayTime(REFRESH_RATE_MS);
});
}
-
- @Override
- public void onAnimationCancelled() {
- }
};
return ActivityOptionsCompat.makeRemoteAnimation(
new RemoteAnimationAdapterCompat(runner, 500, 380)).toBundle();
}
+ /**
+ * @return Animators that control the movements of the Launcher and icon of the opening target.
+ */
private AnimatorSet getLauncherAnimators(View v) {
AnimatorSet launcherAnimators = new AnimatorSet();
- launcherAnimators.play(getHideLauncherAnimator());
- launcherAnimators.play(getAppIconAnimator(v));
+ launcherAnimators.play(getLauncherContentAnimator(false /* show */));
+ launcherAnimators.play(getIconAnimator(v));
return launcherAnimators;
}
- private AnimatorSet getHideLauncherAnimator() {
+ /**
+ * Content is everything on screen except the background and the floating view (if any).
+ *
+ * @param show If true: Animate the content so that it moves upwards and fades in.
+ * Else: Animate the content so that it moves downwards and fades out.
+ */
+ private AnimatorSet getLauncherContentAnimator(boolean show) {
AnimatorSet hideLauncher = new AnimatorSet();
- // Animate the background content so that it moves downwards and fades out.
- if (mLauncher.isInState(LauncherState.ALL_APPS)) {
+ float[] alphas = show
+ ? new float[] {0, 1}
+ : new float[] {1, 0};
+ float[] trans = show
+ ? new float[] {mContentTransY, 0,}
+ : new float[] {0, mContentTransY};
+
+ if (mLauncher.isInState(LauncherState.ALL_APPS) && !mDeviceProfile.isVerticalBarLayout()) {
+ // All Apps in portrait mode is full screen, so we only animate AllAppsContainerView.
View appsView = mLauncher.getAppsView();
- ObjectAnimator alpha = ObjectAnimator.ofFloat(appsView, View.ALPHA, 1f, 0f);
+ ObjectAnimator alpha = ObjectAnimator.ofFloat(appsView, View.ALPHA, alphas);
alpha.setDuration(217);
alpha.setInterpolator(Interpolators.LINEAR);
- ObjectAnimator transY = ObjectAnimator.ofFloat(appsView, View.TRANSLATION_Y, 0,
- mDragLayerTransY);
+ ObjectAnimator transY = ObjectAnimator.ofFloat(appsView, View.TRANSLATION_Y, trans);
transY.setInterpolator(Interpolators.AGGRESSIVE_EASE);
transY.setDuration(350);
hideLauncher.play(alpha);
hideLauncher.play(transY);
} else {
- ObjectAnimator dragLayerAlpha = ObjectAnimator.ofFloat(mDragLayer, View.ALPHA, 1f, 0f);
+ ObjectAnimator dragLayerAlpha = ObjectAnimator.ofFloat(mDragLayer, View.ALPHA, alphas);
dragLayerAlpha.setDuration(217);
dragLayerAlpha.setInterpolator(Interpolators.LINEAR);
ObjectAnimator dragLayerTransY = ObjectAnimator.ofFloat(mDragLayer, View.TRANSLATION_Y,
- 0, mDragLayerTransY);
+ trans);
dragLayerTransY.setInterpolator(Interpolators.AGGRESSIVE_EASE);
dragLayerTransY.setDuration(350);
@@ -150,22 +184,32 @@
return hideLauncher;
}
- private AnimatorSet getAppIconAnimator(View v) {
- // Create a copy of the app icon
+ /**
+ * @return Animator that controls the icon used to launch the target.
+ */
+ private AnimatorSet getIconAnimator(View v) {
+ boolean isBubbleTextView = v instanceof BubbleTextView;
mFloatingView = new ImageView(mLauncher);
- Bitmap iconBitmap = ((FastBitmapDrawable) ((BubbleTextView) v).getIcon()).getBitmap();
- mFloatingView.setImageDrawable(new FastBitmapDrawable(iconBitmap));
+ if (isBubbleTextView) {
+ // Create a copy of the app icon
+ Bitmap iconBitmap = ((FastBitmapDrawable) ((BubbleTextView) v).getIcon()).getBitmap();
+ mFloatingView.setImageDrawable(new FastBitmapDrawable(iconBitmap));
+ }
- // Position the copy of the app icon exactly on top of the original
+ // Position the floating view exactly on top of the original
Rect rect = new Rect();
mDragLayer.getDescendantRectRelativeToSelf(v, rect);
- int viewLocationLeft = rect.left;
+ int viewLocationStart = mIsRtl
+ ? mDeviceProfile.widthPx - rect.right
+ : rect.left;
int viewLocationTop = rect.top;
- ((BubbleTextView) v).getIconBounds(rect);
+ if (isBubbleTextView) {
+ ((BubbleTextView) v).getIconBounds(rect);
+ }
LayoutParams lp = new LayoutParams(rect.width(), rect.height());
lp.ignoreInsets = true;
- lp.leftMargin = viewLocationLeft + rect.left;
+ lp.setMarginStart(viewLocationStart + rect.left);
lp.topMargin = viewLocationTop + rect.top;
mFloatingView.setLayoutParams(lp);
@@ -177,8 +221,13 @@
// Animate the app icon to the center
float centerX = mDeviceProfile.widthPx / 2;
float centerY = mDeviceProfile.heightPx / 2;
- float dX = centerX - lp.leftMargin - (lp.width / 2);
+
+ float xPosition = mIsRtl
+ ? mDeviceProfile.widthPx - lp.getMarginStart() - rect.width()
+ : lp.getMarginStart();
+ float dX = centerX - xPosition - (lp.width / 2);
float dY = centerY - lp.topMargin - (lp.height / 2);
+
ObjectAnimator x = ObjectAnimator.ofFloat(mFloatingView, View.TRANSLATION_X, 0f, dX);
ObjectAnimator y = ObjectAnimator.ofFloat(mFloatingView, View.TRANSLATION_Y, 0f, dY);
@@ -213,9 +262,16 @@
return appIconAnimatorSet;
}
- private ValueAnimator getAppWindowAnimators(View v, RemoteAnimationTargetCompat[] targets) {
- Rect iconBounds = new Rect();
- ((BubbleTextView) v).getIconBounds(iconBounds);
+ /**
+ * @return Animator that controls the window of the opening targets.
+ */
+ private ValueAnimator getWindowAnimators(View v, RemoteAnimationTargetCompat[] targets) {
+ Rect bounds = new Rect();
+ if (v instanceof BubbleTextView) {
+ ((BubbleTextView) v).getIconBounds(bounds);
+ } else {
+ mDragLayer.getDescendantRectRelativeToSelf(v, bounds);
+ }
int[] floatingViewBounds = new int[2];
Rect crop = new Rect();
@@ -228,12 +284,19 @@
@Override
public void onAnimationUpdate(ValueAnimator animation) {
+ final Surface surface = getSurface(mFloatingView);
+ final long frameNumber = surface != null ? getNextFrameNumber(surface) : -1;
+ if (frameNumber == -1) {
+ // Booo, not cool! Our surface got destroyed, so no reason to animate anything.
+ Log.w(TAG, "Failed to animate, surface got destroyed.");
+ return;
+ }
final float percent = animation.getAnimatedFraction();
final float easePercent = Interpolators.AGGRESSIVE_EASE.getInterpolation(percent);
// Calculate app icon size.
- float iconWidth = iconBounds.width() * mFloatingView.getScaleX();
- float iconHeight = iconBounds.height() * mFloatingView.getScaleY();
+ float iconWidth = bounds.width() * mFloatingView.getScaleX();
+ float iconHeight = bounds.height() * mFloatingView.getScaleY();
// Scale the app window to match the icon size.
float scaleX = iconWidth / mDeviceProfile.widthPx;
@@ -257,7 +320,7 @@
// Fade in the app window.
float alphaDelay = 0;
float alphaDuration = 50;
- float alpha = getValue(1f, 0f, alphaDelay, alphaDuration,
+ float alpha = getValue(0f, 1f, alphaDelay, alphaDuration,
appAnimator.getDuration() * percent, Interpolators.AGGRESSIVE_EASE);
// Animate the window crop so that it starts off as a square, and then reveals
@@ -273,9 +336,12 @@
for (RemoteAnimationTargetCompat target : targets) {
if (target.mode == RemoteAnimationTargetCompat.MODE_OPENING) {
t.setAlpha(target.leash, alpha);
+
+ // TODO: This isn't correct at the beginning of the animation, but better
+ // than nothing.
+ matrix.postTranslate(target.position.x, target.position.y);
t.setMatrix(target.leash, matrix);
t.setWindowCrop(target.leash, crop);
- Surface surface = getSurface(mFloatingView);
t.deferTransactionUntil(target.leash, surface, getNextFrameNumber(surface));
}
if (isFirstFrame) {
@@ -287,19 +353,168 @@
matrix.reset();
isFirstFrame = false;
}
-
- /**
- * Helper method that allows us to get interpolated values for embedded
- * animations with a delay and/or different duration.
- */
- private float getValue(float start, float end, float delay, float duration,
- float currentPlayTime, Interpolator i) {
- float time = Math.max(0, currentPlayTime - delay);
- float newPercent = Math.min(1f, time / duration);
- newPercent = i.getInterpolation(newPercent);
- return start * newPercent + end * (1 - newPercent);
- }
});
return appAnimator;
}
+
+ /**
+ * Registers remote animations used when closing apps to home screen.
+ */
+ public void registerRemoteAnimations() {
+ RemoteAnimationDefinitionCompat definition = new RemoteAnimationDefinitionCompat();
+ definition.addRemoteAnimation(WindowManagerWrapper.TRANSIT_WALLPAPER_OPEN,
+ new RemoteAnimationAdapterCompat(getWallpaperOpenRunner(), 0,
+ CLOSING_TRANSITION_DURATION_MS));
+
+// TODO: App controlled transition for unlock to home TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER
+
+ new ActivityCompat(mLauncher).registerRemoteAnimations(definition);
+ }
+
+ /**
+ * @return Runner that plays when user goes to Launcher
+ * ie. pressing home, swiping up from nav bar.
+ */
+ private RemoteAnimationRunnerCompat getWallpaperOpenRunner() {
+ return new LauncherAnimationRunner(mLauncher) {
+ @Override
+ public void onAnimationStart(RemoteAnimationTargetCompat[] targets,
+ Runnable finishedCallback) {
+ Handler handler = mLauncher.getWindow().getDecorView().getHandler();
+ postAtFrontOfQueueAsynchronously(handler, () -> {
+ // We use a separate transition for Overview mode.
+ if (mLauncher.isInState(LauncherState.OVERVIEW)) {
+ finishedCallback.run();
+ return;
+ }
+
+ mAnimator = new AnimatorSet();
+ mAnimator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ finishedCallback.run();
+ }
+ });
+ mAnimator.play(getClosingWindowAnimators(targets));
+ mAnimator.play(getLauncherResumeAnimation());
+ mAnimator.start();
+ });
+ }
+ };
+ }
+
+ /**
+ * Animator that controls the transformations of the windows the targets that are closing.
+ */
+ private Animator getClosingWindowAnimators(RemoteAnimationTargetCompat[] targets) {
+ Matrix matrix = new Matrix();
+ float height = mLauncher.getDeviceProfile().heightPx;
+ float width = mLauncher.getDeviceProfile().widthPx;
+ float endX = Utilities.isRtl(mLauncher.getResources()) ? -width : width;
+
+ ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1);
+ closingAnimator.setDuration(CLOSING_TRANSITION_DURATION_MS);
+
+ closingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ boolean isFirstFrame = true;
+
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ final float percent = animation.getAnimatedFraction();
+ float currentPlayTime = percent * closingAnimator.getDuration();
+
+ float scale = getValue(1f, 0.8f, 0, 267, currentPlayTime,
+ Interpolators.AGGRESSIVE_EASE);
+ matrix.setScale(scale, scale);
+
+ float dX = getValue(0, endX, 0, 350, currentPlayTime,
+ Interpolators.AGGRESSIVE_EASE_IN_OUT);
+
+ TransactionCompat t = new TransactionCompat();
+ for (RemoteAnimationTargetCompat app : targets) {
+ if (app.mode == RemoteAnimationTargetCompat.MODE_CLOSING) {
+ t.setAlpha(app.leash, 1f - percent);
+
+ float dY = (height - (app.clipRect.height() * scale)) / 2f;
+ matrix.postTranslate(dX, dY);
+ t.setMatrix(app.leash, matrix);
+ }
+ // TODO: Layer should be set only once, but there is possibly a race condition
+ // where WindowManager is also calling setLayer.
+ int layer = app.mode == RemoteAnimationTargetCompat.MODE_CLOSING
+ ? Integer.MAX_VALUE
+ : app.prefixOrderIndex;
+ t.setLayer(app.leash, layer);
+ if (isFirstFrame) {
+ t.show(app.leash);
+ }
+ }
+ t.apply();
+
+ matrix.reset();
+ isFirstFrame = false;
+ }
+ });
+ return closingAnimator;
+ }
+
+ /**
+ * @return Animator that modifies Launcher as a result from {@link #getWallpaperOpenRunner}.
+ */
+ private AnimatorSet getLauncherResumeAnimation() {
+ if (mLauncher.isInState(LauncherState.ALL_APPS)
+ || mLauncher.getDeviceProfile().isVerticalBarLayout()) {
+ return getLauncherContentAnimator(true /* show */);
+ } else {
+ AnimatorSet workspaceAnimator = new AnimatorSet();
+ mLauncher.getWorkspace().setTranslationY(mWorkspaceTransY);
+ mLauncher.getWorkspace().setAlpha(0f);
+ workspaceAnimator.play(ObjectAnimator.ofFloat(mLauncher.getWorkspace(),
+ View.TRANSLATION_Y, mWorkspaceTransY, 0));
+ workspaceAnimator.play(ObjectAnimator.ofFloat(mLauncher.getWorkspace(), View.ALPHA,
+ 0, 1f));
+ workspaceAnimator.setStartDelay(150);
+ workspaceAnimator.setDuration(333);
+ workspaceAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+
+ // Animate the shelf
+ AllAppsScrim allAppsScrim = mLauncher.findViewById(R.id.all_apps_scrim);
+ View hotseat = mLauncher.getHotseat();
+ final float endY = mShelfMinValue;
+ int startY = hotseat.getMeasuredHeight()
+ + (allAppsScrim.getShadowBitmap().getHeight() / 2);
+ hotseat.setTranslationY(startY);
+ allAppsScrim.setTranslationY(startY);
+
+ AnimatorSet hotseatSlideIn = new AnimatorSet();
+ hotseatSlideIn.play(ObjectAnimator.ofFloat(hotseat, View.TRANSLATION_Y, startY, endY));
+ hotseatSlideIn.play(ObjectAnimator.ofFloat(allAppsScrim, SCRIM_PROGRESS, startY, endY));
+ hotseatSlideIn.setStartDelay(150);
+ hotseatSlideIn.setDuration(317);
+ hotseatSlideIn.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+
+ AnimatorSet hotseatOvershoot = new AnimatorSet();
+ hotseatOvershoot.play(ObjectAnimator.ofFloat(hotseat, View.TRANSLATION_Y, endY, 0));
+ hotseatOvershoot.play(ObjectAnimator.ofFloat(allAppsScrim, SCRIM_PROGRESS, endY, 0));
+ hotseatOvershoot.setDuration(153);
+ hotseatOvershoot.setInterpolator(Interpolators.OVERSHOOT_0);
+
+ AnimatorSet resumeLauncherAnimation = new AnimatorSet();
+ resumeLauncherAnimation.play(workspaceAnimator);
+ resumeLauncherAnimation.playSequentially(hotseatSlideIn, hotseatOvershoot);
+ return resumeLauncherAnimation;
+ }
+ }
+
+ /**
+ * Helper method that allows us to get interpolated values for embedded
+ * animations with a delay and/or different duration.
+ */
+ private static float getValue(float start, float end, float delay, float duration,
+ float currentPlayTime, Interpolator i) {
+ float time = Math.max(0, currentPlayTime - delay);
+ float newPercent = Math.min(1f, time / duration);
+ newPercent = i.getInterpolation(newPercent);
+ return end * newPercent + start * (1 - newPercent);
+ }
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
index 6395473..426fe35 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
@@ -83,7 +83,7 @@
@Override
public float getHoseatAlpha(Launcher launcher) {
- return launcher.getDeviceProfile().isVerticalBarLayout() ? 0 : 1;
+ return 0;
}
@Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OptionsPopupView.java b/quickstep/src/com/android/launcher3/uioverrides/OptionsPopupView.java
new file mode 100644
index 0000000..c089d06
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/uioverrides/OptionsPopupView.java
@@ -0,0 +1,276 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.uioverrides;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Outline;
+import android.graphics.PointF;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.ViewOutlineProvider;
+import android.widget.Toast;
+
+import com.android.launcher3.AbstractFloatingView;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherAnimUtils;
+import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.anim.Interpolators;
+import com.android.launcher3.anim.RevealOutlineAnimation;
+import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
+import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.graphics.GradientView;
+import com.android.launcher3.widget.WidgetsFullSheet;
+
+/**
+ * Popup shown on long pressing an empty space in launcher
+ */
+public class OptionsPopupView extends AbstractFloatingView implements OnClickListener {
+
+ private final float mOutlineRadius;
+ private final Launcher mLauncher;
+ private final PointF mTouchPoint = new PointF();
+
+ private final GradientView mGradientView;
+
+ protected Animator mOpenCloseAnimator;
+
+ public OptionsPopupView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public OptionsPopupView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+
+ mOutlineRadius = getResources().getDimension(R.dimen.bg_round_rect_radius);
+ setClipToOutline(true);
+ setOutlineProvider(new ViewOutlineProvider() {
+ @Override
+ public void getOutline(View view, Outline outline) {
+ outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mOutlineRadius);
+ }
+ });
+
+ mLauncher = Launcher.getLauncher(context);
+
+ mGradientView = (GradientView) mLauncher.getLayoutInflater().inflate(
+ R.layout.widgets_bottom_sheet_scrim, mLauncher.getDragLayer(), false);
+ mGradientView.setProgress(1, false);
+ mGradientView.setAlpha(0);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ findViewById(R.id.wallpaper_button).setOnClickListener(this);
+ findViewById(R.id.widget_button).setOnClickListener(this);
+ findViewById(R.id.settings_button).setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View view) {
+ if (view.getId() == R.id.wallpaper_button) {
+ mLauncher.onClickWallpaperPicker(null);
+ close(true);
+ } else if (view.getId() == R.id.widget_button) {
+ if (mLauncher.getPackageManager().isSafeMode()) {
+ Toast.makeText(mLauncher, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
+ } else {
+ WidgetsFullSheet.show(mLauncher, true /* animated */);
+ close(true);
+ }
+ } else if (view.getId() == R.id.settings_button) {
+ mLauncher.startActivity(new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
+ .setPackage(mLauncher.getPackageName())
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ close(true);
+ }
+ }
+
+ @Override
+ public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
+ if (ev.getAction() != MotionEvent.ACTION_DOWN) {
+ return false;
+ }
+ if (mLauncher.getDragLayer().isEventOverView(this, ev)) {
+ return false;
+ }
+ close(true);
+ return true;
+ }
+
+ @Override
+ protected void handleClose(boolean animate) {
+ if (animate) {
+ animateClose();
+ } else {
+ closeComplete();
+ }
+ }
+
+ protected void animateClose() {
+ if (!mIsOpen) {
+ return;
+ }
+ mIsOpen = false;
+
+ final AnimatorSet closeAnim = LauncherAnimUtils.createAnimatorSet();
+ closeAnim.setDuration(getResources().getInteger(R.integer.config_popupOpenCloseDuration));
+
+ // Rectangular reveal (reversed).
+ final ValueAnimator revealAnim = createOpenCloseOutlineProvider()
+ .createRevealAnimator(this, true);
+ closeAnim.play(revealAnim);
+
+ Animator fadeOut = ObjectAnimator.ofFloat(this, ALPHA, 0);
+ fadeOut.setInterpolator(Interpolators.DEACCEL);
+ closeAnim.play(fadeOut);
+
+ Animator gradientAlpha = ObjectAnimator.ofFloat(mGradientView, ALPHA, 0);
+ gradientAlpha.setInterpolator(Interpolators.DEACCEL);
+ closeAnim.play(gradientAlpha);
+
+ closeAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mOpenCloseAnimator = null;
+ closeComplete();
+ }
+ });
+ if (mOpenCloseAnimator != null) {
+ mOpenCloseAnimator.cancel();
+ }
+ mOpenCloseAnimator = closeAnim;
+ closeAnim.start();
+ }
+
+ /**
+ * Closes the popup without animation.
+ */
+ private void closeComplete() {
+ if (mOpenCloseAnimator != null) {
+ mOpenCloseAnimator.cancel();
+ mOpenCloseAnimator = null;
+ }
+ mIsOpen = false;
+ mLauncher.getDragLayer().removeView(this);
+ mLauncher.getDragLayer().removeView(mGradientView);
+ }
+
+ @Override
+ public void logActionCommand(int command) {
+ // TODO:
+ }
+
+ @Override
+ protected boolean isOfType(int type) {
+ return (type & TYPE_OPTIONS_POPUP) != 0;
+ }
+
+ private RoundedRectRevealOutlineProvider createOpenCloseOutlineProvider() {
+ DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
+ Rect startRect = new Rect();
+ startRect.offset((int) (mTouchPoint.x - lp.x), (int) (mTouchPoint.y - lp.y));
+
+ Rect endRect = new Rect(0, 0, lp.width, lp.height);
+ if (getOutlineProvider() instanceof RevealOutlineAnimation) {
+ ((RevealOutlineAnimation) getOutlineProvider()).getOutline(endRect);
+ }
+
+ return new RoundedRectRevealOutlineProvider
+ (mOutlineRadius, mOutlineRadius, startRect, endRect);
+ }
+
+ private void animateOpen() {
+ mIsOpen = true;
+ final AnimatorSet openAnim = LauncherAnimUtils.createAnimatorSet();
+ openAnim.setDuration(getResources().getInteger(R.integer.config_popupOpenCloseDuration));
+
+ final ValueAnimator revealAnim = createOpenCloseOutlineProvider()
+ .createRevealAnimator(this, false);
+ openAnim.play(revealAnim);
+
+ Animator gradientAlpha = ObjectAnimator.ofFloat(mGradientView, ALPHA, 1);
+ gradientAlpha.setInterpolator(Interpolators.ACCEL);
+ openAnim.play(gradientAlpha);
+
+ mOpenCloseAnimator = openAnim;
+
+ openAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mOpenCloseAnimator = null;
+ }
+ });
+ openAnim.start();
+ }
+
+ public static void show(Launcher launcher, float x, float y) {
+ DragLayer dl = launcher.getDragLayer();
+ OptionsPopupView view = (OptionsPopupView) launcher.getLayoutInflater()
+ .inflate(R.layout.longpress_options_menu, dl, false);
+ DragLayer.LayoutParams lp = (DragLayer.LayoutParams) view.getLayoutParams();
+
+ int maxWidth = dl.getWidth();
+ int maxHeight = dl.getHeight();
+ if (x <= 0 || y <= 0 || x >= maxWidth || y >= maxHeight) {
+ x = maxWidth / 2;
+ y = maxHeight / 2;
+ }
+ view.mTouchPoint.set(x, y);
+
+ int height = lp.height;
+
+ // Find a good width;
+ int childCount = view.getChildCount();
+ int heightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
+ int widthSpec = MeasureSpec.makeMeasureSpec(maxWidth / childCount, MeasureSpec.AT_MOST);
+ int maxChildWidth = 0;
+
+ for (int i = 0; i < childCount; i ++) {
+ View child = ((ViewGroup) view.getChildAt(i)).getChildAt(0);
+ child.measure(widthSpec, heightSpec);
+ maxChildWidth = Math.max(maxChildWidth, child.getMeasuredWidth());
+ }
+ Rect insets = dl.getInsets();
+ int margin = (int) (2 * view.getElevation());
+
+ int width = Math.min(maxWidth - insets.left - insets.right - 2 * margin,
+ maxChildWidth * childCount);
+ lp.width = width;
+
+ // Position is towards the finger
+ lp.customPosition = true;
+ lp.x = Utilities.boundToRange((int) (x - width / 2), insets.left + margin,
+ maxWidth - insets.right - width - margin);
+ lp.y = Utilities.boundToRange((int) (y - height / 2), insets.top + margin,
+ maxHeight - insets.bottom - height - margin);
+
+ launcher.getDragLayer().addView(view.mGradientView);
+ launcher.getDragLayer().addView(view);
+ view.animateOpen();
+ }
+}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index a05304b..e9d928c 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -16,23 +16,19 @@
package com.android.launcher3.uioverrides;
-import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.PointF;
import android.os.Bundle;
import android.view.View;
import android.view.View.AccessibilityDelegate;
-import android.widget.PopupMenu;
-import android.widget.Toast;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppTransitionManager;
import com.android.launcher3.LauncherStateManager.StateHandler;
-import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.BitmapRenderer;
import com.android.launcher3.util.TouchController;
-import com.android.launcher3.widget.WidgetsFullSheet;
import com.android.quickstep.RecentsView;
import com.android.systemui.shared.recents.view.RecentsTransition;
@@ -65,31 +61,8 @@
new RecentsViewStateController(launcher)};
}
- public static void onWorkspaceLongPress(Launcher launcher) {
- PopupMenu menu = new PopupMenu(launcher.getApplicationContext(),
- launcher.getWorkspace().getPageIndicator());
-
- menu.getMenu().add(R.string.wallpaper_button_text).setOnMenuItemClickListener((i) -> {
- launcher.onClickWallpaperPicker(null);
- return true;
- });
- menu.getMenu().add(R.string.widget_button_text).setOnMenuItemClickListener((i) -> {
- if (launcher.getPackageManager().isSafeMode()) {
- Toast.makeText(launcher, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
- } else {
- WidgetsFullSheet.show(launcher, true /* animated */);
- }
- return true;
- });
- if (launcher.hasSettings()) {
- menu.getMenu().add(R.string.settings_button_text).setOnMenuItemClickListener((i) -> {
- launcher.startActivity(new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
- .setPackage(launcher.getPackageName())
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
- return true;
- });
- }
- menu.show();
+ public static void onWorkspaceLongPress(Launcher launcher, PointF touchPoint) {
+ OptionsPopupView.show(launcher, touchPoint.x, touchPoint.y);
}
public static Bitmap createFromRenderer(int width, int height, boolean forceSoftwareRenderer,
@@ -117,4 +90,12 @@
return launcher.getDefaultActivityLaunchOptions(v);
}
}
+
+ public static void registerRemoteAnimations(Launcher launcher) {
+ try {
+ new LauncherAppTransitionManager(launcher).registerRemoteAnimations();
+ } catch (NoClassDefFoundError e) {
+ // Gracefully fall back if the user's platform doesn't have the latest changes
+ }
+ }
}
diff --git a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
index 168c1fe..b295df0 100644
--- a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
+++ b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
@@ -15,6 +15,11 @@
*/
package com.android.quickstep;
+import static com.android.quickstep.TouchInteractionService.INTERACTION_NORMAL;
+import static com.android.quickstep.TouchInteractionService.INTERACTION_QUICK_SCRUB;
+import static com.android.quickstep.TouchInteractionService.INTERACTION_QUICK_SWITCH;
+import static com.android.quickstep.TouchInteractionService.isInteractionQuick;
+
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.RectEvaluator;
@@ -27,7 +32,6 @@
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Build;
-import android.os.Handler;
import android.os.UserHandle;
import android.support.annotation.UiThread;
import android.view.View;
@@ -41,12 +45,13 @@
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.states.InternalStateHandler;
-import com.android.launcher3.uioverrides.RecentsViewStateController;
+import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.TraceHelper;
-import com.android.launcher3.views.AllAppsScrim;
+import com.android.quickstep.TouchInteractionService.InteractionType;
import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task.TaskKey;
@@ -61,7 +66,6 @@
private static final int STATE_SCALED_SNAPSHOT_RECENTS = 1 << 5;
private static final int STATE_SCALED_SNAPSHOT_APP = 1 << 6;
- private static final long RECENTS_VIEW_VISIBILITY_DURATION = 150;
private static final long MAX_SWIPE_DURATION = 200;
private static final long MIN_SWIPE_DURATION = 80;
private static final int QUICK_SWITCH_SNAP_DURATION = 120;
@@ -95,21 +99,22 @@
private Launcher mLauncher;
private SnapshotDragView mDragView;
private RecentsView mRecentsView;
- private RecentsViewStateController mStateController;
private QuickScrubController mQuickScrubController;
private Hotseat mHotseat;
- private AllAppsScrim mAllAppsScrim;
+
+ private boolean mWasLauncherAlreadyVisible;
private boolean mLauncherReady;
private boolean mTouchEndHandled;
private float mCurrentDisplacement;
- private @TouchInteractionService.InteractionType int mInteractionType;
+
+ private @InteractionType int mInteractionType;
private boolean mStartedQuickScrubFromHome;
private Bitmap mTaskSnapshot;
NavBarSwipeInteractionHandler(RunningTaskInfo runningTaskInfo, Context context,
- @TouchInteractionService.InteractionType int interactionType) {
+ @InteractionType int interactionType) {
// TODO: We need a better way for this
TaskKey taskKey = new TaskKey(runningTaskInfo.id, 0, null, UserHandle.myUserId(), 0);
mRunningTask = new Task(taskKey, null, null, "", "", Color.BLACK, Color.BLACK,
@@ -186,9 +191,8 @@
mLauncher = launcher;
mRecentsView = launcher.getOverviewPanel();
mRecentsView.showTask(mRunningTask);
- mStateController = mRecentsView.getStateController();
mHotseat = mLauncher.getHotseat();
- mAllAppsScrim = mLauncher.findViewById(R.id.all_apps_scrim);
+ mWasLauncherAlreadyVisible = alreadyOnHome;
AbstractFloatingView.closeAllOpenViews(mLauncher, alreadyOnHome);
mLauncher.getStateManager().goToState(LauncherState.OVERVIEW, alreadyOnHome);
@@ -198,17 +202,8 @@
mDragView.setPivotX(0);
mDragView.setPivotY(0);
- boolean interactionIsQuick
- = mInteractionType == TouchInteractionService.INTERACTION_QUICK_SCRUB
- || mInteractionType == TouchInteractionService.INTERACTION_QUICK_SWITCH;
- mStartedQuickScrubFromHome = alreadyOnHome && interactionIsQuick;
- if (interactionIsQuick) {
- mQuickScrubController = mRecentsView.getQuickScrubController();
- mQuickScrubController.onQuickScrubStart(mStartedQuickScrubFromHome);
- animateToProgress(1f, MAX_SWIPE_DURATION);
- if (mStartedQuickScrubFromHome) {
- mDragView.setVisibility(View.INVISIBLE);
- }
+ if (isInteractionQuick(mInteractionType)) {
+ updateUiForQuickScrub();
}
// Optimization
@@ -219,6 +214,34 @@
TraceHelper.partitionSection("TouchInt", "Launcher on new intent");
}
+
+ public void updateInteractionType(@InteractionType int interactionType) {
+ Preconditions.assertUIThread();
+ if (mInteractionType != INTERACTION_NORMAL) {
+ throw new IllegalArgumentException(
+ "Can't change interaction type from " + mInteractionType);
+ }
+ if (!isInteractionQuick(interactionType)) {
+ throw new IllegalArgumentException(
+ "Can't change interaction type to " + interactionType);
+ }
+ mInteractionType = interactionType;
+
+ if (mLauncher != null) {
+ updateUiForQuickScrub();
+ }
+ }
+
+ private void updateUiForQuickScrub() {
+ mStartedQuickScrubFromHome = mWasLauncherAlreadyVisible;
+ mQuickScrubController = mRecentsView.getQuickScrubController();
+ mQuickScrubController.onQuickScrubStart(mStartedQuickScrubFromHome);
+ animateToProgress(1f, MAX_SWIPE_DURATION);
+ if (mStartedQuickScrubFromHome) {
+ mDragView.setVisibility(View.INVISIBLE);
+ }
+ }
+
@UiThread
public void updateDisplacement(float displacement) {
mCurrentDisplacement = displacement;
@@ -242,11 +265,10 @@
}
float shift = mCurrentShift.value * mActivityMultiplier.value;
- int hotseatSize = getHotseatSize();
- float hotseatTranslation = (1 - shift) * hotseatSize;
- mHotseat.setTranslationY(hotseatTranslation);
- mAllAppsScrim.setTranslationY(hotseatTranslation);
+ AllAppsTransitionController controller = mLauncher.getAllAppsController();
+ float range = getHotseatSize() / controller.getShiftRange();
+ controller.setProgress(1 + (1 - shift) * range);
mRectEvaluator.evaluate(shift, mSourceRect, mTargetRect);
@@ -329,8 +351,7 @@
private void cleanupLauncher() {
// TODO: These should be done as part of ActivityOptions#OnAnimationStarted
- mHotseat.setTranslationY(0);
- mAllAppsScrim.setTranslationY(0);
+ mLauncher.getStateManager().reapplyState();
mLauncher.setOnResumeCallback(() -> mDragView.close(false));
}
@@ -340,7 +361,7 @@
if (currentRecentsPage instanceof TaskView) {
((TaskView) currentRecentsPage).animateIconToScale(1f);
}
- if (mInteractionType == TouchInteractionService.INTERACTION_QUICK_SWITCH) {
+ if (mInteractionType == INTERACTION_QUICK_SWITCH) {
for (int i = mRecentsView.getFirstTaskIndex(); i < mRecentsView.getPageCount(); i++) {
TaskView taskView = (TaskView) mRecentsView.getPageAt(i);
// TODO: Match the keys directly
@@ -351,7 +372,7 @@
break;
}
}
- } else if (mInteractionType == TouchInteractionService.INTERACTION_QUICK_SCRUB) {
+ } else if (mInteractionType == INTERACTION_QUICK_SCRUB) {
if (mQuickScrubController != null) {
mQuickScrubController.snapToPageForCurrentQuickScrubSection();
}
@@ -361,12 +382,16 @@
public void onQuickScrubEnd() {
if (mQuickScrubController != null) {
mQuickScrubController.onQuickScrubEnd();
+ } else {
+ // TODO:
}
}
public void onQuickScrubProgress(float progress) {
if (mQuickScrubController != null) {
mQuickScrubController.onQuickScrubProgress(progress);
+ } else {
+ // TODO:
}
}
}
diff --git a/quickstep/src/com/android/quickstep/RecentsView.java b/quickstep/src/com/android/quickstep/RecentsView.java
index 836e713..31f8058 100644
--- a/quickstep/src/com/android/quickstep/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/RecentsView.java
@@ -438,7 +438,9 @@
}
mFirstTask = task;
setCurrentPage(mFirstTaskIndex);
- ((TaskView) getPageAt(mCurrentPage)).setIconScale(0);
+ if (mCurrentPage >= mFirstTaskIndex) {
+ ((TaskView) getPageAt(mCurrentPage)).setIconScale(0);
+ }
}
private static boolean keysEquals(Task t1, Task t2) {
diff --git a/quickstep/src/com/android/quickstep/TaskMenuView.java b/quickstep/src/com/android/quickstep/TaskMenuView.java
index bf75376..196a227 100644
--- a/quickstep/src/com/android/quickstep/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/TaskMenuView.java
@@ -35,6 +35,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
import com.android.launcher3.dragndrop.DragLayer;
@@ -170,7 +171,8 @@
measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
mLauncher.getDragLayer().getDescendantRectRelativeToSelf(taskView, sTempRect);
Rect insets = mLauncher.getDragLayer().getInsets();
- setX(sTempRect.left + (sTempRect.width() - getMeasuredWidth()) / 2 - insets.left);
+ int x = sTempRect.left + (sTempRect.width() - getMeasuredWidth()) / 2 - insets.left;
+ setX(Utilities.isRtl(getResources()) ? -x : x);
setY(sTempRect.top - mTaskIconAndName.getPaddingTop() - insets.top);
}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index c35ffee..9b31c14 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -52,6 +52,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.util.TraceHelper;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
@@ -99,6 +100,7 @@
@Override
public void onQuickSwitch() {
startTouchTracking(INTERACTION_QUICK_SWITCH);
+ mInteractionHandler = null;
}
@Override
@@ -110,6 +112,7 @@
public void onQuickScrubEnd() {
if (mInteractionHandler != null) {
mInteractionHandler.onQuickScrubEnd();
+ mInteractionHandler = null;
}
}
@@ -137,6 +140,7 @@
private Intent mHomeIntent;
private ComponentName mLauncher;
private MotionEventQueue mEventQueue;
+ private MainThreadExecutor mMainThreadExecutor;
private final PointF mDownPos = new PointF();
private final PointF mLastPos = new PointF();
@@ -156,6 +160,7 @@
super.onCreate();
mAM = ActivityManagerWrapper.getInstance();
mRecentsModel = RecentsModel.getInstance(this);
+ mMainThreadExecutor = new MainThreadExecutor();
mHomeIntent = new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)
@@ -284,7 +289,17 @@
return mDisplayRotation == Surface.ROTATION_270 && mStableInsets.left > 0;
}
+
private void startTouchTracking(@InteractionType int interactionType) {
+ if (isInteractionQuick(interactionType)) {
+ // TODO: Send action cancel if its the Launcher consumer
+ }
+ if (mInteractionHandler != null) {
+ final NavBarSwipeInteractionHandler handler = mInteractionHandler;
+ mMainThreadExecutor.execute(() -> handler.updateInteractionType(interactionType));
+ return;
+ }
+
// Create the shared handler
final NavBarSwipeInteractionHandler handler =
new NavBarSwipeInteractionHandler(mRunningTask, this, interactionType);
@@ -430,4 +445,9 @@
ev.setEdgeFlags(flags);
}
}
+
+ public static boolean isInteractionQuick(@InteractionType int interactionType) {
+ return interactionType == INTERACTION_QUICK_SCRUB ||
+ interactionType == INTERACTION_QUICK_SWITCH;
+ }
}
diff --git a/res/drawable/ic_setting.xml b/res/drawable/ic_setting.xml
index 1bab189..08eba25 100644
--- a/res/drawable/ic_setting.xml
+++ b/res/drawable/ic_setting.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48dp"
- android:height="48dp"
+ android:width="@dimen/options_menu_icon_size"
+ android:height="@dimen/options_menu_icon_size"
android:viewportWidth="48.0"
android:viewportHeight="48.0">
<path
diff --git a/res/drawable/ic_wallpaper.xml b/res/drawable/ic_wallpaper.xml
index 9e9222f..0c5a125 100644
--- a/res/drawable/ic_wallpaper.xml
+++ b/res/drawable/ic_wallpaper.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48dp"
- android:height="48dp"
+ android:width="@dimen/options_menu_icon_size"
+ android:height="@dimen/options_menu_icon_size"
android:viewportWidth="48.0"
android:viewportHeight="48.0">
<path
diff --git a/res/drawable/ic_widget.xml b/res/drawable/ic_widget.xml
index de2980f..4bb23b3 100644
--- a/res/drawable/ic_widget.xml
+++ b/res/drawable/ic_widget.xml
@@ -14,12 +14,12 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48dp"
- android:height="48dp"
+ android:width="@dimen/options_menu_icon_size"
+ android:height="@dimen/options_menu_icon_size"
android:viewportWidth="48.0"
android:viewportHeight="48.0">
<path
- android:fillColor="#FFFFFFFF"
+ android:fillColor="?android:attr/textColorPrimary"
android:pathData="M26,28v12c0,1,0.8,2,2,2h12c1,0,2-1,2-2V28c0-1.2-1-2-2-2H28C26.8,26,26,26.8,26,28z M8,42h12c1.2,0,2-1,2-2V28
c0-1.2-0.8-2-2-2H8c-1,0-2,0.8-2,2v12C6,41,7,42,8,42z M6,8v12c0,1.2,1,2,2,2h12c1.2,0,2-0.8,2-2V8c0-1-0.8-2-2-2H8C7,6,6,7,6,8z
M32.6,4.6l-8,8c-0.8,0.8-0.8,2,0,2.8l8,8c0.8,0.8,2,0.8,2.8,0l8-8c0.8-0.8,0.8-2,0-2.8l-8-8C34.6,3.8,33.4,3.8,32.6,4.6z"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 00ef8b2..2aff936 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -227,6 +227,6 @@
<dimen name="popup_item_divider_height">0.5dp</dimen>
<dimen name="swipe_helper_falsing_threshold">70dp</dimen>
-<!-- Recents -->
- <dimen name="recents_page_spacing">10dp</dimen>
+<!-- Overview -->
+ <dimen name="options_menu_icon_size">48dp</dimen>
</resources>
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index 824040a..12f022f 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -42,9 +42,11 @@
TYPE_WIDGETS_BOTTOM_SHEET,
TYPE_WIDGET_RESIZE_FRAME,
TYPE_WIDGETS_FULL_SHEET,
- TYPE_QUICKSTEP_PREVIEW,
TYPE_ON_BOARD_POPUP,
- TYPE_TASK_MENU
+
+ TYPE_QUICKSTEP_PREVIEW,
+ TYPE_TASK_MENU,
+ TYPE_OPTIONS_POPUP
})
@Retention(RetentionPolicy.SOURCE)
public @interface FloatingViewType {}
@@ -53,17 +55,20 @@
public static final int TYPE_WIDGETS_BOTTOM_SHEET = 1 << 2;
public static final int TYPE_WIDGET_RESIZE_FRAME = 1 << 3;
public static final int TYPE_WIDGETS_FULL_SHEET = 1 << 4;
- public static final int TYPE_QUICKSTEP_PREVIEW = 1 << 5;
- public static final int TYPE_ON_BOARD_POPUP = 1 << 6;
+ public static final int TYPE_ON_BOARD_POPUP = 1 << 5;
+
+ // Popups related to quickstep UI
+ public static final int TYPE_QUICKSTEP_PREVIEW = 1 << 6;
public static final int TYPE_TASK_MENU = 1 << 7;
+ public static final int TYPE_OPTIONS_POPUP = 1 << 8;
public static final int TYPE_ALL = TYPE_FOLDER | TYPE_ACTION_POPUP
| TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET
- | TYPE_QUICKSTEP_PREVIEW | TYPE_ON_BOARD_POPUP | TYPE_TASK_MENU;
+ | TYPE_QUICKSTEP_PREVIEW | TYPE_ON_BOARD_POPUP | TYPE_TASK_MENU | TYPE_OPTIONS_POPUP;
// Type of popups which should be kept open during launcher rebind
public static final int TYPE_REBIND_SAFE = TYPE_WIDGETS_FULL_SHEET
- | TYPE_QUICKSTEP_PREVIEW | TYPE_ON_BOARD_POPUP;
+ | TYPE_QUICKSTEP_PREVIEW | TYPE_ON_BOARD_POPUP | TYPE_OPTIONS_POPUP;
protected boolean mIsOpen;
diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java
index 289242f..e52fd76 100644
--- a/src/com/android/launcher3/InfoDropTarget.java
+++ b/src/com/android/launcher3/InfoDropTarget.java
@@ -70,7 +70,7 @@
Rect sourceBounds, Bundle opts) {
if (info instanceof PromiseAppInfo) {
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
- context.startActivity(promiseAppInfo.getMarketIntent());
+ context.startActivity(promiseAppInfo.getMarketIntent(context));
return null;
}
ComponentName componentName = null;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 38a3044..5db0a3b 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -56,6 +56,7 @@
import android.content.pm.PackageManager;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Point;
+import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@@ -268,7 +269,7 @@
*/
private PendingRequestArgs mPendingRequestArgs;
- private float mLastDispatchTouchEventX = 0.0f;
+ private final PointF mLastDispatchTouchEvent = new PointF();
public ViewGroupFocusHelper mFocusHandler;
private boolean mRotationEnabled = false;
@@ -402,6 +403,10 @@
getSystemUiController().updateUiState(SystemUiController.UI_STATE_BASE_WINDOW,
Themes.getAttrBoolean(this, R.attr.isWorkspaceDarkText));
+ if (!isInMultiWindowModeCompat()) {
+ UiFactory.registerRemoteAnimations(this);
+ }
+
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onCreate(savedInstanceState);
}
@@ -1738,7 +1743,7 @@
private void startMarketIntentForPackage(View v, String packageName) {
ItemInfo item = (ItemInfo) v.getTag();
- Intent intent = PackageManagerHelper.getMarketIntent(packageName);
+ Intent intent = new PackageManagerHelper(v.getContext()).getMarketIntent(packageName);
startActivitySafely(v, intent, item);
}
@@ -1803,7 +1808,7 @@
Intent intent;
if (item instanceof PromiseAppInfo) {
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
- intent = promiseAppInfo.getMarketIntent();
+ intent = promiseAppInfo.getMarketIntent(this);
} else {
intent = item.getIntent();
}
@@ -2013,7 +2018,7 @@
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
- mLastDispatchTouchEventX = ev.getX();
+ mLastDispatchTouchEvent.set(ev.getX(), ev.getY());
return super.dispatchTouchEvent(ev);
}
@@ -2024,7 +2029,7 @@
if (!isInState(NORMAL) && !isInState(OVERVIEW)) return false;
boolean ignoreLongPressToOverview =
- mDeviceProfile.shouldIgnoreLongPressToOverview(mLastDispatchTouchEventX);
+ mDeviceProfile.shouldIgnoreLongPressToOverview(mLastDispatchTouchEvent.x);
if (v instanceof Workspace) {
if (!isInState(OVERVIEW)) {
@@ -2032,7 +2037,7 @@
getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
Action.Direction.NONE, ContainerType.WORKSPACE,
mWorkspace.getCurrentPage());
- UiFactory.onWorkspaceLongPress(this);
+ UiFactory.onWorkspaceLongPress(this, mLastDispatchTouchEvent);
mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
return true;
@@ -2069,7 +2074,7 @@
getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
Action.Direction.NONE, ContainerType.WORKSPACE,
mWorkspace.getCurrentPage());
- UiFactory.onWorkspaceLongPress(this);
+ UiFactory.onWorkspaceLongPress(this, mLastDispatchTouchEvent);
}
mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
diff --git a/src/com/android/launcher3/PromiseAppInfo.java b/src/com/android/launcher3/PromiseAppInfo.java
index 07515d0..ea9f752 100644
--- a/src/com/android/launcher3/PromiseAppInfo.java
+++ b/src/com/android/launcher3/PromiseAppInfo.java
@@ -16,6 +16,7 @@
package com.android.launcher3;
+import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
@@ -46,7 +47,7 @@
return shortcut;
}
- public Intent getMarketIntent() {
- return PackageManagerHelper.getMarketIntent(componentName.getPackageName());
+ public Intent getMarketIntent(Context context) {
+ return new PackageManagerHelper(context).getMarketIntent(componentName.getPackageName());
}
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index c946a44..e6aa6be 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -179,27 +179,6 @@
private SpringLoadedDragController mSpringLoadedDragController;
- // Direction used for moving the workspace and hotseat UI
- public enum Direction {
- X (TRANSLATION_X),
- Y (TRANSLATION_Y);
-
- private final Property<View, Float> viewProperty;
-
- Direction(Property<View, Float> viewProperty) {
- this.viewProperty = viewProperty;
- }
- }
-
- private static final int HOTSEAT_STATE_ALPHA_INDEX = 2;
-
- /**
- * Hotseat alpha can be changed when moving horizontally, vertically, changing states.
- * The values correspond to {@link Direction#X}, {@link Direction#Y} &
- * {@link #HOTSEAT_STATE_ALPHA_INDEX} respectively.
- */
- private final float[] mHotseatAlpha = new float[] {1, 1, 1};
-
private boolean mIsSwitchingState = false;
boolean mChildrenLayersEnabled = true;
@@ -1206,81 +1185,8 @@
// TODO(adamcohen): figure out a final effect here. We may need to recommend
// different effects based on device performance. On at least one relatively high-end
// device I've tried, translating the launcher causes things to get quite laggy.
- setWorkspaceTranslationAndAlpha(transX, alpha);
- setHotseatTranslationAndAlpha(Direction.X, transX, alpha);
- }
-
- /**
- * Moves the workspace UI in the provided direction.
- * @param translation the amount of horizontal shift.
- * @param alpha the alpha for the workspace page
- */
- private void setWorkspaceTranslationAndAlpha(float translation, float alpha) {
- float finalAlpha = alpha;
-
- View currentChild = getChildAt(getCurrentPage());
- if (currentChild != null) {
- currentChild.setTranslationX(translation);
- currentChild.setAlpha(finalAlpha);
- }
-
- // When the animation finishes, reset all pages, just in case we missed a page.
- if (Float.compare(translation, 0) == 0) {
- for (int i = getChildCount() - 1; i >= 0; i--) {
- View child = getChildAt(i);
- child.setTranslationX(0);
- child.setAlpha(finalAlpha);
- }
- }
- }
-
- /**
- * Moves the Hotseat UI in the provided direction.
- * @param direction the direction to move the workspace
- * @param translation the amount of shift.
- * @param alpha the alpha for the hotseat page
- */
- public void setHotseatTranslationAndAlpha(Direction direction, float translation, float alpha) {
- Property<View, Float> property = direction.viewProperty;
- // Skip the page indicator movement in the vertical bar layout
- if (direction != Direction.Y || !mLauncher.getDeviceProfile().isVerticalBarLayout()) {
- property.set(mPageIndicator, translation);
- }
- property.set(mLauncher.getHotseat(), translation);
- setHotseatAlphaAtIndex(alpha, direction.ordinal());
- }
-
- private void setHotseatAlphaAtIndex(float alpha, int index) {
- mHotseatAlpha[index] = alpha;
- final float hotseatAlpha = mHotseatAlpha[0] * mHotseatAlpha[1] * mHotseatAlpha[2];
- final float pageIndicatorAlpha = mHotseatAlpha[0] * mHotseatAlpha[2];
-
- mLauncher.getHotseat().setAlpha(hotseatAlpha);
- mPageIndicator.setAlpha(pageIndicatorAlpha);
- }
-
- public ValueAnimator createHotseatAlphaAnimator(float finalValue) {
- if (Float.compare(finalValue, mHotseatAlpha[HOTSEAT_STATE_ALPHA_INDEX]) == 0) {
- // Return a dummy animator to avoid null checks.
- return ValueAnimator.ofFloat(0, 0);
- } else {
- ValueAnimator animator = ValueAnimator
- .ofFloat(mHotseatAlpha[HOTSEAT_STATE_ALPHA_INDEX], finalValue);
- animator.addUpdateListener(new AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator valueAnimator) {
- float value = (Float) valueAnimator.getAnimatedValue();
- setHotseatAlphaAtIndex(value, HOTSEAT_STATE_ALPHA_INDEX);
- }
- });
-
- final boolean accessibilityEnabled = isAccessibilityEnabled(mLauncher);
- animator.addUpdateListener(
- new AlphaUpdateListener(mLauncher.getHotseat(), accessibilityEnabled));
- animator.addUpdateListener(
- new AlphaUpdateListener(mPageIndicator, accessibilityEnabled));
- return animator;
- }
+ mLauncher.getDragLayer().setTranslationX(transX);
+ mLauncher.getDragLayer().setAlpha(alpha);
}
@Override
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index cf35e52..21f5d67 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -138,9 +138,8 @@
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
scaleAndTranslation[2], Interpolators.ZOOM_IN);
- float hotseatAlpha = state.getHoseatAlpha(mLauncher);
- propertySetter.setViewAlpha(mWorkspace.createHotseatAlphaAnimator(hotseatAlpha),
- mLauncher.getHotseat(), hotseatAlpha);
+ propertySetter.setViewAlpha(mLauncher.getHotseat(), state.getHoseatAlpha(mLauncher),
+ pageAlphaProvider.interpolator);
// Set scrim
propertySetter.setInt(mLauncher.getDragLayer().getScrim(), DRAWABLE_ALPHA,
@@ -165,11 +164,7 @@
public static class PropertySetter {
- public void setViewAlpha(Animator anim, View view, float alpha) {
- if (anim != null) {
- anim.end();
- return;
- }
+ public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
view.setAlpha(alpha);
AlphaUpdateListener.updateVisibility(view, isAccessibilityEnabled(view.getContext()));
}
@@ -196,17 +191,14 @@
}
@Override
- public void setViewAlpha(Animator anim, View view, float alpha) {
- if (anim == null) {
- if (view.getAlpha() == alpha) {
- return;
- }
- anim = ObjectAnimator.ofFloat(view, View.ALPHA, alpha);
- anim.addListener(new AlphaUpdateListener(view,
- isAccessibilityEnabled(view.getContext())));
+ public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
+ if (view.getAlpha() == alpha) {
+ return;
}
-
- anim.setDuration(mDuration).setInterpolator(getFadeInterpolator(alpha));
+ ObjectAnimator anim = ObjectAnimator.ofFloat(view, View.ALPHA, alpha);
+ anim.addListener(new AlphaUpdateListener(
+ view, isAccessibilityEnabled(view.getContext())));
+ anim.setDuration(mDuration).setInterpolator(interpolator);
mStateAnimator.play(anim);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index d8a0d64..c02f2df 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -20,7 +20,6 @@
import com.android.launcher3.Workspace;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorSetBuilder;
-import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.AllAppsScrim;
@@ -52,8 +51,6 @@
}
};
- private final Interpolator mHotseatAccelInterpolator = Interpolators.ACCEL_1_5;
-
public static final float PARALLAX_COEFFICIENT = .125f;
private AllAppsContainerView mAppsView;
@@ -111,7 +108,6 @@
float workspaceHotseatAlpha = Utilities.boundToRange(progress, 0f, 1f);
float alpha = 1 - workspaceHotseatAlpha;
- float hotseatAlpha = mHotseatAccelInterpolator.getInterpolation(workspaceHotseatAlpha);
mAppsView.setTranslationY(shiftCurrent);
if (mAllAppsScrim == null) {
@@ -122,8 +118,8 @@
if (!mIsVerticalLayout) {
mAppsView.setAlpha(alpha);
- mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y, hotseatTranslation,
- hotseatAlpha);
+ mLauncher.getHotseat().setTranslationY(hotseatTranslation);
+ mLauncher.getWorkspace().getPageIndicator().setTranslationY(hotseatTranslation);
// Use a light system UI (dark icons) if all apps is behind at least half of the
// status bar.
diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java
index f3a3539..ee0dba6 100644
--- a/src/com/android/launcher3/anim/Interpolators.java
+++ b/src/com/android/launcher3/anim/Interpolators.java
@@ -20,6 +20,7 @@
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
+import android.view.animation.OvershootInterpolator;
import android.view.animation.PathInterpolator;
@@ -43,6 +44,9 @@
public static final Interpolator FAST_OUT_SLOW_IN = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
public static final Interpolator AGGRESSIVE_EASE = new PathInterpolator(0.2f, 0f, 0f, 1f);
+ public static final Interpolator AGGRESSIVE_EASE_IN_OUT = new PathInterpolator(0.8f,0, 0.4f, 1);
+
+ public static final Interpolator OVERSHOOT_0 = new OvershootInterpolator(0);
/**
* Inversion of zInterpolate, compounded with an ease-out.
diff --git a/src/com/android/launcher3/anim/RevealOutlineAnimation.java b/src/com/android/launcher3/anim/RevealOutlineAnimation.java
index c6b62fa..afb8875 100644
--- a/src/com/android/launcher3/anim/RevealOutlineAnimation.java
+++ b/src/com/android/launcher3/anim/RevealOutlineAnimation.java
@@ -80,4 +80,8 @@
public float getRadius() {
return mOutlineRadius;
}
+
+ public void getOutline(Rect out) {
+ out.set(mOutline);
+ }
}
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 93a5679..677694f 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -366,6 +366,16 @@
}
@Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ ev.offsetLocation(getTranslationX(), 0);
+ try {
+ return super.dispatchTouchEvent(ev);
+ } finally {
+ ev.offsetLocation(-getTranslationX(), 0);
+ }
+ }
+
+ @Override
public LayoutParams generateLayoutParams(AttributeSet attrs) {
return new LayoutParams(getContext(), attrs);
}
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index f90abb4..b3ef7bb 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -62,6 +62,7 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate;
+import com.android.launcher3.anim.RevealOutlineAnimation;
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.dragndrop.DragController;
@@ -810,10 +811,10 @@
return;
}
mEndRect.setEmpty();
+ if (getOutlineProvider() instanceof RevealOutlineAnimation) {
+ ((RevealOutlineAnimation) getOutlineProvider()).getOutline(mEndRect);
+ }
if (mOpenCloseAnimator != null) {
- Outline outline = new Outline();
- getOutlineProvider().getOutline(this, outline);
- outline.getRect(mEndRect);
mOpenCloseAnimator.cancel();
}
mIsOpen = false;
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index 83cbf59..d2bcd18 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -82,7 +82,7 @@
@Override
public void onClick(View view) {
Rect sourceBounds = launcher.getViewBounds(view);
- Bundle opts = launcher.getActivityLaunchOptions(view, true);
+ Bundle opts = launcher.getActivityLaunchOptions(view, false);
InfoDropTarget.startDetailsActivityForInfo(itemInfo, launcher, sourceBounds, opts);
launcher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
ControlType.APPINFO_TARGET, view);
@@ -115,8 +115,8 @@
public View.OnClickListener createOnClickListener(Launcher launcher, ItemInfo itemInfo) {
return view -> {
- Intent intent = PackageManagerHelper.getMarketIntent(itemInfo
- .getTargetComponent().getPackageName());
+ Intent intent = new PackageManagerHelper(view.getContext()).getMarketIntent(
+ itemInfo.getTargetComponent().getPackageName());
launcher.startActivitySafely(view, intent, itemInfo);
AbstractFloatingView.closeAllOpenViews(launcher);
};
diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java
index 13034dd..81df153 100644
--- a/src/com/android/launcher3/util/PackageManagerHelper.java
+++ b/src/com/android/launcher3/util/PackageManagerHelper.java
@@ -143,13 +143,15 @@
return false;
}
- public static Intent getMarketIntent(String packageName) {
+ public Intent getMarketIntent(String packageName) {
return new Intent(Intent.ACTION_VIEW)
.setData(new Uri.Builder()
.scheme("market")
.authority("details")
.appendQueryParameter("id", packageName)
- .build());
+ .build())
+ .putExtra(Intent.EXTRA_REFERRER, new Uri.Builder().scheme("android-app")
+ .authority(mContext.getPackageName()).build());
}
/**
diff --git a/src/com/android/launcher3/views/AllAppsScrim.java b/src/com/android/launcher3/views/AllAppsScrim.java
index 5d39adb..6cd40fd 100644
--- a/src/com/android/launcher3/views/AllAppsScrim.java
+++ b/src/com/android/launcher3/views/AllAppsScrim.java
@@ -23,6 +23,7 @@
import android.graphics.Rect;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
+import android.util.Property;
import android.view.View;
import com.android.launcher3.DeviceProfile;
@@ -46,6 +47,7 @@
protected final WallpaperColorInfo mWallpaperColorInfo;
private final Paint mFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private final Rect mDrawRect = new Rect();
private final Rect mPadding = new Rect();
private final Rect mInsets = new Rect();
private final DeviceProfile mGrid;
@@ -59,10 +61,24 @@
private final NinePatchDrawHelper mShadowHelper = new NinePatchDrawHelper();
+ private float mProgress;
private int mFillAlpha;
private float mDrawHeight;
- private float mTranslateY;
+ private float mDrawOffsetY;
+
+ public static final Property<AllAppsScrim, Float> SCRIM_PROGRESS =
+ new Property<AllAppsScrim, Float>(Float.class, "allAppsScrimProgress") {
+ @Override
+ public Float get(AllAppsScrim allAppsScrim) {
+ return allAppsScrim.getProgress();
+ }
+
+ @Override
+ public void set(AllAppsScrim allAppsScrim, Float progress) {
+ allAppsScrim.setProgress(progress);
+ }
+ };
public AllAppsScrim(Context context) {
this(context, null);
@@ -108,6 +124,10 @@
return result;
}
+ public Bitmap getShadowBitmap() {
+ return mShadowBitmap;
+ }
+
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
@@ -135,7 +155,7 @@
@Override
protected void onDraw(Canvas canvas) {
- float edgeTop = getHeight() + mTranslateY - mDrawHeight + mPadding.top;
+ float edgeTop = getHeight() + mDrawOffsetY - mDrawHeight + mPadding.top;
float edgeRight = getWidth() - mPadding.right;
if (mPadding.left > 0 || mPadding.right > 0) {
@@ -153,12 +173,39 @@
}
public void setProgress(float translateY, float alpha) {
- mFillAlpha = Math.round(alpha * mAlphaRange + mMinAlpha);
- mFillPaint.setAlpha(mFillAlpha);
+ int newAlpha = Math.round(alpha * mAlphaRange + mMinAlpha);
+ if (newAlpha != mFillAlpha) {
+ mFillAlpha = newAlpha;
+ mFillPaint.setAlpha(mFillAlpha);
+ invalidateDrawRect();
+ }
- mTranslateY = translateY;
+ setProgress(translateY);
+ }
- invalidate();
+ public void setProgress(float translateY) {
+ // Negative translation means the scrim is moving up. For negative translation, we change
+ // draw offset as it requires redraw (since more area of the scrim needs to be shown). For
+ // position translation, we simply translate the scrim down as it avoids invalidate and
+ // hence could be optimized by the platform.
+ float drawOffsetY = Math.min(translateY, 0);
+
+ if (drawOffsetY != mDrawOffsetY) {
+ mDrawOffsetY = drawOffsetY;
+ invalidateDrawRect();
+ }
+
+ setTranslationY(Math.max(translateY, 0));
+ }
+
+ public float getProgress() {
+ return mProgress;
+ }
+
+ private void invalidateDrawRect() {
+ mDrawRect.top = (int) (getHeight()
+ + mDrawOffsetY - mDrawHeight + mPadding.top - mShadowBlur - 0.5f);
+ invalidate(mDrawRect);
}
public void setDrawRegion(float height) {
@@ -178,6 +225,24 @@
float scrimMargin = getResources().getDimension(R.dimen.all_apps_scrim_margin);
setDrawRegion(mGrid.hotseatBarSizePx + insets.bottom + scrimMargin);
}
+ updateDrawRect();
invalidate();
}
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ updateDrawRect();
+ }
+
+ private void updateDrawRect() {
+ mDrawRect.bottom = getHeight();
+ if (mGrid.isVerticalBarLayout()) {
+ mDrawRect.left = (int) (mPadding.left - mShadowBlur - 0.5f);
+ mDrawRect.right = (int) (getWidth() - mPadding.right + 0.5f);
+ } else {
+ mDrawRect.left = 0;
+ mDrawRect.right = getWidth();
+ }
+ }
}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
index 24236d8..fd33ee1 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
@@ -62,6 +62,11 @@
}
@Override
+ public float getHoseatAlpha(Launcher launcher) {
+ return 0;
+ }
+
+ @Override
public View getFinalFocus(Launcher launcher) {
return launcher.getAppsView();
}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
index 9a09c97..2d39505 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
@@ -37,6 +37,7 @@
import com.android.launcher3.WorkspaceStateTransitionAnimation.AnimatedPropertySetter;
import com.android.launcher3.WorkspaceStateTransitionAnimation.PropertySetter;
import com.android.launcher3.anim.AnimatorSetBuilder;
+import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.widget.WidgetsFullSheet;
@@ -173,8 +174,7 @@
}
private void setState(LauncherState state, PropertySetter setter) {
- float hotseatAlpha = state.getHoseatAlpha(mLauncher);
- setter.setViewAlpha(null, this, 1f - hotseatAlpha);
+ setter.setViewAlpha(this, 1f - state.getHoseatAlpha(mLauncher), Interpolators.ACCEL);
}
public static int getButtonBarHeight(Launcher launcher) {
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
index 9819d71..c857bf6 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -18,20 +18,15 @@
import static com.android.launcher3.LauncherState.OVERVIEW;
-import android.app.ActivityOptions;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
+import android.graphics.PointF;
import android.os.Bundle;
import android.view.View;
import android.view.View.AccessibilityDelegate;
-import com.android.launcher3.BubbleTextView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherStateManager.StateHandler;
-import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
import com.android.launcher3.graphics.BitmapRenderer;
import com.android.launcher3.util.TouchController;
@@ -54,7 +49,7 @@
launcher.getAllAppsController(), launcher.getWorkspace() };
}
- public static void onWorkspaceLongPress(Launcher launcher) {
+ public static void onWorkspaceLongPress(Launcher launcher, PointF touchPoint) {
launcher.getStateManager().goToState(OVERVIEW);
}
@@ -70,4 +65,6 @@
public static Bundle getActivityLaunchOptions(Launcher launcher, View v) {
return launcher.getDefaultActivityLaunchOptions(v);
}
+
+ public static void registerRemoteAnimations(Launcher launcher) { }
}