diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java index 676114860c..ce6bb7d79e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIcon.java @@ -47,6 +47,7 @@ import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.touch.ItemClickHandler; import com.android.launcher3.touch.ItemLongClickListener; import com.android.launcher3.util.SafeCloseable; +import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.DoubleShadowBubbleTextView; /** @@ -68,7 +69,6 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements private int mPlateColor; boolean mDrawForDrag = false; - public PredictedAppIcon(Context context) { this(context, null, 0); } @@ -79,10 +79,8 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements public PredictedAppIcon(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - mDeviceProfile = Launcher.getLauncher(context).getDeviceProfile(); + mDeviceProfile = ActivityContext.lookupContext(context).getDeviceProfile(); mNormalizedIconRadius = IconNormalizer.getNormalizedCircleSize(getIconSize()) / 2; - setOnClickListener(ItemClickHandler.INSTANCE); - setOnFocusChangeListener(Launcher.getLauncher(context).getFocusHandler()); int shadowSize = context.getResources().getDimensionPixelSize( R.dimen.blur_size_thin_outline); mShadowFilter = new BlurMaskFilter(shadowSize, BlurMaskFilter.Blur.OUTER); @@ -241,6 +239,8 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements PredictedAppIcon icon = (PredictedAppIcon) LayoutInflater.from(parent.getContext()) .inflate(R.layout.predicted_app_icon, parent, false); icon.applyFromWorkspaceItem(info); + icon.setOnClickListener(ItemClickHandler.INSTANCE); + icon.setOnFocusChangeListener(Launcher.getLauncher(parent.getContext()).getFocusHandler()); return icon; } diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIconInflater.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIconInflater.java new file mode 100644 index 0000000000..8f1d3197cd --- /dev/null +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PredictedAppIconInflater.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 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.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.android.launcher3.R; +import com.android.launcher3.model.data.WorkspaceItemInfo; + +/** A util class that inflates a predicted app icon */ +public class PredictedAppIconInflater { + public static View inflate(LayoutInflater inflater, ViewGroup parent, WorkspaceItemInfo info) { + PredictedAppIcon icon = (PredictedAppIcon) inflater.inflate( + R.layout.predicted_app_icon, parent, false); + icon.applyFromWorkspaceItem(info); + return icon; + } +} diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index c1b68aba6b..da304e5eb5 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -19,6 +19,7 @@ import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherState.HOTSEAT_ICONS; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; +import static com.android.launcher3.LauncherState.OVERVIEW_BUTTONS; import static com.android.launcher3.LauncherState.QUICK_SWITCH; import static com.android.launcher3.anim.AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD; import static com.android.launcher3.anim.Interpolators.ACCEL_0_75; @@ -242,6 +243,8 @@ public class NoButtonQuickSwitchTouchController implements TouchController, ADJACENT_PAGE_OFFSET.set(mRecentsView, 1f); mRecentsView.setContentAlpha(1); mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress()); + mLauncher.getActionsView().getVisibilityAlpha().setValue( + (fromState.getVisibleElements(mLauncher) & OVERVIEW_BUTTONS) != 0 ? 1f : 0f); float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher); // As we drag right, animate the following properties: diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java index 3e0daaf2ea..ebc9f96394 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java @@ -32,6 +32,7 @@ import android.animation.ValueAnimator; import android.view.View; import android.view.ViewGroup; +import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; @@ -42,6 +43,7 @@ import com.android.launcher3.Workspace; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.SpringAnimationBuilder; import com.android.launcher3.graphics.OverviewScrim; +import com.android.launcher3.statehandlers.DepthController; import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.util.DynamicResource; import com.android.quickstep.views.RecentsView; @@ -128,6 +130,8 @@ public class StaggeredWorkspaceAnim { addScrimAnimationForState(launcher, NORMAL, ALPHA_DURATION_MS); } + addDepthAnimationForState(launcher, NORMAL, ALPHA_DURATION_MS); + mAnimators.play(launcher.getDragLayer().getScrim().createSysuiMultiplierAnim(0f, 1f) .setDuration(ALPHA_DURATION_MS)); mAnimators.addListener(new AnimatorListenerAdapter() { @@ -221,4 +225,14 @@ public class StaggeredWorkspaceAnim { ACCEL_DEACCEL); mAnimators.play(builder.buildAnim()); } + + private void addDepthAnimationForState(Launcher launcher, LauncherState state, long duration) { + if (!(launcher instanceof BaseQuickstepLauncher)) { + return; + } + PendingAnimation builder = new PendingAnimation(duration); + DepthController depthController = ((BaseQuickstepLauncher) launcher).getDepthController(); + depthController.setStateWithAnimation(state, new StateAnimationConfig(), builder); + mAnimators.play(builder.buildAnim()); + } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/OverviewActionsView.java index e41e14e373..ea33d007f4 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/OverviewActionsView.java @@ -53,8 +53,7 @@ public class OverviewActionsView extends FrameLayo HIDDEN_NON_ZERO_ROTATION, HIDDEN_NO_TASKS, HIDDEN_GESTURE_RUNNING, - HIDDEN_NO_RECENTS, - HIDDEN_FULLESCREEN_PROGRESS}) + HIDDEN_NO_RECENTS}) @Retention(RetentionPolicy.SOURCE) public @interface ActionsHiddenFlags { } @@ -64,11 +63,11 @@ public class OverviewActionsView extends FrameLayo public static final int HIDDEN_NO_TASKS = 1 << 3; public static final int HIDDEN_GESTURE_RUNNING = 1 << 4; public static final int HIDDEN_NO_RECENTS = 1 << 5; - public static final int HIDDEN_FULLESCREEN_PROGRESS = 1 << 6; private static final int INDEX_CONTENT_ALPHA = 0; private static final int INDEX_VISIBILITY_ALPHA = 1; - private static final int INDEX_HIDDEN_FLAGS_ALPHA = 2; + private static final int INDEX_FULLSCREEN_ALPHA = 2; + private static final int INDEX_HIDDEN_FLAGS_ALPHA = 3; private final MultiValueAlpha mMultiValueAlpha; @@ -87,7 +86,7 @@ public class OverviewActionsView extends FrameLayo public OverviewActionsView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr, 0); - mMultiValueAlpha = new MultiValueAlpha(this, 3); + mMultiValueAlpha = new MultiValueAlpha(this, 4); } @Override @@ -151,6 +150,10 @@ public class OverviewActionsView extends FrameLayo return mMultiValueAlpha.getProperty(INDEX_VISIBILITY_ALPHA); } + public AlphaProperty getFullscreenAlpha() { + return mMultiValueAlpha.getProperty(INDEX_FULLSCREEN_ALPHA); + } + /** Updates vertical margins for different navigation mode. */ public void updateVerticalMarginForNavModeChange(Mode mode) { int bottomMargin = 0; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index 2097b1d934..a506b7eb0c 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -43,7 +43,6 @@ import static com.android.launcher3.userevent.nano.LauncherLogProto.ControlType. import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW; import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId; -import static com.android.quickstep.views.OverviewActionsView.HIDDEN_FULLESCREEN_PROGRESS; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_GESTURE_RUNNING; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NON_ZERO_ROTATION; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_RECENTS; @@ -805,9 +804,8 @@ public abstract class RecentsView extends PagedView impl getTaskViewAt(i).setFullscreenProgress(mFullscreenProgress); } // Fade out the actions view quickly (0.1 range) - mActionsView.getVisibilityAlpha().setValue( + mActionsView.getFullscreenAlpha().setValue( mapToRange(fullscreenProgress, 0, 0.1f, 1f, 0f, LINEAR)); - mActionsView.updateHiddenFlags(HIDDEN_FULLESCREEN_PROGRESS, fullscreenProgress == 1.0f); } private void updateTaskStackListenerState() { @@ -1206,8 +1204,8 @@ public abstract class RecentsView extends PagedView impl private void animateActionsViewIn() { mActionsView.updateHiddenFlags(HIDDEN_GESTURE_RUNNING, false); ObjectAnimator anim = ObjectAnimator.ofFloat( - mActionsView.getVisibilityAlpha(), MultiValueAlpha.VALUE, 1); - anim.setDuration(OverviewActionsView.VISIBILITY_TRANSITION_DURATION_MS); + mActionsView.getVisibilityAlpha(), MultiValueAlpha.VALUE, 0, 1); + anim.setDuration(TaskView.SCALE_ICON_DURATION); anim.start(); } diff --git a/quickstep/res/layout/overview_actions_container.xml b/quickstep/res/layout/overview_actions_container.xml index 2371d86b0e..e05688eca3 100644 --- a/quickstep/res/layout/overview_actions_container.xml +++ b/quickstep/res/layout/overview_actions_container.xml @@ -38,7 +38,7 @@ style="@style/OverviewActionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:drawableTop="@drawable/ic_screenshot" + android:drawableStart="@drawable/ic_screenshot" android:text="@string/action_screenshot" android:theme="@style/ThemeControlHighlightWorkspaceColor" /> @@ -52,7 +52,7 @@ style="@style/OverviewActionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:drawableTop="@drawable/ic_share" + android:drawableStart="@drawable/ic_share" android:text="@string/action_share" android:theme="@style/ThemeControlHighlightWorkspaceColor" android:visibility="gone" /> diff --git a/quickstep/res/values/styles.xml b/quickstep/res/values/styles.xml index d3c4f4d93b..90957e42ff 100644 --- a/quickstep/res/values/styles.xml +++ b/quickstep/res/values/styles.xml @@ -82,7 +82,7 @@ @color/overview_button @color/overview_button ?attr/workspaceTextColor - 4dp + 8dp false \ No newline at end of file diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java index 6e91d7006d..15f4e3fcec 100644 --- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java @@ -22,6 +22,7 @@ import static android.view.View.VISIBLE; import static com.android.launcher3.config.FeatureFlags.ENABLE_LAUNCHER_PREVIEW_IN_GRID_PICKER; import static com.android.launcher3.config.FeatureFlags.MULTI_DB_GRID_MIRATION_ALGO; import static com.android.launcher3.model.ModelUtils.filterCurrentWorkspaceItems; +import static com.android.launcher3.model.ModelUtils.getMissingHotseatRanks; import static com.android.launcher3.model.ModelUtils.sortWorkspaceItemsSpatially; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; @@ -80,13 +81,16 @@ import com.android.launcher3.model.LoaderResults; import com.android.launcher3.model.LoaderTask; import com.android.launcher3.model.WidgetItem; import com.android.launcher3.model.WidgetsModel; +import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.InstallSessionHelper; import com.android.launcher3.pm.UserCache; +import com.android.launcher3.uioverrides.PredictedAppIconInflater; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; +import com.android.launcher3.util.IntArray; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.BaseDragLayer; @@ -376,6 +380,13 @@ public class LauncherPreviewRenderer implements Callable { addInScreenFromBind(view, info); } + private void inflateAndAddPredictedIcon(WorkspaceItemInfo info) { + View view = PredictedAppIconInflater.inflate(mHomeElementInflater, mWorkspace, info); + if (view != null) { + addInScreenFromBind(view, info); + } + } + private void dispatchVisibilityAggregated(View view, boolean isVisible) { // Similar to View.dispatchVisibilityAggregated implementation. final boolean thisVisible = view.getVisibility() == VISIBLE; @@ -468,6 +479,21 @@ public class LauncherPreviewRenderer implements Callable { break; } } + + IntArray ranks = getMissingHotseatRanks(currentWorkspaceItems, + mIdp.numHotseatIcons); + int count = Math.min(ranks.size(), workspaceResult.mCachedPredictedItems.size()); + for (int i = 0; i < count; i++) { + AppInfo appInfo = workspaceResult.mCachedPredictedItems.get(i); + int rank = ranks.get(i); + WorkspaceItemInfo itemInfo = new WorkspaceItemInfo(appInfo); + itemInfo.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION; + itemInfo.rank = rank; + itemInfo.cellX = mHotseat.getCellXFromOrder(rank); + itemInfo.cellY = mHotseat.getCellYFromOrder(rank); + itemInfo.screenId = rank; + inflateAndAddPredictedIcon(itemInfo); + } } else { // Add hotseat icons for (int i = 0; i < mIdp.numHotseatIcons; i++) { @@ -561,7 +587,7 @@ public class LauncherPreviewRenderer implements Callable { } return new WorkspaceResult(mBgDataModel.workspaceItems, mBgDataModel.appWidgets, - mBgDataModel.widgetsModel); + mBgDataModel.cachedPredictedItems, mBgDataModel.widgetsModel); } } @@ -590,7 +616,7 @@ public class LauncherPreviewRenderer implements Callable { loadWorkspace(allShortcuts, LauncherSettings.Favorites.PREVIEW_CONTENT_URI); mBgDataModel.widgetsModel.update(mApp, null); return new WorkspaceResult(mBgDataModel.workspaceItems, mBgDataModel.appWidgets, - mBgDataModel.widgetsModel); + mBgDataModel.cachedPredictedItems, mBgDataModel.widgetsModel); } } @@ -610,12 +636,15 @@ public class LauncherPreviewRenderer implements Callable { private static class WorkspaceResult { private final ArrayList mWorkspaceItems; private final ArrayList mAppWidgets; + private final ArrayList mCachedPredictedItems; private final WidgetsModel mWidgetsModel; private WorkspaceResult(ArrayList workspaceItems, - ArrayList appWidgets, WidgetsModel widgetsModel) { + ArrayList appWidgets, + ArrayList cachedPredictedItems, WidgetsModel widgetsModel) { mWorkspaceItems = workspaceItems; mAppWidgets = appWidgets; + mCachedPredictedItems = cachedPredictedItems; mWidgetsModel = widgetsModel; } } diff --git a/src/com/android/launcher3/logging/FileLog.java b/src/com/android/launcher3/logging/FileLog.java index bfeb1dc3ef..6bc1ecb126 100644 --- a/src/com/android/launcher3/logging/FileLog.java +++ b/src/com/android/launcher3/logging/FileLog.java @@ -235,6 +235,9 @@ public final class FileLog { * Gets files used for FileLog */ public static File[] getLogFiles() { + try { + flushAll(null); + } catch (InterruptedException e) { } File[] files = new File[LOG_DAYS]; for (int i = 0; i < LOG_DAYS; i++) { files[i] = new File(sLogsDirectory, FILE_NAME_PREFIX + i); diff --git a/src/com/android/launcher3/statemanager/StateManager.java b/src/com/android/launcher3/statemanager/StateManager.java index 44f7db95d0..60b87d984b 100644 --- a/src/com/android/launcher3/statemanager/StateManager.java +++ b/src/com/android/launcher3/statemanager/StateManager.java @@ -306,8 +306,10 @@ public class StateManager> { + state); } PendingAnimation builder = new PendingAnimation(mConfig.duration); - for (StateHandler handler : getStateHandlers()) { - handler.setStateWithAnimation(state, mConfig, builder); + if (mConfig.getAnimComponents() != 0) { + for (StateHandler handler : getStateHandlers()) { + handler.setStateWithAnimation(state, mConfig, builder); + } } builder.addListener(new AnimationSuccessListener() { diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/PredictedAppIconInflater.java b/src_ui_overrides/com/android/launcher3/uioverrides/PredictedAppIconInflater.java new file mode 100644 index 0000000000..4893c1740e --- /dev/null +++ b/src_ui_overrides/com/android/launcher3/uioverrides/PredictedAppIconInflater.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 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.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.android.launcher3.model.data.WorkspaceItemInfo; + +/** A util class that inflates a predicted app icon */ +public class PredictedAppIconInflater { + public static View inflate(LayoutInflater inflater, ViewGroup parent, WorkspaceItemInfo info) { + return null; + } +} diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 45d181ad45..081d43aa57 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -28,6 +28,7 @@ import android.app.ActivityManager; import android.app.Instrumentation; import android.app.UiAutomation; import android.content.ComponentName; +import android.content.ContentProviderClient; import android.content.ContentResolver; import android.content.Context; import android.content.pm.PackageManager; @@ -39,6 +40,7 @@ import android.graphics.Rect; import android.net.Uri; import android.os.Bundle; import android.os.Parcelable; +import android.os.RemoteException; import android.os.SystemClock; import android.text.TextUtils; import android.util.Log; @@ -260,7 +262,12 @@ public final class LauncherInstrumentation { } Bundle getTestInfo(String request) { - return getContext().getContentResolver().call(mTestProviderUri, request, null, null); + try (ContentProviderClient client = getContext().getContentResolver() + .acquireContentProviderClient(mTestProviderUri)) { + return client.call(request, null, null); + } catch (RemoteException e) { + throw new RuntimeException(e); + } } Insets getTargetInsets() {