Merge "Make app-controlled animations more robust" 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/res/drawable-hdpi/recents_horizontal_scrim_left.png b/quickstep/res/drawable-hdpi/recents_horizontal_scrim_left.png
new file mode 100644
index 0000000..d4f995d
--- /dev/null
+++ b/quickstep/res/drawable-hdpi/recents_horizontal_scrim_left.png
Binary files differ
diff --git a/quickstep/res/drawable-hdpi/recents_horizontal_scrim_right.png b/quickstep/res/drawable-hdpi/recents_horizontal_scrim_right.png
new file mode 100644
index 0000000..9013c1a
--- /dev/null
+++ b/quickstep/res/drawable-hdpi/recents_horizontal_scrim_right.png
Binary files differ
diff --git a/quickstep/res/drawable-mdpi/recents_horizontal_scrim_left.png b/quickstep/res/drawable-mdpi/recents_horizontal_scrim_left.png
new file mode 100644
index 0000000..6e924ec
--- /dev/null
+++ b/quickstep/res/drawable-mdpi/recents_horizontal_scrim_left.png
Binary files differ
diff --git a/quickstep/res/drawable-mdpi/recents_horizontal_scrim_right.png b/quickstep/res/drawable-mdpi/recents_horizontal_scrim_right.png
new file mode 100644
index 0000000..33d0edd
--- /dev/null
+++ b/quickstep/res/drawable-mdpi/recents_horizontal_scrim_right.png
Binary files differ
diff --git a/quickstep/res/drawable-xhdpi/recents_horizontal_scrim_left.png b/quickstep/res/drawable-xhdpi/recents_horizontal_scrim_left.png
new file mode 100644
index 0000000..20c85e6
--- /dev/null
+++ b/quickstep/res/drawable-xhdpi/recents_horizontal_scrim_left.png
Binary files differ
diff --git a/quickstep/res/drawable-xhdpi/recents_horizontal_scrim_right.png b/quickstep/res/drawable-xhdpi/recents_horizontal_scrim_right.png
new file mode 100644
index 0000000..58a1ca0
--- /dev/null
+++ b/quickstep/res/drawable-xhdpi/recents_horizontal_scrim_right.png
Binary files differ
diff --git a/quickstep/res/drawable-xxhdpi/recents_horizontal_scrim_left.png b/quickstep/res/drawable-xxhdpi/recents_horizontal_scrim_left.png
new file mode 100644
index 0000000..9d3dc31
--- /dev/null
+++ b/quickstep/res/drawable-xxhdpi/recents_horizontal_scrim_left.png
Binary files differ
diff --git a/quickstep/res/drawable-xxhdpi/recents_horizontal_scrim_right.png b/quickstep/res/drawable-xxhdpi/recents_horizontal_scrim_right.png
new file mode 100644
index 0000000..7fb248b
--- /dev/null
+++ b/quickstep/res/drawable-xxhdpi/recents_horizontal_scrim_right.png
Binary files differ
diff --git a/quickstep/res/drawable-xxxhdpi/recents_horizontal_scrim_left.png b/quickstep/res/drawable-xxxhdpi/recents_horizontal_scrim_left.png
new file mode 100644
index 0000000..49ec7aa
--- /dev/null
+++ b/quickstep/res/drawable-xxxhdpi/recents_horizontal_scrim_left.png
Binary files differ
diff --git a/quickstep/res/drawable-xxxhdpi/recents_horizontal_scrim_right.png b/quickstep/res/drawable-xxxhdpi/recents_horizontal_scrim_right.png
new file mode 100644
index 0000000..a8922e2
--- /dev/null
+++ b/quickstep/res/drawable-xxxhdpi/recents_horizontal_scrim_right.png
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..40436d1 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>
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 67a7d6a..c4ffc0f 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -16,25 +16,22 @@
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;
+import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;
public class UiFactory {
@@ -63,31 +60,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,
@@ -107,6 +81,12 @@
}
public static Bundle getActivityLaunchOptions(Launcher launcher, View v) {
- return new LauncherAppTransitionManager(launcher).getActivityLauncherOptions(v);
+ try {
+ return new LauncherAppTransitionManager(launcher).getActivityLauncherOptions(v);
+ } catch (NoClassDefFoundError e) {
+ // Gracefully fall back to default launch options if the user's platform doesn't have
+ // the latest changes.
+ return launcher.getDefaultActivityLaunchOptions(v);
+ }
}
}
diff --git a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
index 168c1fe..eb5195c 100644
--- a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
+++ b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java
@@ -27,7 +27,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 +40,12 @@
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.TraceHelper;
-import com.android.launcher3.views.AllAppsScrim;
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 +60,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;
@@ -98,7 +96,6 @@
private RecentsViewStateController mStateController;
private QuickScrubController mQuickScrubController;
private Hotseat mHotseat;
- private AllAppsScrim mAllAppsScrim;
private boolean mLauncherReady;
private boolean mTouchEndHandled;
@@ -188,7 +185,6 @@
mRecentsView.showTask(mRunningTask);
mStateController = mRecentsView.getStateController();
mHotseat = mLauncher.getHotseat();
- mAllAppsScrim = mLauncher.findViewById(R.id.all_apps_scrim);
AbstractFloatingView.closeAllOpenViews(mLauncher, alreadyOnHome);
mLauncher.getStateManager().goToState(LauncherState.OVERVIEW, alreadyOnHome);
@@ -242,11 +238,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 +324,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));
}
diff --git a/quickstep/src/com/android/quickstep/RecentsView.java b/quickstep/src/com/android/quickstep/RecentsView.java
index 605c83c..31f8058 100644
--- a/quickstep/src/com/android/quickstep/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/RecentsView.java
@@ -18,12 +18,25 @@
import android.animation.LayoutTransition;
import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.PorterDuff.Mode;
+import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
+import android.graphics.Shader;
+import android.graphics.Shader.TileMode;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
+import android.widget.FrameLayout;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
@@ -48,7 +61,7 @@
/**
* A list of recent tasks.
*/
-public class RecentsView extends PagedView {
+public class RecentsView extends PagedView implements Insettable {
private static final Rect sTempStableInsets = new Rect();
@@ -87,6 +100,12 @@
private Task mFirstTask;
+ private Bitmap mScrim;
+ private Paint mFadePaint;
+ private Shader mFadeShader;
+ private Matrix mFadeMatrix;
+ private boolean mScrimOnLeft;
+
public RecentsView(Context context) {
this(context, null);
}
@@ -99,8 +118,8 @@
super(context, attrs, defStyleAttr);
setPageSpacing(getResources().getDimensionPixelSize(R.dimen.recents_page_spacing));
enableFreeScroll(true);
- setClipChildren(true);
setupLayoutTransition();
+ setClipToOutline(true);
mLauncher = Launcher.getLauncher(context);
mQuickScrubController = new QuickScrubController(mLauncher);
@@ -123,10 +142,6 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
-
- Rect padding =
- getPadding(Launcher.getLauncher(getContext()).getDeviceProfile(), getContext());
- setPadding(padding.left, padding.top, padding.right, padding.bottom);
mFirstTaskIndex = getPageCount();
}
@@ -148,6 +163,43 @@
updateTaskStackListenerState();
}
+ @Override
+ public void setInsets(Rect insets) {
+ mInsets.set(insets);
+ DeviceProfile dp = Launcher.getLauncher(getContext()).getDeviceProfile();
+ Rect padding = getPadding(dp, getContext());
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
+ lp.bottomMargin = padding.bottom;
+ setLayoutParams(lp);
+
+ setPadding(padding.left, padding.top, padding.right, 0);
+
+ if (dp.isVerticalBarLayout()) {
+ boolean wasScrimOnLeft = mScrimOnLeft;
+ mScrimOnLeft = insets.left > insets.right;
+
+ if (mScrim == null || wasScrimOnLeft != mScrimOnLeft) {
+ Drawable scrim = getContext().getDrawable(mScrimOnLeft
+ ? R.drawable.recents_horizontal_scrim_left
+ : R.drawable.recents_horizontal_scrim_right);
+ if (scrim instanceof BitmapDrawable) {
+ mScrim = ((BitmapDrawable) scrim).getBitmap();
+ mFadePaint = new Paint();
+ mFadePaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
+ mFadeShader = new BitmapShader(mScrim, TileMode.CLAMP, TileMode.REPEAT);
+ mFadeMatrix = new Matrix();
+ } else {
+ mScrim = null;
+ }
+ }
+ } else {
+ mScrim = null;
+ mFadePaint = null;
+ mFadeShader = null;
+ mFadeMatrix = null;
+ }
+ }
+
public int getFirstTaskIndex() {
return mFirstTaskIndex;
}
@@ -234,10 +286,9 @@
if (profile.isVerticalBarLayout()) {
// Use the same padding on both sides for symmetry.
float availableWidth = taskWidth - 2 * Math.max(padding.left, padding.right);
- float availableHeight = profile.availableHeightPx - padding.top - padding.bottom
- - sTempStableInsets.top
- - profile.heightPx * (1 - OverviewState.getVerticalProgress(profile, context));
-
+ float availableHeight = profile.availableHeightPx - padding.top
+ - sTempStableInsets.top - Math.max(padding.bottom,
+ profile.heightPx * (1 - OverviewState.getVerticalProgress(profile, context)));
float scaledRatio = Math.min(availableWidth / taskWidth, availableHeight / taskHeight);
overviewHeight = taskHeight * scaledRatio;
overviewWidth = taskWidth * scaledRatio;
@@ -306,11 +357,11 @@
if (getPageCount() == 0 || getPageAt(0).getMeasuredWidth() == 0) {
return;
}
- final int halfScreenWidth = getMeasuredWidth() / 2;
- final int screenCenter = halfScreenWidth + getScrollX();
- final int pageSpacing = mPageSpacing;
final int halfPageWidth = mScrollState.halfPageWidth = getNormalChildWidth() / 2;
mScrollState.lastScrollType = SCROLL_TYPE_NONE;
+ final int screenCenter = mInsets.left + getPaddingLeft() + getScrollX() + halfPageWidth;
+ final int halfScreenWidth = getMeasuredWidth() / 2;
+ final int pageSpacing = mPageSpacing;
final int pageCount = getPageCount();
for (int i = 0; i < pageCount; i++) {
@@ -387,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) {
@@ -399,6 +452,35 @@
return mQuickScrubController;
}
+ @Override
+ public void draw(Canvas canvas) {
+ if (mScrim == null) {
+ super.draw(canvas);
+ return;
+ }
+
+ final int flags = Canvas.HAS_ALPHA_LAYER_SAVE_FLAG;
+
+ int length = mScrim.getWidth();
+ int height = getHeight();
+ int saveCount = canvas.getSaveCount();
+
+ int scrimLeft;
+ if (mScrimOnLeft) {
+ scrimLeft = getScrollX();
+ } else {
+ scrimLeft = getScrollX() + getWidth() - length;
+ }
+ canvas.saveLayer(scrimLeft, 0, scrimLeft + length, height, null, flags);
+ super.draw(canvas);
+
+ mFadeMatrix.setTranslate(scrimLeft, 0);
+ mFadeShader.setLocalMatrix(mFadeMatrix);
+ mFadePaint.setShader(mFadeShader);
+ canvas.drawRect(scrimLeft, 0, scrimLeft + length, height, mFadePaint);
+ canvas.restoreToCount(saveCount);
+ }
+
public interface PageCallbacks {
/**
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/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/drawable/round_rect_primary.xml b/res/drawable/round_rect_primary.xml
index 2c47e06..9f8f4da 100644
--- a/res/drawable/round_rect_primary.xml
+++ b/res/drawable/round_rect_primary.xml
@@ -17,5 +17,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?android:attr/colorPrimary" />
- <corners android:radius="2dp" />
+ <corners android:radius="8dp" />
</shape>
diff --git a/res/drawable/tooltip_frame.xml b/res/drawable/tooltip_frame.xml
new file mode 100644
index 0000000..0319051
--- /dev/null
+++ b/res/drawable/tooltip_frame.xml
@@ -0,0 +1,21 @@
+<?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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="?android:attr/colorBackground" />
+ <corners android:radius="2dp" />
+</shape>
\ No newline at end of file
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index f26bfbd..bcaba81 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -67,7 +67,7 @@
<include
android:id="@+id/drop_target_bar"
- layout="@layout/drop_target_bar_vert" />
+ layout="@layout/drop_target_bar" />
<include layout="@layout/all_apps"
android:id="@+id/apps_view"
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index cde3bd5..eb9c34c 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -66,7 +66,7 @@
<include
android:id="@+id/drop_target_bar"
- layout="@layout/drop_target_bar_horz" />
+ layout="@layout/drop_target_bar" />
<include layout="@layout/all_apps"
android:id="@+id/apps_view"
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index fe2f108..fa1a100 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -60,7 +60,7 @@
<include
android:id="@+id/drop_target_bar"
- layout="@layout/drop_target_bar_horz" />
+ layout="@layout/drop_target_bar" />
<!-- Keep these behind the workspace so that they are not visible when
we go into AllApps -->
diff --git a/res/layout/drop_target_bar.xml b/res/layout/drop_target_bar.xml
new file mode 100644
index 0000000..d376bcf
--- /dev/null
+++ b/res/layout/drop_target_bar.xml
@@ -0,0 +1,55 @@
+<?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.DropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/dynamic_grid_drop_target_size"
+ android:layout_gravity="center_horizontal|top"
+ android:focusable="false"
+ android:alpha="0"
+ android:theme="@style/HomeScreenElementTheme"
+ android:visibility="invisible">
+
+ <!-- Delete target -->
+ <com.android.launcher3.DeleteDropTarget
+ android:id="@+id/delete_target_text"
+ style="@style/DropTargetButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/remove_drop_target_label" />
+
+ <!-- App Info -->
+ <com.android.launcher3.InfoDropTarget
+ android:id="@+id/info_target_text"
+ style="@style/DropTargetButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/app_info_drop_target_label" />
+
+ <!-- Uninstall target -->
+ <com.android.launcher3.UninstallDropTarget
+ android:id="@+id/uninstall_target_text"
+ style="@style/DropTargetButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/uninstall_drop_target_label" />
+
+</com.android.launcher3.DropTargetBar>
\ No newline at end of file
diff --git a/res/layout/drop_target_bar_horz.xml b/res/layout/drop_target_bar_horz.xml
deleted file mode 100644
index ed18192..0000000
--- a/res/layout/drop_target_bar_horz.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2015 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.DropTargetBar
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res-auto"
- android:theme="@style/HomeScreenElementTheme"
- android:layout_width="match_parent"
- android:layout_height="@dimen/dynamic_grid_drop_target_size"
- android:visibility="invisible"
- android:layout_gravity="center_horizontal|top"
- android:focusable="false">
-
- <FrameLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1" >
-
- <!-- Delete target -->
-
- <com.android.launcher3.DeleteDropTarget
- launcher:hideParentOnDisable="true"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:id="@+id/delete_target_text"
- style="@style/DropTargetButton"
- android:text="@string/remove_drop_target_label" />
- </FrameLayout>
-
- <FrameLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1" >
-
- <!-- App Info -->
-
- <com.android.launcher3.InfoDropTarget
- launcher:hideParentOnDisable="true"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:id="@+id/info_target_text"
- style="@style/DropTargetButton"
- android:text="@string/app_info_drop_target_label" />
- </FrameLayout>
-
- <FrameLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1" >
-
- <!-- Uninstall target -->
-
- <com.android.launcher3.UninstallDropTarget
- launcher:hideParentOnDisable="true"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="center"
- android:id="@+id/uninstall_target_text"
- style="@style/DropTargetButton"
- android:text="@string/uninstall_drop_target_label" />
- </FrameLayout>
-
-</com.android.launcher3.DropTargetBar>
\ No newline at end of file
diff --git a/res/layout/drop_target_bar_vert.xml b/res/layout/drop_target_bar_vert.xml
deleted file mode 100644
index 2394d0d..0000000
--- a/res/layout/drop_target_bar_vert.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 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.DropTargetBar
- android:theme="@style/HomeScreenElementTheme"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/dynamic_grid_drop_target_size"
- android:orientation="vertical"
- android:layout_height="match_parent"
- android:layout_gravity="left"
- android:visibility="invisible"
- android:focusable="false"
- android:paddingTop="@dimen/vert_drop_target_vertical_gap" >
-
- <!-- Delete target -->
- <com.android.launcher3.DeleteDropTarget
- android:layout_width="match_parent"
- android:layout_height="@dimen/dynamic_grid_drop_target_size"
- android:gravity="center"
- android:paddingLeft="@dimen/vert_drop_target_horizontal_gap"
- android:paddingRight="@dimen/vert_drop_target_horizontal_gap"
- android:id="@+id/delete_target_text" />
-
- <!-- Uninstall target -->
- <com.android.launcher3.UninstallDropTarget
- android:layout_width="match_parent"
- android:layout_height="@dimen/dynamic_grid_drop_target_size"
- android:gravity="center"
- android:paddingLeft="@dimen/vert_drop_target_horizontal_gap"
- android:paddingRight="@dimen/vert_drop_target_horizontal_gap"
- android:id="@+id/uninstall_target_text"
- android:layout_marginTop="@dimen/vert_drop_target_vertical_gap"/>
-
- <Space
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <!-- App Info -->
- <com.android.launcher3.InfoDropTarget
- android:layout_width="match_parent"
- android:layout_height="@dimen/dynamic_grid_drop_target_size"
- android:gravity="center"
- android:paddingLeft="@dimen/vert_drop_target_horizontal_gap"
- android:paddingRight="@dimen/vert_drop_target_horizontal_gap"
- android:id="@+id/info_target_text"
- android:layout_marginBottom="64dp"/>
-
-</com.android.launcher3.DropTargetBar>
\ No newline at end of file
diff --git a/res/layout/drop_target_tool_tip.xml b/res/layout/drop_target_tool_tip.xml
new file mode 100644
index 0000000..a3efec4
--- /dev/null
+++ b/res/layout/drop_target_tool_tip.xml
@@ -0,0 +1,31 @@
+<?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.
+-->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/tooltip_frame"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:maxWidth="256dp"
+ android:paddingBottom="6.5dp"
+ android:paddingEnd="16dp"
+ android:paddingStart="16dp"
+ android:paddingTop="6.5dp"
+ android:textSize="14sp"
+ android:fontFamily="sans-serif"
+ android:textColor="?android:attr/colorForeground" />
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index ad5f0b8..2033d46 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -91,10 +91,6 @@
<attr name="layout_ignoreInsets" format="boolean" />
</declare-styleable>
- <declare-styleable name="ButtonDropTarget">
- <attr name="hideParentOnDisable" format="boolean" />
- </declare-styleable>
-
<declare-styleable name="InvariantDeviceProfile">
<attr name="name" format="string" />
<attr name="minWidthDps" format="float" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f53fe79..2aff936 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -43,14 +43,13 @@
<dimen name="dynamic_grid_hotseat_side_padding">0dp</dimen>
<!-- Hotseat/all-apps scrim -->
- <dimen name="all_apps_scrim_radius">10dp</dimen>
- <dimen name="all_apps_scrim_margin">10dp</dimen>
- <dimen name="all_apps_scrim_blur">5dp</dimen>
+ <dimen name="all_apps_scrim_radius">8dp</dimen>
+ <dimen name="all_apps_scrim_margin">8dp</dimen>
+ <dimen name="all_apps_scrim_blur">4dp</dimen>
<!-- Drop target bar -->
<dimen name="dynamic_grid_drop_target_size">48dp</dimen>
- <dimen name="vert_drop_target_vertical_gap">20dp</dimen>
- <dimen name="vert_drop_target_horizontal_gap">14dp</dimen>
+ <dimen name="drop_target_vertical_gap">20dp</dimen>
<!-- App Widget resize frame -->
<dimen name="widget_handle_margin">13dp</dimen>
@@ -204,7 +203,7 @@
<dimen name="system_shortcut_header_icon_padding">12dp</dimen>
<!-- Notifications -->
- <dimen name="bg_round_rect_radius">12dp</dimen>
+ <dimen name="bg_round_rect_radius">8dp</dimen>
<dimen name="notification_padding_start">16dp</dimen>
<dimen name="notification_padding_end">12dp</dimen>
<!-- notification_padding_end + (icon_size - footer_icon_size) / 2 -->
@@ -228,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/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index cfb55cc..a9cf8cc 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -16,27 +16,28 @@
package com.android.launcher3;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+
import static com.android.launcher3.LauncherState.NORMAL;
import android.animation.AnimatorSet;
import android.animation.FloatArrayEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
-import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
+import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
+import android.widget.PopupWindow;
import android.widget.TextView;
import com.android.launcher3.anim.Interpolators;
@@ -56,7 +57,10 @@
private static final int[] sTempCords = new int[2];
private static final int DRAG_VIEW_DROP_DURATION = 285;
- private final boolean mHideParentOnDisable;
+ public static final int TOOLTIP_DEFAULT = 0;
+ public static final int TOOLTIP_LEFT = 1;
+ public static final int TOOLTIP_RIGHT = 2;
+
protected final Launcher mLauncher;
private int mBottomDragPadding;
@@ -75,6 +79,10 @@
protected CharSequence mText;
protected ColorStateList mOriginalTextColor;
protected Drawable mDrawable;
+ private boolean mTextVisible = true;
+
+ private PopupWindow mToolTip;
+ private int mToolTipLocation;
private AnimatorSet mCurrentColorAnim;
@Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter;
@@ -89,11 +97,6 @@
Resources resources = getResources();
mBottomDragPadding = resources.getDimensionPixelSize(R.dimen.drop_target_drag_padding);
-
- TypedArray a = context.obtainStyledAttributes(attrs,
- R.styleable.ButtonDropTarget, defStyle, 0);
- mHideParentOnDisable = a.getBoolean(R.styleable.ButtonDropTarget_hideParentOnDisable, false);
- a.recycle();
mDragDistanceThreshold = resources.getDimensionPixelSize(R.dimen.drag_distanceThreshold);
}
@@ -102,21 +105,56 @@
super.onFinishInflate();
mText = getText();
mOriginalTextColor = getTextColors();
+ setContentDescription(mText);
}
protected void setDrawable(int resId) {
// We do not set the drawable in the xml as that inflates two drawables corresponding to
// drawableLeft and drawableStart.
- setCompoundDrawablesRelativeWithIntrinsicBounds(resId, 0, 0, 0);
- mDrawable = getCompoundDrawablesRelative()[0];
+ if (mTextVisible) {
+ setCompoundDrawablesRelativeWithIntrinsicBounds(resId, 0, 0, 0);
+ mDrawable = getCompoundDrawablesRelative()[0];
+ } else {
+ setCompoundDrawablesRelativeWithIntrinsicBounds(0, resId, 0, 0);
+ mDrawable = getCompoundDrawablesRelative()[1];
+ }
}
public void setDropTargetBar(DropTargetBar dropTargetBar) {
mDropTargetBar = dropTargetBar;
}
+ private void hideTooltip() {
+ if (mToolTip != null) {
+ mToolTip.dismiss();
+ mToolTip = null;
+ }
+ }
+
@Override
public final void onDragEnter(DragObject d) {
+ if (!d.accessibleDrag && !mTextVisible) {
+ // Show tooltip
+ hideTooltip();
+
+ TextView message = (TextView) LayoutInflater.from(getContext()).inflate(
+ R.layout.drop_target_tool_tip, null);
+ message.setText(mText);
+
+ mToolTip = new PopupWindow(message, WRAP_CONTENT, WRAP_CONTENT);
+ int x = 0, y = 0;
+ if (mToolTipLocation != TOOLTIP_DEFAULT) {
+ y = -getMeasuredHeight();
+ message.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
+ if (mToolTipLocation == TOOLTIP_LEFT) {
+ x = - getMeasuredWidth() - message.getMeasuredWidth() / 2;
+ } else {
+ x = getMeasuredWidth() / 2 + message.getMeasuredWidth() / 2;
+ }
+ }
+ mToolTip.showAsDropDown(this, x, y);
+ }
+
d.dragView.setColor(mHoverColor);
animateTextColor(mHoverColor);
if (d.stateAnnouncer != null) {
@@ -153,13 +191,9 @@
ValueAnimator anim1 = ValueAnimator.ofObject(
new FloatArrayEvaluator(mCurrentFilter.getArray()),
mSrcFilter.getArray(), mDstFilter.getArray());
- anim1.addUpdateListener(new AnimatorUpdateListener() {
-
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
- invalidate();
- }
+ anim1.addUpdateListener((anim) -> {
+ mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
+ invalidate();
});
mCurrentColorAnim.play(anim1);
@@ -169,6 +203,8 @@
@Override
public final void onDragExit(DragObject d) {
+ hideTooltip();
+
if (!d.dragComplete) {
d.dragView.setColor(0);
resetHoverColor();
@@ -187,8 +223,7 @@
mCurrentColorAnim = null;
}
setTextColor(mOriginalTextColor);
- (mHideParentOnDisable ? ((ViewGroup) getParent()) : this)
- .setVisibility(mActive ? View.VISIBLE : View.GONE);
+ setVisibility(mActive ? View.VISIBLE : View.GONE);
mAccessibleDrag = options.isAccessibleDrag;
setOnClickListener(mAccessibleDrag ? this : null);
@@ -230,14 +265,12 @@
final float scale = (float) to.width() / from.width();
mDropTargetBar.deferOnDragEnd();
- Runnable onAnimationEndRunnable = new Runnable() {
- @Override
- public void run() {
- completeDrop(d);
- mDropTargetBar.onDragEnd();
- mLauncher.getStateManager().goToState(NORMAL);
- }
+ Runnable onAnimationEndRunnable = () -> {
+ completeDrop(d);
+ mDropTargetBar.onDragEnd();
+ mLauncher.getStateManager().goToState(NORMAL);
};
+
dragLayer.animateView(d.dragView, from, to, scale, 1f, 1f, 0.1f, 0.1f,
DRAG_VIEW_DROP_DURATION,
Interpolators.DEACCEL_2, Interpolators.LINEAR, onAnimationEndRunnable,
@@ -294,8 +327,8 @@
to.set(left, top, right, bottom);
// Center the destination rect about the trash icon
- final int xOffset = (int) -(viewWidth - width) / 2;
- final int yOffset = (int) -(viewHeight - height) / 2;
+ final int xOffset = -(viewWidth - width) / 2;
+ final int yOffset = -(viewHeight - height) / 2;
to.offset(xOffset, yOffset);
return to;
@@ -310,25 +343,24 @@
return getTextColors().getDefaultColor();
}
- /**
- * Returns True if any update was made.
- */
- public boolean updateText(boolean hide) {
- if ((hide && getText().toString().isEmpty()) || (!hide && mText.equals(getText()))) {
- return false;
+ public void setTextVisible(boolean isVisible) {
+ if (mTextVisible != isVisible) {
+ mTextVisible = isVisible;
+ setText(isVisible ? mText : "");
+ if (mTextVisible) {
+ setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null);
+ } else {
+ setCompoundDrawablesRelativeWithIntrinsicBounds(null, mDrawable, null, null);
+ }
}
-
- setText(hide ? "" : mText);
- return true;
}
- public boolean isTextTruncated() {
- int availableWidth = getMeasuredWidth();
- if (mHideParentOnDisable) {
- ViewGroup parent = (ViewGroup) getParent();
- availableWidth = parent.getMeasuredWidth() - parent.getPaddingLeft()
- - parent.getPaddingRight();
- }
+ public void setToolTipLocation(int location) {
+ mToolTipLocation = location;
+ hideTooltip();
+ }
+
+ public boolean isTextTruncated(int availableWidth) {
availableWidth -= (getPaddingLeft() + getPaddingRight() + mDrawable.getIntrinsicWidth()
+ getCompoundDrawablePadding());
CharSequence displayedText = TextUtils.ellipsize(mText, getPaint(), availableWidth,
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index 494aae4..d78043d 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -17,6 +17,9 @@
package com.android.launcher3;
import static com.android.launcher3.AlphaUpdateListener.updateVisibility;
+import static com.android.launcher3.ButtonDropTarget.TOOLTIP_DEFAULT;
+import static com.android.launcher3.ButtonDropTarget.TOOLTIP_LEFT;
+import static com.android.launcher3.ButtonDropTarget.TOOLTIP_RIGHT;
import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
import android.animation.TimeInterpolator;
@@ -26,22 +29,18 @@
import android.view.Gravity;
import android.view.View;
import android.view.ViewDebug;
-import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.widget.FrameLayout;
-import android.widget.LinearLayout;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragController.DragListener;
import com.android.launcher3.dragndrop.DragOptions;
-import java.util.ArrayList;
-
/*
* The top bar containing various drop targets: Delete/App Info/Uninstall.
*/
-public class DropTargetBar extends LinearLayout
+public class DropTargetBar extends FrameLayout
implements DragListener, Insettable {
protected static final int DEFAULT_DRAG_FADE_DURATION = 175;
@@ -59,6 +58,8 @@
private ButtonDropTarget[] mDropTargets;
private ViewPropertyAnimator mCurrentAnimation;
+ private boolean mIsVertical = true;
+
public DropTargetBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -70,25 +71,30 @@
@Override
protected void onFinishInflate() {
super.onFinishInflate();
-
- // Initialize with hidden state
- setAlpha(0f);
+ mDropTargets = new ButtonDropTarget[getChildCount()];
+ for (int i = 0; i < mDropTargets.length; i++) {
+ mDropTargets[i] = (ButtonDropTarget) getChildAt(i);
+ mDropTargets[i].setDropTargetBar(this);
+ }
}
@Override
public void setInsets(Rect insets) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile();
+ mIsVertical = grid.isVerticalBarLayout();
lp.leftMargin = insets.left;
lp.topMargin = insets.top;
lp.bottomMargin = insets.bottom;
lp.rightMargin = insets.right;
+ int tooltipLocation = TOOLTIP_DEFAULT;
if (grid.isVerticalBarLayout()) {
lp.width = grid.dropTargetBarSizePx;
lp.height = grid.availableHeightPx - 2 * grid.edgeMarginPx;
lp.gravity = insets.left > insets.right ? Gravity.RIGHT : Gravity.LEFT;
+ tooltipLocation = insets.left > insets.right ? TOOLTIP_LEFT : TOOLTIP_RIGHT;
} else {
int gap;
if (grid.isTablet) {
@@ -107,83 +113,95 @@
lp.height = grid.dropTargetBarSizePx;
}
setLayoutParams(lp);
+ for (ButtonDropTarget button : mDropTargets) {
+ button.setToolTipLocation(tooltipLocation);
+ }
}
public void setup(DragController dragController) {
dragController.addDragListener(this);
- ArrayList<ButtonDropTarget> outList = new ArrayList<>();
- findDropTargets(this, outList);
-
- mDropTargets = new ButtonDropTarget[outList.size()];
for (int i = 0; i < mDropTargets.length; i++) {
- mDropTargets[i] = outList.get(i);
- mDropTargets[i].setDropTargetBar(this);
dragController.addDragListener(mDropTargets[i]);
dragController.addDropTarget(mDropTargets[i]);
}
}
- private static void findDropTargets(View view, ArrayList<ButtonDropTarget> outTargets) {
- if (view instanceof ButtonDropTarget) {
- outTargets.add((ButtonDropTarget) view);
- } else if (view instanceof ViewGroup) {
- ViewGroup vg = (ViewGroup) view;
- for (int i = vg.getChildCount() - 1; i >= 0; i--) {
- findDropTargets(vg.getChildAt(i), outTargets);
- }
- }
- }
-
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int width = MeasureSpec.getSize(widthMeasureSpec);
+ int height = MeasureSpec.getSize(heightMeasureSpec);
- boolean hideText = hideTextHelper(false /* shouldUpdateText */, false /* no-op */);
- if (hideTextHelper(true /* shouldUpdateText */, hideText)) {
- // Text has changed, so we need to re-measure.
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
- }
+ if (mIsVertical) {
+ int widthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
+ int heightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
- /**
- * Helper method that iterates through the children and returns whether any of the visible
- * {@link ButtonDropTarget} has truncated text.
- *
- * @param shouldUpdateText If True, updates the text of all children.
- * @param hideText If True and {@param shouldUpdateText} is True, clears the text of all
- * children; otherwise it sets the original text value.
- *
- *
- * @return If shouldUpdateText is True, returns whether any of the children updated their text.
- * Else, returns whether any of the children have truncated their text.
- */
- private boolean hideTextHelper(boolean shouldUpdateText, boolean hideText) {
- boolean result = false;
- View visibleView;
- ButtonDropTarget dropTarget;
- for (int i = getChildCount() - 1; i >= 0; --i) {
- if (getChildAt(i) instanceof ButtonDropTarget) {
- visibleView = dropTarget = (ButtonDropTarget) getChildAt(i);
- } else if (getChildAt(i) instanceof ViewGroup) {
- // The Drop Target is wrapped in a FrameLayout.
- visibleView = getChildAt(i);
- dropTarget = (ButtonDropTarget) ((ViewGroup) visibleView).getChildAt(0);
- } else {
- // Ignore other views.
- continue;
+ for (ButtonDropTarget button : mDropTargets) {
+ if (button.getVisibility() != GONE) {
+ button.setTextVisible(false);
+ button.measure(widthSpec, heightSpec);
+ }
+ }
+ } else {
+ int visibleCount = getVisibleButtonsCount();
+ int availableWidth = width / visibleCount;
+ boolean textVisible = true;
+ for (ButtonDropTarget buttons : mDropTargets) {
+ if (buttons.getVisibility() != GONE) {
+ textVisible = textVisible && !buttons.isTextTruncated(availableWidth);
+ }
}
- if (visibleView.getVisibility() == View.VISIBLE) {
- if (shouldUpdateText) {
- result |= dropTarget.updateText(hideText);
- } else if (dropTarget.isTextTruncated()) {
- result = true;
- break;
+ int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
+ int heightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
+ for (ButtonDropTarget button : mDropTargets) {
+ if (button.getVisibility() != GONE) {
+ button.setTextVisible(textVisible);
+ button.measure(widthSpec, heightSpec);
}
}
}
+ setMeasuredDimension(width, height);
+ }
- return result;
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ if (mIsVertical) {
+ int gap = getResources().getDimensionPixelSize(R.dimen.drop_target_vertical_gap);
+ int start = gap;
+ int end;
+
+ for (ButtonDropTarget button : mDropTargets) {
+ if (button.getVisibility() != GONE) {
+ end = start + button.getMeasuredHeight();
+ button.layout(0, start, button.getMeasuredWidth(), end);
+ start = end + gap;
+ }
+ }
+ } else {
+ int visibleCount = getVisibleButtonsCount();
+ int frameSize = (right - left) / visibleCount;
+
+ int start = frameSize / 2;
+ int halfWidth;
+ for (ButtonDropTarget button : mDropTargets) {
+ if (button.getVisibility() != GONE) {
+ halfWidth = button.getMeasuredWidth() / 2;
+ button.layout(start - halfWidth, 0,
+ start + halfWidth, button.getMeasuredHeight());
+ start = start + frameSize;
+ }
+ }
+ }
+ }
+
+ private int getVisibleButtonsCount() {
+ int visibleCount = 0;
+ for (ButtonDropTarget buttons : mDropTargets) {
+ if (buttons.getVisibility() != GONE) {
+ visibleCount++;
+ }
+ }
+ return visibleCount;
}
private void animateToVisibility(boolean isVisible) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 38a3044..32342b2 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;
@@ -2013,7 +2014,7 @@
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
- mLastDispatchTouchEventX = ev.getX();
+ mLastDispatchTouchEvent.set(ev.getX(), ev.getY());
return super.dispatchTouchEvent(ev);
}
@@ -2024,7 +2025,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 +2033,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 +2070,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/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/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/util/TraceHelper.java b/src/com/android/launcher3/util/TraceHelper.java
index 0f3ac57..bde9c0a 100644
--- a/src/com/android/launcher3/util/TraceHelper.java
+++ b/src/com/android/launcher3/util/TraceHelper.java
@@ -55,7 +55,7 @@
public static void partitionSection(String sectionName, String partition) {
if (ENABLED) {
MutableLong time = sUpTimes.get(sectionName);
- if (time.value >= 0) {
+ if (time != null && time.value >= 0) {
if (SYSTEM_TRACE) {
Trace.endSection();
@@ -78,7 +78,7 @@
public static void endSection(String sectionName, String msg) {
if (ENABLED) {
MutableLong time = sUpTimes.get(sectionName);
- if (time.value >= 0) {
+ if (time != null && time.value >= 0) {
if (SYSTEM_TRACE) {
Trace.endSection();
}
diff --git a/src/com/android/launcher3/views/AllAppsScrim.java b/src/com/android/launcher3/views/AllAppsScrim.java
index 5d39adb..cc73182 100644
--- a/src/com/android/launcher3/views/AllAppsScrim.java
+++ b/src/com/android/launcher3/views/AllAppsScrim.java
@@ -46,6 +46,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;
@@ -62,7 +63,7 @@
private int mFillAlpha;
private float mDrawHeight;
- private float mTranslateY;
+ private float mDrawOffsetY;
public AllAppsScrim(Context context) {
this(context, null);
@@ -135,7 +136,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 +154,29 @@
}
public void setProgress(float translateY, float alpha) {
- mFillAlpha = Math.round(alpha * mAlphaRange + mMinAlpha);
- mFillPaint.setAlpha(mFillAlpha);
+ float newAlpha = Math.round(alpha * mAlphaRange + mMinAlpha);
+ // 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);
- mTranslateY = translateY;
+ if (newAlpha != mFillAlpha || drawOffsetY != mDrawOffsetY) {
+ invalidateDrawRect();
- invalidate();
+ mFillAlpha = Math.round(alpha * mAlphaRange + mMinAlpha);
+ mFillPaint.setAlpha(mFillAlpha);
+ mDrawOffsetY = drawOffsetY;
+ invalidateDrawRect();
+ }
+
+ setTranslationY(Math.max(translateY, 0));
+ }
+
+ private void invalidateDrawRect() {
+ mDrawRect.top = (int) (getHeight()
+ + mDrawOffsetY - mDrawHeight + mPadding.top - mShadowBlur - 0.5f);
+ invalidate(mDrawRect);
}
public void setDrawRegion(float height) {
@@ -178,6 +196,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..0488fae 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -21,6 +21,7 @@
import android.app.ActivityOptions;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -54,7 +55,7 @@
launcher.getAllAppsController(), launcher.getWorkspace() };
}
- public static void onWorkspaceLongPress(Launcher launcher) {
+ public static void onWorkspaceLongPress(Launcher launcher, PointF touchPoint) {
launcher.getStateManager().goToState(OVERVIEW);
}