diff --git a/Android.bp b/Android.bp index df0a96fe4e..7e6a565f46 100644 --- a/Android.bp +++ b/Android.bp @@ -115,6 +115,9 @@ android_library { manifest: "AndroidManifest-common.xml", sdk_version: "current", min_sdk_version: "26", + lint: { + baseline_filename: "lint-baseline-res-lib.xml", + }, } // @@ -127,6 +130,9 @@ android_library { sdk_version: "current", min_sdk_version: "26", manifest: "AndroidManifest-common.xml", + lint: { + baseline_filename: "lint-baseline-common-deps-lib.xml", + }, } // @@ -171,6 +177,9 @@ android_app { additional_manifests: [ "AndroidManifest-common.xml", ], + lint: { + baseline_filename: "lint-baseline-launcher3.xml", + }, } // Library with all the dependencies for building quickstep @@ -236,5 +245,8 @@ android_library { "AndroidManifest-common.xml", ], min_sdk_version: "29", + lint: { + baseline_filename: "lint-baseline-go-res-lib.xml", + }, } diff --git a/lint-baseline-common-deps-lib.xml b/lint-baseline-common-deps-lib.xml new file mode 100644 index 0000000000..e52f8fbc70 --- /dev/null +++ b/lint-baseline-common-deps-lib.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/lint-baseline-go-res-lib.xml b/lint-baseline-go-res-lib.xml new file mode 100644 index 0000000000..c5669f2a61 --- /dev/null +++ b/lint-baseline-go-res-lib.xml @@ -0,0 +1,576 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lint-baseline-launcher3.xml b/lint-baseline-launcher3.xml new file mode 100644 index 0000000000..469ad942d9 --- /dev/null +++ b/lint-baseline-launcher3.xml @@ -0,0 +1,576 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lint-baseline-res-lib.xml b/lint-baseline-res-lib.xml new file mode 100644 index 0000000000..e52f8fbc70 --- /dev/null +++ b/lint-baseline-res-lib.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/quickstep/res/layout/taskbar.xml b/quickstep/res/layout/taskbar.xml index 84e23043b0..732222ade8 100644 --- a/quickstep/res/layout/taskbar.xml +++ b/quickstep/res/layout/taskbar.xml @@ -24,7 +24,6 @@ android:id="@+id/taskbar_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="@color/taskbar_background" android:gravity="center"/> \ No newline at end of file diff --git a/quickstep/res/layout/taskbar_divider.xml b/quickstep/res/layout/taskbar_divider.xml deleted file mode 100644 index 87649f752e..0000000000 --- a/quickstep/res/layout/taskbar_divider.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - \ No newline at end of file diff --git a/quickstep/res/values/colors.xml b/quickstep/res/values/colors.xml index 54730f100e..3bc8ddc0a8 100644 --- a/quickstep/res/values/colors.xml +++ b/quickstep/res/values/colors.xml @@ -27,5 +27,4 @@ #101010 - #C0C0C0 \ No newline at end of file diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 3e6c78f4de..99be50295d 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -134,7 +134,5 @@ 54dp 8dp - 1dp - 32dp 16dp diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 4415b516f1..0524b213b2 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -108,6 +108,7 @@ public abstract class BaseQuickstepLauncher extends Launcher SysUINavigationMode.INSTANCE.get(this).removeModeChangeListener(this); if (mTaskbarController != null) { mTaskbarController.cleanup(); + mTaskbarController = null; } super.onDestroy(); diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduController.java index 4451e7a6c1..a6844e48b7 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduController.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduController.java @@ -89,7 +89,7 @@ public class HotseatEduController { ArrayList putIntoFolder = new ArrayList<>(); //separate folders and items that can get in folders - for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) { + for (int i = 0; i < mLauncher.getDeviceProfile().numShownHotseatIcons; i++) { View view = mHotseat.getChildAt(i, 0); if (view == null) continue; ItemInfo info = (ItemInfo) view.getTag(); @@ -188,7 +188,7 @@ public class HotseatEduController { .getInt(LauncherSettings.Settings.EXTRA_VALUE); mNewScreens = IntArray.wrap(pageId); } - for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) { + for (int i = 0; i < mLauncher.getDeviceProfile().numShownHotseatIcons; i++) { View child = mHotseat.getChildAt(i, 0); if (child == null || child.getTag() == null) continue; ItemInfo tag = (ItemInfo) child.getTag(); @@ -224,7 +224,7 @@ public class HotseatEduController { void showDimissTip() { if (mHotseat.getShortcutsAndWidgets().getChildCount() - < mLauncher.getDeviceProfile().inv.numHotseatIcons) { + < mLauncher.getDeviceProfile().numShownHotseatIcons) { Snackbar.show(mLauncher, R.string.hotseat_tip_gaps_filled, R.string.hotseat_prediction_settings, null, () -> mLauncher.startActivity(getSettingsIntent())); diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java index c3677ea41e..a2ed21143c 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduDialog.java @@ -88,7 +88,7 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable Rect padding = grid.getHotseatLayoutPadding(); mSampleHotseat.getLayoutParams().height = grid.cellHeightPx; - mSampleHotseat.setGridSize(grid.inv.numHotseatIcons, 1); + mSampleHotseat.setGridSize(grid.numShownHotseatIcons, 1); mSampleHotseat.setPadding(padding.left, 0, padding.right, 0); Button turnOnBtn = findViewById(R.id.turn_predictions_on); @@ -178,7 +178,7 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable } private void populatePreview(List predictions) { - for (int i = 0; i < mLauncher.getDeviceProfile().inv.numHotseatIcons; i++) { + for (int i = 0; i < mLauncher.getDeviceProfile().numShownHotseatIcons; i++) { WorkspaceItemInfo info = predictions.get(i); PredictedAppIcon icon = PredictedAppIcon.createIcon(mSampleHotseat, info); icon.setEnabled(false); @@ -194,7 +194,7 @@ public class HotseatEduDialog extends AbstractSlideInView implements Insettable */ public void show(List predictions) { if (getParent() != null - || predictions.size() < mLauncher.getDeviceProfile().inv.numHotseatIcons + || predictions.size() < mLauncher.getDeviceProfile().numShownHotseatIcons || mHotseatEduController == null) { return; } diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index f297343552..67ed5fb5e5 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -33,10 +33,10 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.DragSource; import com.android.launcher3.DropTarget; import com.android.launcher3.Hotseat; -import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; import com.android.launcher3.anim.AnimationSuccessListener; @@ -68,7 +68,7 @@ import java.util.stream.Collectors; * pinning of predicted apps and manages replacement of predicted apps with user drag. */ public class HotseatPredictionController implements DragController.DragListener, - SystemShortcut.Factory, InvariantDeviceProfile.OnIDPChangeListener, + SystemShortcut.Factory, DeviceProfile.OnDeviceProfileChangeListener, DragSource, ViewGroup.OnHierarchyChangeListener { private static final int FLAG_UPDATE_PAUSED = 1 << 0; @@ -115,10 +115,10 @@ public class HotseatPredictionController implements DragController.DragListener, public HotseatPredictionController(QuickstepLauncher launcher) { mLauncher = launcher; mHotseat = launcher.getHotseat(); - mHotSeatItemsCount = mLauncher.getDeviceProfile().inv.numHotseatIcons; + mHotSeatItemsCount = mLauncher.getDeviceProfile().numShownHotseatIcons; mLauncher.getDragController().addDragListener(this); - launcher.getDeviceProfile().inv.addOnChangeListener(this); + launcher.addOnDeviceProfileChangeListener(this); mHotseat.getShortcutsAndWidgets().setOnHierarchyChangeListener(this); } @@ -281,7 +281,7 @@ public class HotseatPredictionController implements DragController.DragListener, * Unregisters callbacks and frees resources */ public void destroy() { - mLauncher.getDeviceProfile().inv.removeOnChangeListener(this); + mLauncher.removeOnDeviceProfileChangeListener(this); } /** @@ -446,8 +446,8 @@ public class HotseatPredictionController implements DragController.DragListener, } @Override - public void onIdpChanged(int changeFlags, InvariantDeviceProfile profile) { - this.mHotSeatItemsCount = profile.numHotseatIcons; + public void onDeviceProfileChanged(DeviceProfile profile) { + this.mHotSeatItemsCount = profile.numShownHotseatIcons; } @Override diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatRestoreHelper.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatRestoreHelper.java index 90f762e24c..4956fa1b86 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatRestoreHelper.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatRestoreHelper.java @@ -44,7 +44,7 @@ public class HotseatRestoreHelper { .getBinder(LauncherSettings.Settings.EXTRA_VALUE)) { InvariantDeviceProfile idp = LauncherAppState.getIDP(context); GridBackupTable backupTable = new GridBackupTable(context, - transaction.getDb(), idp.numHotseatIcons, idp.numColumns, + transaction.getDb(), idp.numDatabaseHotseatIcons, idp.numColumns, idp.numRows); backupTable.createCustomBackupTable(HYBRID_HOTSEAT_BACKUP_TABLE); transaction.commit(); @@ -69,7 +69,7 @@ public class HotseatRestoreHelper { } InvariantDeviceProfile idp = LauncherAppState.getIDP(context); GridBackupTable backupTable = new GridBackupTable(context, - transaction.getDb(), idp.numHotseatIcons, idp.numColumns, + transaction.getDb(), idp.numDatabaseHotseatIcons, idp.numColumns, idp.numRows); backupTable.restoreFromCustomBackupTable(HYBRID_HOTSEAT_BACKUP_TABLE, true); transaction.commit(); diff --git a/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java b/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java index df3657d01d..8c6887250e 100644 --- a/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java +++ b/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java @@ -111,7 +111,7 @@ public class QuickstepModelDelegate extends ModelDelegate implements OnIDPChange mDataModel.extraItems.put(CONTAINER_PREDICTION, mAllAppsState.items); WorkspaceItemFactory hotseatFactory = - new WorkspaceItemFactory(mApp, ums, pinnedShortcuts, mIDP.numHotseatIcons); + new WorkspaceItemFactory(mApp, ums, pinnedShortcuts, mIDP.numDatabaseHotseatIcons); mHotseatState.items.setItems( mHotseatState.storage.read(mApp.getContext(), hotseatFactory, ums.allUsers::get)); mDataModel.extraItems.put(CONTAINER_HOTSEAT_PREDICTION, mHotseatState.items); @@ -211,7 +211,7 @@ public class QuickstepModelDelegate extends ModelDelegate implements OnIDPChange registerPredictor(mHotseatState, apm.createAppPredictionSession( new AppPredictionContext.Builder(context) .setUiSurface("hotseat") - .setPredictedTargetCount(mIDP.numHotseatIcons) + .setPredictedTargetCount(mIDP.numDatabaseHotseatIcons) .setExtras(convertDataModelToAppTargetBundle(context, mDataModel)) .build())); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarAnimationController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarAnimationController.java index 7c54e2d6b9..46e4506f1f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarAnimationController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarAnimationController.java @@ -50,6 +50,10 @@ public class TaskbarAnimationController { private final AnimatedFloat mTaskbarScaleForLauncherState = new AnimatedFloat( this::updateScale); + // TranslationY. + private final AnimatedFloat mTaskbarTranslationYForLauncherState = new AnimatedFloat( + this::updateTranslationY); + public TaskbarAnimationController(BaseQuickstepLauncher launcher, TaskbarController.TaskbarAnimationControllerCallbacks taskbarCallbacks) { mLauncher = launcher; @@ -81,6 +85,10 @@ public class TaskbarAnimationController { return mTaskbarScaleForLauncherState; } + protected AnimatedFloat getTaskbarTranslationYForLauncherState() { + return mTaskbarTranslationYForLauncherState; + } + protected Animator createAnimToBackgroundAlpha(float toAlpha, long duration) { return mTaskbarBackgroundAlpha.animateToValue(mTaskbarBackgroundAlpha.value, toAlpha) .setDuration(duration); @@ -95,6 +103,7 @@ public class TaskbarAnimationController { mTaskbarCallbacks.updateTaskbarBackgroundAlpha(mTaskbarBackgroundAlpha.value); updateVisibilityAlpha(); updateScale(); + updateTranslationY(); } private void updateVisibilityAlpha() { @@ -120,6 +129,15 @@ public class TaskbarAnimationController { mTaskbarCallbacks.updateTaskbarScale(scale); } + private void updateTranslationY() { + // We use mTaskbarBackgroundAlpha as a proxy for whether Launcher is resumed/paused, the + // assumption being that Taskbar should always be at translationY 0f regardless of the + // current LauncherState if Launcher is paused. + float translationY = mTaskbarTranslationYForLauncherState.value; + translationY = Utilities.mapRange(mTaskbarBackgroundAlpha.value, translationY, 0f); + mTaskbarCallbacks.updateTaskbarTranslationY(translationY); + } + private void setNavBarButtonAlpha(float navBarAlpha) { SystemUiProxy.INSTANCE.get(mLauncher).setNavBarButtonAlpha(navBarAlpha, false); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarContainerView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarContainerView.java index ccf6b41e5d..621bba7e85 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarContainerView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarContainerView.java @@ -19,6 +19,8 @@ import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsI import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION; import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; @@ -38,6 +40,7 @@ public class TaskbarContainerView extends BaseDragLayer private final int[] mTempLoc = new int[2]; private final int mFolderMargin; + private final Paint mTaskbarBackgroundPaint; // Initialized in TaskbarController constructor. private TaskbarController.TaskbarContainerViewCallbacks mControllerCallbacks; @@ -63,6 +66,8 @@ public class TaskbarContainerView extends BaseDragLayer int defStyleAttr, int defStyleRes) { super(context, attrs, 1 /* alphaChannelCount */); mFolderMargin = getResources().getDimensionPixelSize(R.dimen.taskbar_folder_margin); + mTaskbarBackgroundPaint = new Paint(); + mTaskbarBackgroundPaint.setColor(getResources().getColor(R.color.taskbar_background)); } protected void construct(TaskbarController.TaskbarContainerViewCallbacks callbacks) { @@ -97,11 +102,14 @@ public class TaskbarContainerView extends BaseDragLayer // mTaskbarView is, since its position never changes and insets rather than overlays. int[] loc = mTempLoc; float scale = mTaskbarView.getScaleX(); + float translationY = mTaskbarView.getTranslationY(); mTaskbarView.setScaleX(1); mTaskbarView.setScaleY(1); + mTaskbarView.setTranslationY(0); mTaskbarView.getLocationInWindow(loc); mTaskbarView.setScaleX(scale); mTaskbarView.setScaleY(scale); + mTaskbarView.setTranslationY(translationY); insetsInfo.contentInsets.left = loc[0]; insetsInfo.contentInsets.top = loc[1]; insetsInfo.contentInsets.right = getWidth() - (loc[0] + mTaskbarView.getWidth()); @@ -153,4 +161,20 @@ public class TaskbarContainerView extends BaseDragLayer protected TaskbarActivityContext getTaskbarActivityContext() { return mActivity; } + + @Override + protected void dispatchDraw(Canvas canvas) { + canvas.drawRect(0, canvas.getHeight() - mTaskbarView.getHeight(), canvas.getWidth(), + canvas.getHeight(), mTaskbarBackgroundPaint); + super.dispatchDraw(canvas); + } + + /** + * Sets the alpha of the background color behind all the Taskbar contents. + * @param alpha 0 is fully transparent, 1 is fully opaque. + */ + protected void setTaskbarBackgroundAlpha(float alpha) { + mTaskbarBackgroundPaint.setAlpha((int) (alpha * 255)); + invalidate(); + } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java index 559ede1956..c93de00f4f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java @@ -25,7 +25,6 @@ import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTR import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.app.ActivityOptions; -import android.content.ComponentName; import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.Rect; @@ -56,9 +55,6 @@ import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.WindowManagerWrapper; -import java.util.ArrayList; -import java.util.List; - /** * Interfaces with Launcher/WindowManager/SystemUI to determine what to show in TaskbarView. */ @@ -76,17 +72,11 @@ public class TaskbarController { private final TaskbarStateHandler mTaskbarStateHandler; private final TaskbarAnimationController mTaskbarAnimationController; private final TaskbarHotseatController mHotseatController; - private final TaskbarRecentsController mRecentsController; private final TaskbarDragController mDragController; // Initialized in init(). private WindowManager.LayoutParams mWindowLayoutParams; - // Contains all loaded Tasks, not yet deduped from Hotseat items. - private List mLatestLoadedRecentTasks; - // Contains all loaded Hotseat items. - private ItemInfo[] mLatestLoadedHotseatItems; - private @Nullable Animator mAnimator; private boolean mIsAnimatingToLauncher; @@ -106,8 +96,6 @@ public class TaskbarController { createTaskbarAnimationControllerCallbacks()); mHotseatController = new TaskbarHotseatController(mLauncher, createTaskbarHotseatControllerCallbacks()); - mRecentsController = new TaskbarRecentsController(mLauncher, - createTaskbarRecentsControllerCallbacks()); mDragController = new TaskbarDragController(mLauncher); } @@ -115,7 +103,7 @@ public class TaskbarController { return new TaskbarAnimationControllerCallbacks() { @Override public void updateTaskbarBackgroundAlpha(float alpha) { - mTaskbarViewInApp.setBackgroundAlpha(alpha); + mTaskbarContainerView.setTaskbarBackgroundAlpha(alpha); } @Override @@ -129,6 +117,18 @@ public class TaskbarController { mTaskbarViewInApp.setScaleX(scale); mTaskbarViewInApp.setScaleY(scale); } + + @Override + public void updateTaskbarTranslationY(float translationY) { + if (translationY < 0) { + // Resize to accommodate the max translation we'll reach. + setTaskbarWindowHeight(mTaskbarSize.y + + mLauncher.getHotseat().getTaskbarOffsetY()); + } else { + setTaskbarWindowHeight(mTaskbarSize.y); + } + mTaskbarViewInApp.setTranslationY(translationY); + } }; } @@ -220,24 +220,6 @@ public class TaskbarController { @Override public void updateHotseatItems(ItemInfo[] hotseatItemInfos) { mTaskbarViewInApp.updateHotseatItems(hotseatItemInfos); - mLatestLoadedHotseatItems = hotseatItemInfos; - dedupeAndUpdateRecentItems(); - } - }; - } - - private TaskbarRecentsControllerCallbacks createTaskbarRecentsControllerCallbacks() { - return new TaskbarRecentsControllerCallbacks() { - @Override - public void updateRecentItems(ArrayList recentTasks) { - mLatestLoadedRecentTasks = recentTasks; - dedupeAndUpdateRecentItems(); - } - - @Override - public void updateRecentTaskAtIndex(int taskIndex, Task task) { - mTaskbarViewInApp.updateRecentTaskAtIndex(taskIndex, task); - mTaskbarViewOnHome.updateRecentTaskAtIndex(taskIndex, task); } }; } @@ -246,16 +228,13 @@ public class TaskbarController { * Initializes the Taskbar, including adding it to the screen. */ public void init() { - mTaskbarViewInApp.init(mHotseatController.getNumHotseatIcons(), - mRecentsController.getNumRecentIcons()); - mTaskbarViewOnHome.init(mHotseatController.getNumHotseatIcons(), - mRecentsController.getNumRecentIcons()); + mTaskbarViewInApp.init(mHotseatController.getNumHotseatIcons()); + mTaskbarViewOnHome.init(mHotseatController.getNumHotseatIcons()); mTaskbarContainerView.init(mTaskbarViewInApp); addToWindowManager(); mTaskbarStateHandler.setTaskbarCallbacks(createTaskbarStateHandlerCallbacks()); mTaskbarAnimationController.init(); mHotseatController.init(); - mRecentsController.init(); setWhichTaskbarViewIsVisible(mLauncher.hasBeenResumed() ? mTaskbarViewOnHome @@ -273,6 +252,11 @@ public class TaskbarController { public AnimatedFloat getScaleTarget() { return mTaskbarAnimationController.getTaskbarScaleForLauncherState(); } + + @Override + public AnimatedFloat getTranslationYTarget() { + return mTaskbarAnimationController.getTaskbarTranslationYForLauncherState(); + } }; } @@ -292,7 +276,6 @@ public class TaskbarController { mTaskbarStateHandler.setTaskbarCallbacks(null); mTaskbarAnimationController.cleanup(); mHotseatController.cleanup(); - mRecentsController.cleanup(); setWhichTaskbarViewIsVisible(null); } @@ -425,53 +408,6 @@ public class TaskbarController { return mTaskbarViewInApp.isDraggingItem() || mTaskbarViewOnHome.isDraggingItem(); } - private void dedupeAndUpdateRecentItems() { - if (mLatestLoadedRecentTasks == null || mLatestLoadedHotseatItems == null) { - return; - } - - final int numRecentIcons = mRecentsController.getNumRecentIcons(); - - // From most recent to least recently opened. - List dedupedTasksInDescendingOrder = new ArrayList<>(); - for (int i = mLatestLoadedRecentTasks.size() - 1; i >= 0; i--) { - Task task = mLatestLoadedRecentTasks.get(i); - boolean isTaskInHotseat = false; - for (ItemInfo hotseatItem : mLatestLoadedHotseatItems) { - if (hotseatItem == null) { - continue; - } - ComponentName hotseatActivity = hotseatItem.getTargetComponent(); - if (hotseatActivity != null && task.key.sourceComponent.getPackageName() - .equals(hotseatActivity.getPackageName())) { - isTaskInHotseat = true; - break; - } - } - if (!isTaskInHotseat) { - dedupedTasksInDescendingOrder.add(task); - if (dedupedTasksInDescendingOrder.size() == numRecentIcons) { - break; - } - } - } - - // TaskbarView expects an array of all the recent tasks to show, in the order to show them. - // So we create an array of the proper size, then fill it in such that the most recent items - // are at the end. If there aren't enough elements to fill the array, leave them null. - Task[] tasksArray = new Task[numRecentIcons]; - for (int i = 0; i < tasksArray.length; i++) { - Task task = i >= dedupedTasksInDescendingOrder.size() - ? null - : dedupedTasksInDescendingOrder.get(i); - tasksArray[tasksArray.length - 1 - i] = task; - } - - mTaskbarViewInApp.updateRecentTasks(tasksArray); - mTaskbarViewOnHome.updateRecentTasks(tasksArray); - mRecentsController.loadIconsForTasks(tasksArray); - } - /** * @return Whether the given View is in the same window as Taskbar. */ @@ -487,13 +423,15 @@ public class TaskbarController { Rect hotseatBounds = new Rect(); DeviceProfile grid = mLauncher.getDeviceProfile(); int hotseatHeight = grid.workspacePadding.bottom + grid.taskbarSize; - int hotseatTopDiff = hotseatHeight - grid.taskbarSize; + int taskbarOffset = mLauncher.getHotseat().getTaskbarOffsetY(); + int hotseatTopDiff = hotseatHeight - grid.taskbarSize - taskbarOffset; + int hotseatBottomDiff = taskbarOffset; mTaskbarViewOnHome.getHotseatBounds().roundOut(hotseatBounds); mLauncher.getHotseat().setPadding(hotseatBounds.left, hotseatBounds.top + hotseatTopDiff, mTaskbarViewOnHome.getWidth() - hotseatBounds.right, - mTaskbarViewOnHome.getHeight() - hotseatBounds.bottom); + mTaskbarViewOnHome.getHeight() - hotseatBounds.bottom + hotseatBottomDiff); } private void setWhichTaskbarViewIsVisible(@Nullable TaskbarView visibleTaskbar) { @@ -519,13 +457,15 @@ public class TaskbarController { * Updates the TaskbarContainer to MATCH_PARENT vs original Taskbar size. */ private void setTaskbarWindowFullscreen(boolean fullscreen) { - if (fullscreen) { - mWindowLayoutParams.width = MATCH_PARENT; - mWindowLayoutParams.height = MATCH_PARENT; - } else { - mWindowLayoutParams.width = mTaskbarSize.x; - mWindowLayoutParams.height = mTaskbarSize.y; - } + setTaskbarWindowHeight(fullscreen ? MATCH_PARENT : mTaskbarSize.y); + } + + /** + * Updates the TaskbarContainer height (pass mTaskbarSize.y to reset). + */ + private void setTaskbarWindowHeight(int height) { + mWindowLayoutParams.width = mTaskbarSize.x; + mWindowLayoutParams.height = height; mWindowManager.updateViewLayout(mTaskbarContainerView, mWindowLayoutParams); } @@ -535,6 +475,7 @@ public class TaskbarController { protected interface TaskbarStateHandlerCallbacks { AnimatedFloat getAlphaTarget(); AnimatedFloat getScaleTarget(); + AnimatedFloat getTranslationYTarget(); } /** @@ -545,6 +486,7 @@ public class TaskbarController { void updateTaskbarBackgroundAlpha(float alpha); void updateTaskbarVisibilityAlpha(float alpha); void updateTaskbarScale(float scale); + void updateTaskbarTranslationY(float translationY); } /** @@ -573,12 +515,4 @@ public class TaskbarController { protected interface TaskbarHotseatControllerCallbacks { void updateHotseatItems(ItemInfo[] hotseatItemInfos); } - - /** - * Contains methods that TaskbarRecentsController can call to interface with TaskbarController. - */ - protected interface TaskbarRecentsControllerCallbacks { - void updateRecentItems(ArrayList recentTasks); - void updateRecentTaskAtIndex(int taskIndex, Task task); - } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java index b1bafdb879..68829cd0fb 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java @@ -52,7 +52,7 @@ public class TaskbarHotseatController { mLauncher = launcher; mHotseat = mLauncher.getHotseat(); mTaskbarCallbacks = taskbarCallbacks; - mNumHotseatIcons = mLauncher.getDeviceProfile().inv.numHotseatIcons; + mNumHotseatIcons = mLauncher.getDeviceProfile().numShownHotseatIcons; } protected void init() { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java deleted file mode 100644 index 4256d2bd88..0000000000 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2021 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.taskbar; - -import com.android.launcher3.BaseQuickstepLauncher; -import com.android.quickstep.RecentsModel; -import com.android.quickstep.util.CancellableTask; -import com.android.systemui.shared.recents.model.Task; -import com.android.systemui.shared.system.TaskStackChangeListener; -import com.android.systemui.shared.system.TaskStackChangeListeners; - -import java.util.ArrayList; - -/** - * Works with TaskbarController to update the TaskbarView's Recent items. - */ -public class TaskbarRecentsController { - - private final int mNumRecentIcons = 2; - private final BaseQuickstepLauncher mLauncher; - private final TaskbarController.TaskbarRecentsControllerCallbacks mTaskbarCallbacks; - private final RecentsModel mRecentsModel; - - private final TaskStackChangeListener mTaskStackChangeListener = new TaskStackChangeListener() { - @Override - public void onTaskStackChanged() { - reloadRecentTasksIfNeeded(); - } - }; - - // TODO: add TaskbarVisualsChangedListener as well (for calendar/clock?) - - // Used to keep track of the last requested task list id, so that we do not request to load the - // tasks again if we have already requested it and the task list has not changed - private int mTaskListChangeId = -1; - - // 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; - mTaskbarCallbacks = taskbarCallbacks; - mRecentsModel = RecentsModel.INSTANCE.get(mLauncher); - } - - protected void init() { - mIsAlive = true; - TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackChangeListener); - reloadRecentTasksIfNeeded(); - } - - protected void cleanup() { - mIsAlive = false; - TaskStackChangeListeners.getInstance().unregisterTaskStackListener( - mTaskStackChangeListener); - cancelAllPendingIconLoadTasks(); - } - - private void reloadRecentTasksIfNeeded() { - if (!mRecentsModel.isTaskListValid(mTaskListChangeId)) { - mTaskListChangeId = mRecentsModel.getTasks(this::onRecentTasksChanged); - } - } - - private void cancelAllPendingIconLoadTasks() { - for (int i = 0; i < mIconLoadRequests.length; i++) { - if (mIconLoadRequests[i] != null) { - mIconLoadRequests[i].cancel(); - } - mIconLoadRequests[i] = null; - } - } - - private void onRecentTasksChanged(ArrayList tasks) { - if (mIsAlive) { - mTaskbarCallbacks.updateRecentItems(tasks); - } - } - - /** - * For each Task, loads its icon from the cache in the background, then calls - * {@link TaskbarController.TaskbarRecentsControllerCallbacks#updateRecentTaskAtIndex}. - */ - protected void loadIconsForTasks(Task[] tasks) { - cancelAllPendingIconLoadTasks(); - for (int i = 0; i < tasks.length; i++) { - Task task = tasks[i]; - if (task == null) { - continue; - } - final int taskIndex = i; - mIconLoadRequests[i] = mRecentsModel.getIconCache().updateIconInBackground( - task, updatedTask -> onTaskIconLoaded(task, taskIndex)); - } - } - - private void onTaskIconLoaded(Task task, int taskIndex) { - mTaskbarCallbacks.updateRecentTaskAtIndex(taskIndex, task); - } - - protected int getNumRecentIcons() { - return mNumRecentIcons; - } -} diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java index 9fc7d995a7..6ea51fa5eb 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java @@ -16,6 +16,7 @@ package com.android.launcher3.taskbar; import static com.android.launcher3.LauncherState.TASKBAR; +import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; import static com.android.launcher3.anim.Interpolators.LINEAR; import androidx.annotation.Nullable; @@ -54,9 +55,11 @@ public class TaskbarStateHandler implements StateManager.StateHandler { if (getLayoutTransition() == mLayoutTransition) { @@ -165,7 +146,6 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa endAllLayoutTransitionAnimators(); setLayoutTransition(null); removeAllViews(); - mHotseatRecentsDivider = null; } private void endAllLayoutTransitionAnimators() { @@ -176,14 +156,6 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa mLayoutTransition.getAnimator(LayoutTransition.DISAPPEARING).end(); } - /** - * Sets the alpha of the background color behind all the Taskbar contents. - * @param alpha 0 is fully transparent, 1 is fully opaque. - */ - public void setBackgroundAlpha(float alpha) { - mBackgroundDrawable.setAlpha((int) (alpha * 255)); - } - /** * Inflates/binds the Hotseat views to show in the Taskbar given their ItemInfos. */ @@ -248,8 +220,6 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa } updateHotseatItemVisibility(hotseatView); } - - updateHotseatRecentsDividerVisibility(); } protected void updateHotseatItemsVisibility() { @@ -273,95 +243,6 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa } } - private View addDivider(int dividerIndex) { - View divider = inflate(R.layout.taskbar_divider); - LayoutParams lp = new LayoutParams(mDividerWidth, mDividerHeight); - lp.setMargins(mItemMarginLeftRight, 0, mItemMarginLeftRight, 0); - divider.setScaleX(mNonIconScale); - divider.setScaleY(mNonIconScale); - addView(divider, dividerIndex, lp); - return divider; - } - - /** - * Inflates/binds the Recents items to show in the Taskbar given their Tasks. - */ - protected void updateRecentTasks(Task[] tasks) { - for (int i = 0; i < tasks.length; i++) { - Task task = tasks[i]; - int recentsIndex = mRecentsStartIndex + i; - View recentsView = getChildAt(recentsIndex); - - // Inflate empty icon Views. - if (recentsView == null) { - BubbleTextView btv = (BubbleTextView) inflate(R.layout.taskbar_app_icon); - LayoutParams lp = new LayoutParams(btv.getIconSize(), btv.getIconSize()); - lp.setMargins(mItemMarginLeftRight, 0, mItemMarginLeftRight, 0); - recentsView = btv; - addView(recentsView, recentsIndex, lp); - } - - // Apply the Task, or hide the view if there is none for a given index. - if (recentsView instanceof BubbleTextView && task != null) { - applyTaskToBubbleTextView((BubbleTextView) recentsView, task); - recentsView.setVisibility(VISIBLE); - recentsView.setOnClickListener(mControllerCallbacks.getItemOnClickListener()); - recentsView.setOnLongClickListener( - mControllerCallbacks.getItemOnLongClickListener()); - } else { - recentsView.setVisibility(GONE); - recentsView.setOnClickListener(null); - recentsView.setOnLongClickListener(null); - } - } - - updateHotseatRecentsDividerVisibility(); - } - - private void applyTaskToBubbleTextView(BubbleTextView btv, Task task) { - if (task.icon != null) { - Drawable icon = task.icon.getConstantState().newDrawable().mutate(); - btv.applyIconAndLabel(icon, task.titleDescription); - } - btv.setTag(task); - } - - protected void updateRecentTaskAtIndex(int taskIndex, Task task) { - View taskView = getChildAt(mRecentsStartIndex + taskIndex); - if (taskView instanceof BubbleTextView) { - applyTaskToBubbleTextView((BubbleTextView) taskView, task); - } - } - - /** - * Make the divider VISIBLE between the Hotseat and Recents if there is at least one icon in - * each, otherwise make it GONE. - */ - private void updateHotseatRecentsDividerVisibility() { - if (mHotseatRecentsDivider == null) { - return; - } - - boolean hasAtLeastOneHotseatItem = false; - for (int i = mHotseatStartIndex; i <= mHotseatEndIndex; i++) { - if (getChildAt(i).getVisibility() != GONE) { - hasAtLeastOneHotseatItem = true; - break; - } - } - - boolean hasAtLeastOneRecentItem = false; - for (int i = mRecentsStartIndex; i <= mRecentsEndIndex; i++) { - if (getChildAt(i).getVisibility() != GONE) { - hasAtLeastOneRecentItem = true; - break; - } - } - - mHotseatRecentsDivider.setVisibility(hasAtLeastOneHotseatItem && hasAtLeastOneRecentItem - ? VISIBLE : GONE); - } - @Override public boolean onTouchEvent(MotionEvent event) { boolean handled = delegateTouchIfNecessary(event); diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java index 6cdeb0f74b..30c07b050f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -87,6 +87,11 @@ public class OverviewState extends LauncherState { return 1f; } + @Override + public float getTaskbarTranslationY(Launcher launcher) { + return 0f; + } + @Override public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) { return new PageAlphaProvider(DEACCEL_2) { diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 2a903eb9fc..c547d00250 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -801,11 +801,9 @@ public abstract class AbsSwipeUpHandler, } } if (mParallelRunningAnim != null) { - if (cancel) { - mParallelRunningAnim.cancel(); - } else { - mParallelRunningAnim.end(); - } + // Unlike the above animation, the parallel animation won't have anything to take up + // the work if it's canceled, so just end it instead. + mParallelRunningAnim.end(); } } diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java index e13d1a4511..8168e88e57 100644 --- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java +++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java @@ -27,6 +27,7 @@ import android.view.MotionEvent; import androidx.annotation.Nullable; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.touch.PagedOrientationHandler; import com.android.quickstep.fallback.RecentsState; import com.android.quickstep.util.ActivityInitListener; @@ -139,7 +140,25 @@ public final class FallbackActivityInterface extends @Override public void onExitOverview(RotationTouchHelper deviceState, Runnable exitRunnable) { - // no-op, fake landscape not supported for 3P + final StateManager stateManager = getCreatedActivity().getStateManager(); + if (stateManager.getState() == HOME) { + exitRunnable.run(); + notifyRecentsOfOrientation(deviceState); + return; + } + + stateManager.addStateListener( + new StateManager.StateListener() { + @Override + public void onStateTransitionComplete(RecentsState toState) { + // Are we going from Recents to Workspace? + if (toState == HOME) { + exitRunnable.run(); + notifyRecentsOfOrientation(deviceState); + stateManager.removeStateListener(this); + } + } + }); } @Override diff --git a/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java b/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java index b336d2fcea..4c10822fb8 100644 --- a/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java +++ b/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java @@ -149,6 +149,7 @@ public class SettingsChangeLogger implements SharedPreferences prefs = getPrefs(mContext); StatsLogManager.LauncherEvent gridSizeChangedEvent = null; + // TODO(b/184981523): This doesn't work for 2-panel grid, which has 6 hotseat icons switch (prefs.getInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, -1)) { case 5: gridSizeChangedEvent = LAUNCHER_GRID_SIZE_5; diff --git a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java index 0436a1c53a..3b4fd31fa5 100644 --- a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java +++ b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java @@ -15,8 +15,6 @@ */ package com.android.quickstep.util; -import static com.android.systemui.shared.system.TransactionCompat.deferTransactionUntil; - import android.annotation.TargetApi; import android.os.Build; import android.os.Handler; @@ -90,11 +88,10 @@ public class SurfaceTransactionApplier extends ReleaseCheck { for (int i = params.length - 1; i >= 0; i--) { SurfaceParams surfaceParams = params[i]; if (surfaceParams.surface.isValid()) { - deferTransactionUntil(t, surfaceParams.surface, mBarrierSurfaceControl, frame); - surfaceParams.applyTo(t); + surfaceParams.applyTo(t); } } - t.apply(); + mTargetViewRootImpl.mergeWithNextTransaction(t, frame); Message.obtain(mApplyHandler, MSG_UPDATE_SEQUENCE_NUMBER, toApplySeqNo, 0) .sendToTarget(); }); diff --git a/res/drawable/ic_allapps_search.xml b/res/drawable/ic_allapps_search.xml index c0e20f1bb8..dbed824358 100644 --- a/res/drawable/ic_allapps_search.xml +++ b/res/drawable/ic_allapps_search.xml @@ -17,7 +17,8 @@ android:width="24dp" android:height="24dp" android:viewportHeight="24.0" - android:viewportWidth="24.0"> + android:viewportWidth="24.0" + android:autoMirrored="true"> diff --git a/res/layout/widgets_search_bar.xml b/res/layout/widgets_search_bar.xml index e3836df108..c3dd19e0bb 100644 --- a/res/layout/widgets_search_bar.xml +++ b/res/layout/widgets_search_bar.xml @@ -13,7 +13,9 @@ android:id="@+id/widgets_search_bar_edit_text" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="12dp" + android:paddingVertical="12dp" + android:paddingStart="12dp" + android:paddingEnd="0dp" android:drawablePadding="8dp" android:drawableStart="@drawable/ic_allapps_search" android:background="@null" @@ -21,6 +23,7 @@ android:maxLines="1" android:layout_weight="1" android:inputType="text" + android:imeOptions="actionSearch" android:textColor="?android:attr/textColorSecondary" android:textColorHint="?android:attr/textColorTertiary"/> @@ -28,7 +31,9 @@ android:id="@+id/widgets_search_cancel_button" android:layout_height="wrap_content" android:layout_width="wrap_content" - android:padding="8dp" + android:paddingVertical="12dp" + android:paddingStart="8dp" + android:paddingEnd="12dp" android:src="@drawable/ic_gm_close_24" android:background="?android:selectableItemBackground" android:layout_gravity="center" diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 381b0fef21..699c2e317f 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -175,6 +175,9 @@ + + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 51dddab6f7..638eec7426 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -140,6 +140,9 @@ 8dp 2dp + 120dp + 4dp + 0dp 0dp diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml index e4bea508b3..8195cc1997 100644 --- a/res/xml/launcher_preferences.xml +++ b/res/xml/launcher_preferences.xml @@ -22,14 +22,7 @@ android:key="pref_icon_badging" android:title="@string/notification_dots_title" android:persistent="false" - android:widgetLayout="@layout/notification_pref_warning" > - - - - - + android:widgetLayout="@layout/notification_pref_warning" />