Merge "Import translations. DO NOT MERGE" into ub-launcher3-master
diff --git a/quickstep/res/drawable/task_thumbnail_background.xml b/quickstep/res/drawable/task_thumbnail_background.xml
deleted file mode 100644
index f1f48ac..0000000
--- a/quickstep/res/drawable/task_thumbnail_background.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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">
- <corners android:radius="2dp" />
-</shape>
diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml
index 839d934..91b6aa3 100644
--- a/quickstep/res/layout/task.xml
+++ b/quickstep/res/layout/task.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,23 +13,20 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<com.android.quickstep.TaskView
- xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.quickstep.TaskView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:elevation="4dp">
<com.android.quickstep.TaskThumbnailView
android:id="@+id/snapshot"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/task_thumbnail_top_margin"
- android:scaleType="matrix"
- android:background="@drawable/task_thumbnail_background"
- android:elevation="4dp" />
+ android:layout_marginTop="@dimen/task_thumbnail_top_margin" />
+
<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/task_thumbnail_icon_size"
android:layout_height="@dimen/task_thumbnail_icon_size"
- android:layout_gravity="top|center_horizontal"
- android:elevation="5dp"/>
+ android:layout_gravity="top|center_horizontal" />
</com.android.quickstep.TaskView>
\ No newline at end of file
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index a09e38d..9ef8e82 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -19,6 +19,9 @@
<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="quickstep_fling_threshold_velocity">500dp</dimen>
<dimen name="quickstep_fling_min_velocity">250dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
index d2777f0..8ee1b85 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
@@ -88,7 +88,6 @@
mDragLayer.setAlpha(1f);
mDragLayer.setTranslationY(0f);
- mDragLayer.getBackground().setAlpha(255);
finishedCallback.run();
}
});
@@ -118,12 +117,6 @@
private AnimatorSet getHideLauncherAnimator() {
AnimatorSet hideLauncher = new AnimatorSet();
- // Fade out the scrim fast to avoid the hard line
- ObjectAnimator scrimAlpha = ObjectAnimator.ofInt(mDragLayer.getBackground(),
- LauncherAnimUtils.DRAWABLE_ALPHA, 255, 0);
- scrimAlpha.setDuration(130);
- scrimAlpha.setInterpolator(Interpolators.AGGRESSIVE_EASE);
-
// Animate Launcher so that it moves downwards and fades out.
ObjectAnimator dragLayerAlpha = ObjectAnimator.ofFloat(mDragLayer, View.ALPHA, 1f, 0f);
dragLayerAlpha.setDuration(217);
@@ -133,7 +126,6 @@
dragLayerTransY.setInterpolator(Interpolators.AGGRESSIVE_EASE);
dragLayerTransY.setDuration(350);
- hideLauncher.play(scrimAlpha);
hideLauncher.play(dragLayerAlpha);
hideLauncher.play(dragLayerTransY);
return hideLauncher;
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
index d2057cf..68f6eed 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -100,12 +100,12 @@
float scale = pageRect.height() / childHeight;
Rect insets = launcher.getDragLayer().getInsets();
- float halfHeight = ws.getHeight() / 2;
+ float halfHeight = ws.getExpectedHeight() / 2;
float childTop = halfHeight - scale * (halfHeight - ws.getPaddingTop() - insets.top);
float translationY = pageRect.top - childTop;
// Align the workspace horizontally centered with the task rect
- float halfWidth = ws.getWidth() / 2;
+ float halfWidth = ws.getExpectedWidth() / 2;
float childCenter = halfWidth -
scale * (halfWidth - ws.getPaddingLeft() - insets.left - childWidth / 2);
float translationX = pageRect.exactCenterX() - childCenter;
diff --git a/quickstep/src/com/android/quickstep/RecentsView.java b/quickstep/src/com/android/quickstep/RecentsView.java
index 9c757bf..605c83c 100644
--- a/quickstep/src/com/android/quickstep/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/RecentsView.java
@@ -72,7 +72,7 @@
for (int i = mFirstTaskIndex; i < getChildCount(); i++) {
final TaskView taskView = (TaskView) getChildAt(i);
if (taskView.getTask().key.id == taskId) {
- taskView.getThumbnail().setThumbnail(snapshot);
+ taskView.getThumbnail().setThumbnail(taskView.getTask(), snapshot);
return;
}
}
diff --git a/quickstep/src/com/android/quickstep/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/TaskThumbnailView.java
index 473681f..87dec67 100644
--- a/quickstep/src/com/android/quickstep/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/TaskThumbnailView.java
@@ -22,35 +22,43 @@
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.ComposeShader;
import android.graphics.LightingColorFilter;
+import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
+import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.Shader;
import android.util.AttributeSet;
-import android.widget.FrameLayout;
+import android.view.View;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
+import com.android.launcher3.R;
+import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
/**
* A task in the Recents view.
*/
-public class TaskThumbnailView extends FrameLayout {
+public class TaskThumbnailView extends View {
+
+ private static final LightingColorFilter[] sDimFilterCache = new LightingColorFilter[256];
+
+ private final float mCornerRadius;
+ private final float mFadeLength;
+
+ private final Paint mPaint = new Paint();
+
+ private final Matrix mMatrix = new Matrix();
+ private final Rect mThumbnailRect = new Rect();
private ThumbnailData mThumbnailData;
-
- private Rect mThumbnailRect = new Rect();
- private float mThumbnailScale;
-
- private Matrix mMatrix = new Matrix();
- private Paint mDrawPaint = new Paint();
- protected Paint mBgFillPaint = new Paint();
protected BitmapShader mBitmapShader;
+ private float mThumbnailScale;
private float mDimAlpha = 1f;
- private LightingColorFilter mLightingColorFilter = new LightingColorFilter(Color.WHITE, 0);
public TaskThumbnailView(Context context) {
this(context, null);
@@ -62,32 +70,34 @@
public TaskThumbnailView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- setWillNotDraw(false);
- setClipToOutline(true);
+ mCornerRadius = getResources().getDimension(R.dimen.task_corner_radius);
+ mFadeLength = getResources().getDimension(R.dimen.task_fade_length);
}
/**
* Updates this thumbnail.
*/
- public void setThumbnail(ThumbnailData thumbnailData) {
+ public void setThumbnail(Task task, ThumbnailData thumbnailData) {
+ mPaint.setColor(task == null ? Color.BLACK : task.colorBackground | 0xFF000000);
+
if (thumbnailData != null && thumbnailData.thumbnail != null) {
Bitmap bm = thumbnailData.thumbnail;
bm.prepareToDraw();
mThumbnailScale = thumbnailData.scale;
mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
- mDrawPaint.setShader(mBitmapShader);
+ mPaint.setShader(mBitmapShader);
mThumbnailRect.set(0, 0,
bm.getWidth() - thumbnailData.insets.left - thumbnailData.insets.right,
bm.getHeight() - thumbnailData.insets.top - thumbnailData.insets.bottom);
mThumbnailData = thumbnailData;
updateThumbnailMatrix();
- updateThumbnailPaintFilter();
} else {
mBitmapShader = null;
- mDrawPaint.setShader(null);
- mThumbnailRect.setEmpty();
mThumbnailData = null;
+ mPaint.setShader(null);
+ mThumbnailRect.setEmpty();
}
+ updateThumbnailPaintFilter();
}
/**
@@ -100,43 +110,17 @@
@Override
protected void onDraw(Canvas canvas) {
- int viewWidth = getMeasuredWidth();
- int viewHeight = getMeasuredHeight();
- int thumbnailWidth = Math.min(viewWidth,
- (int) (mThumbnailRect.width() * mThumbnailScale));
- int thumbnailHeight = Math.min(viewHeight,
- (int) (mThumbnailRect.height() * mThumbnailScale));
-
- if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) {
- // Draw the background, there will be some small overdraw with the thumbnail
- if (thumbnailWidth < viewWidth) {
- // Portrait thumbnail on a landscape task view
- canvas.drawRect(Math.max(0, thumbnailWidth), 0, viewWidth, viewHeight,
- mBgFillPaint);
- }
- if (thumbnailHeight < viewHeight) {
- // Landscape thumbnail on a portrait task view
- canvas.drawRect(0, Math.max(0, thumbnailHeight), viewWidth, viewHeight,
- mBgFillPaint);
- }
-
- // Draw the thumbnail
- canvas.drawRect(0, 0, thumbnailWidth, thumbnailHeight, mDrawPaint);
- } else {
- canvas.drawRect(0, 0, viewWidth, viewHeight, mBgFillPaint);
- }
+ canvas.drawRoundRect(0, 0, getMeasuredWidth(), getMeasuredHeight(),
+ mCornerRadius, mCornerRadius, mPaint);
}
private void updateThumbnailPaintFilter() {
int mul = (int) (mDimAlpha * 255);
if (mBitmapShader != null) {
- mLightingColorFilter = new LightingColorFilter(Color.argb(255, mul, mul, mul), 0);
- mDrawPaint.setColorFilter(mLightingColorFilter);
- mDrawPaint.setColor(0xFFffffff);
- mBgFillPaint.setColorFilter(mLightingColorFilter);
+ mPaint.setColorFilter(getLightingColorFilter(mul));
} else {
- mDrawPaint.setColorFilter(null);
- mDrawPaint.setColor(Color.argb(255, mul, mul, mul));
+ mPaint.setColorFilter(null);
+ mPaint.setColor(Color.argb(255, mul, mul, mul));
}
invalidate();
}
@@ -170,6 +154,26 @@
mMatrix.setTranslate(-mThumbnailData.insets.left, -mThumbnailData.insets.top);
mMatrix.postScale(mThumbnailScale, mThumbnailScale);
mBitmapShader.setLocalMatrix(mMatrix);
+
+ float bitmapHeight = Math.max(mThumbnailRect.height() * mThumbnailScale, 0);
+ Shader shader = mBitmapShader;
+ if (bitmapHeight < getMeasuredHeight()) {
+ int color = mPaint.getColor();
+ LinearGradient fade = new LinearGradient(
+ 0, bitmapHeight - mFadeLength, 0, bitmapHeight,
+ color & 0x00FFFFFF, color, Shader.TileMode.CLAMP);
+ shader = new ComposeShader(fade, shader, Mode.DST_OVER);
+ }
+
+ float bitmapWidth = Math.max(mThumbnailRect.width() * mThumbnailScale, 0);
+ if (bitmapWidth < getMeasuredWidth()) {
+ int color = mPaint.getColor();
+ LinearGradient fade = new LinearGradient(
+ bitmapWidth - mFadeLength, 0, bitmapWidth, 0,
+ color & 0x00FFFFFF, color, Shader.TileMode.CLAMP);
+ shader = new ComposeShader(fade, shader, Mode.DST_OVER);
+ }
+ mPaint.setShader(shader);
}
invalidate();
}
@@ -179,4 +183,17 @@
super.onSizeChanged(w, h, oldw, oldh);
updateThumbnailMatrix();
}
+
+ private static LightingColorFilter getLightingColorFilter(int dimColor) {
+ if (dimColor < 0) {
+ dimColor = 0;
+ } else if (dimColor > 255) {
+ dimColor = 255;
+ }
+ if (sDimFilterCache[dimColor] == null) {
+ sDimFilterCache[dimColor] =
+ new LightingColorFilter(Color.argb(255, dimColor, dimColor, dimColor), 0);
+ }
+ return sDimFilterCache[dimColor];
+ }
}
diff --git a/quickstep/src/com/android/quickstep/TaskView.java b/quickstep/src/com/android/quickstep/TaskView.java
index 5c15a76..0e999f8 100644
--- a/quickstep/src/com/android/quickstep/TaskView.java
+++ b/quickstep/src/com/android/quickstep/TaskView.java
@@ -16,13 +16,20 @@
package com.android.quickstep;
+import static com.android.quickstep.RecentsView.SCROLL_TYPE_TASK;
+import static com.android.quickstep.RecentsView.SCROLL_TYPE_WORKSPACE;
+
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.app.ActivityOptions;
import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Outline;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Property;
+import android.view.View;
+import android.view.ViewOutlineProvider;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -40,9 +47,6 @@
import java.util.ArrayList;
import java.util.List;
-import static com.android.quickstep.RecentsView.SCROLL_TYPE_TASK;
-import static com.android.quickstep.RecentsView.SCROLL_TYPE_WORKSPACE;
-
/**
* A task in the Recents view.
*/
@@ -90,9 +94,8 @@
public TaskView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- setOnClickListener((view) -> {
- launchTask(true /* animate */);
- });
+ setOnClickListener((view) -> launchTask(true /* animate */));
+ setOutlineProvider(new TaskOutlineProvider(getResources()));
}
@Override
@@ -155,14 +158,14 @@
@Override
public void onTaskDataLoaded(Task task, ThumbnailData thumbnailData) {
- mSnapshotView.setThumbnail(thumbnailData);
+ mSnapshotView.setThumbnail(task, thumbnailData);
mIconView.setImageDrawable(task.icon);
mIconView.setOnLongClickListener(icon -> TaskMenuView.showForTask(this));
}
@Override
public void onTaskDataUnloaded() {
- mSnapshotView.setThumbnail(null);
+ mSnapshotView.setThumbnail(null, null);
mIconView.setImageDrawable(null);
mIconView.setOnLongClickListener(null);
}
@@ -216,4 +219,22 @@
scrollState.prevPageExtraWidth = 0;
return SCROLL_TYPE_TASK;
}
+
+
+ private static final class TaskOutlineProvider extends ViewOutlineProvider {
+
+ private final int mMarginTop;
+ private final float mRadius;
+
+ TaskOutlineProvider(Resources res) {
+ mMarginTop = res.getDimensionPixelSize(R.dimen.task_thumbnail_top_margin);
+ mRadius = res.getDimension(R.dimen.task_corner_radius);
+ }
+
+ @Override
+ public void getOutline(View view, Outline outline) {
+ outline.setRoundRect(0, mMarginTop, view.getWidth(),
+ view.getHeight(), mRadius);
+ }
+ }
}
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 9bd3c67..f26bfbd 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -21,13 +21,13 @@
android:id="@+id/launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="?attr/workspaceStatusBarScrim"
android:fitsSystemWindows="true">
<com.android.launcher3.dragndrop.DragLayer
android:id="@+id/drag_layer"
android:clipChildren="false"
android:clipToPadding="false"
- android:background="?attr/workspaceStatusBarScrim"
android:importantForAccessibility="no"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index b678398..cde3bd5 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -22,6 +22,7 @@
android:id="@+id/launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="?attr/workspaceStatusBarScrim"
android:fitsSystemWindows="true">
<com.android.launcher3.dragndrop.DragLayer
@@ -29,7 +30,6 @@
android:clipChildren="false"
android:importantForAccessibility="no"
android:clipToPadding="false"
- android:background="?attr/workspaceStatusBarScrim"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index 7e6c659..fe2f108 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -21,6 +21,7 @@
android:id="@+id/launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="?attr/workspaceStatusBarScrim"
android:fitsSystemWindows="true">
<com.android.launcher3.dragndrop.DragLayer
@@ -28,7 +29,6 @@
android:clipChildren="false"
android:clipToPadding="false"
android:importantForAccessibility="no"
- android:background="?attr/workspaceStatusBarScrim"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index bfd3d69..38a3044 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -769,12 +769,12 @@
mAppWidgetHost.setListenIfResumed(true);
NotificationListener.setNotificationsChangedListener(mPopupDataProvider);
- if (mShouldFadeInScrim && mDragLayer.getBackground() != null) {
+ if (mShouldFadeInScrim && mLauncherView.getBackground() != null) {
if (mScrimAnimator != null) {
mScrimAnimator.cancel();
}
- mDragLayer.getBackground().setAlpha(0);
- mScrimAnimator = ObjectAnimator.ofInt(mDragLayer.getBackground(),
+ mLauncherView.getBackground().setAlpha(0);
+ mScrimAnimator = ObjectAnimator.ofInt(mLauncherView.getBackground(),
LauncherAnimUtils.DRAWABLE_ALPHA, 0, 255);
mScrimAnimator.addListener(new AnimatorListenerAdapter() {
@Override
@@ -1857,7 +1857,9 @@
if (v != null) {
intent.setSourceBounds(getViewBounds(v));
// If there is no target package, use the default intent chooser animation
- launchOptions = hasTargetPackage ? getActivityLaunchOptions(v) : null;
+ launchOptions = hasTargetPackage
+ ? getActivityLaunchOptions(v, isInMultiWindowModeCompat())
+ : null;
} else {
launchOptions = null;
}
@@ -1911,9 +1913,38 @@
}
}
+ public Bundle getDefaultActivityLaunchOptions(View v) {
+ if (Utilities.ATLEAST_MARSHMALLOW) {
+ int left = 0, top = 0;
+ int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
+ if (v instanceof BubbleTextView) {
+ // Launch from center of icon, not entire view
+ Drawable icon = ((BubbleTextView) v).getIcon();
+ if (icon != null) {
+ Rect bounds = icon.getBounds();
+ left = (width - bounds.width()) / 2;
+ top = v.getPaddingTop();
+ width = bounds.width();
+ height = bounds.height();
+ }
+ }
+ return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height)
+ .toBundle();
+ } else if (Utilities.ATLEAST_LOLLIPOP_MR1) {
+ // On L devices, we use the device default slide-up transition.
+ // On L MR1 devices, we use a custom version of the slide-up transition which
+ // doesn't have the delay present in the device default.
+ return ActivityOptions.makeCustomAnimation(
+ this, R.anim.task_open_enter, R.anim.no_anim).toBundle();
+ }
+ return null;
+ }
+
@TargetApi(Build.VERSION_CODES.M)
- public Bundle getActivityLaunchOptions(View v) {
- return UiFactory.getActivityLaunchOptions(this, v);
+ public Bundle getActivityLaunchOptions(View v, boolean useDefaultLaunchOptions) {
+ return useDefaultLaunchOptions
+ ? getDefaultActivityLaunchOptions(v)
+ : UiFactory.getActivityLaunchOptions(this, v);
}
public Rect getViewBounds(View v) {
@@ -1928,11 +1959,20 @@
Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
return mAppLaunchSuccess;
}
+
+ boolean isShortcut = Utilities.ATLEAST_MARSHMALLOW
+ && (item instanceof ShortcutInfo)
+ && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
+ || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
+ && !((ShortcutInfo) item).isPromise();
+
// Only launch using the new animation if the shortcut has not opted out (this is a
// private contract between launcher and may be ignored in the future).
boolean useLaunchAnimation = (v != null) &&
!intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
- Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null;
+ Bundle optsBundle = useLaunchAnimation
+ ? getActivityLaunchOptions(v, isShortcut || isInMultiWindowModeCompat())
+ : null;
UserHandle user = item == null ? null : item.user;
@@ -1942,11 +1982,7 @@
intent.setSourceBounds(getViewBounds(v));
}
try {
- if (Utilities.ATLEAST_MARSHMALLOW
- && (item instanceof ShortcutInfo)
- && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
- || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
- && !((ShortcutInfo) item).isPromise()) {
+ if (isShortcut) {
// Shortcuts need some special checks due to legacy reasons.
startShortcutIntentSafely(intent, optsBundle, item);
} else if (user == null || user.equals(Process.myUserHandle())) {
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index 1a1bec6..18d5234 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -11,6 +11,8 @@
import android.view.View;
import android.view.ViewDebug;
+import com.android.launcher3.util.Themes;
+
import static com.android.launcher3.util.SystemUiController.FLAG_DARK_NAV;
import static com.android.launcher3.util.SystemUiController.UI_STATE_ROOT_VIEW;
@@ -66,6 +68,7 @@
// Update device profile before notifying th children.
mLauncher.getDeviceProfile().updateInsets(insets);
+ boolean resetState = !insets.equals(mInsets);
setInsets(insets);
if (mAlignedView != null) {
@@ -77,10 +80,20 @@
mAlignedView.setLayoutParams(lp);
}
}
+ if (resetState) {
+ mLauncher.getStateManager().reapplyState();
+ }
return true; // I'll take it from here
}
+ @Override
+ public void setInsets(Rect insets) {
+ super.setInsets(insets);
+ setBackground(insets.top == 0 ? null
+ : Themes.getAttrDrawable(getContext(), R.attr.workspaceStatusBarScrim));
+ }
+
public void dispatchInsets() {
fitSystemWindows(mInsets);
}
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index bcb6252..8eeeec3 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -146,6 +146,14 @@
goToState(state, true, delay, null);
}
+ public void reapplyState() {
+ if (mConfig.mCurrentAnimation == null) {
+ for (StateHandler handler : getStateHandlers()) {
+ handler.setState(mState);
+ }
+ }
+ }
+
private void goToState(LauncherState state, boolean animated, long delay,
Runnable onCompleteRunnable) {
if (mLauncher.isInState(state) && mConfig.mCurrentAnimation == null) {
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 4c30853..ad94a6b 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -563,13 +563,21 @@
computeScrollHelper();
}
+ public int getExpectedHeight() {
+ return getMeasuredHeight();
+ }
+
public int getNormalChildHeight() {
- return getMeasuredHeight() - getPaddingTop() - getPaddingBottom()
+ return getExpectedHeight() - getPaddingTop() - getPaddingBottom()
- mInsets.top - mInsets.bottom;
}
+ public int getExpectedWidth() {
+ return getMeasuredWidth();
+ }
+
public int getNormalChildWidth() {
- return getMeasuredWidth() - getPaddingLeft() - getPaddingRight()
+ return getExpectedWidth() - getPaddingLeft() - getPaddingRight()
- mInsets.left - mInsets.right;
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index de3b09a..c946a44 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -3447,6 +3447,18 @@
}
@Override
+ public int getExpectedHeight() {
+ return getMeasuredHeight() <= 0
+ ? mLauncher.getDeviceProfile().heightPx : getMeasuredHeight();
+ }
+
+ @Override
+ public int getExpectedWidth() {
+ return getMeasuredWidth() <= 0
+ ? mLauncher.getDeviceProfile().widthPx : getMeasuredWidth();
+ }
+
+ @Override
protected String getPageIndicatorDescription() {
return getResources().getString(R.string.all_apps_button_label);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index af7ca51..2e544ec 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -27,7 +27,6 @@
import android.support.v7.widget.RecyclerView;
import android.text.Selection;
import android.text.SpannableStringBuilder;
-import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -149,9 +148,7 @@
*/
public void setApps(List<AppInfo> apps) {
boolean hasWorkProfileApp = hasWorkProfileApp(apps);
- if (mUsingTabs != hasWorkProfileApp) {
- rebindAdapters(hasWorkProfileApp);
- }
+ rebindAdapters(hasWorkProfileApp);
mComponentToAppMap.clear();
addOrUpdateApps(apps);
}
@@ -262,7 +259,7 @@
});
mHeader = findViewById(R.id.all_apps_header);
- rebindAdapters(mUsingTabs);
+ rebindAdapters(mUsingTabs, true /* force */);
mSearchContainer = findViewById(R.id.search_container_all_apps);
mSearchUiManager = (SearchUiManager) mSearchContainer;
@@ -396,9 +393,14 @@
}
private void rebindAdapters(boolean showTabs) {
- if (showTabs != mUsingTabs) {
- replaceRVContainer(showTabs);
+ rebindAdapters(showTabs, false /* force */);
+ }
+
+ private void rebindAdapters(boolean showTabs, boolean force) {
+ if (showTabs == mUsingTabs && !force) {
+ return;
}
+ replaceRVContainer(showTabs);
mUsingTabs = showTabs;
if (mUsingTabs) {
@@ -540,13 +542,16 @@
for (int i = 0; i < mAH.length; i++) {
mAH[i].adapter.setLastSearchQuery(query);
}
- boolean hasQuery = !TextUtils.isEmpty(query);
- if (mUsingTabs && hasQuery) {
+ if (mUsingTabs) {
mSearchModeWhileUsingTabs = true;
rebindAdapters(false); // hide tabs
- } else if (mSearchModeWhileUsingTabs && !hasQuery) {
- mSearchModeWhileUsingTabs = false;
+ }
+ }
+
+ public void onClearSearchResult() {
+ if (mSearchModeWhileUsingTabs) {
rebindAdapters(true); // show tabs
+ mSearchModeWhileUsingTabs = false;
}
}
diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
index e65a2c4..ed41f13 100644
--- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
+++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
@@ -184,6 +184,7 @@
mSearchQueryBuilder.clear();
mSearchQueryBuilder.clearSpans();
Selection.setSelection(mSearchQueryBuilder, 0);
+ mAppsView.onClearSearchResult();
}
@Override
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index c75e616..93a5679 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -366,13 +366,6 @@
}
@Override
- public void setInsets(Rect insets) {
- super.setInsets(insets);
- setBackground(insets.top == 0 ? null
- : Themes.getAttrDrawable(getContext(), R.attr.workspaceStatusBarScrim));
- }
-
- @Override
public LayoutParams generateLayoutParams(AttributeSet attrs) {
return new LayoutParams(getContext(), attrs);
}
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index 42aa12b..83cbf59 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);
+ Bundle opts = launcher.getActivityLaunchOptions(view, true);
InfoDropTarget.startDetailsActivityForInfo(itemInfo, launcher, sourceBounds, opts);
launcher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
ControlType.APPINFO_TARGET, view);
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
index 26dd68f..9a09c97 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
@@ -158,7 +158,7 @@
.setPackage(getContext().getPackageName());
intent.setSourceBounds(mLauncher.getViewBounds(v));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getContext().startActivity(intent, mLauncher.getActivityLaunchOptions(v));
+ getContext().startActivity(intent, mLauncher.getActivityLaunchOptions(v, false));
}
@Override
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
index d1b903c..9819d71 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -68,28 +68,6 @@
public static void resetOverview(Launcher launcher) { }
public static Bundle getActivityLaunchOptions(Launcher launcher, View v) {
- if (Utilities.ATLEAST_MARSHMALLOW) {
- int left = 0, top = 0;
- int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
- if (v instanceof BubbleTextView) {
- // Launch from center of icon, not entire view
- Drawable icon = ((BubbleTextView) v).getIcon();
- if (icon != null) {
- Rect bounds = icon.getBounds();
- left = (width - bounds.width()) / 2;
- top = v.getPaddingTop();
- width = bounds.width();
- height = bounds.height();
- }
- }
- return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height).toBundle();
- } else if (Utilities.ATLEAST_LOLLIPOP_MR1) {
- // On L devices, we use the device default slide-up transition.
- // On L MR1 devices, we use a custom version of the slide-up transition which
- // doesn't have the delay present in the device default.
- return ActivityOptions.makeCustomAnimation(
- launcher, R.anim.task_open_enter, R.anim.no_anim).toBundle();
- }
- return null;
+ return launcher.getDefaultActivityLaunchOptions(v);
}
}