From ead22a52577f9cda982af2ff3e62e2ee2d0fdd86 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 2 Feb 2021 23:21:55 -0800 Subject: [PATCH 1/9] Removing released features Bug: 179224463 Test: Presubmit Change-Id: I6aa989fa8e52398112cca2c7f4bed0ae69881f7b --- .../hybridhotseat/HotseatEduActivity.java | 3 +- .../hybridhotseat/HotseatFileLog.java | 128 ------------------ .../HotseatPredictionController.java | 12 -- .../uioverrides/PredictedAppIcon.java | 2 +- .../uioverrides/QuickstepLauncher.java | 33 ++--- .../quickstep/util/MotionPauseDetector.java | 75 ++-------- .../util/QuickstepOnboardingPrefs.java | 3 +- .../launcher3/InvariantDeviceProfile.java | 9 +- .../launcher3/config/FeatureFlags.java | 10 -- .../android/launcher3/logging/FileLog.java | 3 +- 10 files changed, 27 insertions(+), 251 deletions(-) delete mode 100644 quickstep/src/com/android/launcher3/hybridhotseat/HotseatFileLog.java diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java index c968de96a4..3a1a2f7ae2 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduActivity.java @@ -29,7 +29,6 @@ import com.android.launcher3.util.ActivityTracker; */ public class HotseatEduActivity extends Activity { - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -49,7 +48,7 @@ public class HotseatEduActivity extends Activity { @Override public boolean init(BaseActivity activity, boolean alreadyOnHome) { QuickstepLauncher launcher = (QuickstepLauncher) activity; - if (launcher != null && launcher.getHotseatPredictionController() != null) { + if (launcher != null) { launcher.getHotseatPredictionController().showEdu(); } return false; diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatFileLog.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatFileLog.java deleted file mode 100644 index 20e1edc05f..0000000000 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatFileLog.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.hybridhotseat; - -import android.content.Context; -import android.os.Handler; -import android.util.Log; - -import com.android.launcher3.logging.FileLog; -import com.android.launcher3.util.Executors; -import com.android.launcher3.util.MainThreadInitializedObject; - -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.text.DateFormat; -import java.util.Calendar; -import java.util.Date; - -/** - * Helper class to allow hot seat file logging - */ -public class HotseatFileLog { - - public static final int LOG_DAYS = 10; - private static final String FILE_NAME_PREFIX = "hotseat-log-"; - private static final DateFormat DATE_FORMAT = - DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); - public static final MainThreadInitializedObject INSTANCE = - new MainThreadInitializedObject<>(HotseatFileLog::new); - - - private final Handler mHandler = new Handler( - Executors.createAndStartNewLooper("hotseat-logger")); - private final File mLogsDir; - private PrintWriter mCurrentWriter; - private String mFileName; - - private HotseatFileLog(Context context) { - mLogsDir = context.getFilesDir(); - } - - /** - * Prints log values to disk - */ - public void log(String tag, String msg) { - String out = String.format("%s %s %s", DATE_FORMAT.format(new Date()), tag, msg); - - mHandler.post(() -> { - synchronized (this) { - PrintWriter writer = getWriter(); - if (writer != null) { - writer.println(out); - } - } - }); - } - - private PrintWriter getWriter() { - Calendar cal = Calendar.getInstance(); - String fName = FILE_NAME_PREFIX + (cal.get(Calendar.DAY_OF_YEAR) % 10); - if (fName.equals(mFileName)) return mCurrentWriter; - - boolean append = false; - File logFile = new File(mLogsDir, fName); - if (logFile.exists()) { - Calendar modifiedTime = Calendar.getInstance(); - modifiedTime.setTimeInMillis(logFile.lastModified()); - - // If the file was modified more that 36 hours ago, purge the file. - // We use instead of 24 to account for day-365 followed by day-1 - modifiedTime.add(Calendar.HOUR, 36); - append = cal.before(modifiedTime); - } - - - if (mCurrentWriter != null) { - mCurrentWriter.close(); - } - try { - mCurrentWriter = new PrintWriter(new FileWriter(logFile, append)); - mFileName = fName; - } catch (Exception ex) { - Log.e("HotseatLogs", "Error writing logs to file", ex); - closeWriter(); - } - return mCurrentWriter; - } - - - private synchronized void closeWriter() { - mFileName = null; - if (mCurrentWriter != null) { - mCurrentWriter.close(); - } - mCurrentWriter = null; - } - - - /** - * Returns a list of all log files - */ - public synchronized File[] getLogFiles() { - File[] files = new File[LOG_DAYS + FileLog.LOG_DAYS]; - //include file log files here - System.arraycopy(FileLog.getLogFiles(), 0, files, 0, FileLog.LOG_DAYS); - - closeWriter(); - for (int i = 0; i < LOG_DAYS; i++) { - files[FileLog.LOG_DAYS + i] = new File(mLogsDir, FILE_NAME_PREFIX + i); - } - return files; - } -} diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index 88cfacb3a6..5e81fbaf08 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -26,7 +26,6 @@ import android.animation.Animator; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.content.ComponentName; -import android.os.Process; import android.view.HapticFeedbackConstants; import android.view.View; import android.view.ViewGroup; @@ -40,7 +39,6 @@ import com.android.launcher3.Hotseat; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragController; @@ -446,16 +444,6 @@ public class HotseatPredictionController implements DragController.DragListener, * Logs rank info based on current list of predicted items */ public void logLaunchedAppRankingInfo(@NonNull ItemInfo itemInfo, InstanceId instanceId) { - if (Utilities.IS_DEBUG_DEVICE) { - final String pkg = itemInfo.getTargetComponent() != null - ? itemInfo.getTargetComponent().getPackageName() : "unknown"; - HotseatFileLog.INSTANCE.get(mLauncher).log("UserEvent", - "appLaunch: packageName:" + pkg + ",isWorkApp:" + (itemInfo.user != null - && !Process.myUserHandle().equals(itemInfo.user)) - + ",launchLocation:" + itemInfo.container); - } - - ComponentName targetCN = itemInfo.getTargetComponent(); if (targetCN == null) { return; diff --git a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java index 22c4a7eba3..2d501257c3 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java +++ b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java @@ -160,7 +160,7 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView implements public boolean performAccessibilityAction(int action, ItemInfo info) { QuickstepLauncher launcher = Launcher.cast(Launcher.getLauncher(getContext())); if (action == PIN_PREDICTION) { - if (launcher == null || launcher.getHotseatPredictionController() == null) { + if (launcher == null) { return false; } HotseatPredictionController controller = launcher.getHotseatPredictionController(); diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 9a1e707baa..6098b520be 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -49,7 +49,6 @@ import com.android.launcher3.allapps.AllAppsContainerView; import com.android.launcher3.allapps.search.SearchAdapterProvider; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.appprediction.PredictionRowView; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.hybridhotseat.HotseatPredictionController; import com.android.launcher3.logging.InstanceId; import com.android.launcher3.logging.StatsLogManager.StatsLogger; @@ -104,9 +103,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { @Override protected void setupViews() { super.setupViews(); - if (FeatureFlags.ENABLE_HYBRID_HOTSEAT.get()) { - mHotseatPredictionController = new HotseatPredictionController(this); - } + mHotseatPredictionController = new HotseatPredictionController(this); } @Override @@ -141,9 +138,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { } logger.log(LAUNCHER_APP_LAUNCH_TAP); - if (mHotseatPredictionController != null) { - mHotseatPredictionController.logLaunchedAppRankingInfo(info, instanceId); - } + mHotseatPredictionController.logLaunchedAppRankingInfo(info, instanceId); } /** @@ -166,10 +161,8 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { @Override public boolean startActivitySafely(View v, Intent intent, ItemInfo item) { - if (mHotseatPredictionController != null) { - // Only pause is taskbar controller is not present - mHotseatPredictionController.setPauseUIUpdate(getTaskbarController() == null); - } + // Only pause is taskbar controller is not present + mHotseatPredictionController.setPauseUIUpdate(getTaskbarController() == null); return super.startActivitySafely(v, intent, item); } @@ -181,7 +174,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { onStateOrResumeChanging((getActivityFlags() & ACTIVITY_STATE_TRANSITION_ACTIVE) == 0); } - if (mHotseatPredictionController != null && ((changeBits & ACTIVITY_STATE_STARTED) != 0 + if (((changeBits & ACTIVITY_STATE_STARTED) != 0 || (changeBits & getActivityFlags() & ACTIVITY_STATE_DEFERRED_RESUMED) != 0)) { mHotseatPredictionController.setPauseUIUpdate(false); } @@ -195,12 +188,8 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { @Override public Stream getSupportedShortcuts() { - if (mHotseatPredictionController != null) { - return Stream.concat(super.getSupportedShortcuts(), - Stream.of(mHotseatPredictionController)); - } else { - return super.getSupportedShortcuts(); - } + return Stream.concat( + super.getSupportedShortcuts(), Stream.of(mHotseatPredictionController)); } /** @@ -227,8 +216,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { mAllAppsPredictions = item; getAppsView().getFloatingHeaderView().findFixedRowByType(PredictionRowView.class) .setPredictedApps(item.items); - } else if (item.containerId == Favorites.CONTAINER_HOTSEAT_PREDICTION - && mHotseatPredictionController != null) { + } else if (item.containerId == Favorites.CONTAINER_HOTSEAT_PREDICTION) { mHotseatPredictionController.setPredictedItems(item); } } @@ -246,10 +234,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { public void onDestroy() { super.onDestroy(); getAppsView().getSearchUiManager().destroy(); - if (mHotseatPredictionController != null) { - mHotseatPredictionController.destroy(); - mHotseatPredictionController = null; - } + mHotseatPredictionController.destroy(); } @Override diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java index 8cde5f2659..8151d412ab 100644 --- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java +++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java @@ -15,8 +15,6 @@ */ package com.android.quickstep.util; -import static com.android.launcher3.config.FeatureFlags.ENABLE_SYSTEM_VELOCITY_PROVIDER; - import android.content.Context; import android.content.res.Resources; import android.view.MotionEvent; @@ -51,7 +49,7 @@ public class MotionPauseDetector { private final Alarm mForcePauseTimeout; private final boolean mMakePauseHarderToTrigger; private final Context mContext; - private final VelocityProvider mVelocityProvider; + private final SystemVelocityProvider mVelocityProvider; private Float mPreviousVelocity = null; @@ -88,8 +86,7 @@ public class MotionPauseDetector { mForcePauseTimeout = new Alarm(); mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */)); mMakePauseHarderToTrigger = makePauseHarderToTrigger; - mVelocityProvider = ENABLE_SYSTEM_VELOCITY_PROVIDER.get() - ? new SystemVelocityProvider(axis) : new LinearVelocityProvider(axis); + mVelocityProvider = new SystemVelocityProvider(axis); } /** @@ -124,8 +121,8 @@ public class MotionPauseDetector { mForcePauseTimeout.setAlarm(mMakePauseHarderToTrigger ? HARDER_TRIGGER_TIMEOUT : FORCE_PAUSE_TIMEOUT); - Float newVelocity = mVelocityProvider.addMotionEvent(ev, pointerIndex); - if (newVelocity != null && mPreviousVelocity != null) { + float newVelocity = mVelocityProvider.addMotionEvent(ev, pointerIndex); + if (mPreviousVelocity != null) { checkMotionPaused(newVelocity, mPreviousVelocity, ev.getEventTime()); } mPreviousVelocity = newVelocity; @@ -210,58 +207,7 @@ public class MotionPauseDetector { default void onMotionPauseChanged(boolean isPaused) { } } - /** - * Interface to abstract out velocity calculations - */ - protected interface VelocityProvider { - - /** - * Adds a new motion events, and returns the velocity at this point, or null if - * the velocity is not available - */ - Float addMotionEvent(MotionEvent ev, int pointer); - - /** - * Clears all stored motion event records - */ - void clear(); - } - - private static class LinearVelocityProvider implements VelocityProvider { - - private Long mPreviousTime = null; - private Float mPreviousPosition = null; - - private final int mAxis; - - LinearVelocityProvider(int axis) { - mAxis = axis; - } - - @Override - public Float addMotionEvent(MotionEvent ev, int pointer) { - long time = ev.getEventTime(); - float position = ev.getAxisValue(mAxis, pointer); - Float velocity = null; - - if (mPreviousTime != null && mPreviousPosition != null) { - long changeInTime = Math.max(1, time - mPreviousTime); - float changeInPosition = position - mPreviousPosition; - velocity = changeInPosition / changeInTime; - } - mPreviousTime = time; - mPreviousPosition = position; - return velocity; - } - - @Override - public void clear() { - mPreviousTime = null; - mPreviousPosition = null; - } - } - - private static class SystemVelocityProvider implements VelocityProvider { + private static class SystemVelocityProvider { private final VelocityTracker mVelocityTracker; private final int mAxis; @@ -271,8 +217,11 @@ public class MotionPauseDetector { mAxis = axis; } - @Override - public Float addMotionEvent(MotionEvent ev, int pointer) { + /** + * Adds a new motion events, and returns the velocity at this point, or null if + * the velocity is not available + */ + public float addMotionEvent(MotionEvent ev, int pointer) { mVelocityTracker.addMovement(ev); mVelocityTracker.computeCurrentVelocity(1); // px / ms return mAxis == MotionEvent.AXIS_X @@ -280,7 +229,9 @@ public class MotionPauseDetector { : mVelocityTracker.getYVelocity(pointer); } - @Override + /** + * Clears all stored motion event records + */ public void clear() { mVelocityTracker.clear(); } diff --git a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java index cb81d36b4e..b316423911 100644 --- a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java +++ b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java @@ -66,8 +66,7 @@ public class QuickstepOnboardingPrefs extends OnboardingPrefs }); } - if (FeatureFlags.ENABLE_HYBRID_HOTSEAT.get() && !hasReachedMaxCount( - HOTSEAT_DISCOVERY_TIP_COUNT)) { + if (!hasReachedMaxCount(HOTSEAT_DISCOVERY_TIP_COUNT)) { stateManager.addStateListener(new StateListener() { boolean mFromAllApps = false; diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 5fd9e01b2e..aa3ef9b139 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -18,7 +18,6 @@ package com.android.launcher3; import static com.android.launcher3.Utilities.getDevicePrefs; import static com.android.launcher3.Utilities.getPointString; -import static com.android.launcher3.config.FeatureFlags.APPLY_CONFIG_AT_RUNTIME; import static com.android.launcher3.config.FeatureFlags.ENABLE_FOUR_COLUMNS; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter; @@ -174,8 +173,7 @@ public class InvariantDeviceProfile { .putString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, getPointString(numColumns, numRows)) .apply(); - mConfigMonitor = new ConfigMonitor(context, - APPLY_CONFIG_AT_RUNTIME.get() ? this::onConfigChanged : this::killProcess); + mConfigMonitor = new ConfigMonitor(context, this::onConfigChanged); mOverlayMonitor = new OverlayMonitor(context); } @@ -317,11 +315,6 @@ public class InvariantDeviceProfile { mChangeListeners.remove(listener); } - private void killProcess(Context context) { - Log.e("ConfigMonitor", "restarting launcher"); - android.os.Process.killProcess(android.os.Process.myPid()); - } - public void verifyConfigChangedInBackground(final Context context) { String savedIconMaskPath = getDevicePrefs(context).getString(KEY_ICON_PATH_REF, ""); // Good place to check if grid size changed in themepicker when launcher was dead. diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index b61799f79c..625aafb68a 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -72,9 +72,6 @@ public final class FeatureFlags { "PROMISE_APPS_NEW_INSTALLS", true, "Adds a promise icon to the home screen for new install sessions."); - public static final BooleanFlag APPLY_CONFIG_AT_RUNTIME = getDebugFlag( - "APPLY_CONFIG_AT_RUNTIME", true, "Apply display changes dynamically"); - public static final BooleanFlag QUICKSTEP_SPRINGS = getDebugFlag( "QUICKSTEP_SPRINGS", true, "Enable springs for quickstep animations"); @@ -133,9 +130,6 @@ public final class FeatureFlags { "ASSISTANT_GIVES_LAUNCHER_FOCUS", false, "Allow Launcher to handle nav bar gestures while Assistant is running over it"); - public static final BooleanFlag ENABLE_HYBRID_HOTSEAT = getDebugFlag( - "ENABLE_HYBRID_HOTSEAT", true, "Fill gaps in hotseat with predicted apps"); - public static final BooleanFlag HOTSEAT_MIGRATE_TO_FOLDER = getDebugFlag( "HOTSEAT_MIGRATE_TO_FOLDER", false, "Should move hotseat items into a folder"); @@ -175,10 +169,6 @@ public final class FeatureFlags { "Replace Smartspace with the enhanced version. " + "Ignored if ENABLE_SMARTSPACE_UNIVERSAL is enabled."); - public static final BooleanFlag ENABLE_SYSTEM_VELOCITY_PROVIDER = getDebugFlag( - "ENABLE_SYSTEM_VELOCITY_PROVIDER", true, - "Use system VelocityTracker's algorithm for motion pause detection."); - public static final BooleanFlag ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS = getDebugFlag( "ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS", false, diff --git a/src/com/android/launcher3/logging/FileLog.java b/src/com/android/launcher3/logging/FileLog.java index 6bc1ecb126..cdd0bda49e 100644 --- a/src/com/android/launcher3/logging/FileLog.java +++ b/src/com/android/launcher3/logging/FileLog.java @@ -10,7 +10,6 @@ import android.util.Pair; import androidx.annotation.VisibleForTesting; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.IOUtils; import java.io.BufferedReader; @@ -43,7 +42,7 @@ public final class FileLog { private static Handler sHandler = null; private static File sLogsDirectory = null; - public static final int LOG_DAYS = FeatureFlags.ENABLE_HYBRID_HOTSEAT.get() ? 10 : 4; + public static final int LOG_DAYS = 4; public static void setDir(File logsDir) { if (ENABLED) { From 6c7e594d06bda791fda266c9dadd17b327ac03c4 Mon Sep 17 00:00:00 2001 From: Sreyas Date: Thu, 4 Feb 2021 17:05:40 -0800 Subject: [PATCH 2/9] Updating Chips UI Old Screenshot: https://drive.google.com/file/d/1_ptMdXCQGTz_vafOMbB-BZVZ_EP1LsaN/view?usp=sharing New Screenshot: https://drive.google.com/file/d/1bM6Ur5H5OJdG22XU0MdRfVlNBAf_8aUy/view?usp=sharing Test: Manual Bug: 179490983 Change-Id: I14715b07a412239535b4916ba9cb355a0f0cf09e --- .../res/drawable/chip_scrim_gradient.xml | 8 ------- quickstep/res/layout/task.xml | 1 + .../com/android/quickstep/views/TaskView.java | 24 +------------------ 3 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 quickstep/res/drawable/chip_scrim_gradient.xml diff --git a/quickstep/res/drawable/chip_scrim_gradient.xml b/quickstep/res/drawable/chip_scrim_gradient.xml deleted file mode 100644 index 5a2dfb7b4a..0000000000 --- a/quickstep/res/drawable/chip_scrim_gradient.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml index f9bb2f2b14..c90706b703 100644 --- a/quickstep/res/layout/task.xml +++ b/quickstep/res/layout/task.xml @@ -17,6 +17,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" + android:clipChildren="false" android:defaultFocusHighlightEnabled="false" android:elevation="4dp" android:focusable="true"> diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 59cf3b2b8b..c7924fdd5f 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -50,8 +50,6 @@ import android.graphics.Outline; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.InsetDrawable; import android.os.Bundle; import android.os.Handler; import android.util.AttributeSet; @@ -401,9 +399,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { mContextualChip.setScaleX(comp(modalness)); mContextualChip.setScaleY(comp(modalness)); } - if (mContextualChipWrapper != null) { - mContextualChipWrapper.setAlpha(comp(modalness)); - } mDigitalWellBeingToast.updateBannerOffset(modalness); } @@ -736,30 +731,16 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { layoutParams.gravity = BOTTOM | CENTER_HORIZONTAL; int expectedChipHeight = getExpectedViewHeight(view); float chipOffset = getResources().getDimension(R.dimen.chip_hint_vertical_offset); - layoutParams.bottomMargin = (int) - (((MarginLayoutParams) mSnapshotView.getLayoutParams()).bottomMargin - - expectedChipHeight + chipOffset); + layoutParams.bottomMargin = -expectedChipHeight - (int) chipOffset; mContextualChip = ((FrameLayout) mContextualChipWrapper).getChildAt(0); mContextualChip.setScaleX(0f); mContextualChip.setScaleY(0f); - GradientDrawable scrimDrawable = (GradientDrawable) getResources().getDrawable( - R.drawable.chip_scrim_gradient, mActivity.getTheme()); - float cornerRadius = getTaskCornerRadius(); - scrimDrawable.setCornerRadii( - new float[]{0, 0, 0, 0, cornerRadius, cornerRadius, cornerRadius, - cornerRadius}); - InsetDrawable scrimDrawableInset = new InsetDrawable(scrimDrawable, 0, 0, 0, - (int) (expectedChipHeight - chipOffset)); - mContextualChipWrapper.setBackground(scrimDrawableInset); - mContextualChipWrapper.setPadding(0, 0, 0, 0); - mContextualChipWrapper.setAlpha(0f); addView(view, getChildCount(), layoutParams); if (mContextualChip != null) { mContextualChip.animate().scaleX(1f).scaleY(1f).setDuration(50); } if (mContextualChipWrapper != null) { mChipTouchDelegate = new TransformingTouchDelegate(mContextualChipWrapper); - mContextualChipWrapper.animate().alpha(1f).setDuration(50); } } } @@ -982,10 +963,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { public void setFullscreenProgress(float progress) { progress = Utilities.boundToRange(progress, 0, 1); mFullscreenProgress = progress; - boolean isFullscreen = mFullscreenProgress > 0; mIconView.setVisibility(progress < 1 ? VISIBLE : INVISIBLE); - setClipChildren(!isFullscreen); - setClipToPadding(!isFullscreen); TaskThumbnailView thumbnail = getThumbnail(); updateCurrentFullscreenParams(thumbnail.getPreviewPositionHelper()); From df256ae86be7ab2034c3152ac9730a7ad66c5cd7 Mon Sep 17 00:00:00 2001 From: Himanshu Jaju Date: Fri, 8 Jan 2021 17:10:47 +0000 Subject: [PATCH 3/9] Add screen size to touch regions cache. The general design for foldable devices contains a smaller screen and a larger screen. Hence we need to move from caching based on rotation to caching based on {display size, rotation} tuple. Test: Manual on fold2 Bug: 172240450 Change-Id: I445a7545e684134d7d880f957bb97ff847b726b7 --- .../OrientationTouchTransformerTest.java | 98 ++++++++++++++----- .../OrientationTouchTransformer.java | 77 +++++++++++---- 2 files changed, 128 insertions(+), 47 deletions(-) diff --git a/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java b/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java index 5cb55ec2d0..eca27b5566 100644 --- a/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java +++ b/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java @@ -43,8 +43,18 @@ import org.robolectric.RobolectricTestRunner; @RunWith(RobolectricTestRunner.class) public class OrientationTouchTransformerTest { - private static final int SIZE_WIDTH = 1080; - private static final int SIZE_HEIGHT = 2280; + static class ScreenSize { + int mHeight; + int mWidth; + + ScreenSize(int height, int width) { + mHeight = height; + mWidth = width; + } + } + + private static final ScreenSize NORMAL_SCREEN_SIZE = new ScreenSize(2280, 1080); + private static final ScreenSize LARGE_SCREEN_SIZE = new ScreenSize(3280, 1080); private static final float DENSITY_DISPLAY_METRICS = 3.0f; private OrientationTouchTransformer mTouchTransformer; @@ -63,14 +73,16 @@ public class OrientationTouchTransformerTest { DisplayMetrics mockDisplayMetrics = new DisplayMetrics(); mockDisplayMetrics.density = DENSITY_DISPLAY_METRICS; when(mResources.getDisplayMetrics()).thenReturn(mockDisplayMetrics); - mInfo = createDisplayInfo(Surface.ROTATION_0); + mInfo = createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_0); mTouchTransformer = new OrientationTouchTransformer(mResources, NO_BUTTON, () -> 0); } @Test public void disabledMultipleRegions_shouldOverrideFirstRegion() { - float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1; - float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1; + float portraitRegionY = + generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1; + float landscapeRegionY = + generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1; mTouchTransformer.createOrAddTouchRegion(mInfo); tapAndAssertTrue(100, portraitRegionY, @@ -83,7 +95,8 @@ public class OrientationTouchTransformerTest { event -> mTouchTransformer.touchInAssistantRegion(event)); // Override region - mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90)); + mTouchTransformer + .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90)); tapAndAssertFalse(100, portraitRegionY, event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY())); tapAndAssertTrue(100, landscapeRegionY, @@ -107,10 +120,13 @@ public class OrientationTouchTransformerTest { @Test public void enableMultipleRegions_shouldOverrideFirstRegion() { - float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1; - float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1; + float portraitRegionY = + generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1; + float landscapeRegionY = + generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1; - mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90)); + mTouchTransformer + .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90)); tapAndAssertFalse(100, portraitRegionY, event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY())); tapAndAssertTrue(100, landscapeRegionY, @@ -136,11 +152,14 @@ public class OrientationTouchTransformerTest { @Test public void enableMultipleRegions_assistantTriggersInMostRecent() { - float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1; - float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1; + float portraitRegionY = + generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1; + float landscapeRegionY = + generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1; mTouchTransformer.enableMultipleRegions(true, mInfo); - mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90)); + mTouchTransformer + .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90)); mTouchTransformer.createOrAddTouchRegion(mInfo); tapAndAssertTrue(0, portraitRegionY, event -> mTouchTransformer.touchInAssistantRegion(event)); @@ -150,12 +169,15 @@ public class OrientationTouchTransformerTest { @Test public void enableMultipleRegions_assistantTriggersInCurrentOrientationAfterDisable() { - float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1; - float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1; + float portraitRegionY = + generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1; + float landscapeRegionY = + generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1; mTouchTransformer.enableMultipleRegions(true, mInfo); mTouchTransformer.createOrAddTouchRegion(mInfo); - mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90)); + mTouchTransformer + .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90)); mTouchTransformer.enableMultipleRegions(false, mInfo); tapAndAssertTrue(0, portraitRegionY, event -> mTouchTransformer.touchInAssistantRegion(event)); @@ -163,6 +185,26 @@ public class OrientationTouchTransformerTest { event -> mTouchTransformer.touchInAssistantRegion(event)); } + @Test + public void assistantTriggersInCurrentScreenAfterScreenSizeChange() { + float smallerScreenPortraitRegionY = + generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1; + float largerScreenPortraitRegionY = + generateTouchRegionHeight(LARGE_SCREEN_SIZE, Surface.ROTATION_0) + 1; + + mTouchTransformer.enableMultipleRegions(false, + createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_0)); + tapAndAssertTrue(0, smallerScreenPortraitRegionY, + event -> mTouchTransformer.touchInAssistantRegion(event)); + + mTouchTransformer + .enableMultipleRegions(false, createDisplayInfo(LARGE_SCREEN_SIZE, Surface.ROTATION_0)); + tapAndAssertTrue(0, largerScreenPortraitRegionY, + event -> mTouchTransformer.touchInAssistantRegion(event)); + tapAndAssertFalse(0, smallerScreenPortraitRegionY, + event -> mTouchTransformer.touchInAssistantRegion(event)); + } + @Test public void applyTransform_taskNotFrozen_notInRegion() { mTouchTransformer.createOrAddTouchRegion(mInfo); @@ -182,7 +224,7 @@ public class OrientationTouchTransformerTest { public void applyTransform_taskFrozen_noRotate_inRegion() { mTouchTransformer.createOrAddTouchRegion(mInfo); mTouchTransformer.enableMultipleRegions(true, mInfo); - float y = generateTouchRegionHeight(Surface.ROTATION_0) + 1; + float y = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1; tapAndAssertTrue(100, y, event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY())); } @@ -190,15 +232,16 @@ public class OrientationTouchTransformerTest { @Test public void applyTransform_taskNotFrozen_noRotate_inDefaultRegion() { mTouchTransformer.createOrAddTouchRegion(mInfo); - float y = generateTouchRegionHeight(Surface.ROTATION_0) + 1; + float y = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_0) + 1; tapAndAssertTrue(100, y, event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY())); } @Test public void applyTransform_taskNotFrozen_90Rotate_inRegion() { - mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90)); - float y = generateTouchRegionHeight(Surface.ROTATION_90) + 1; + mTouchTransformer + .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90)); + float y = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1; tapAndAssertTrue(100, y, event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY())); } @@ -210,9 +253,10 @@ public class OrientationTouchTransformerTest { public void applyTransform_taskNotFrozen_90Rotate_inTwoRegions() { mTouchTransformer.createOrAddTouchRegion(mInfo); mTouchTransformer.enableMultipleRegions(true, mInfo); - mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90)); + mTouchTransformer + .createOrAddTouchRegion(createDisplayInfo(NORMAL_SCREEN_SIZE, Surface.ROTATION_90)); // Landscape point - float y1 = generateTouchRegionHeight(Surface.ROTATION_90) + 1; + float y1 = generateTouchRegionHeight(NORMAL_SCREEN_SIZE, Surface.ROTATION_90) + 1; MotionEvent inRegion1_down = generateMotionEvent(MotionEvent.ACTION_DOWN, 10, y1); MotionEvent inRegion1_up = generateMotionEvent(MotionEvent.ACTION_UP, 10, y1); // Portrait point in landscape orientation axis @@ -231,18 +275,18 @@ public class OrientationTouchTransformerTest { assertTrue(mTouchTransformer.touchInValidSwipeRegions(inRegion2.getX(), inRegion2.getY())); } - private DisplayController.Info createDisplayInfo(int rotation) { - Point p = new Point(SIZE_WIDTH, SIZE_HEIGHT); + private DisplayController.Info createDisplayInfo(ScreenSize screenSize, int rotation) { + Point p = new Point(screenSize.mWidth, screenSize.mHeight); if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { - p = new Point(SIZE_HEIGHT, SIZE_WIDTH); + p = new Point(screenSize.mHeight, screenSize.mWidth); } return new DisplayController.Info(0, rotation, 0, p, p, p, null); } - private float generateTouchRegionHeight(int rotation) { - float height = SIZE_HEIGHT; + private float generateTouchRegionHeight(ScreenSize screenSize, int rotation) { + float height = screenSize.mHeight; if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { - height = SIZE_WIDTH; + height = screenSize.mWidth; } return height - ResourceUtils.DEFAULT_NAVBAR_VALUE * DENSITY_DISPLAY_METRICS; } diff --git a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java index b258a10c85..6a32dc4f8e 100644 --- a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java +++ b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java @@ -30,7 +30,6 @@ import android.graphics.Matrix; import android.graphics.Point; import android.graphics.RectF; import android.util.Log; -import android.util.SparseArray; import android.view.MotionEvent; import android.view.Surface; @@ -40,6 +39,9 @@ import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.DisplayController.Info; import java.io.PrintWriter; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; /** * Maintains state for supporting nav bars and tracking their gestures in multiple orientations. @@ -51,6 +53,37 @@ import java.io.PrintWriter; */ class OrientationTouchTransformer { + class CurrentDisplay { + public Point size; + public int rotation; + + CurrentDisplay() { + this.size = new Point(0, 0); + this.rotation = 0; + } + + CurrentDisplay(Point size, int rotation) { + this.size = size; + this.rotation = rotation; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + CurrentDisplay display = (CurrentDisplay) o; + if (rotation != display.rotation) return false; + + return Objects.equals(size, display.size); + } + + @Override + public int hashCode() { + return Objects.hash(size, rotation); + } + }; + private static final String TAG = "OrientationTouchTransformer"; private static final boolean DEBUG = false; private static final int MAX_ORIENTATIONS = 4; @@ -60,11 +93,12 @@ class OrientationTouchTransformer { private final Matrix mTmpMatrix = new Matrix(); private final float[] mTmpPoint = new float[2]; - private SparseArray mSwipeTouchRegions = new SparseArray<>(MAX_ORIENTATIONS); + private Map mSwipeTouchRegions = + new HashMap(); private final RectF mAssistantLeftRegion = new RectF(); private final RectF mAssistantRightRegion = new RectF(); private final RectF mOneHandedModeRegion = new RectF(); - private int mCurrentDisplayRotation; + private CurrentDisplay mCurrentDisplay = new CurrentDisplay(); private int mNavBarGesturalHeight; private int mNavBarLargerGesturalHeight; private boolean mEnableMultipleRegions; @@ -147,21 +181,22 @@ class OrientationTouchTransformer { * @see #enableMultipleRegions(boolean, Info) */ void createOrAddTouchRegion(Info info) { - mCurrentDisplayRotation = info.rotation; + mCurrentDisplay = new CurrentDisplay(info.realSize, info.rotation); + if (mQuickStepStartingRotation > QUICKSTEP_ROTATION_UNINITIALIZED - && mCurrentDisplayRotation == mQuickStepStartingRotation) { + && mCurrentDisplay.rotation == mQuickStepStartingRotation) { // User already was swiping and the current screen is same rotation as the starting one // Remove active nav bars in other rotations except for the one we started out in resetSwipeRegions(info); return; } - OrientationRectF region = mSwipeTouchRegions.get(mCurrentDisplayRotation); + OrientationRectF region = mSwipeTouchRegions.get(mCurrentDisplay); if (region != null) { return; } if (mEnableMultipleRegions) { - mSwipeTouchRegions.put(mCurrentDisplayRotation, createRegionForDisplay(info)); + mSwipeTouchRegions.put(mCurrentDisplay, createRegionForDisplay(info)); } else { resetSwipeRegions(info); } @@ -208,31 +243,31 @@ class OrientationTouchTransformer { */ private void resetSwipeRegions(Info region) { if (DEBUG) { - Log.d(TAG, "clearing all regions except rotation: " + mCurrentDisplayRotation); + Log.d(TAG, "clearing all regions except rotation: " + mCurrentDisplay.rotation); } - mCurrentDisplayRotation = region.rotation; - OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplayRotation); + mCurrentDisplay = new CurrentDisplay(region.realSize, region.rotation); + OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplay); if (regionToKeep == null) { regionToKeep = createRegionForDisplay(region); } mSwipeTouchRegions.clear(); - mSwipeTouchRegions.put(mCurrentDisplayRotation, regionToKeep); + mSwipeTouchRegions.put(mCurrentDisplay, regionToKeep); updateAssistantRegions(regionToKeep); } private void resetSwipeRegions() { - OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplayRotation); + OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplay); mSwipeTouchRegions.clear(); if (regionToKeep != null) { - mSwipeTouchRegions.put(mCurrentDisplayRotation, regionToKeep); + mSwipeTouchRegions.put(mCurrentDisplay, regionToKeep); updateAssistantRegions(regionToKeep); } } private OrientationRectF createRegionForDisplay(Info display) { if (DEBUG) { - Log.d(TAG, "creating rotation region for: " + mCurrentDisplayRotation); + Log.d(TAG, "creating rotation region for: " + mCurrentDisplay.rotation); } Point size = display.realSize; @@ -341,7 +376,9 @@ class OrientationTouchTransformer { } for (int i = 0; i < MAX_ORIENTATIONS; i++) { - OrientationRectF rect = mSwipeTouchRegions.get(i); + CurrentDisplay display = new CurrentDisplay(mCurrentDisplay.size, i); + OrientationRectF rect = mSwipeTouchRegions.get(display); + if (TestProtocol.sDebugTracing) { Log.d(TestProtocol.NO_SWIPE_TO_HOME, "transform:DOWN, rect=" + rect); } @@ -355,7 +392,7 @@ class OrientationTouchTransformer { mLastRectTouched = rect; mActiveTouchRotation = rect.mRotation; if (mEnableMultipleRegions - && mCurrentDisplayRotation == mActiveTouchRotation) { + && mCurrentDisplay.rotation == mActiveTouchRotation) { // TODO(b/154580671) might make this block unnecessary // Start a touch session for the default nav region for the display mQuickStepStartingRotation = mLastRectTouched.mRotation; @@ -378,8 +415,8 @@ class OrientationTouchTransformer { pw.println(" lastTouchedRegion=" + mLastRectTouched); pw.println(" multipleRegionsEnabled=" + mEnableMultipleRegions); StringBuilder regions = new StringBuilder(" currentTouchableRotations="); - for(int i = 0; i < mSwipeTouchRegions.size(); i++) { - OrientationRectF rectF = mSwipeTouchRegions.get(mSwipeTouchRegions.keyAt(i)); + for (CurrentDisplay key: mSwipeTouchRegions.keySet()) { + OrientationRectF rectF = mSwipeTouchRegions.get(key); regions.append(rectF).append(" "); } pw.println(regions.toString()); @@ -417,12 +454,12 @@ class OrientationTouchTransformer { boolean applyTransform(MotionEvent event, boolean forceTransform) { mTmpMatrix.reset(); - postDisplayRotation(deltaRotation(mCurrentDisplayRotation, mRotation), + postDisplayRotation(deltaRotation(mCurrentDisplay.rotation, mRotation), mHeight, mWidth, mTmpMatrix); if (forceTransform) { if (DEBUG) { Log.d(TAG, "Transforming rotation due to forceTransform, " - + "mCurrentRotation: " + mCurrentDisplayRotation + + "mCurrentRotation: " + mCurrentDisplay.rotation + "mRotation: " + mRotation); } event.transform(mTmpMatrix); From 7944ee5c79136be7f28eb52260d6be779510e749 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 8 Jan 2021 19:07:25 +0000 Subject: [PATCH 4/9] Enable variable size thumbnail for large screen - Introduced a feature flag - Refresh TaskView size when thumbnail is refreshed or Recents resizes - Disable edge scale down in large screens - Added temp method to get task width/height ratio - In fullscreen, scale down TaskThumbnailView and disable TaskView elevation - Task boxing mechanism: http://screen/3NkePthAVUVH2Rv.png Bug: 174464656 Test: Manually test overview and quickswitch for folded and unfolded, including with RTL. Change-Id: I2ce24d588a246cc6a2408039a37d884021aa0800 --- .../TaskViewTouchController.java | 7 +- .../com/android/quickstep/TaskViewUtils.java | 9 +- .../quickstep/util/TaskViewSimulator.java | 5 +- .../android/quickstep/views/RecentsView.java | 83 +++++- .../quickstep/views/TaskThumbnailView.java | 35 ++- .../com/android/quickstep/views/TaskView.java | 267 +++++++++++++++--- src/com/android/launcher3/PagedView.java | 8 +- .../launcher3/config/FeatureFlags.java | 4 + 8 files changed, 361 insertions(+), 57 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java index 7675a7968a..c2e5cdabf2 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java @@ -32,6 +32,7 @@ import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.anim.PendingAnimation; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.touch.BaseSwipeDetector; import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.touch.SingleAxisSwipeDetector; @@ -150,9 +151,11 @@ public abstract class TaskViewTouchController mTaskBeingDragged = view; int upDirection = mRecentsView.getPagedOrientationHandler() .getUpDirection(mIsRtl); - if (!SysUINavigationMode.getMode(mActivity).hasGestures) { + if (!SysUINavigationMode.getMode(mActivity).hasGestures || ( + mActivity.getDeviceProfile().isTablet + && FeatureFlags.ENABLE_OVERVIEW_GRID.get())) { // Don't allow swipe down to open if we don't support swipe up - // to enter overview. + // to enter overview, or when grid layout is enabled. directionsToDetectScroll = upDirection; mAllowGoingUp = true; mAllowGoingDown = false; diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 9da306eec0..25c0928e8d 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -49,6 +49,7 @@ import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.anim.PendingAnimation; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.statehandlers.DepthController; import com.android.launcher3.statemanager.StateManager; @@ -174,11 +175,13 @@ public final class TaskViewUtils { final RecentsView recentsView = v.getRecentsView(); int taskIndex = recentsView.indexOfChild(v); - boolean parallaxCenterAndAdjacentTask = taskIndex != recentsView.getCurrentPage(); - int startScroll = recentsView.getScrollOffset(taskIndex); - Context context = v.getContext(); DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile(); + boolean parallaxCenterAndAdjacentTask = + taskIndex != recentsView.getCurrentPage() && !(dp.isTablet + && FeatureFlags.ENABLE_OVERVIEW_GRID.get()); + int startScroll = recentsView.getScrollOffset(taskIndex); + TaskViewSimulator topMostSimulator = null; if (tsv == null && targets.apps.length > 0) { diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 65bcf26305..6f16781c64 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -276,8 +276,9 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { int start = mOrientationState.getOrientationHandler() .getPrimaryValue(mTaskRect.left, mTaskRect.top); mScrollState.screenCenter = start + mScrollState.scroll + mScrollState.halfPageSize; - mScrollState.updateInterpolation(start); - mCurveScale = TaskView.getCurveScaleForInterpolation(mScrollState.linearInterpolation); + mScrollState.updateInterpolation(mDp, start); + mCurveScale = TaskView.getCurveScaleForInterpolation(mDp, + mScrollState.linearInterpolation); } float progress = Utilities.boundToRange(fullScreenProgress.value, 0, 1); diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index d9d0a936b2..38d488c470 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -898,9 +898,14 @@ public abstract class RecentsView extends PagedView public void setFullscreenProgress(float fullscreenProgress) { mFullscreenProgress = fullscreenProgress; int taskCount = getTaskViewCount(); + float accumulatedTranslationX = 0; for (int i = 0; i < taskCount; i++) { - getTaskViewAt(i).setFullscreenProgress(mFullscreenProgress); + TaskView taskView = getTaskViewAt(i); + taskView.setFullscreenProgress(mFullscreenProgress); + taskView.setAccumulatedTranslationX(accumulatedTranslationX); + accumulatedTranslationX += taskView.getFullscreenTranslationX(); } + // Fade out the actions view quickly (0.1 range) mActionsView.getFullscreenAlpha().setValue( mapToRange(fullscreenProgress, 0, 0.1f, 1f, 0f, LINEAR)); @@ -934,6 +939,11 @@ public abstract class RecentsView extends PagedView setPadding(mTempRect.left - mInsets.left, mTempRect.top - mInsets.top, dp.widthPx - mInsets.right - mTempRect.right, dp.heightPx - mInsets.bottom - mTempRect.bottom); + // Force TaskView to update size from thumbnail + final int taskCount = getTaskViewCount(); + for (int i = 0; i < taskCount; i++) { + getTaskViewAt(i).updateTaskSize(); + } } public void getTaskSize(Rect outRect) { @@ -942,6 +952,11 @@ public abstract class RecentsView extends PagedView mLastComputedTaskSize.set(outRect); } + /** Gets the last computed task size */ + public Rect getLastComputedTaskSize() { + return mLastComputedTaskSize; + } + /** Gets the task size for modal state. */ public void getModalTaskSize(Rect outRect) { mSizeStrategy.calculateModalTaskSize(mActivity, mActivity.getDeviceProfile(), outRect); @@ -987,7 +1002,7 @@ public abstract class RecentsView extends PagedView final int pageCount = getPageCount(); for (int i = 0; i < pageCount; i++) { View page = getPageAt(i); - mScrollState.updateInterpolation( + mScrollState.updateInterpolation(mActivity.getDeviceProfile(), mOrientationHandler.getChildStartWithTranslation(page)); ((PageCallbacks) page).onPageScroll(mScrollState); } @@ -1422,13 +1437,13 @@ public abstract class RecentsView extends PagedView /** * Updates linearInterpolation for the provided child position */ - public void updateInterpolation(float childStart) { + public void updateInterpolation(DeviceProfile deviceProfile, float childStart) { float pageCenter = childStart + halfPageSize; float distanceFromScreenCenter = screenCenter - pageCenter; // How far the page has to move from the center to be offscreen, taking into account // the EDGE_SCALE_DOWN_FACTOR that will be applied at that position. float distanceToReachEdge = halfScreenSize - + halfPageSize * (1 - TaskView.EDGE_SCALE_DOWN_FACTOR); + + halfPageSize * (1 - TaskView.getEdgeScaleDownFactor(deviceProfile)); linearInterpolation = Math.min(1, Math.abs(distanceFromScreenCenter) / distanceToReachEdge); } @@ -1444,12 +1459,13 @@ public abstract class RecentsView extends PagedView } } - private void addDismissedTaskAnimations(View taskView, long duration, PendingAnimation anim) { + private void addDismissedTaskAnimations(TaskView taskView, long duration, + PendingAnimation anim) { // Use setFloat instead of setViewAlpha as we want to keep the view visible even when it's // alpha is set to 0 so that it can be recycled in the view pool properly anim.setFloat(taskView, VIEW_ALPHA, 0, ACCEL_2); - FloatProperty secondaryViewTranslate = - mOrientationHandler.getSecondaryViewTranslate(); + FloatProperty secondaryViewTranslate = + taskView.getDismissTaskTranslationProperty(); int secondaryTaskDimension = mOrientationHandler.getSecondaryDimension(taskView); int verticalFactor = mOrientationHandler.getSecondaryTranslationDirectionFactor(); @@ -1515,7 +1531,7 @@ public abstract class RecentsView extends PagedView int scrollDiff = newScroll[i] - oldScroll[i] + offset; if (scrollDiff != 0) { FloatProperty translationProperty = child instanceof TaskView - ? ((TaskView) child).getPrimaryFillDismissGapTranslationProperty() + ? ((TaskView) child).getFillDismissGapTranslationProperty() : mOrientationHandler.getPrimaryViewTranslate(); ResourceProvider rp = DynamicResource.provider(mActivity); @@ -1971,7 +1987,8 @@ public abstract class RecentsView extends PagedView // Find the task's scale based on its offscreen progress, then see how far it still needs to // move to be completely offscreen. Utilities.scaleRectFAboutCenter(taskPosition, - TaskView.getCurveScaleForInterpolation(centerToOffscreenProgress)); + TaskView.getCurveScaleForInterpolation(mActivity.getDeviceProfile(), + centerToOffscreenProgress)); distanceToOffscreen = desiredLeft - taskPosition.left; // Finally, we need to account for RecentsView scale, because it moves tasks based on its // pivot. To do this, we move the task position to where it would be offscreen at scale = 1 @@ -1990,7 +2007,7 @@ public abstract class RecentsView extends PagedView mTaskViewsSecondaryTranslation = translation; for (int i = 0; i < getTaskViewCount(); i++) { TaskView task = getTaskViewAt(i); - mOrientationHandler.getSecondaryViewTranslate().set(task, translation / getScaleY()); + task.getTaskResistanceTranslationProperty().set(task, translation / getScaleY()); } mLiveTileTaskViewSimulator.recentsViewSecondaryTranslation.value = translation; } @@ -2358,6 +2375,52 @@ public abstract class RecentsView extends PagedView return super.computeMinScroll(); } + @Override + protected boolean getPageScrolls(int[] outPageScrolls, boolean layoutChildren, + ComputePageScrollsLogic scrollLogic) { + boolean pageScrollChanged = super.getPageScrolls(outPageScrolls, layoutChildren, + scrollLogic); + + final int taskCount = getTaskViewCount(); + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + if (childCount < mTaskViewStartIndex) { + continue; + } + + final TaskView taskView = getTaskViewAt( + Utilities.boundToRange(i, mTaskViewStartIndex, taskCount - 1)); + float scrollDiff = + taskView.getFullscreenTranslationX() + taskView.getAccumulatedTranslationX(); + if (scrollDiff != 0) { + outPageScrolls[i] += scrollDiff; + pageScrollChanged = true; + } + } + return pageScrollChanged; + } + + @Override + protected int getChildOffset(int index) { + if (index < mTaskViewStartIndex) { + return super.getChildOffset(index); + } + + final TaskView taskView = getTaskViewAt( + Utilities.boundToRange(index, mTaskViewStartIndex, getTaskViewCount() - 1)); + return super.getChildOffset(index) + (int) taskView.getFullscreenTranslationX() + + (int) taskView.getAccumulatedTranslationX(); + } + + @Override + protected int getChildVisibleSize(int index) { + final TaskView taskView = getTaskViewAtByAbsoluteIndex(index); + if (taskView == null) { + return super.getChildVisibleSize(index); + } + return super.getChildVisibleSize(index) - (int) taskView.getFullscreenTranslationX(); + } + @Override protected int computeMaxScroll() { if (getTaskViewCount() > 0) { diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java index 445e49085b..3bd883ddc4 100644 --- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java @@ -51,6 +51,7 @@ import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.Utilities; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.SystemUiController; @@ -110,6 +111,9 @@ public class TaskThumbnailView extends View implements PluginListener FILL_DISMISS_GAP_TRANSLATION_X = - new FloatProperty("fillDismissGapTranslationX") { + private static final FloatProperty DISMISS_TRANSLATION_X = + new FloatProperty("dismissTranslationX") { @Override public void setValue(TaskView taskView, float v) { - taskView.setFillDismissGapTranslationX(v); + taskView.setDismissTranslationX(v); } @Override public Float get(TaskView taskView) { - return taskView.mFillDismissGapTranslationX; + return taskView.mDismissTranslationX; } }; - private static final FloatProperty FILL_DISMISS_GAP_TRANSLATION_Y = - new FloatProperty("fillDismissGapTranslationY") { + private static final FloatProperty DISMISS_TRANSLATION_Y = + new FloatProperty("dismissTranslationY") { @Override public void setValue(TaskView taskView, float v) { - taskView.setFillDismissGapTranslationY(v); + taskView.setDismissTranslationY(v); } @Override public Float get(TaskView taskView) { - return taskView.mFillDismissGapTranslationY; + return taskView.mDismissTranslationY; } }; @@ -204,6 +206,32 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { } }; + private static final FloatProperty TASK_RESISTANCE_TRANSLATION_X = + new FloatProperty("taskResistanceTranslationX") { + @Override + public void setValue(TaskView taskView, float v) { + taskView.setTaskResistanceTranslationX(v); + } + + @Override + public Float get(TaskView taskView) { + return taskView.mTaskResistanceTranslationX; + } + }; + + private static final FloatProperty TASK_RESISTANCE_TRANSLATION_Y = + new FloatProperty("taskResistanceTranslationY") { + @Override + public void setValue(TaskView taskView, float v) { + taskView.setTaskResistanceTranslationY(v); + } + + @Override + public Float get(TaskView taskView) { + return taskView.mTaskResistanceTranslationY; + } + }; + private final OnAttachStateChangeListener mTaskMenuStateListener = new OnAttachStateChangeListener() { @Override @@ -228,15 +256,22 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { private final DigitalWellBeingToast mDigitalWellBeingToast; private float mCurveScale; private float mFullscreenProgress; + private float mScaleAtFullscreen = 1; + private float mFullscreenScale = 1; private final FullscreenDrawParams mCurrentFullscreenParams; private final StatefulActivity mActivity; // Various causes of changing primary translation, which we aggregate to setTranslationX/Y(). - // TODO: We should do this for secondary translation properties as well. - private float mFillDismissGapTranslationX; - private float mFillDismissGapTranslationY; + private float mDismissTranslationX; + private float mDismissTranslationY; private float mTaskOffsetTranslationX; private float mTaskOffsetTranslationY; + private float mTaskResistanceTranslationX; + private float mTaskResistanceTranslationY; + // The following translation variables should only be used in the same orientation as Launcher. + private float mFullscreenTranslationX; + private float mAccumulatedTranslationX; + private float mBoxTranslationY; private ObjectAnimator mIconAndDimAnimator; private float mIconScaleAnimStartProgress = 0; @@ -425,6 +460,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { cancelPendingLoadTasks(); mTask = task; mSnapshotView.bind(task); + updateTaskSize(); setOrientationState(orientedState); } @@ -668,10 +704,12 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { protected void resetViewTransforms() { setCurveScale(1); - mFillDismissGapTranslationX = mTaskOffsetTranslationX = 0f; - mFillDismissGapTranslationY = mTaskOffsetTranslationY = 0f; - setTranslationX(0f); - setTranslationY(0f); + // fullscreenTranslation and accumulatedTranslation should not be reset, as + // resetViewTransforms is called during Quickswitch scrolling. + mDismissTranslationX = mTaskOffsetTranslationX = mTaskResistanceTranslationX = 0f; + mDismissTranslationY = mTaskOffsetTranslationY = mTaskResistanceTranslationY = 0f; + applyTranslationX(); + applyTranslationY(); setTranslationZ(0); setAlpha(mStableAlpha); setIconScaleAndDim(1); @@ -684,6 +722,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { @Override public void onRecycle() { + mFullscreenTranslationX = mAccumulatedTranslationX = mBoxTranslationY = 0f; resetViewTransforms(); // Clear any references to the thumbnail (it will be re-read either from the cache or the // system on next bind) @@ -702,7 +741,7 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { float curveInterpolation = CURVE_INTERPOLATOR.getInterpolation(scrollState.linearInterpolation); float curveScaleForCurveInterpolation = getCurveScaleForCurveInterpolation( - curveInterpolation); + mActivity.getDeviceProfile(), curveInterpolation); mSnapshotView.setDimAlpha(curveInterpolation * MAX_PAGE_SCRIM_ALPHA); setCurveScale(curveScaleForCurveInterpolation); @@ -787,40 +826,70 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); - setPivotX((right - left) * 0.5f); - setPivotY(mSnapshotView.getTop() + mSnapshotView.getHeight() * 0.5f); + if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) { + setPivotX(getLayoutDirection() == LAYOUT_DIRECTION_RTL ? (right - left) : 0); + setPivotY(0); + } else { + setPivotX((right - left) * 0.5f); + setPivotY(mSnapshotView.getTop() + mSnapshotView.getHeight() * 0.5f); + } if (Utilities.ATLEAST_Q) { SYSTEM_GESTURE_EXCLUSION_RECT.get(0).set(0, 0, getWidth(), getHeight()); setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT); } } - public static float getCurveScaleForInterpolation(float linearInterpolation) { + /** + * How much to scale down pages near the edge of the screen according to linearInterpolation. + */ + public static float getCurveScaleForInterpolation(DeviceProfile deviceProfile, + float linearInterpolation) { float curveInterpolation = CURVE_INTERPOLATOR.getInterpolation(linearInterpolation); - return getCurveScaleForCurveInterpolation(curveInterpolation); + return getCurveScaleForCurveInterpolation(deviceProfile, curveInterpolation); } - private static float getCurveScaleForCurveInterpolation(float curveInterpolation) { - return 1 - curveInterpolation * EDGE_SCALE_DOWN_FACTOR; + private static float getCurveScaleForCurveInterpolation(DeviceProfile deviceProfile, + float curveInterpolation) { + return 1 - curveInterpolation * getEdgeScaleDownFactor(deviceProfile); + } + + /** + * How much to scale down pages near the edge of the screen. + */ + public static float getEdgeScaleDownFactor(DeviceProfile deviceProfile) { + if (deviceProfile.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) { + return EDGE_SCALE_DOWN_FACTOR_GRID; + } else { + return EDGE_SCALE_DOWN_FACTOR_CAROUSEL; + } } private void setCurveScale(float curveScale) { mCurveScale = curveScale; - setScaleX(mCurveScale); - setScaleY(mCurveScale); + applyScale(); + } + + private void setFullscreenScale(float fullscreenScale) { + mFullscreenScale = fullscreenScale; + applyScale(); + } + + private void applyScale() { + setScaleX(mCurveScale * mFullscreenScale); + setScaleY(mCurveScale * mFullscreenScale); } public float getCurveScale() { return mCurveScale; } - private void setFillDismissGapTranslationX(float x) { - mFillDismissGapTranslationX = x; + private void setDismissTranslationX(float x) { + mDismissTranslationX = x; applyTranslationX(); } - private void setFillDismissGapTranslationY(float y) { - mFillDismissGapTranslationY = y; + private void setDismissTranslationY(float y) { + mDismissTranslationY = y; applyTranslationY(); } @@ -834,17 +903,59 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { applyTranslationY(); } + private void setTaskResistanceTranslationX(float x) { + mTaskResistanceTranslationX = x; + applyTranslationX(); + } + + private void setTaskResistanceTranslationY(float y) { + mTaskResistanceTranslationY = y; + applyTranslationY(); + } + + private void setFullscreenTranslationX(float fullscreenTranslationX) { + mFullscreenTranslationX = fullscreenTranslationX; + applyTranslationX(); + } + + public float getFullscreenTranslationX() { + return mFullscreenTranslationX; + } + + public void setAccumulatedTranslationX(float accumulatedTranslationX) { + mAccumulatedTranslationX = accumulatedTranslationX; + applyTranslationX(); + } + + public float getAccumulatedTranslationX() { + return mAccumulatedTranslationX; + } + + private void setBoxTranslationY(float boxTranslationY) { + mBoxTranslationY = boxTranslationY; + applyTranslationY(); + } + private void applyTranslationX() { - setTranslationX(mFillDismissGapTranslationX + mTaskOffsetTranslationX); + setTranslationX( + mDismissTranslationX + mTaskOffsetTranslationX + mTaskResistanceTranslationX + + mFullscreenTranslationX + mAccumulatedTranslationX); } private void applyTranslationY() { - setTranslationY(mFillDismissGapTranslationY + mTaskOffsetTranslationY); + setTranslationY( + mDismissTranslationY + mTaskOffsetTranslationY + mTaskResistanceTranslationY + + mBoxTranslationY); } - public FloatProperty getPrimaryFillDismissGapTranslationProperty() { + public FloatProperty getFillDismissGapTranslationProperty() { return getPagedOrientationHandler().getPrimaryValue( - FILL_DISMISS_GAP_TRANSLATION_X, FILL_DISMISS_GAP_TRANSLATION_Y); + DISMISS_TRANSLATION_X, DISMISS_TRANSLATION_Y); + } + + public FloatProperty getDismissTaskTranslationProperty() { + return getPagedOrientationHandler().getSecondaryValue( + DISMISS_TRANSLATION_X, DISMISS_TRANSLATION_Y); } public FloatProperty getPrimaryTaskOffsetTranslationProperty() { @@ -852,6 +963,11 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { TASK_OFFSET_TRANSLATION_X, TASK_OFFSET_TRANSLATION_Y); } + public FloatProperty getTaskResistanceTranslationProperty() { + return getPagedOrientationHandler().getSecondaryValue( + TASK_RESISTANCE_TRANSLATION_X, TASK_RESISTANCE_TRANSLATION_Y); + } + @Override public boolean hasOverlappingRendering() { // TODO: Clip-out the icon region from the thumbnail, since they are overlapping. @@ -987,6 +1103,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { setClipChildren(!isFullscreen); setClipToPadding(!isFullscreen); + updateTaskScaling(); + TaskThumbnailView thumbnail = getThumbnail(); updateCurrentFullscreenParams(thumbnail.getPreviewPositionHelper()); @@ -1012,6 +1130,83 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { previewPositionHelper); } + void updateTaskSize() { + ViewGroup.LayoutParams params = getLayoutParams(); + if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) { + final int thumbnailPadding = (int) getResources().getDimension( + R.dimen.task_thumbnail_top_margin); + + Rect lastComputedTaskSize = getRecentsView().getLastComputedTaskSize(); + int taskWidth = lastComputedTaskSize.width(); + int taskHeight = lastComputedTaskSize.height(); + int boxLength = Math.max(taskWidth, taskHeight); + float thumbnailRatio = mSnapshotView.getThumbnailRatio(); + + int expectedWidth; + int expectedHeight; + if (thumbnailRatio > 1) { + expectedWidth = boxLength; + expectedHeight = (int) (boxLength / thumbnailRatio) + thumbnailPadding; + } else { + expectedWidth = (int) (boxLength * thumbnailRatio); + expectedHeight = boxLength + thumbnailPadding; + } + + float heightDiff = (expectedHeight - thumbnailPadding - taskHeight) / 2.0f; + setBoxTranslationY(heightDiff); + + if (expectedWidth > taskWidth) { + // In full screen, expectedWidth should not be larger than taskWidth. + mScaleAtFullscreen = taskWidth / (float) expectedWidth; + } else if (expectedHeight - thumbnailPadding > taskHeight) { + // In full screen, expectedHeight should not be larger than taskHeight. + mScaleAtFullscreen = taskHeight / (float) (expectedHeight - thumbnailPadding); + } else { + mScaleAtFullscreen = 1f; + } + + if (params.width != expectedWidth || params.height != expectedHeight) { + params.width = expectedWidth; + params.height = expectedHeight; + setLayoutParams(params); + } + } else { + setBoxTranslationY(0); + if (params.width != ViewGroup.LayoutParams.MATCH_PARENT) { + params.width = ViewGroup.LayoutParams.MATCH_PARENT; + params.height = ViewGroup.LayoutParams.MATCH_PARENT; + setLayoutParams(params); + } + } + updateTaskScaling(); + } + + private void updateTaskScaling() { + if (mActivity.getDeviceProfile().isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get()) { + ViewGroup.LayoutParams params = getLayoutParams(); + if (params.width == ViewGroup.LayoutParams.MATCH_PARENT + || params.height == ViewGroup.LayoutParams.MATCH_PARENT) { + // Snapshot is not loaded yet, skip. + return; + } + + float progress = EXAGGERATED_EASE.getInterpolation(mFullscreenProgress); + setFullscreenScale(Utilities.mapRange(progress, 1f, mScaleAtFullscreen)); + + float widthDiff = params.width * (1 - mFullscreenScale); + setFullscreenTranslationX(getFullscreenTrans( + getLayoutDirection() == LAYOUT_DIRECTION_RTL ? -widthDiff : widthDiff)); + } else { + setFullscreenScale(1); + setFullscreenTranslationX(0); + } + } + + private float getFullscreenTrans(float endTranslation) { + float progress = ACCEL_DEACCEL.getInterpolation(mFullscreenProgress); + return Utilities.mapRange(progress, 0, endTranslation); + } + public boolean isRunningTask() { if (getRecentsView() == null) { return false; diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 4303dee769..ada297f340 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -745,6 +745,11 @@ public abstract class PagedView extends ViewGrou return mOrientationHandler.getChildStart(pageAtIndex); } + protected int getChildVisibleSize(int index) { + View layout = getPageAt(index); + return mOrientationHandler.getMeasuredSize(layout); + } + @Override public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) { int page = indexToPage(indexOfChild(child)); @@ -1457,8 +1462,7 @@ public abstract class PagedView extends ViewGrou } private int getDisplacementFromScreenCenter(int childIndex, int screenCenter) { - View layout = getPageAt(childIndex); - int childSize = mOrientationHandler.getMeasuredSize(layout); + int childSize = getChildVisibleSize(childIndex); int halfChildSize = (childSize / 2); int childCenter = getChildOffset(childIndex) + halfChildSize; return childCenter - screenCenter; diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index ac0083c1ee..2b373a84f8 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -214,6 +214,10 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_TASKBAR = new DeviceFlag( "ENABLE_TASKBAR", false, "Allows a system Taskbar to be shown on larger devices."); + public static final BooleanFlag ENABLE_OVERVIEW_GRID = new DeviceFlag( + "ENABLE_OVERVIEW_GRID", false, "Uses grid overview layout. " + + "Only applicable on large screen devices."); + public static void initialize(Context context) { synchronized (sDebugFlags) { for (DebugFlag flag : sDebugFlags) { From afd0d81a70ad148ba5c4c3ebe2a9ac6406557834 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 8 Feb 2021 11:52:57 -0800 Subject: [PATCH 5/9] Fix some issues with taskbar - Update Hotseat items in init() to ensure they are reloaded - Don't update Recent items if we get the new tasks after cleanup() Test: Fold and unfold, ensure Taskbar disappears/reappears without crashing Bug: 171917176 Change-Id: I1c2ae1022ae56cddece655b22db187684f691bf8 --- .../launcher3/taskbar/TaskbarHotseatController.java | 1 + .../launcher3/taskbar/TaskbarRecentsController.java | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java index 4dc051aaa9..082343ea0b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java @@ -57,6 +57,7 @@ public class TaskbarHotseatController { protected void init() { mLauncher.getDragController().addDragListener(mDragListener); + onHotseatUpdated(); } protected void cleanup() { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java index 9d4e000da0..4256d2bd88 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java @@ -50,6 +50,8 @@ public class TaskbarRecentsController { // The current background requests to load the task icons private CancellableTask[] mIconLoadRequests = new CancellableTask[mNumRecentIcons]; + private boolean mIsAlive; + public TaskbarRecentsController(BaseQuickstepLauncher launcher, TaskbarController.TaskbarRecentsControllerCallbacks taskbarCallbacks) { mLauncher = launcher; @@ -58,11 +60,13 @@ public class TaskbarRecentsController { } protected void init() { + mIsAlive = true; TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackChangeListener); reloadRecentTasksIfNeeded(); } protected void cleanup() { + mIsAlive = false; TaskStackChangeListeners.getInstance().unregisterTaskStackListener( mTaskStackChangeListener); cancelAllPendingIconLoadTasks(); @@ -84,7 +88,9 @@ public class TaskbarRecentsController { } private void onRecentTasksChanged(ArrayList tasks) { - mTaskbarCallbacks.updateRecentItems(tasks); + if (mIsAlive) { + mTaskbarCallbacks.updateRecentItems(tasks); + } } /** From fb674c7d81d31a5eaf208b51a82b77a25f2873f7 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Mon, 8 Feb 2021 16:24:42 -0800 Subject: [PATCH 6/9] Added API to specify if split-screen should exit on hide Bug: 179176511 Test: presubmits Change-Id: I6eaecec2ac3fd1bbfbf548078eef525376ddbe72 --- .../src/com/android/quickstep/SystemUiProxy.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index 85b21e09aa..64d05e1401 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -480,6 +480,17 @@ public class SystemUiProxy implements ISystemUiProxy { } } + @Override + public void exitSplitScreenOnHide(boolean exitSplitScreenOnHide) { + if (mSystemUiProxy != null) { + try { + mSystemUiProxy.exitSplitScreenOnHide(exitSplitScreenOnHide); + } catch (RemoteException e) { + Log.w(TAG, "Failed call exitSplitScreen"); + } + } + } + @Override public void startTask(int taskId, int stage, int position, Bundle options) { if (mSystemUiProxy != null) { From 61620e75375b45fb88c72336624a9bf3d355fbe3 Mon Sep 17 00:00:00 2001 From: thiruram Date: Tue, 9 Feb 2021 09:53:37 -0800 Subject: [PATCH 7/9] Fixes NPE with LAUNCHER_ALLAPPS_EXIT log event. Bug: 179720471 Test: rnlt -until-error -t com.android.launcher3.ui.TaplTestsLauncher3 Change-Id: Ic8f91092aa060a2225c059a89a33b6877cf35f36 --- .../android/launcher3/allapps/search/LiveSearchManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/allapps/search/LiveSearchManager.java b/src/com/android/launcher3/allapps/search/LiveSearchManager.java index e52c79049f..608affeb2b 100644 --- a/src/com/android/launcher3/allapps/search/LiveSearchManager.java +++ b/src/com/android/launcher3/allapps/search/LiveSearchManager.java @@ -157,7 +157,10 @@ public class LiveSearchManager implements StateListener { if (finalState.equals(ALL_APPS)) { mLogInstanceId = new InstanceIdSequence().newInstanceId(); logger.withInstanceId(mLogInstanceId).log(LAUNCHER_ALLAPPS_ENTRY); - } else if (mPrevLauncherState.equals(ALL_APPS)) { + } else if (mPrevLauncherState.equals(ALL_APPS) + // Check if mLogInstanceId is not null; to avoid NPE when LAUNCHER_ALLAPPS_EXIT is + // triggered multiple times + && mLogInstanceId != null) { logger.withInstanceId(mLogInstanceId).log(LAUNCHER_ALLAPPS_EXIT); mLogInstanceId = null; } From c402fdaf7b644ecf5ea3b1668fb8cc310483f18a Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 5 Feb 2021 12:59:36 -0800 Subject: [PATCH 8/9] Deduping multiple prediction UI update calls Bug: 179445858 Test: Manual Change-Id: I6ad86af247a6d94dcaf45206b3d7fb8c44c602d6 --- .../HotseatPredictionController.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index 5e81fbaf08..0156e8f513 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -74,11 +74,13 @@ public class HotseatPredictionController implements DragController.DragListener, private static final int FLAG_UPDATE_PAUSED = 1 << 0; private static final int FLAG_DRAG_IN_PROGRESS = 1 << 1; private static final int FLAG_FILL_IN_PROGRESS = 1 << 2; + private static final int FLAG_REMOVING_PREDICTED_ICON = 1 << 3; private int mHotSeatItemsCount; private QuickstepLauncher mLauncher; private final Hotseat mHotseat; + private final Runnable mUpdateFillIfNotLoading = this::updateFillIfNotLoading; private List mPredictedItems = Collections.emptyList(); @@ -132,7 +134,8 @@ public class HotseatPredictionController implements DragController.DragListener, private void onHotseatHierarchyChanged() { if (mPauseFlags == 0 && !mLauncher.isWorkspaceLoading()) { // Post update after a single frame to avoid layout within layout - MAIN_EXECUTOR.getHandler().post(this::updateFillIfNotLoading); + MAIN_EXECUTOR.getHandler().removeCallbacks(mUpdateFillIfNotLoading); + MAIN_EXECUTOR.getHandler().post(mUpdateFillIfNotLoading); } } @@ -374,7 +377,7 @@ public class HotseatPredictionController implements DragController.DragListener, continue; } if (dragObject.dragSource == this && icon.equals(dragObject.originalView)) { - mHotseat.removeView(icon); + removeIconWithoutNotify(icon); continue; } int rank = ((WorkspaceItemInfo) icon.getTag()).rank; @@ -386,7 +389,7 @@ public class HotseatPredictionController implements DragController.DragListener, @Override public void onAnimationSuccess(Animator animator) { if (icon.getParent() != null) { - mHotseat.removeView(icon); + removeIconWithoutNotify(icon); } } }); @@ -395,6 +398,17 @@ public class HotseatPredictionController implements DragController.DragListener, mIconRemoveAnimators.start(); } + /** + * Removes icon while suppressing any extra tasks performed on view-hierarchy changes. + * This avoids recursive/redundant updates as the control updates the UI anyway after + * it's animation. + */ + private void removeIconWithoutNotify(PredictedAppIcon icon) { + mPauseFlags |= FLAG_REMOVING_PREDICTED_ICON; + mHotseat.removeView(icon); + mPauseFlags &= ~FLAG_REMOVING_PREDICTED_ICON; + } + @Override public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) { removePredictedApps(mOutlineDrawings, dragObject); From a3a30a9224f5841e702244cafaed9891629143ff Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Mon, 8 Feb 2021 13:25:41 -0800 Subject: [PATCH 9/9] Migrate AA+ Search related files Bug: 179495850 Test: Manual Change-Id: I32180f14a11eaf72d5d4981e76c2f2ea74472494 --- .../res/layout/fallback_search_input.xml | 35 -- quickstep/res/layout/search_edu_view.xml | 73 ---- quickstep/res/layout/search_result_icon.xml | 20 -- .../res/layout/search_result_icon_row.xml | 90 ----- quickstep/res/layout/search_result_slice.xml | 40 --- .../layout/search_result_small_icon_row.xml | 73 ---- .../res/layout/search_result_thumbnail.xml | 19 - .../res/layout/search_result_widget_live.xml | 43 --- .../layout/search_result_widget_preview.xml | 8 - quickstep/res/layout/search_section_title.xml | 25 -- .../search/DeviceSearchAdapterProvider.java | 152 -------- .../launcher3/search/DeviceSearchEdu.java | 220 ------------ .../search/FallbackSearchInputView.java | 140 -------- .../launcher3/search/SearchAdapterItem.java | 66 ---- .../launcher3/search/SearchResultIcon.java | 325 ------------------ .../launcher3/search/SearchResultIconRow.java | 158 --------- .../search/SearchResultIconSlice.java | 122 ------- .../search/SearchResultSmallIconRow.java | 142 -------- .../search/SearchResultThumbnailView.java | 102 ------ .../launcher3/search/SearchResultWidget.java | 228 ------------ .../search/SearchResultWidgetPreview.java | 130 ------- .../search/SearchSectionHeaderView.java | 50 --- .../search/SearchServicePipeline.java | 153 --------- .../search/SearchSessionTracker.java | 81 ----- .../launcher3/search/SearchTargetHandler.java | 46 --- .../launcher3/search/SearchTargetUtil.java | 198 ----------- .../uioverrides/QuickstepLauncher.java | 8 - .../util/QuickstepOnboardingPrefs.java | 20 -- 28 files changed, 2767 deletions(-) delete mode 100644 quickstep/res/layout/fallback_search_input.xml delete mode 100644 quickstep/res/layout/search_edu_view.xml delete mode 100644 quickstep/res/layout/search_result_icon.xml delete mode 100644 quickstep/res/layout/search_result_icon_row.xml delete mode 100644 quickstep/res/layout/search_result_slice.xml delete mode 100644 quickstep/res/layout/search_result_small_icon_row.xml delete mode 100644 quickstep/res/layout/search_result_thumbnail.xml delete mode 100644 quickstep/res/layout/search_result_widget_live.xml delete mode 100644 quickstep/res/layout/search_result_widget_preview.xml delete mode 100644 quickstep/res/layout/search_section_title.xml delete mode 100644 quickstep/src/com/android/launcher3/search/DeviceSearchAdapterProvider.java delete mode 100644 quickstep/src/com/android/launcher3/search/DeviceSearchEdu.java delete mode 100644 quickstep/src/com/android/launcher3/search/FallbackSearchInputView.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchAdapterItem.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchResultIcon.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchResultIconRow.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchResultSmallIconRow.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchResultThumbnailView.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchResultWidget.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchResultWidgetPreview.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchSectionHeaderView.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchServicePipeline.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchSessionTracker.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchTargetHandler.java delete mode 100644 quickstep/src/com/android/launcher3/search/SearchTargetUtil.java diff --git a/quickstep/res/layout/fallback_search_input.xml b/quickstep/res/layout/fallback_search_input.xml deleted file mode 100644 index 0fb2924d96..0000000000 --- a/quickstep/res/layout/fallback_search_input.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - \ No newline at end of file diff --git a/quickstep/res/layout/search_edu_view.xml b/quickstep/res/layout/search_edu_view.xml deleted file mode 100644 index d89f5c7fb9..0000000000 --- a/quickstep/res/layout/search_edu_view.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - -