Merge "Always draw background for task thumbnail" into sc-v2-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index b2c29b2..593bfd8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -49,13 +49,15 @@
public static final int FLAG_RESUMED = 1 << 0;
public static final int FLAG_RECENTS_ANIMATION_RUNNING = 1 << 1;
- public static final int FLAG_TRANSITION_STATE_START_STASHED = 1 << 2;
- public static final int FLAG_TRANSITION_STATE_COMMITTED_STASHED = 1 << 3;
+ public static final int FLAG_TRANSITION_STATE_RUNNING = 1 << 2;
+
+ /** Equivalent to an int with all 1s for binary operation purposes */
+ private static final int FLAGS_ALL = ~0;
private final AnimatedFloat mIconAlignmentForResumedState =
- new AnimatedFloat(this::onIconAlignmentRatioChanged);
+ new AnimatedFloat(this::onIconAlignmentRatioChangedForAppAndHomeTransition);
private final AnimatedFloat mIconAlignmentForGestureState =
- new AnimatedFloat(this::onIconAlignmentRatioChanged);
+ new AnimatedFloat(this::onIconAlignmentRatioChangedForAppAndHomeTransition);
private final AnimatedFloat mIconAlignmentForLauncherState =
new AnimatedFloat(this::onIconAlignmentRatioChangedForStateTransition);
@@ -64,8 +66,9 @@
private MultiValueAlpha.AlphaProperty mIconAlphaForHome;
private BaseQuickstepLauncher mLauncher;
- private int mPrevState;
+ private Integer mPrevState;
private int mState;
+ private LauncherState mLauncherState = LauncherState.NORMAL;
private boolean mIsAnimatingToLauncherViaGesture;
private boolean mIsAnimatingToLauncherViaResume;
@@ -75,15 +78,20 @@
@Override
public void onStateTransitionStart(LauncherState toState) {
- updateStateForFlag(FLAG_TRANSITION_STATE_START_STASHED,
- toState.isTaskbarStashed());
+ if (toState != mLauncherState) {
+ // Treat FLAG_TRANSITION_STATE_RUNNING as a changed flag even if a previous
+ // state transition was already running, so we update the new target.
+ mPrevState &= ~FLAG_TRANSITION_STATE_RUNNING;
+ mLauncherState = toState;
+ }
+ updateStateForFlag(FLAG_TRANSITION_STATE_RUNNING, true);
applyState();
}
@Override
public void onStateTransitionComplete(LauncherState finalState) {
- updateStateForFlag(FLAG_TRANSITION_STATE_COMMITTED_STASHED,
- finalState.isTaskbarStashed());
+ mLauncherState = finalState;
+ updateStateForFlag(FLAG_TRANSITION_STATE_RUNNING, false);
applyState();
}
};
@@ -100,7 +108,7 @@
(Consumer<Float>) alpha -> mLauncher.getHotseat().setIconsAlpha(alpha > 0 ? 0 : 1));
mIconAlignmentForResumedState.finishAnimation();
- onIconAlignmentRatioChanged();
+ onIconAlignmentRatioChangedForAppAndHomeTransition();
mLauncher.getStateManager().addStateListener(mStateListener);
}
@@ -121,9 +129,10 @@
// If going home, align the icons to hotseat
AnimatorSet animatorSet = new AnimatorSet();
+ // Update stashed flags first to ensure goingToUnstashedLauncherState() returns correctly.
TaskbarStashController stashController = mControllers.taskbarStashController;
stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE,
- toState.isTaskbarStashed());
+ toState.isTaskbarStashed(mLauncher));
stashController.updateStateForFlag(FLAG_IN_APP, false);
updateStateForFlag(FLAG_RECENTS_ANIMATION_RUNNING, true);
@@ -182,10 +191,11 @@
public Animator applyState(long duration, boolean start) {
Animator animator = null;
- if (mPrevState != mState) {
- int changedFlags = mPrevState ^ mState;
- animator = onStateChangeApplied(changedFlags, duration, start);
+ if (mPrevState == null || mPrevState != mState) {
+ // If this is our initial state, treat all flags as changed.
+ int changedFlags = mPrevState == null ? FLAGS_ALL : mPrevState ^ mState;
mPrevState = mState;
+ animator = onStateChangeApplied(changedFlags, duration, start);
}
return animator;
}
@@ -195,7 +205,8 @@
if (hasAnyFlag(changedFlags, FLAG_RESUMED)) {
boolean isResumed = isResumed();
ObjectAnimator anim = mIconAlignmentForResumedState
- .animateToValue(isResumed ? 1 : 0)
+ .animateToValue(isResumed && goingToUnstashedLauncherState()
+ ? 1 : 0)
.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
@@ -219,7 +230,8 @@
if (hasAnyFlag(changedFlags, FLAG_RECENTS_ANIMATION_RUNNING)) {
boolean isRecentsAnimationRunning = isRecentsAnimationRunning();
Animator animator = mIconAlignmentForGestureState
- .animateToValue(isRecentsAnimationRunning ? 1 : 0);
+ .animateToValue(isRecentsAnimationRunning && goingToUnstashedLauncherState()
+ ? 1 : 0);
if (isRecentsAnimationRunning) {
animator.setDuration(duration);
}
@@ -237,14 +249,21 @@
animatorSet.play(animator);
}
- if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_START_STASHED)) {
- playStateTransitionAnim(isTransitionStateStartStashed(), animatorSet, duration,
- false /* committed */);
+ if (hasAnyFlag(changedFlags, FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING)) {
+ boolean goingToLauncher = hasAnyFlag(FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING);
+ animatorSet.play(mTaskbarBackgroundAlpha.animateToValue(goingToLauncher ? 0 : 1)
+ .setDuration(duration));
}
- if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_COMMITTED_STASHED)) {
- playStateTransitionAnim(isTransitionStateCommittedStashed(), animatorSet, duration,
- true /* committed */);
+ if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_RUNNING)) {
+ boolean committed = !hasAnyFlag(FLAG_TRANSITION_STATE_RUNNING);
+ playStateTransitionAnim(animatorSet, duration, committed);
+
+ if (committed && mLauncherState == LauncherState.QUICK_SWITCH) {
+ // We're about to be paused, set immediately to ensure seamless handoff.
+ updateStateForFlag(FLAG_RESUMED, false);
+ applyState(0 /* duration */);
+ }
}
if (start) {
@@ -253,17 +272,24 @@
return animatorSet;
}
- private void playStateTransitionAnim(boolean isTransitionStateStashed,
- AnimatorSet animatorSet, long duration, boolean committed) {
+ /** Returns whether we're going to a state where taskbar icons should align with launcher. */
+ private boolean goingToUnstashedLauncherState() {
+ return !mControllers.taskbarStashController.isInStashedLauncherState();
+ }
+
+ private void playStateTransitionAnim(AnimatorSet animatorSet, long duration,
+ boolean committed) {
+ boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
+ float toAlignment = mLauncherState.isTaskbarAlignedWithHotseat(mLauncher) ? 1 : 0;
+
TaskbarStashController controller = mControllers.taskbarStashController;
- controller.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE,
- isTransitionStateStashed);
+ controller.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState);
Animator stashAnimator = controller.applyStateWithoutStart(duration);
if (stashAnimator != null) {
stashAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- if (isTransitionStateStashed && committed) {
+ if (isInStashedState && committed) {
// Reset hotseat alpha to default
mLauncher.getHotseat().setIconsAlpha(1);
}
@@ -271,14 +297,16 @@
@Override
public void onAnimationStart(Animator animation) {
- mIconAlphaForHome.setValue(mLauncher.getHotseat().getIconsAlpha());
+ if (mLauncher.getHotseat().getIconsAlpha() > 0) {
+ mIconAlphaForHome.setValue(mLauncher.getHotseat().getIconsAlpha());
+ }
}
});
animatorSet.play(stashAnimator);
- animatorSet.play(mIconAlignmentForLauncherState.animateToValue(
- getCurrentIconAlignmentRatioForLauncherState(),
- isTransitionStateStashed ? 0 : 1));
}
+
+ animatorSet.play(mIconAlignmentForLauncherState.animateToValue(toAlignment)
+ .setDuration(duration));
}
private boolean isResumed() {
@@ -289,20 +317,15 @@
return (mState & FLAG_RECENTS_ANIMATION_RUNNING) != 0;
}
- private boolean isTransitionStateStartStashed() {
- return (mState & FLAG_TRANSITION_STATE_START_STASHED) != 0;
- }
-
- private boolean isTransitionStateCommittedStashed() {
- return (mState & FLAG_TRANSITION_STATE_COMMITTED_STASHED) != 0;
- }
-
private void onIconAlignmentRatioChangedForStateTransition() {
+ if (!isResumed()) {
+ return;
+ }
onIconAlignmentRatioChanged(this::getCurrentIconAlignmentRatioForLauncherState);
}
- private void onIconAlignmentRatioChanged() {
- onIconAlignmentRatioChanged(this::getCurrentIconAlignmentRatio);
+ private void onIconAlignmentRatioChangedForAppAndHomeTransition() {
+ onIconAlignmentRatioChanged(this::getCurrentIconAlignmentRatioBetweenAppAndHome);
}
private void onIconAlignmentRatioChanged(Supplier<Float> alignmentSupplier) {
@@ -313,13 +336,11 @@
mControllers.taskbarViewController.setLauncherIconAlignment(
alignment, mLauncher.getDeviceProfile());
- mTaskbarBackgroundAlpha.updateValue(1 - alignment);
-
// Switch taskbar and hotseat in last frame
setTaskbarViewVisible(alignment < 1);
}
- private float getCurrentIconAlignmentRatio() {
+ private float getCurrentIconAlignmentRatioBetweenAppAndHome() {
return Math.max(mIconAlignmentForResumedState.value, mIconAlignmentForGestureState.value);
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 8965dc4..a3ad835 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -216,6 +216,13 @@
return hasAnyFlag(FLAGS_STASHED_IN_APP);
}
+ /**
+ * Returns whether the taskbar should be stashed in the current LauncherState.
+ */
+ public boolean isInStashedLauncherState() {
+ return hasAnyFlag(FLAG_IN_STASHED_LAUNCHER_STATE) && supportsVisualStashing();
+ }
+
private boolean hasAnyFlag(int flagMask) {
return hasAnyFlag(mState, flagMask);
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
index c554fd0..8f89d30 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -69,7 +69,7 @@
}
@Override
- public boolean isTaskbarStashed() {
+ public boolean isTaskbarStashed(Launcher launcher) {
return true;
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index a4eff87..08d0a80 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -92,7 +92,7 @@
}
@Override
- public boolean isTaskbarStashed() {
+ public boolean isTaskbarStashed(Launcher launcher) {
return true;
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java b/quickstep/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java
index edfb921..969abc2 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java
@@ -17,6 +17,7 @@
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
+import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.util.Themes;
@@ -42,6 +43,10 @@
@Override
public int getWorkspaceScrimColor(Launcher launcher) {
+ DeviceProfile dp = launcher.getDeviceProfile();
+ if (dp.isTaskbarPresentInApps) {
+ return launcher.getColor(R.color.taskbar_background);
+ }
return Themes.getAttrColor(launcher, R.attr.overviewScrimColor);
}
@@ -55,4 +60,14 @@
public int getVisibleElements(Launcher launcher) {
return NONE;
}
+
+ @Override
+ public boolean isTaskbarStashed(Launcher launcher) {
+ return !launcher.getDeviceProfile().isTaskbarPresentInApps;
+ }
+
+ @Override
+ public boolean isTaskbarAlignedWithHotseat(Launcher launcher) {
+ return false;
+ }
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
index ff3c517..f6148a7 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
@@ -236,8 +236,10 @@
// - RecentsView fade (if it's empty)
PendingAnimation xAnim = new PendingAnimation((long) (mXRange * 2));
xAnim.setFloat(mRecentsView, ADJACENT_PAGE_HORIZONTAL_OFFSET, scaleAndOffset[1], LINEAR);
+ // Use QuickSwitchState instead of OverviewState to determine scrim color,
+ // since we need to take potential taskbar into account.
xAnim.setViewBackgroundColor(mLauncher.getScrimView(),
- toState.getWorkspaceScrimColor(mLauncher), LINEAR);
+ QUICK_SWITCH.getWorkspaceScrimColor(mLauncher), LINEAR);
if (mRecentsView.getTaskViewCount() == 0) {
xAnim.addFloat(mRecentsView, CONTENT_ALPHA, 0f, 1f, LINEAR);
}
@@ -310,6 +312,11 @@
}
});
overviewAnim.start();
+
+ // Create an empty state transition so StateListeners get onStateTransitionStart().
+ mLauncher.getStateManager().createAnimationToNewWorkspace(
+ OVERVIEW, config.duration, StateAnimationConfig.SKIP_ALL_ANIMATIONS)
+ .dispatchOnStart();
return;
}
@@ -384,6 +391,7 @@
config.animFlags = SKIP_ALL_ANIMATIONS;
updateNonOverviewAnim(targetState, config);
nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();
+ mNonOverviewAnim.dispatchOnStart();
new WorkspaceRevealAnim(mLauncher, false /* animateOverviewScrim */).start();
} else {
diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
index fcc6272..0294828 100644
--- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
+++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
@@ -16,8 +16,6 @@
package com.android.quickstep.views;
-import static com.android.quickstep.SysUINavigationMode.Mode.THREE_BUTTONS;
-
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
@@ -35,7 +33,6 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.R;
-import com.android.launcher3.uioverrides.ApiWrapper;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.quickstep.SysUINavigationMode;
@@ -155,7 +152,7 @@
public void setInsets(Rect insets) {
mInsets.set(insets);
updateVerticalMargin(SysUINavigationMode.getMode(getContext()));
- updatePaddingAndTranslations();
+ updateHorizontalPadding();
}
public void updateHiddenFlags(@ActionsHiddenFlags int visibilityFlags, boolean enable) {
@@ -198,37 +195,8 @@
return mMultiValueAlpha.getProperty(INDEX_FULLSCREEN_ALPHA);
}
- /**
- * Aligns OverviewActionsView vertically with and offsets horizontal position based on
- * 3 button nav container in taskbar.
- */
- private void updatePaddingAndTranslations() {
- boolean alignFor3ButtonTaskbar = mDp.isTaskbarPresent &&
- SysUINavigationMode.getMode(getContext()) == THREE_BUTTONS;
- if (alignFor3ButtonTaskbar) {
- // Add extra horizontal spacing
- int additionalPadding = ApiWrapper.getHotseatEndOffset(getContext());
- if (isLayoutRtl()) {
- setPadding(mInsets.left + additionalPadding, 0, mInsets.right, 0);
- } else {
- setPadding(mInsets.left, 0, mInsets.right + additionalPadding, 0);
- }
-
- // Align vertically, using taskbar height + mDp.taskbarOffsetY() to guestimate
- // where the button nav top is
- View startActionView = findViewById(R.id.action_screenshot);
- int marginBottom = getOverviewActionsBottomMarginPx(
- SysUINavigationMode.getMode(getContext()), mDp);
- int actionsTop = (mDp.heightPx - marginBottom - mInsets.bottom);
- int navTop = mDp.heightPx - (mDp.taskbarSize + mDp.getTaskbarOffsetY());
- int transY = navTop - actionsTop
- + ((mDp.taskbarSize - startActionView.getHeight()) / 2);
- setTranslationY(transY);
- } else {
- setPadding(mInsets.left, 0, mInsets.right, 0);
- setTranslationX(0);
- setTranslationY(0);
- }
+ private void updateHorizontalPadding() {
+ setPadding(mInsets.left, 0, mInsets.right, 0);
}
/** Updates vertical margins for different navigation mode or configuration changes. */
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 428cc98..ed238d8 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -630,7 +630,7 @@
* this doesn't get adjusted to reflect the new child count after the taskView is dismissed/
* removed from recentsView
*/
- private int mSplitHiddenTaskViewIndex;
+ private int mSplitHiddenTaskViewIndex = -1;
@Nullable
private FloatingTaskView mFirstFloatingTaskView;
@Nullable
@@ -3969,6 +3969,9 @@
/** TODO(b/181707736) More gracefully handle exiting split selection state */
private void resetFromSplitSelectionState() {
+ if (mSplitHiddenTaskViewIndex == -1) {
+ return;
+ }
if (!mActivity.getDeviceProfile().overviewShowAsGrid) {
int pageToSnapTo = mCurrentPage;
if (mSplitHiddenTaskViewIndex <= pageToSnapTo) {
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 08f0089..08570eb 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -154,7 +154,15 @@
<attr name="demoModeLayoutId" format="reference" />
<attr name="isScalable" format="boolean" />
<attr name="devicePaddingId" format="reference" />
- <attr name="gridEnabled" format="boolean" />
+ <!-- By default all categories are enabled -->
+ <attr name="deviceCategory" format="integer" >
+ <!-- Enable on phone only -->
+ <flag name="phone" value="1" />
+ <!-- Enable on tablets only -->
+ <flag name="tablet" value="2" />
+ <!-- Enable on multi display devices only -->
+ <flag name="multi_display" value="4" />
+ </attr>
</declare-styleable>
diff --git a/res/xml/default_workspace_6x5.xml b/res/xml/default_workspace_6x5.xml
new file mode 100644
index 0000000..b078cfd
--- /dev/null
+++ b/res/xml/default_workspace_6x5.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<favorites xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3">
+
+ <!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
+ <!-- Mail Calendar Gallery Store Internet Camera -->
+ <resolve
+ launcher:container="-101"
+ launcher:screen="0"
+ launcher:x="0"
+ launcher:y="0" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_EMAIL;end" />
+ <favorite launcher:uri="mailto:" />
+ </resolve>
+
+ <resolve
+ launcher:container="-101"
+ launcher:screen="1"
+ launcher:x="1"
+ launcher:y="0" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_CALENDAR;end" />
+ </resolve>
+
+ <resolve
+ launcher:container="-101"
+ launcher:screen="2"
+ launcher:x="2"
+ launcher:y="0" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_GALLERY;end" />
+ <favorite launcher:uri="#Intent;type=images/*;end" />
+ </resolve>
+
+ <resolve
+ launcher:container="-101"
+ launcher:screen="3"
+ launcher:x="3"
+ launcher:y="0" >
+ <favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_MARKET;end" />
+ <favorite launcher:uri="market://details?id=com.android.launcher" />
+ </resolve>
+
+ <resolve
+ launcher:container="-101"
+ launcher:screen="4"
+ launcher:x="4"
+ launcher:y="0" >
+ <favorite
+ launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.APP_BROWSER;end" />
+ <favorite launcher:uri="http://www.example.com/" />
+ </resolve>
+
+ <!-- Resolve camera intent if GoogleCamera is not available e.g. on emulator -->
+ <resolve
+ launcher:container="-101"
+ launcher:screen="5"
+ launcher:x="5"
+ launcher:y="0" >
+ <favorite launcher:uri="#Intent;action=android.media.action.STILL_IMAGE_CAMERA;end" />
+ <favorite launcher:uri="#Intent;action=android.intent.action.CAMERA_BUTTON;end" />
+ </resolve>
+
+</favorites>
diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml
index e030f81..b4bb43e 100644
--- a/res/xml/device_profiles.xml
+++ b/res/xml/device_profiles.xml
@@ -133,4 +133,32 @@
</grid-option>
+ <grid-option
+ launcher:name="6_by_5"
+ launcher:numRows="5"
+ launcher:numColumns="6"
+ launcher:numFolderRows="3"
+ launcher:numFolderColumns="3"
+ launcher:numHotseatIcons="6"
+ launcher:numAllAppsColumns="6"
+ launcher:dbFile="launcher_6_by_5.db"
+ launcher:defaultLayoutId="@xml/default_workspace_6x5"
+ launcher:deviceCategory="tablet">
+
+ <display-option
+ launcher:name="Tablet"
+ launcher:minWidthDps="900"
+ launcher:minHeightDps="820"
+ launcher:minCellHeightDps="104"
+ launcher:minCellWidthDps="80"
+ launcher:iconImageSize="60"
+ launcher:iconTextSize="14"
+ launcher:borderSpaceDps="16"
+ launcher:allAppsIconSize="60"
+ launcher:allAppsIconTextSize="14"
+ launcher:allAppsCellSpacingDps="16"
+ launcher:canBeDefault="true" />
+
+ </grid-option>
+
</profiles>
\ No newline at end of file
diff --git a/res/xml/device_profiles_split.xml b/res/xml/device_profiles_split.xml
deleted file mode 100644
index 2fad0c9..0000000
--- a/res/xml/device_profiles_split.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- 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.
--->
-
-<profiles xmlns:launcher="http://schemas.android.com/apk/res-auto" >
-
- <grid-option
- launcher:name="3_by_3"
- launcher:numRows="3"
- launcher:numColumns="3"
- launcher:numFolderRows="2"
- launcher:numFolderColumns="3"
- launcher:numHotseatIcons="3"
- launcher:dbFile="launcher_3_by_3.db"
- launcher:defaultLayoutId="@xml/default_workspace_3x3" >
-
- <display-option
- launcher:name="Super Short Stubby"
- launcher:minWidthDps="255"
- launcher:minHeightDps="300"
- launcher:iconImageSize="48"
- launcher:iconTextSize="13.0"
- launcher:canBeDefault="true" />
-
- <display-option
- launcher:name="Shorter Stubby"
- launcher:minWidthDps="255"
- launcher:minHeightDps="400"
- launcher:iconImageSize="48"
- launcher:iconTextSize="13.0"
- launcher:canBeDefault="true" />
-
- </grid-option>
-
- <grid-option
- launcher:name="4_by_4"
- launcher:numRows="4"
- launcher:numColumns="4"
- launcher:numFolderRows="3"
- launcher:numFolderColumns="4"
- launcher:numHotseatIcons="4"
- launcher:dbFile="launcher_4_by_4.db"
- launcher:defaultLayoutId="@xml/default_workspace_4x4" >
-
- <display-option
- launcher:name="Short Stubby"
- launcher:minWidthDps="275"
- launcher:minHeightDps="420"
- launcher:iconImageSize="48"
- launcher:iconTextSize="13.0"
- launcher:canBeDefault="true" />
-
- <display-option
- launcher:name="Stubby"
- launcher:minWidthDps="255"
- launcher:minHeightDps="450"
- launcher:iconImageSize="48"
- launcher:iconTextSize="13.0"
- launcher:canBeDefault="true" />
-
- <display-option
- launcher:name="Nexus S"
- launcher:minWidthDps="296"
- launcher:minHeightDps="491.33"
- launcher:iconImageSize="48"
- launcher:iconTextSize="13.0"
- launcher:canBeDefault="true" />
-
- <display-option
- launcher:name="Nexus 4"
- launcher:minWidthDps="359"
- launcher:minHeightDps="567"
- launcher:iconImageSize="54"
- launcher:iconTextSize="13.0"
- launcher:canBeDefault="true" />
-
- <display-option
- launcher:name="Nexus 5"
- launcher:minWidthDps="335"
- launcher:minHeightDps="567"
- launcher:iconImageSize="54"
- launcher:iconTextSize="13.0"
- launcher:canBeDefault="true" />
-
- </grid-option>
-
- <grid-option
- launcher:name="5_by_5"
- launcher:numRows="5"
- launcher:numColumns="5"
- launcher:numFolderRows="4"
- launcher:numFolderColumns="4"
- launcher:numHotseatIcons="5"
- launcher:numExtendedHotseatIcons="8"
- launcher:dbFile="launcher.db"
- launcher:defaultLayoutId="@xml/default_workspace_5x5" >
-
- <display-option
- launcher:name="Large Phone"
- launcher:minWidthDps="406"
- launcher:minHeightDps="694"
- launcher:iconImageSize="56"
- launcher:iconTextSize="14.4"
- launcher:canBeDefault="true" />
-
- <display-option
- launcher:name="Large Phone Split Display"
- launcher:minWidthDps="406"
- launcher:minHeightDps="694"
- launcher:iconImageSize="56"
- launcher:iconTextSize="14.4"
- launcher:canBeDefault="true" />
-
- <display-option
- launcher:name="Shorter Stubby"
- launcher:minWidthDps="255"
- launcher:minHeightDps="400"
- launcher:iconImageSize="48"
- launcher:iconTextSize="13.0"
- launcher:canBeDefault="true" />
-
- </grid-option>
-
-</profiles>
\ No newline at end of file
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 2ebedf7..ff7a90c 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -42,6 +42,7 @@
import android.util.Xml;
import android.view.Display;
+import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
@@ -58,6 +59,8 @@
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -70,6 +73,13 @@
public static final MainThreadInitializedObject<InvariantDeviceProfile> INSTANCE =
new MainThreadInitializedObject<>(InvariantDeviceProfile::new);
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET})
+ public @interface DeviceType{}
+ public static final int TYPE_PHONE = 0;
+ public static final int TYPE_MULTI_DISPLAY = 1;
+ public static final int TYPE_TABLET = 2;
+
private static final String KEY_IDP_GRID_NAME = "idp_grid_name";
private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48;
@@ -106,7 +116,7 @@
public float[] iconTextSize;
public int iconBitmapSize;
public int fillResIconDpi;
- public boolean isSplitDisplay;
+ public @DeviceType int deviceType;
public PointF[] minCellSize;
@@ -198,13 +208,21 @@
String gridName = getCurrentGridName(context);
// Get the display info based on default display and interpolate it to existing display
+ Info defaultInfo = DisplayController.INSTANCE.get(context).getInfo();
+ @DeviceType int defaultDeviceType = getDeviceType(defaultInfo);
DisplayOption defaultDisplayOption = invDistWeightedInterpolate(
- DisplayController.INSTANCE.get(context).getInfo(),
- getPredefinedDeviceProfiles(context, gridName, false, false), false);
+ defaultInfo,
+ getPredefinedDeviceProfiles(context, gridName, defaultDeviceType,
+ /*allowDisabledGrid=*/false),
+ defaultDeviceType);
Info myInfo = new Info(context, display);
+ @DeviceType int deviceType = getDeviceType(myInfo);
DisplayOption myDisplayOption = invDistWeightedInterpolate(
- myInfo, getPredefinedDeviceProfiles(context, gridName, false, false), false);
+ myInfo,
+ getPredefinedDeviceProfiles(context, gridName, deviceType,
+ /*allowDisabledGrid=*/false),
+ deviceType);
DisplayOption result = new DisplayOption(defaultDisplayOption.grid)
.add(myDisplayOption);
@@ -220,7 +238,7 @@
System.arraycopy(defaultDisplayOption.borderSpaces, 0, result.borderSpaces, 0,
COUNT_SIZES);
- initGrid(context, myInfo, result, false);
+ initGrid(context, myInfo, result, deviceType);
}
/**
@@ -246,6 +264,18 @@
}
}
+ private static @DeviceType int getDeviceType(Info displayInfo) {
+ // Each screen has two profiles (portrait/landscape), so devices with four or more
+ // supported profiles implies two or more internal displays.
+ if (displayInfo.supportedBounds.size() >= 4 && ENABLE_TWO_PANEL_HOME.get()) {
+ return TYPE_MULTI_DISPLAY;
+ } else if (displayInfo.supportedBounds.stream().allMatch(displayInfo::isTablet)) {
+ return TYPE_TABLET;
+ } else {
+ return TYPE_PHONE;
+ }
+ }
+
public static String getCurrentGridName(Context context) {
return Utilities.isGridOptionsEnabled(context)
? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null) : null;
@@ -253,23 +283,19 @@
private String initGrid(Context context, String gridName) {
Info displayInfo = DisplayController.INSTANCE.get(context).getInfo();
- // Each screen has two profiles (portrait/landscape), so devices with four or more
- // supported profiles implies two or more internal displays.
- boolean isSplitDisplay =
- displayInfo.supportedBounds.size() >= 4 && ENABLE_TWO_PANEL_HOME.get();
+ @DeviceType int deviceType = getDeviceType(displayInfo);
ArrayList<DisplayOption> allOptions =
- getPredefinedDeviceProfiles(context, gridName, isSplitDisplay,
+ getPredefinedDeviceProfiles(context, gridName, deviceType,
RestoreDbTask.isPending(context));
DisplayOption displayOption =
- invDistWeightedInterpolate(displayInfo, allOptions, isSplitDisplay);
- initGrid(context, displayInfo, displayOption, isSplitDisplay);
+ invDistWeightedInterpolate(displayInfo, allOptions, deviceType);
+ initGrid(context, displayInfo, displayOption, deviceType);
return displayOption.grid.name;
}
- private void initGrid(
- Context context, Info displayInfo, DisplayOption displayOption,
- boolean isSplitDisplay) {
+ private void initGrid(Context context, Info displayInfo, DisplayOption displayOption,
+ @DeviceType int deviceType) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
GridOption closestProfile = displayOption.grid;
numRows = closestProfile.numRows;
@@ -281,7 +307,7 @@
numFolderColumns = closestProfile.numFolderColumns;
isScalable = closestProfile.isScalable;
devicePaddingId = closestProfile.devicePaddingId;
- this.isSplitDisplay = isSplitDisplay;
+ this.deviceType = deviceType;
mExtraAttrs = closestProfile.extraAttrs;
@@ -303,11 +329,11 @@
horizontalMargin = displayOption.horizontalMargin;
numShownHotseatIcons = closestProfile.numHotseatIcons;
- numDatabaseHotseatIcons = isSplitDisplay
+ numDatabaseHotseatIcons = deviceType == TYPE_MULTI_DISPLAY
? closestProfile.numDatabaseHotseatIcons : closestProfile.numHotseatIcons;
numAllAppsColumns = closestProfile.numAllAppsColumns;
- numDatabaseAllAppsColumns = isSplitDisplay
+ numDatabaseAllAppsColumns = deviceType == TYPE_MULTI_DISPLAY
? closestProfile.numDatabaseAllAppsColumns : closestProfile.numAllAppsColumns;
if (!Utilities.isGridOptionsEnabled(context)) {
@@ -327,7 +353,7 @@
defaultWallpaperSize = new Point(displayInfo.currentSize);
for (WindowBounds bounds : displayInfo.supportedBounds) {
localSupportedProfiles.add(new DeviceProfile.Builder(context, this, displayInfo)
- .setUseTwoPanels(isSplitDisplay)
+ .setUseTwoPanels(deviceType == TYPE_MULTI_DISPLAY)
.setWindowBounds(bounds).build());
// Wallpaper size should be the maximum of the all possible sizes Launcher expects
@@ -350,11 +376,6 @@
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
}
- @Nullable
- public TypedValue getAttrValue(int attr) {
- return mExtraAttrs == null ? null : mExtraAttrs.get(attr);
- }
-
public void addOnChangeListener(OnIDPChangeListener listener) {
mChangeListeners.add(listener);
}
@@ -389,12 +410,11 @@
}
}
- private static ArrayList<DisplayOption> getPredefinedDeviceProfiles(
- Context context, String gridName, boolean isSplitDisplay, boolean allowDisabledGrid) {
+ private static ArrayList<DisplayOption> getPredefinedDeviceProfiles(Context context,
+ String gridName, @DeviceType int deviceType, boolean allowDisabledGrid) {
ArrayList<DisplayOption> profiles = new ArrayList<>();
- int xmlResource = isSplitDisplay ? R.xml.device_profiles_split : R.xml.device_profiles;
- try (XmlResourceParser parser = context.getResources().getXml(xmlResource)) {
+ try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
final int depth = parser.getDepth();
int type;
while (((type = parser.next()) != XmlPullParser.END_TAG ||
@@ -402,8 +422,8 @@
if ((type == XmlPullParser.START_TAG)
&& GridOption.TAG_NAME.equals(parser.getName())) {
- GridOption gridOption =
- new GridOption(context, Xml.asAttributeSet(parser), isSplitDisplay);
+ GridOption gridOption = new GridOption(context, Xml.asAttributeSet(parser),
+ deviceType);
if (gridOption.isEnabled || allowDisabledGrid) {
final int displayDepth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG
@@ -450,9 +470,8 @@
*/
public List<GridOption> parseAllGridOptions(Context context) {
List<GridOption> result = new ArrayList<>();
- int xmlResource = isSplitDisplay ? R.xml.device_profiles_split : R.xml.device_profiles;
- try (XmlResourceParser parser = context.getResources().getXml(xmlResource)) {
+ try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
final int depth = parser.getDepth();
int type;
while (((type = parser.next()) != XmlPullParser.END_TAG
@@ -460,7 +479,7 @@
if ((type == XmlPullParser.START_TAG)
&& GridOption.TAG_NAME.equals(parser.getName())) {
GridOption option =
- new GridOption(context, Xml.asAttributeSet(parser), isSplitDisplay);
+ new GridOption(context, Xml.asAttributeSet(parser), deviceType);
if (option.isEnabled) {
result.add(option);
}
@@ -514,12 +533,12 @@
}
private static DisplayOption invDistWeightedInterpolate(
- Info displayInfo, ArrayList<DisplayOption> points, boolean isSplitDisplay) {
+ Info displayInfo, ArrayList<DisplayOption> points, @DeviceType int deviceType) {
int minWidthPx = Integer.MAX_VALUE;
int minHeightPx = Integer.MAX_VALUE;
for (WindowBounds bounds : displayInfo.supportedBounds) {
boolean isTablet = displayInfo.isTablet(bounds);
- if (isTablet && isSplitDisplay) {
+ if (isTablet && deviceType == TYPE_MULTI_DISPLAY) {
// For split displays, take half width per page
minWidthPx = Math.min(minWidthPx, bounds.availableSize.x / 2);
minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
@@ -643,6 +662,12 @@
public static final String TAG_NAME = "grid-option";
+ private static final int DEVICE_CATEGORY_PHONE = 1 << 0;
+ private static final int DEVICE_CATEGORY_TABLET = 1 << 1;
+ private static final int DEVICE_CATEGORY_MULTI_DISPLAY = 1 << 2;
+ private static final int DEVICE_CATEGORY_ALL =
+ DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY;
+
public final String name;
public final int numRows;
public final int numColumns;
@@ -666,7 +691,7 @@
private final SparseArray<TypedValue> extraAttrs;
- public GridOption(Context context, AttributeSet attrs, boolean isSplitDisplay) {
+ public GridOption(Context context, AttributeSet attrs, @DeviceType int deviceType) {
TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.GridDisplayOption);
name = a.getString(R.styleable.GridDisplayOption_name);
@@ -674,7 +699,7 @@
numColumns = a.getInt(R.styleable.GridDisplayOption_numColumns, 0);
dbFile = a.getString(R.styleable.GridDisplayOption_dbFile);
- defaultLayoutId = a.getResourceId(isSplitDisplay && a.hasValue(
+ defaultLayoutId = a.getResourceId(deviceType == TYPE_MULTI_DISPLAY && a.hasValue(
R.styleable.GridDisplayOption_defaultSplitDisplayLayoutId)
? R.styleable.GridDisplayOption_defaultSplitDisplayLayoutId
: R.styleable.GridDisplayOption_defaultLayoutId, 0);
@@ -701,7 +726,15 @@
devicePaddingId = a.getResourceId(
R.styleable.GridDisplayOption_devicePaddingId, 0);
- isEnabled = a.getBoolean(R.styleable.GridDisplayOption_gridEnabled, true);
+ int deviceCategory = a.getInt(R.styleable.GridDisplayOption_deviceCategory,
+ DEVICE_CATEGORY_ALL);
+ isEnabled = (deviceType == TYPE_PHONE
+ && ((deviceCategory & DEVICE_CATEGORY_PHONE) == DEVICE_CATEGORY_PHONE))
+ || (deviceType == TYPE_TABLET
+ && ((deviceCategory & DEVICE_CATEGORY_TABLET) == DEVICE_CATEGORY_TABLET))
+ || (deviceType == TYPE_MULTI_DISPLAY
+ && ((deviceCategory & DEVICE_CATEGORY_MULTI_DISPLAY)
+ == DEVICE_CATEGORY_MULTI_DISPLAY));
a.recycle();
extraAttrs = Themes.createValueMap(context, attrs,
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 9324ea5..be2cd88 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -196,10 +196,16 @@
return (getVisibleElements(launcher) & elements) == elements;
}
- public boolean isTaskbarStashed() {
+ /** Returns whether taskbar is stashed and thus should replace hotseat with a handle */
+ public boolean isTaskbarStashed(Launcher launcher) {
return false;
}
+ /** Returns whether taskbar is aligned with the hotseat vs position inside apps */
+ public boolean isTaskbarAlignedWithHotseat(Launcher launcher) {
+ return !isTaskbarStashed(launcher);
+ }
+
/**
* Fraction shift in the vertical translation UI and related properties
*
diff --git a/src/com/android/launcher3/model/DeviceGridState.java b/src/com/android/launcher3/model/DeviceGridState.java
index 0fc4c2d..01ebc53 100644
--- a/src/com/android/launcher3/model/DeviceGridState.java
+++ b/src/com/android/launcher3/model/DeviceGridState.java
@@ -16,6 +16,9 @@
package com.android.launcher3.model;
+import static com.android.launcher3.InvariantDeviceProfile.DeviceType;
+import static com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY;
+import static com.android.launcher3.InvariantDeviceProfile.TYPE_PHONE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_GRID_SIZE_2;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_GRID_SIZE_3;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_GRID_SIZE_4;
@@ -25,15 +28,11 @@
import android.content.SharedPreferences;
import android.text.TextUtils;
-import androidx.annotation.IntDef;
-
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Utilities;
import com.android.launcher3.logging.StatsLogManager.LauncherEvent;
import com.android.launcher3.util.IntSet;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
import java.util.Locale;
import java.util.Objects;
@@ -46,13 +45,6 @@
public static final String KEY_HOTSEAT_COUNT = "migration_src_hotseat_count";
public static final String KEY_DEVICE_TYPE = "migration_src_device_type";
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({TYPE_PHONE, TYPE_MULTI_DISPLAY, TYPE_TABLET})
- public @interface DeviceType{}
- public static final int TYPE_PHONE = 0;
- public static final int TYPE_MULTI_DISPLAY = 1;
- public static final int TYPE_TABLET = 2;
-
private static final IntSet COMPATIBLE_TYPES = IntSet.wrap(TYPE_PHONE, TYPE_MULTI_DISPLAY);
public static boolean deviceTypeCompatible(@DeviceType int typeA, @DeviceType int typeB) {
@@ -67,11 +59,7 @@
public DeviceGridState(InvariantDeviceProfile idp) {
mGridSizeString = String.format(Locale.ENGLISH, "%d,%d", idp.numColumns, idp.numRows);
mNumHotseat = idp.numDatabaseHotseatIcons;
- mDeviceType = idp.supportedProfiles.size() > 2
- ? TYPE_MULTI_DISPLAY
- : idp.supportedProfiles.stream().allMatch(dp -> dp.isTablet)
- ? TYPE_TABLET
- : TYPE_PHONE;
+ mDeviceType = idp.deviceType;
}
public DeviceGridState(Context context) {
diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java
index 8f607a1..4c0930b 100644
--- a/src/com/android/launcher3/provider/RestoreDbTask.java
+++ b/src/com/android/launcher3/provider/RestoreDbTask.java
@@ -16,8 +16,8 @@
package com.android.launcher3.provider;
-import static com.android.launcher3.model.DeviceGridState.TYPE_MULTI_DISPLAY;
-import static com.android.launcher3.model.DeviceGridState.TYPE_PHONE;
+import static com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY;
+import static com.android.launcher3.InvariantDeviceProfile.TYPE_PHONE;
import static com.android.launcher3.provider.LauncherDbUtils.dropTable;
import android.app.backup.BackupManager;