Merge "Adding some task views." into ub-launcher3-master
diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
index 51a8a5e..9bdd7a3 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -16,16 +16,11 @@
package com.android.launcher3.uioverrides;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
-import static com.android.launcher3.Utilities.isAccessibilityEnabled;
-import android.graphics.Rect;
import android.view.View;
-import android.view.accessibility.AccessibilityNodeInfo;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
-import com.android.launcher3.Workspace;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.quickstep.RecentsView;
@@ -37,7 +32,7 @@
// The percent to shrink the workspace during overview mode
public static final float SCALE_FACTOR = 0.7f;
- private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT;
+ private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE;
public OverviewState(int id) {
super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
@@ -46,7 +41,7 @@
@Override
public float[] getWorkspaceScaleAndTranslation(Launcher launcher) {
// TODO: Find a better transition
- return new float[] {SCALE_FACTOR, 0};
+ return new float[] {0f, 0};
}
@Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
new file mode 100644
index 0000000..da1eff9
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+package com.android.launcher3.uioverrides;
+
+import static com.android.launcher3.WorkspaceStateTransitionAnimation.NO_ANIM_PROPERTY_SETTER;
+
+import android.animation.AnimatorSet;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.LauncherStateManager.AnimationConfig;
+import com.android.launcher3.LauncherStateManager.StateHandler;
+import com.android.launcher3.WorkspaceStateTransitionAnimation.AnimatedPropertySetter;
+import com.android.launcher3.WorkspaceStateTransitionAnimation.PropertySetter;
+import com.android.launcher3.anim.AnimationLayerSet;
+
+public class RecentsViewStateController implements StateHandler {
+
+ private final Launcher mLauncher;
+
+ public RecentsViewStateController(Launcher launcher) {
+ mLauncher = launcher;
+ }
+
+ @Override
+ public void setState(LauncherState state) {
+ setState(state, NO_ANIM_PROPERTY_SETTER);
+ }
+
+ @Override
+ public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
+ AnimatorSet anim, AnimationConfig config) {
+ setState(toState, new AnimatedPropertySetter(config.duration, layerViews, anim));
+ }
+
+ private void setState(LauncherState state, PropertySetter setter) {
+ setter.setViewAlpha(null, mLauncher.getOverviewPanel(),
+ state == LauncherState.OVERVIEW ? 1 : 0);
+ }
+}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index 540b200..c490c3f 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -19,6 +19,7 @@
import android.view.View.AccessibilityDelegate;
import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.VerticalSwipeController;
import com.android.launcher3.util.TouchController;
@@ -31,4 +32,10 @@
public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {
return null;
}
+
+ public static StateHandler[] getStateHandler(Launcher launcher) {
+ return new StateHandler[] {
+ launcher.getAllAppsController(), launcher.getWorkspace(),
+ new RecentsViewStateController(launcher)};
+ }
}
diff --git a/quickstep/src/com/android/quickstep/RecentsView.java b/quickstep/src/com/android/quickstep/RecentsView.java
index e474ecb..d85de8f 100644
--- a/quickstep/src/com/android/quickstep/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/RecentsView.java
@@ -17,13 +17,19 @@
package com.android.quickstep;
import android.content.Context;
+import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.HorizontalScrollView;
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.Insettable;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.R;
+
/**
* A placeholder view for recents
*/
-public class RecentsView extends HorizontalScrollView {
+public class RecentsView extends HorizontalScrollView implements Insettable {
public RecentsView(Context context) {
this(context, null);
}
@@ -35,7 +41,23 @@
public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setAlpha(0);
+ setVisibility(INVISIBLE);
}
public void setViewVisible(boolean isVisible) { }
+
+ @Override
+ public void setInsets(Rect insets) {
+ MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
+ lp.topMargin = insets.top;
+ lp.bottomMargin = insets.bottom;
+ lp.leftMargin = insets.left;
+ lp.rightMargin = insets.right;
+
+ DeviceProfile dp = Launcher.getLauncher(getContext()).getDeviceProfile();
+ if (!dp.isVerticalBarLayout()) {
+ lp.bottomMargin += dp.hotseatBarSizePx + getResources().getDimensionPixelSize(
+ R.dimen.dynamic_grid_min_page_indicator_size);
+ }
+ }
}
diff --git a/res/layout/deep_shortcut.xml b/res/layout/deep_shortcut.xml
index 4a2ad42..4a3db1f 100644
--- a/res/layout/deep_shortcut.xml
+++ b/res/layout/deep_shortcut.xml
@@ -35,6 +35,7 @@
android:textColor="?android:attr/textColorPrimary"
android:fontFamily="sans-serif"
launcher:layoutHorizontal="true"
+ launcher:deferShadowGeneration="true"
launcher:iconDisplay="shortcut_popup"
launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size" />
diff --git a/res/layout/system_shortcut.xml b/res/layout/system_shortcut.xml
index 04f3d02..1888e22 100644
--- a/res/layout/system_shortcut.xml
+++ b/res/layout/system_shortcut.xml
@@ -34,6 +34,7 @@
android:fontFamily="sans-serif"
launcher:iconDisplay="shortcut_popup"
launcher:layoutHorizontal="true"
+ launcher:deferShadowGeneration="true"
android:focusable="false" />
<View
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index eb12dc8..957ec19 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -15,7 +15,10 @@
-->
<resources>
-<!-- Dynamic Grid -->
+
+ <dimen name="click_shadow_elevation">4dp</dimen>
+
+ <!-- Dynamic Grid -->
<dimen name="dynamic_grid_edge_margin">8dp</dimen>
<dimen name="dynamic_grid_min_page_indicator_size">32dp</dimen>
<dimen name="dynamic_grid_page_indicator_line_height">1dp</dimen>
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index a5422aa..9796d18 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -21,9 +21,12 @@
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
+import android.os.Build;
+import android.os.Process;
import android.os.UserHandle;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.PackageManagerHelper;
@@ -59,17 +62,12 @@
this.componentName = info.getComponentName();
this.container = ItemInfo.NO_ID;
this.user = user;
- if (PackageManagerHelper.isAppSuspended(info.getApplicationInfo())) {
- runtimeStatusFlags |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
- }
- if (quietModeEnabled) {
- runtimeStatusFlags |= ShortcutInfo.FLAG_DISABLED_QUIET_USER;
- }
-
intent = makeLaunchIntent(info);
- runtimeStatusFlags |= (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0
- ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES;
+ if (quietModeEnabled) {
+ runtimeStatusFlags |= FLAG_DISABLED_QUIET_USER;
+ }
+ updateRuntimeFlagsForActivityTarget(this, info);
}
public AppInfo(AppInfo info) {
@@ -102,4 +100,21 @@
.setComponent(cn)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
}
+
+ public static void updateRuntimeFlagsForActivityTarget(
+ ItemInfoWithIcon info, LauncherActivityInfo lai) {
+ ApplicationInfo appInfo = lai.getApplicationInfo();
+ if (PackageManagerHelper.isAppSuspended(appInfo)) {
+ info.runtimeStatusFlags |= FLAG_DISABLED_SUSPENDED;
+ }
+ info.runtimeStatusFlags |= (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0
+ ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES;
+
+ if (FeatureFlags.LEGACY_ICON_TREATMENT && Utilities.ATLEAST_OREO
+ && appInfo.targetSdkVersion >= Build.VERSION_CODES.O
+ && Process.myUserHandle().equals(lai.getUser())) {
+ // The icon for a non-primary user is badged, hence it's not exactly an adaptive icon.
+ info.runtimeStatusFlags |= FLAG_ADAPTIVE_ICON;
+ }
+ }
}
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 3162286..79a34a0 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -385,16 +385,7 @@
@Override
public void setPressedIcon(BubbleTextView icon, Bitmap background) {
- if (icon == null || background == null) {
- mTouchFeedbackView.setBitmap(null);
- mTouchFeedbackView.animate().cancel();
- } else {
- if (mTouchFeedbackView.setBitmap(background)) {
- mTouchFeedbackView.alignWithIconView(icon, mShortcutsAndWidgets,
- null /* clipAgainstView */);
- mTouchFeedbackView.animateShadow();
- }
- }
+ mTouchFeedbackView.setPressedIcon(icon, background);
}
void setIsDragOverlapping(boolean isDragOverlapping) {
diff --git a/src/com/android/launcher3/ClickShadowView.java b/src/com/android/launcher3/ClickShadowView.java
index aad1112..5391b4d 100644
--- a/src/com/android/launcher3/ClickShadowView.java
+++ b/src/com/android/launcher3/ClickShadowView.java
@@ -16,15 +16,28 @@
package com.android.launcher3;
+import static com.android.launcher3.FastBitmapDrawable.CLICK_FEEDBACK_DURATION;
+import static com.android.launcher3.FastBitmapDrawable.CLICK_FEEDBACK_INTERPOLATOR;
+import static com.android.launcher3.LauncherAnimUtils.ELEVATION;
+import static com.android.launcher3.graphics.HolographicOutlineHelper.ADAPTIVE_ICON_SHADOW_BITMAP;
+
+import android.animation.ObjectAnimator;
+import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Rect;
+import android.graphics.drawable.AdaptiveIconDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.util.Property;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
+import android.view.ViewOutlineProvider;
public class ClickShadowView extends View {
@@ -32,6 +45,8 @@
private static final int SHADOW_LOW_ALPHA = 30;
private static final int SHADOW_HIGH_ALPHA = 60;
+ private static float sAdaptiveIconScaleFactor = 1f;
+
private final Paint mPaint;
@ViewDebug.ExportedProperty(category = "launcher")
@@ -40,6 +55,10 @@
private final float mShadowPadding;
private Bitmap mBitmap;
+ private ObjectAnimator mAnim;
+
+ private Drawable mAdaptiveIcon;
+ private ViewOutlineProvider mOutlineProvider;
public ClickShadowView(Context context) {
super(context);
@@ -50,6 +69,10 @@
mShadowOffset = getResources().getDimension(R.dimen.click_shadow_high_shift);
}
+ public static void setAdaptiveIconScaleFactor(float factor) {
+ sAdaptiveIconScaleFactor = factor;
+ }
+
/**
* @return extra space required by the view to show the shadow.
*/
@@ -57,11 +80,64 @@
return (int) (SHADOW_SIZE_FACTOR * mShadowPadding);
}
+ public void setPressedIcon(BubbleTextView icon, Bitmap background) {
+ if (icon == null) {
+ setBitmap(null);
+ cancelAnim();
+ return;
+ }
+ if (background == null) {
+ if (mBitmap == ADAPTIVE_ICON_SHADOW_BITMAP) {
+ // clear animation shadow
+ }
+ setBitmap(null);
+ cancelAnim();
+ icon.setOutlineProvider(null);
+ } else if (setBitmap(background)) {
+ if (mBitmap == ADAPTIVE_ICON_SHADOW_BITMAP) {
+ setupAdaptiveShadow(icon);
+ cancelAnim();
+ startAnim(icon, ELEVATION,
+ getResources().getDimension(R.dimen.click_shadow_elevation));
+ } else {
+ alignWithIconView(icon);
+ startAnim(this, ALPHA, 1);
+ }
+ }
+ }
+
+ @TargetApi(Build.VERSION_CODES.O)
+ private void setupAdaptiveShadow(final BubbleTextView view) {
+ if (mAdaptiveIcon == null) {
+ mAdaptiveIcon = new AdaptiveIconDrawable(null, null);
+ mOutlineProvider = new ViewOutlineProvider() {
+ @Override
+ public void getOutline(View view, Outline outline) {
+ mAdaptiveIcon.getOutline(outline);
+ }
+ };
+ }
+
+ int iconWidth = view.getRight() - view.getLeft();
+ int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
+ int drawableWidth = view.getIcon().getBounds().width();
+
+ Rect bounds = new Rect();
+ bounds.left = view.getCompoundPaddingLeft() + (iconHSpace - drawableWidth) / 2;
+ bounds.right = bounds.left + drawableWidth;
+ bounds.top = view.getPaddingTop();
+ bounds.bottom = bounds.top + view.getIcon().getBounds().height();
+ Utilities.scaleRectAboutCenter(bounds, sAdaptiveIconScaleFactor);
+
+ mAdaptiveIcon.setBounds(bounds);
+ view.setOutlineProvider(mOutlineProvider);
+ }
+
/**
* Applies the new bitmap.
* @return true if the view was invalidated.
*/
- public boolean setBitmap(Bitmap b) {
+ private boolean setBitmap(Bitmap b) {
if (b != mBitmap){
mBitmap = b;
invalidate();
@@ -80,48 +156,51 @@
}
}
- public void animateShadow() {
- setAlpha(0);
- animate().alpha(1)
- .setDuration(FastBitmapDrawable.CLICK_FEEDBACK_DURATION)
- .setInterpolator(FastBitmapDrawable.CLICK_FEEDBACK_INTERPOLATOR)
- .start();
+ private void cancelAnim() {
+ if (mAnim != null) {
+ mAnim.cancel();
+ mAnim.setCurrentPlayTime(0);
+ mAnim = null;
+ }
+ }
+
+ private void startAnim(View target, Property<View, Float> property, float endValue) {
+ cancelAnim();
+ property.set(target, 0f);
+ mAnim = ObjectAnimator.ofFloat(target, property, endValue);
+ mAnim.setDuration(CLICK_FEEDBACK_DURATION)
+ .setInterpolator(CLICK_FEEDBACK_INTERPOLATOR);
+ mAnim.start();
}
/**
* Aligns the shadow with {@param view}
- * @param viewParent immediate parent of {@param view}. It must be a sibling of this view.
+ * Note: {@param view} must be a descendant of my parent.
*/
- public void alignWithIconView(BubbleTextView view, ViewGroup viewParent, View clipAgainstView) {
- float leftShift = view.getLeft() + viewParent.getLeft() - getLeft();
- float topShift = view.getTop() + viewParent.getTop() - getTop();
+ private void alignWithIconView(BubbleTextView view) {
+ int[] coords = new int[] {0, 0};
+ Utilities.getDescendantCoordRelativeToAncestor(
+ (ViewGroup) view.getParent(), (View) getParent(), coords, false);
+
+ float leftShift = view.getLeft() + coords[0] - getLeft();
+ float topShift = view.getTop() + coords[1] - getTop();
int iconWidth = view.getRight() - view.getLeft();
int iconHeight = view.getBottom() - view.getTop();
int iconHSpace = iconWidth - view.getCompoundPaddingRight() - view.getCompoundPaddingLeft();
float drawableWidth = view.getIcon().getBounds().width();
- if (clipAgainstView != null) {
- // Set the bounds to clip against
- int[] coords = new int[] {0, 0};
- Utilities.getDescendantCoordRelativeToAncestor(clipAgainstView, (View) getParent(),
- coords, false);
- int clipLeft = (int) Math.max(0, coords[0] - leftShift - mShadowPadding);
- int clipTop = (int) Math.max(0, coords[1] - topShift - mShadowPadding) ;
- setClipBounds(new Rect(clipLeft, clipTop, clipLeft + iconWidth, clipTop + iconHeight));
- } else {
- // Reset the clip bounds
- setClipBounds(null);
- }
+ // Set the bounds to clip against
+ int clipLeft = (int) Math.max(0, coords[0] - leftShift - mShadowPadding);
+ int clipTop = (int) Math.max(0, coords[1] - topShift - mShadowPadding) ;
+ setClipBounds(new Rect(clipLeft, clipTop, clipLeft + iconWidth, clipTop + iconHeight));
setTranslationX(leftShift
- + viewParent.getTranslationX()
+ view.getCompoundPaddingLeft() * view.getScaleX()
+ (iconHSpace - drawableWidth) * view.getScaleX() / 2 /* drawable gap */
+ iconWidth * (1 - view.getScaleX()) / 2 /* gap due to scale */
- mShadowPadding /* extra shadow size */
);
setTranslationY(topShift
- + viewParent.getTranslationY()
+ view.getPaddingTop() * view.getScaleY() /* drawable gap */
+ view.getHeight() * (1 - view.getScaleY()) / 2 /* gap due to scale */
- mShadowPadding /* extra shadow size */
diff --git a/src/com/android/launcher3/ItemInfoWithIcon.java b/src/com/android/launcher3/ItemInfoWithIcon.java
index 1c4e88b..fea4dda 100644
--- a/src/com/android/launcher3/ItemInfoWithIcon.java
+++ b/src/com/android/launcher3/ItemInfoWithIcon.java
@@ -67,7 +67,6 @@
FLAG_DISABLED_NOT_AVAILABLE | FLAG_DISABLED_SUSPENDED |
FLAG_DISABLED_QUIET_USER | FLAG_DISABLED_BY_PUBLISHER | FLAG_DISABLED_LOCKED_USER;
-
/**
* The item points to a system app.
*/
@@ -81,6 +80,12 @@
public static final int FLAG_SYSTEM_MASK = FLAG_SYSTEM_YES | FLAG_SYSTEM_NO;
/**
+ * Flag indicating that the icon is an {@link android.graphics.drawable.AdaptiveIconDrawable}
+ * that can be optimized in various way.
+ */
+ public static final int FLAG_ADAPTIVE_ICON = 1 << 8;
+
+ /**
* Status associated with the system state of the underlying item. This is calculated every
* time a new info is created and not persisted on the disk.
*/
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 553a136..baed44d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -339,7 +339,7 @@
mDragController = new DragController(this);
mAllAppsController = new AllAppsTransitionController(this);
- mStateManager = new LauncherStateManager(this, mAllAppsController);
+ mStateManager = new LauncherStateManager(this);
mAppWidgetManager = AppWidgetManagerCompat.getInstance(this);
@@ -1287,6 +1287,10 @@
}
}
+ public AllAppsTransitionController getAllAppsController() {
+ return mAllAppsController;
+ }
+
public DragLayer getDragLayer() {
return mDragLayer;
}
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index dfe51af..9869fdf 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -164,4 +164,17 @@
view.setScaleY(scale);
}
};
+
+ public static final Property<View, Float> ELEVATION =
+ new Property<View, Float>(Float.class, "elevation") {
+ @Override
+ public Float get(View view) {
+ return view.getElevation();
+ }
+
+ @Override
+ public void set(View view, Float elevation) {
+ view.setElevation(elevation);
+ }
+ };
}
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index bb09a9f..d6cd8a3 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -36,9 +36,8 @@
protected static final int FLAG_SHOW_SCRIM = 1 << 0;
protected static final int FLAG_MULTI_PAGE = 1 << 1;
- protected static final int FLAG_HIDE_HOTSEAT = 1 << 2;
- protected static final int FLAG_DISABLE_ACCESSIBILITY = 1 << 3;
- protected static final int FLAG_DO_NOT_RESTORE = 1 << 4;
+ protected static final int FLAG_DISABLE_ACCESSIBILITY = 1 << 2;
+ protected static final int FLAG_DO_NOT_RESTORE = 1 << 3;
private static final LauncherState[] sAllStates = new LauncherState[4];
@@ -80,7 +79,6 @@
* @see WorkspaceStateTransitionAnimation
*/
public final boolean hasScrim;
- public final boolean hideHotseat;
public final int transitionDuration;
/**
@@ -97,7 +95,6 @@
this.hasScrim = (flags & FLAG_SHOW_SCRIM) != 0;
this.hasMultipleVisiblePages = (flags & FLAG_MULTI_PAGE) != 0;
- this.hideHotseat = (flags & FLAG_HIDE_HOTSEAT) != 0;
this.workspaceAccessibilityFlag = (flags & FLAG_DISABLE_ACCESSIBILITY) != 0
? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
: IMPORTANT_FOR_ACCESSIBILITY_AUTO;
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index b99df71..f016e8d 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -29,6 +29,7 @@
import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
+import com.android.launcher3.uioverrides.UiFactory;
/**
* TODO: figure out what kind of tests we can write for this
@@ -78,21 +79,26 @@
private final AnimationConfig mConfig = new AnimationConfig();
private final Handler mUiHandler;
private final Launcher mLauncher;
- private final AllAppsTransitionController mAllAppsController;
+ private StateHandler[] mStateHandlers;
private LauncherState mState = NORMAL;
- public LauncherStateManager(
- Launcher l, AllAppsTransitionController allAppsController) {
+ public LauncherStateManager(Launcher l) {
mUiHandler = new Handler(Looper.getMainLooper());
mLauncher = l;
- mAllAppsController = allAppsController;
}
public LauncherState getState() {
return mState;
}
+ private StateHandler[] getStateHandlers() {
+ if (mStateHandlers == null) {
+ mStateHandlers = UiFactory.getStateHandler(mLauncher);
+ }
+ return mStateHandlers;
+ }
+
/**
* @see #goToState(LauncherState, boolean, Runnable)
*/
@@ -148,8 +154,9 @@
if (!animated) {
setState(state);
- mAllAppsController.setFinalProgress(state.verticalProgress);
- mLauncher.getWorkspace().setState(state);
+ for (StateHandler handler : getStateHandlers()) {
+ handler.setState(state);
+ }
mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
// Run any queued runnable
@@ -190,14 +197,12 @@
protected AnimatorSet createAnimationToNewWorkspaceInternal(final LauncherState state,
final Runnable onCompleteRunnable) {
-
final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
final AnimationLayerSet layerViews = new AnimationLayerSet();
- mAllAppsController.animateToFinalProgress(state.verticalProgress, animation, mConfig);
- mLauncher.getWorkspace().setStateWithAnimation(state,
- layerViews, animation, mConfig);
-
+ for (StateHandler handler : getStateHandlers()) {
+ handler.setStateWithAnimation(state, layerViews, animation, mConfig);
+ }
animation.addListener(layerViews);
animation.addListener(new AnimationSuccessListener() {
@@ -285,4 +290,18 @@
mCurrentAnimation.addListener(this);
}
}
+
+ public interface StateHandler {
+
+ /**
+ * Updates the UI to {@param state} without any animations
+ */
+ void setState(LauncherState state);
+
+ /**
+ * Sets the UI to {@param state} by animating any changes.
+ */
+ void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
+ AnimatorSet anim, AnimationConfig config);
+ }
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 1f87c00..93fe17c 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -105,7 +105,7 @@
public class Workspace extends PagedView
implements DropTarget, DragSource, View.OnTouchListener,
DragController.DragListener, ViewGroup.OnHierarchyChangeListener,
- Insettable {
+ Insettable, LauncherStateManager.StateHandler {
private static final String TAG = "Launcher.Workspace";
/** The value that {@link #mTransitionProgress} must be greater than for
@@ -1557,6 +1557,7 @@
/**
* Sets the current workspace {@link LauncherState} and updates the UI without any animations
*/
+ @Override
public void setState(LauncherState toState) {
onStartStateTransition(toState);
mStateTransitionAnimation.setState(toState);
@@ -1566,6 +1567,7 @@
/**
* Sets the current workspace {@link LauncherState}, then animates the UI
*/
+ @Override
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
AnimatorSet anim, AnimationConfig config) {
StateTransitionListener listener = new StateTransitionListener(toState);
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index e14461e..8edec40 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -90,7 +90,7 @@
*/
public class WorkspaceStateTransitionAnimation {
- private static final PropertySetter NO_ANIM_PROPERTY_SETTER = new PropertySetter();
+ public static final PropertySetter NO_ANIM_PROPERTY_SETTER = new PropertySetter();
public final int mWorkspaceScrimAlpha;
@@ -141,14 +141,6 @@
propertySetter);
}
- float finalHotseatAlpha = state.hideHotseat ? 0f : 1f;
-
- // This is true when transitioning between:
- // - Overview <-> Workspace
- propertySetter.setViewAlpha(null, mLauncher.getOverviewPanel(), 1 - finalHotseatAlpha);
- propertySetter.setViewAlpha(mWorkspace.createHotseatAlphaAnimator(finalHotseatAlpha),
- mLauncher.getHotseat(), finalHotseatAlpha);
-
propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, Interpolators.ZOOM_IN);
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
finalWorkspaceTranslationY, Interpolators.ZOOM_IN);
@@ -176,7 +168,7 @@
}
}
- private static class PropertySetter {
+ public static class PropertySetter {
public void setViewAlpha(Animator anim, View view, float alpha) {
if (anim != null) {
@@ -204,13 +196,14 @@
}
}
- private static class AnimatedPropertySetter extends PropertySetter {
+ public static class AnimatedPropertySetter extends PropertySetter {
private final long mDuration;
private final AnimationLayerSet mLayerViews;
private final AnimatorSet mStateAnimator;
- AnimatedPropertySetter(long duration, AnimationLayerSet layerView, AnimatorSet anim) {
+ public AnimatedPropertySetter(
+ long duration, AnimationLayerSet layerView, AnimatorSet anim) {
mDuration = duration;
mLayerViews = layerView;
mStateAnimator = anim;
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index a1f37ba..81f5842 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -157,14 +157,7 @@
@Override
public void setPressedIcon(BubbleTextView icon, Bitmap background) {
- if (icon == null || background == null) {
- mTouchFeedbackView.setBitmap(null);
- mTouchFeedbackView.animate().cancel();
- } else if (mTouchFeedbackView.setBitmap(background)) {
- View rv = findViewById(R.id.apps_list_view);
- mTouchFeedbackView.alignWithIconView(icon, (ViewGroup) icon.getParent(), rv);
- mTouchFeedbackView.animateShadow();
- }
+ mTouchFeedbackView.setPressedIcon(icon, background);
}
/**
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 9b64043..eb26704 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -15,10 +15,12 @@
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
+import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.graphics.GradientView;
@@ -35,7 +37,8 @@
* If release velocity < THRES1, snap according to either top or bottom depending on whether it's
* closer to top or closer to the page indicator.
*/
-public class AllAppsTransitionController implements SearchUiManager.OnScrollRangeChangeListener {
+public class AllAppsTransitionController
+ implements SearchUiManager.OnScrollRangeChangeListener, LauncherStateManager.StateHandler {
private static final Property<AllAppsTransitionController, Float> PROGRESS =
new Property<AllAppsTransitionController, Float>(Float.class, "progress") {
@@ -122,8 +125,8 @@
*
* @param progress value between 0 and 1, 0 shows all apps and 1 shows workspace
*
- * @see #setFinalProgress(float)
- * @see #animateToFinalProgress(float, AnimatorSet, AnimationConfig)
+ * @see #setState(LauncherState)
+ * @see #setStateWithAnimation(LauncherState, AnimationLayerSet, AnimatorSet, AnimationConfig)
*/
public void setProgress(float progress) {
mProgress = progress;
@@ -161,33 +164,32 @@
}
/**
- * Sets the vertical transition progress to {@param progress} and updates all the dependent UI
+ * Sets the vertical transition progress to {@param state} and updates all the dependent UI
* accordingly.
*/
- public void setFinalProgress(float progress) {
- setProgress(progress);
+ @Override
+ public void setState(LauncherState state) {
+ setProgress(state.verticalProgress);
onProgressAnimationEnd();
}
/**
* Creates an animation which updates the vertical transition progress and updates all the
* dependent UI using various animation events
- *
- * @param progress the final vertical progress at the end of the animation
- * @param animationOut the target AnimatorSet where this animation should be added
- * @param outConfig an in/out configuration which can be shared with other animations
*/
- public void animateToFinalProgress(
- float progress, AnimatorSet animationOut, AnimationConfig outConfig) {
- if (Float.compare(mProgress, progress) == 0) {
+ @Override
+ public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
+ AnimatorSet animationOut, AnimationConfig config) {
+ if (Float.compare(mProgress, toState.verticalProgress) == 0) {
// Fail fast
onProgressAnimationEnd();
return;
}
- Interpolator interpolator = outConfig.userControlled ? LINEAR : FAST_OUT_SLOW_IN;
- ObjectAnimator anim = ObjectAnimator.ofFloat(this, PROGRESS, mProgress, progress);
- anim.setDuration(outConfig.duration);
+ Interpolator interpolator = config.userControlled ? LINEAR : FAST_OUT_SLOW_IN;
+ ObjectAnimator anim = ObjectAnimator.ofFloat(
+ this, PROGRESS, mProgress, toState.verticalProgress);
+ anim.setDuration(config.duration);
anim.setInterpolator(interpolator);
anim.addListener(new AnimationSuccessListener() {
@Override
diff --git a/src/com/android/launcher3/graphics/HolographicOutlineHelper.java b/src/com/android/launcher3/graphics/HolographicOutlineHelper.java
index 9e67f56..fdf2d67 100644
--- a/src/com/android/launcher3/graphics/HolographicOutlineHelper.java
+++ b/src/com/android/launcher3/graphics/HolographicOutlineHelper.java
@@ -16,6 +16,8 @@
package com.android.launcher3.graphics;
+import static com.android.launcher3.ItemInfoWithIcon.FLAG_ADAPTIVE_ICON;
+
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BlurMaskFilter;
@@ -29,6 +31,7 @@
import android.util.SparseArray;
import com.android.launcher3.BubbleTextView;
+import com.android.launcher3.ItemInfoWithIcon;
import com.android.launcher3.R;
/**
@@ -37,6 +40,12 @@
*/
public class HolographicOutlineHelper {
+ /**
+ * Bitmap used as shadow for Adaptive icons
+ */
+ public static final Bitmap ADAPTIVE_ICON_SHADOW_BITMAP =
+ Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8);
+
private static HolographicOutlineHelper sInstance;
private final Canvas mCanvas = new Canvas();
@@ -63,6 +72,11 @@
}
public Bitmap createMediumDropShadow(BubbleTextView view) {
+ if (view.getTag() instanceof ItemInfoWithIcon &&
+ ((((ItemInfoWithIcon) view.getTag()).runtimeStatusFlags & FLAG_ADAPTIVE_ICON)
+ != 0)) {
+ return ADAPTIVE_ICON_SHADOW_BITMAP;
+ }
Drawable drawable = view.getIcon();
if (drawable == null) {
return null;
@@ -119,7 +133,7 @@
}
public void recycleShadowBitmap(Bitmap bitmap) {
- if (bitmap != null) {
+ if (bitmap != null && bitmap != ADAPTIVE_ICON_SHADOW_BITMAP) {
mBitmapCache.put((bitmap.getWidth() << 16) | bitmap.getHeight(), bitmap);
}
}
diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java
index 47f370a..ccef9b7 100644
--- a/src/com/android/launcher3/model/LoaderCursor.java
+++ b/src/com/android/launcher3/model/LoaderCursor.java
@@ -16,15 +16,11 @@
package com.android.launcher3.model;
-import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_NO;
-import static com.android.launcher3.ItemInfoWithIcon.FLAG_SYSTEM_YES;
-
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
-import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.database.Cursor;
import android.database.CursorWrapper;
@@ -36,6 +32,7 @@
import android.util.Log;
import android.util.LongSparseArray;
+import com.android.launcher3.AppInfo;
import com.android.launcher3.IconCache;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ItemInfo;
@@ -52,7 +49,6 @@
import com.android.launcher3.util.ContentWriter;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.LongArrayMap;
-import com.android.launcher3.util.PackageManagerHelper;
import java.net.URISyntaxException;
import java.security.InvalidParameterException;
@@ -206,7 +202,6 @@
return TextUtils.isEmpty(title) ? "" : Utilities.trim(title);
}
-
/**
* Make an ShortcutInfo object for a restored application or shortcut item that points
* to a package that is not yet installed on the system.
@@ -279,12 +274,7 @@
}
if (lai != null) {
- ApplicationInfo appInfo = lai.getApplicationInfo();
- if (PackageManagerHelper.isAppSuspended(appInfo)) {
- info.runtimeStatusFlags |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
- }
- info.runtimeStatusFlags |= (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0
- ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES;
+ AppInfo.updateRuntimeFlagsForActivityTarget(info, lai);
}
// from the db
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index c2cfebb..310416f 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -25,6 +25,7 @@
import android.content.pm.LauncherActivityInfo;
import android.content.pm.PackageInstaller;
import android.graphics.Bitmap;
+import android.graphics.drawable.AdaptiveIconDrawable;
import android.os.Handler;
import android.os.Process;
import android.os.UserHandle;
@@ -35,6 +36,7 @@
import com.android.launcher3.AllAppsList;
import com.android.launcher3.AppInfo;
+import com.android.launcher3.ClickShadowView;
import com.android.launcher3.FolderInfo;
import com.android.launcher3.IconCache;
import com.android.launcher3.InstallShortcutReceiver;
@@ -52,6 +54,7 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIconPreviewVerifier;
+import com.android.launcher3.graphics.IconNormalizer;
import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.provider.ImportDataTask;
@@ -145,7 +148,9 @@
TraceHelper.beginSection(TAG);
try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
- TraceHelper.partitionSection(TAG, "step 1.1: loading workspace");
+ TraceHelper.partitionSection(TAG, "step 1.1: loading UI resources");
+ loadUiResources();
+ TraceHelper.partitionSection(TAG, "step 1.2: loading workspace");
loadWorkspace();
verifyNotStopped();
@@ -208,6 +213,14 @@
this.notify();
}
+ public void loadUiResources() {
+ if (Utilities.ATLEAST_OREO) {
+ ClickShadowView.setAdaptiveIconScaleFactor(
+ IconNormalizer.getInstance(mApp.getContext()).getScale(
+ new AdaptiveIconDrawable(null, null), null, null, null));
+ }
+ }
+
private void loadWorkspace() {
final Context context = mApp.getContext();
final ContentResolver contentResolver = context.getContentResolver();
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
index 1fb56e7..3ce1014 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
@@ -15,12 +15,14 @@
*/
package com.android.launcher3.uioverrides;
+import static com.android.launcher3.WorkspaceStateTransitionAnimation.NO_ANIM_PROPERTY_SETTER;
+
+import android.animation.AnimatorSet;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Rect;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
@@ -28,14 +30,20 @@
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.LauncherStateManager;
+import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.WorkspaceStateTransitionAnimation.AnimatedPropertySetter;
+import com.android.launcher3.WorkspaceStateTransitionAnimation.PropertySetter;
+import com.android.launcher3.anim.AnimationLayerSet;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.widget.WidgetsFullSheet;
public class OverviewPanel extends LinearLayout implements Insettable, View.OnClickListener,
- View.OnLongClickListener {
+ View.OnLongClickListener, LauncherStateManager.StateHandler {
// Out of 100, the percent of space the overview bar should try and take vertically.
private static final float OVERVIEW_ICON_ZONE_RATIO = 0.22f;
@@ -154,10 +162,30 @@
getContext().startActivity(intent, mLauncher.getActivityLaunchOptions(v));
}
+ @Override
+ public void setState(LauncherState state) {
+ setState(state, NO_ANIM_PROPERTY_SETTER);
+ }
+
+ @Override
+ public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
+ AnimatorSet anim, AnimationConfig config) {
+ setState(toState, new AnimatedPropertySetter(config.duration, layerViews, anim));
+ }
+
+ private void setState(LauncherState state, PropertySetter setter) {
+ boolean isOverview = state == LauncherState.OVERVIEW;
+ float finalHotseatAlpha = isOverview ? 0 : 1;
+
+ setter.setViewAlpha(null, this, isOverview ? 1 : 0);
+ setter.setViewAlpha(
+ mLauncher.getWorkspace().createHotseatAlphaAnimator(finalHotseatAlpha),
+ mLauncher.getHotseat(), finalHotseatAlpha);
+ }
public static int getButtonBarHeight(Launcher launcher) {
int zoneHeight = (int) (OVERVIEW_ICON_ZONE_RATIO *
- launcher.getDeviceProfile().availableWidthPx);
+ launcher.getDeviceProfile().availableHeightPx);
Resources res = launcher.getResources();
int overviewModeMinIconZoneHeightPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_min_icon_zone_height);
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java
index 9e2ad98..c339634 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java
@@ -36,7 +36,7 @@
// The percent to shrink the workspace during overview mode
public static final float SCALE_FACTOR = 0.7f;
- private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT;
+ private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE;
public OverviewState(int id) {
super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
index 6776150..8521334 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -19,6 +19,7 @@
import android.view.View.AccessibilityDelegate;
import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.VerticalSwipeController;
import com.android.launcher3.util.TouchController;
@@ -32,4 +33,10 @@
public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {
return new OverviewAccessibilityDelegate();
}
+
+ public static StateHandler[] getStateHandler(Launcher launcher) {
+ return new StateHandler[] {
+ (OverviewPanel) launcher.getOverviewPanel(),
+ launcher.getAllAppsController(), launcher.getWorkspace() };
+ }
}