Adding a flag (enabled by default) to remove the all-apps button.

All apps can still be opened by clicking the caret.

Bug: 29398447
Change-Id: I61f1b05cea83a0a49d7cc16c518c5419618ba779
This commit is contained in:
Sunny Goyal
2016-06-15 15:42:29 -07:00
parent 0af8af3a60
commit bb011dad4e
13 changed files with 99 additions and 108 deletions
@@ -37,6 +37,7 @@ import android.util.Patterns;
import com.android.launcher3.LauncherProvider.SqlArguments; import com.android.launcher3.LauncherProvider.SqlArguments;
import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.Thunk; import com.android.launcher3.util.Thunk;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@@ -157,7 +158,7 @@ public class AutoInstallsLayout {
protected final Resources mSourceRes; protected final Resources mSourceRes;
protected final int mLayoutId; protected final int mLayoutId;
private final int mHotseatAllAppsRank; private final InvariantDeviceProfile mIdp;
private final int mRowCount; private final int mRowCount;
private final int mColumnCount; private final int mColumnCount;
@@ -181,10 +182,9 @@ public class AutoInstallsLayout {
mSourceRes = res; mSourceRes = res;
mLayoutId = layoutId; mLayoutId = layoutId;
InvariantDeviceProfile idp = LauncherAppState.getInstance().getInvariantDeviceProfile(); mIdp = LauncherAppState.getInstance().getInvariantDeviceProfile();
mHotseatAllAppsRank = idp.hotseatAllAppsRank; mRowCount = mIdp.numRows;
mRowCount = idp.numRows; mColumnCount = mIdp.numColumns;
mColumnCount = idp.numColumns;
} }
/** /**
@@ -231,7 +231,8 @@ public class AutoInstallsLayout {
out[0] = Favorites.CONTAINER_HOTSEAT; out[0] = Favorites.CONTAINER_HOTSEAT;
// Hack: hotseat items are stored using screen ids // Hack: hotseat items are stored using screen ids
long rank = Long.parseLong(getAttributeValue(parser, ATTR_RANK)); long rank = Long.parseLong(getAttributeValue(parser, ATTR_RANK));
out[1] = (rank < mHotseatAllAppsRank) ? rank : (rank + 1); out[1] = (FeatureFlags.NO_ALL_APPS_ICON || rank < mIdp.getAllAppsButtonRank())
? rank : (rank + 1);
} else { } else {
out[0] = Favorites.CONTAINER_DESKTOP; out[0] = Favorites.CONTAINER_DESKTOP;
out[1] = Long.parseLong(getAttributeValue(parser, ATTR_SCREEN)); out[1] = Long.parseLong(getAttributeValue(parser, ATTR_SCREEN));
+4 -8
View File
@@ -239,14 +239,12 @@ public class FocusHelper {
if (keyCode == KeyEvent.KEYCODE_DPAD_UP && if (keyCode == KeyEvent.KEYCODE_DPAD_UP &&
!profile.isVerticalBarLayout()) { !profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
true /* hotseat horizontal */, profile.inv.hotseatAllAppsRank);
iconIndex += iconParent.getChildCount(); iconIndex += iconParent.getChildCount();
parent = iconParent; parent = iconParent;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT &&
profile.isVerticalBarLayout()) { profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
false /* hotseat horizontal */, profile.inv.hotseatAllAppsRank);
iconIndex += iconParent.getChildCount(); iconIndex += iconParent.getChildCount();
parent = iconParent; parent = iconParent;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT &&
@@ -372,12 +370,10 @@ public class FocusHelper {
// to take a user to the hotseat. For other dpad navigation, do not use the matrix extended // to take a user to the hotseat. For other dpad navigation, do not use the matrix extended
// with the hotseat. // with the hotseat.
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && !profile.isVerticalBarLayout()) { if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && !profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
true /* horizontal */, profile.inv.hotseatAllAppsRank);
} else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT &&
profile.isVerticalBarLayout()) { profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, matrix = FocusLogic.createSparseMatrixWithHotseat(iconLayout, hotseatLayout, profile);
false /* horizontal */, profile.inv.hotseatAllAppsRank);
} else if (isUninstallKeyChord(e)) { } else if (isUninstallKeyChord(e)) {
matrix = FocusLogic.createSparseMatrix(iconLayout); matrix = FocusLogic.createSparseMatrix(iconLayout);
if (UninstallDropTarget.supportsDrop(launcher, itemInfo)) { if (UninstallDropTarget.supportsDrop(launcher, itemInfo)) {
+32 -37
View File
@@ -31,6 +31,7 @@ import android.view.ViewDebug;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dynamicui.ExtractedColors; import com.android.launcher3.dynamicui.ExtractedColors;
import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -43,9 +44,6 @@ public class Hotseat extends FrameLayout
private Launcher mLauncher; private Launcher mLauncher;
@ViewDebug.ExportedProperty(category = "launcher")
private int mAllAppsButtonRank;
@ViewDebug.ExportedProperty(category = "launcher") @ViewDebug.ExportedProperty(category = "launcher")
private final boolean mHasVerticalHotseat; private final boolean mHasVerticalHotseat;
@@ -106,16 +104,10 @@ public class Hotseat extends FrameLayout
return mHasVerticalHotseat ? (mContent.getCountY() - (rank + 1)) : 0; return mHasVerticalHotseat ? (mContent.getCountY() - (rank + 1)) : 0;
} }
public boolean isAllAppsButtonRank(int rank) {
return rank == mAllAppsButtonRank;
}
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
DeviceProfile grid = mLauncher.getDeviceProfile(); DeviceProfile grid = mLauncher.getDeviceProfile();
mAllAppsButtonRank = grid.inv.hotseatAllAppsRank;
mContent = (CellLayout) findViewById(R.id.layout); mContent = (CellLayout) findViewById(R.id.layout);
if (grid.isLandscape && !grid.isLargeTablet) { if (grid.isLandscape && !grid.isLargeTablet) {
mContent.setGridSize(1, (int) grid.inv.numHotseatIcons); mContent.setGridSize(1, (int) grid.inv.numHotseatIcons);
@@ -130,38 +122,41 @@ public class Hotseat extends FrameLayout
void resetLayout() { void resetLayout() {
mContent.removeAllViewsInLayout(); mContent.removeAllViewsInLayout();
// Add the Apps button if (!FeatureFlags.NO_ALL_APPS_ICON) {
Context context = getContext(); // Add the Apps button
Context context = getContext();
int allAppsButtonRank = mLauncher.getDeviceProfile().inv.getAllAppsButtonRank();
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
TextView allAppsButton = (TextView) TextView allAppsButton = (TextView)
inflater.inflate(R.layout.all_apps_button, mContent, false); inflater.inflate(R.layout.all_apps_button, mContent, false);
Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon); Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
mLauncher.resizeIconDrawable(d); mLauncher.resizeIconDrawable(d);
int scaleDownPx = getResources().getDimensionPixelSize(R.dimen.all_apps_button_scale_down); int scaleDownPx = getResources().getDimensionPixelSize(R.dimen.all_apps_button_scale_down);
Rect bounds = d.getBounds(); Rect bounds = d.getBounds();
d.setBounds(bounds.left, bounds.top + scaleDownPx / 2, bounds.right - scaleDownPx, d.setBounds(bounds.left, bounds.top + scaleDownPx / 2, bounds.right - scaleDownPx,
bounds.bottom - scaleDownPx / 2); bounds.bottom - scaleDownPx / 2);
allAppsButton.setCompoundDrawables(null, d, null, null); allAppsButton.setCompoundDrawables(null, d, null, null);
allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label)); allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener()); allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
if (mLauncher != null) { if (mLauncher != null) {
mLauncher.setAllAppsButton(allAppsButton); mLauncher.setAllAppsButton(allAppsButton);
allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener()); allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
allAppsButton.setOnClickListener(mLauncher); allAppsButton.setOnClickListener(mLauncher);
allAppsButton.setOnLongClickListener(mLauncher); allAppsButton.setOnLongClickListener(mLauncher);
allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler); allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
}
// Note: We do this to ensure that the hotseat is always laid out in the orientation of
// the hotseat in order regardless of which orientation they were added
int x = getCellXFromOrder(allAppsButtonRank);
int y = getCellYFromOrder(allAppsButtonRank);
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x, y, 1, 1);
lp.canReorder = false;
mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
} }
// Note: We do this to ensure that the hotseat is always laid out in the orientation of
// the hotseat in order regardless of which orientation they were added
int x = getCellXFromOrder(mAllAppsButtonRank);
int y = getCellYFromOrder(mAllAppsButtonRank);
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x,y,1,1);
lp.canReorder = false;
mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
} }
@Override @Override
@@ -23,6 +23,8 @@ import android.util.DisplayMetrics;
import android.view.Display; import android.view.Display;
import android.view.WindowManager; import android.view.WindowManager;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.util.Thunk; import com.android.launcher3.util.Thunk;
import java.util.ArrayList; import java.util.ArrayList;
@@ -77,9 +79,6 @@ public class InvariantDeviceProfile {
float hotseatIconSize; float hotseatIconSize;
int defaultLayoutId; int defaultLayoutId;
// Derived invariant properties
public int hotseatAllAppsRank;
DeviceProfile landscapeProfile; DeviceProfile landscapeProfile;
DeviceProfile portraitProfile; DeviceProfile portraitProfile;
@@ -141,7 +140,6 @@ public class InvariantDeviceProfile {
numRows = closestProfile.numRows; numRows = closestProfile.numRows;
numColumns = closestProfile.numColumns; numColumns = closestProfile.numColumns;
numHotseatIcons = closestProfile.numHotseatIcons; numHotseatIcons = closestProfile.numHotseatIcons;
hotseatAllAppsRank = (int) (numHotseatIcons / 2);
defaultLayoutId = closestProfile.defaultLayoutId; defaultLayoutId = closestProfile.defaultLayoutId;
numFolderRows = closestProfile.numFolderRows; numFolderRows = closestProfile.numFolderRows;
numFolderColumns = closestProfile.numFolderColumns; numFolderColumns = closestProfile.numFolderColumns;
@@ -304,6 +302,17 @@ public class InvariantDeviceProfile {
return this; return this;
} }
public int getAllAppsButtonRank() {
if (ProviderConfig.IS_DOGFOOD_BUILD && FeatureFlags.NO_ALL_APPS_ICON) {
throw new IllegalAccessError("Accessing all apps rank when all-apps is disabled");
}
return numHotseatIcons / 2;
}
public boolean isAllAppsButtonRank(int rank) {
return rank == getAllAppsButtonRank();
}
private float weight(float x0, float y0, float x1, float y1, float pow) { private float weight(float x0, float y0, float x1, float y1, float pow) {
float d = dist(x0, y0, x1, y1); float d = dist(x0, y0, x1, y1);
if (Float.compare(d, 0f) == 0) { if (Float.compare(d, 0f) == 0) {
+9 -17
View File
@@ -1457,13 +1457,14 @@ public class Launcher extends Activity
/** /**
* Sets the all apps button. This method is called from {@link Hotseat}. * Sets the all apps button. This method is called from {@link Hotseat}.
* TODO: Get rid of this.
*/ */
public void setAllAppsButton(View allAppsButton) { public void setAllAppsButton(View allAppsButton) {
mAllAppsButton = allAppsButton; mAllAppsButton = allAppsButton;
} }
public View getAllAppsButton() { public View getStartViewForAllAppsRevealAnimation() {
return mAllAppsButton; return FeatureFlags.NO_ALL_APPS_ICON ? mPageIndicator : mAllAppsButton;
} }
public View getWidgetsButton() { public View getWidgetsButton() {
@@ -2491,7 +2492,7 @@ public class Launcher extends Activity
if (v instanceof FolderIcon) { if (v instanceof FolderIcon) {
onClickFolderIcon(v); onClickFolderIcon(v);
} }
} else if (v instanceof PageIndicator || v == mAllAppsButton) { } else if (v instanceof PageIndicator || (v == mAllAppsButton && mAllAppsButton != null)) {
onClickAllAppsButton(v); onClickAllAppsButton(v);
} else if (tag instanceof AppInfo) { } else if (tag instanceof AppInfo) {
startAppShortcutOrInfoActivity(v); startAppShortcutOrInfoActivity(v);
@@ -3096,7 +3097,7 @@ public class Launcher extends Activity
if (isWorkspaceLocked()) return false; if (isWorkspaceLocked()) return false;
if (mState != State.WORKSPACE) return false; if (mState != State.WORKSPACE) return false;
if (v == mAllAppsButton) { if (v == mAllAppsButton && mAllAppsButton != null) {
onLongClickAllAppsButton(v); onLongClickAllAppsButton(v);
return true; return true;
} }
@@ -3127,7 +3128,6 @@ public class Launcher extends Activity
// The hotseat touch handling does not go through Workspace, and we always allow long press // The hotseat touch handling does not go through Workspace, and we always allow long press
// on hotseat items. // on hotseat items.
final boolean inHotseat = isHotseatLayout(v);
if (!mDragController.isDragging()) { if (!mDragController.isDragging()) {
if (itemUnderLongClick == null) { if (itemUnderLongClick == null) {
// User long pressed on empty space // User long pressed on empty space
@@ -3138,13 +3138,12 @@ public class Launcher extends Activity
} else { } else {
showOverviewMode(true); showOverviewMode(true);
mHotseat.requestDisallowInterceptTouchEvent(true); mHotseat.requestDisallowInterceptTouchEvent(true);
} }
} else { } else {
final boolean isAllAppsButton = inHotseat && isAllAppsButtonRank( final boolean isAllAppsButton =
mHotseat.getOrderInHotseat( !FeatureFlags.NO_ALL_APPS_ICON && isHotseatLayout(v) &&
longClickCellInfo.cellX, mDeviceProfile.inv.isAllAppsButtonRank(mHotseat.getOrderInHotseat(
longClickCellInfo.cellY)); longClickCellInfo.cellX, longClickCellInfo.cellY));
if (!(itemUnderLongClick instanceof Folder || isAllAppsButton)) { if (!(itemUnderLongClick instanceof Folder || isAllAppsButton)) {
// User long pressed on an item // User long pressed on an item
mWorkspace.startDrag(longClickCellInfo); mWorkspace.startDrag(longClickCellInfo);
@@ -3989,13 +3988,6 @@ public class Launcher extends Activity
} }
} }
public boolean isAllAppsButtonRank(int rank) {
if (mHotseat != null) {
return mHotseat.isAllAppsButtonRank(rank);
}
return false;
}
private boolean canRunNewAppsAnimation() { private boolean canRunNewAppsAnimation() {
long diff = System.currentTimeMillis() - mDragController.getLastGestureUpTime(); long diff = System.currentTimeMillis() - mDragController.getLastGestureUpTime();
return diff > (NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS * 1000) return diff > (NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS * 1000)
@@ -439,7 +439,6 @@ public class LauncherBackupHelper implements BackupHelper {
data.desktopRows = profile.numRows; data.desktopRows = profile.numRows;
data.desktopCols = profile.numColumns; data.desktopCols = profile.numColumns;
data.hotseatCount = profile.numHotseatIcons; data.hotseatCount = profile.numHotseatIcons;
data.allappsRank = profile.hotseatAllAppsRank;
return data; return data;
} }
+2 -3
View File
@@ -196,7 +196,6 @@ public class LauncherModel extends BroadcastReceiver
public void bindAppInfosRemoved(ArrayList<AppInfo> appInfos); public void bindAppInfosRemoved(ArrayList<AppInfo> appInfos);
public void notifyWidgetProvidersChanged(); public void notifyWidgetProvidersChanged();
public void bindWidgetsModel(WidgetsModel model); public void bindWidgetsModel(WidgetsModel model);
public boolean isAllAppsButtonRank(int rank);
public void onPageBoundSynchronously(int page); public void onPageBoundSynchronously(int page);
public void executeOnNextDraw(ViewOnDrawExecutor executor); public void executeOnNextDraw(ViewOnDrawExecutor executor);
} }
@@ -1450,8 +1449,8 @@ public class LauncherModel extends BroadcastReceiver
long containerIndex = item.screenId; long containerIndex = item.screenId;
if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
// Return early if we detect that an item is under the hotseat button // Return early if we detect that an item is under the hotseat button
if (mCallbacks == null || if (!FeatureFlags.NO_ALL_APPS_ICON &&
mCallbacks.get().isAllAppsButtonRank((int) item.screenId)) { profile.isAllAppsButtonRank((int) item.screenId)) {
Log.e(TAG, "Error loading shortcut into hotseat " + item Log.e(TAG, "Error loading shortcut into hotseat " + item
+ " into position (" + item.screenId + ":" + item.cellX + "," + " into position (" + item.screenId + ":" + item.cellX + ","
+ item.cellY + ") occupied by all apps"); + item.cellY + ") occupied by all apps");
@@ -142,7 +142,7 @@ public class LauncherStateTransitionAnimation {
public void startAnimationToAllApps(final Workspace.State fromWorkspaceState, public void startAnimationToAllApps(final Workspace.State fromWorkspaceState,
final boolean animated, final boolean startSearchAfterTransition) { final boolean animated, final boolean startSearchAfterTransition) {
final AllAppsContainerView toView = mLauncher.getAppsView(); final AllAppsContainerView toView = mLauncher.getAppsView();
final View buttonView = mLauncher.getAllAppsButton(); final View buttonView = mLauncher.getStartViewForAllAppsRevealAnimation();
PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks(1f) { PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks(1f) {
@Override @Override
public float getMaterialRevealViewStartFinalRadius() { public float getMaterialRevealViewStartFinalRadius() {
@@ -525,7 +525,7 @@ public class LauncherStateTransitionAnimation {
}; };
// Only animate the search bar if animating to spring loaded mode from all apps // Only animate the search bar if animating to spring loaded mode from all apps
mCurrentAnimation = startAnimationToWorkspaceFromOverlay(fromWorkspaceState, toWorkspaceState, mCurrentAnimation = startAnimationToWorkspaceFromOverlay(fromWorkspaceState, toWorkspaceState,
mLauncher.getAllAppsButton(), appsView, mLauncher.getStartViewForAllAppsRevealAnimation(), appsView,
animated, type, onCompleteRunnable, cb); animated, type, onCompleteRunnable, cb);
} }
+2 -2
View File
@@ -2509,9 +2509,9 @@ public class Workspace extends PagedView
// Don't show the message if we are dropping on the AllApps button and the hotseat // Don't show the message if we are dropping on the AllApps button and the hotseat
// is full // is full
boolean isHotseat = mLauncher.isHotseatLayout(dropTargetLayout); boolean isHotseat = mLauncher.isHotseatLayout(dropTargetLayout);
if (mTargetCell != null && isHotseat) { if (mTargetCell != null && isHotseat && !FeatureFlags.NO_ALL_APPS_ICON) {
Hotseat hotseat = mLauncher.getHotseat(); Hotseat hotseat = mLauncher.getHotseat();
if (hotseat.isAllAppsButtonRank( if (mLauncher.getDeviceProfile().inv.isAllAppsButtonRank(
hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1]))) { hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1]))) {
return false; return false;
} }
@@ -49,7 +49,7 @@ public class GridSizeMigrationTask {
private static final boolean DEBUG = true; private static final boolean DEBUG = true;
private static final String KEY_MIGRATION_SRC_WORKSPACE_SIZE = "migration_src_workspace_size"; private static final String KEY_MIGRATION_SRC_WORKSPACE_SIZE = "migration_src_workspace_size";
private static final String KEY_MIGRATION_SRC_HOTSEAT_SIZE = "migration_src_hotseat_size"; private static final String KEY_MIGRATION_SRC_HOTSEAT_COUNT = "migration_src_hotseat_count";
// Set of entries indicating minimum size a widget can be resized to. This is used during // Set of entries indicating minimum size a widget can be resized to. This is used during
// restore in case the widget has not been installed yet. // restore in case the widget has not been installed yet.
@@ -78,9 +78,7 @@ public class GridSizeMigrationTask {
private final boolean mShouldRemoveX, mShouldRemoveY; private final boolean mShouldRemoveX, mShouldRemoveY;
private final int mSrcHotseatSize; private final int mSrcHotseatSize;
private final int mSrcAllAppsRank;
private final int mDestHotseatSize; private final int mDestHotseatSize;
private final int mDestAllAppsRank;
protected GridSizeMigrationTask(Context context, InvariantDeviceProfile idp, protected GridSizeMigrationTask(Context context, InvariantDeviceProfile idp,
HashSet<String> validPackages, HashMap<String, Point> widgetMinSize, HashSet<String> validPackages, HashMap<String, Point> widgetMinSize,
@@ -100,22 +98,19 @@ public class GridSizeMigrationTask {
mShouldRemoveY = mTrgY < mSrcY; mShouldRemoveY = mTrgY < mSrcY;
// Non-used variables // Non-used variables
mSrcHotseatSize = mSrcAllAppsRank = mDestHotseatSize = mDestAllAppsRank = -1; mSrcHotseatSize = mDestHotseatSize = -1;
} }
protected GridSizeMigrationTask(Context context, protected GridSizeMigrationTask(Context context,
InvariantDeviceProfile idp, HashSet<String> validPackages, InvariantDeviceProfile idp, HashSet<String> validPackages,
int srcHotseatSize, int srcAllAppsRank, int srcHotseatSize, int destHotseatSize) {
int destHotseatSize, int destAllAppsRank) {
mContext = context; mContext = context;
mIdp = idp; mIdp = idp;
mValidPackages = validPackages; mValidPackages = validPackages;
mSrcHotseatSize = srcHotseatSize; mSrcHotseatSize = srcHotseatSize;
mSrcAllAppsRank = srcAllAppsRank;
mDestHotseatSize = destHotseatSize; mDestHotseatSize = destHotseatSize;
mDestAllAppsRank = destAllAppsRank;
// Non-used variables // Non-used variables
mSrcX = mSrcY = mTrgX = mTrgY = -1; mSrcX = mSrcY = mTrgX = mTrgY = -1;
@@ -187,7 +182,7 @@ public class GridSizeMigrationTask {
} }
newScreenId++; newScreenId++;
if (newScreenId == mDestAllAppsRank) { if (!FeatureFlags.NO_ALL_APPS_ICON && mIdp.isAllAppsButtonRank(newScreenId)) {
newScreenId++; newScreenId++;
} }
} }
@@ -894,8 +889,7 @@ public class GridSizeMigrationTask {
Utilities.getPrefs(context).edit() Utilities.getPrefs(context).edit()
.putString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, .putString(KEY_MIGRATION_SRC_WORKSPACE_SIZE,
getPointString((int) srcProfile.desktopCols, (int) srcProfile.desktopRows)) getPointString((int) srcProfile.desktopCols, (int) srcProfile.desktopRows))
.putString(KEY_MIGRATION_SRC_HOTSEAT_SIZE, .putInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, (int) srcProfile.hotseatCount)
getPointString((int) srcProfile.hotseatCount, srcProfile.allappsRank))
.putStringSet(KEY_MIGRATION_WIDGET_MINSIZE, widgets) .putStringSet(KEY_MIGRATION_WIDGET_MINSIZE, widgets)
.apply(); .apply();
} }
@@ -909,10 +903,9 @@ public class GridSizeMigrationTask {
InvariantDeviceProfile idp = LauncherAppState.getInstance().getInvariantDeviceProfile(); InvariantDeviceProfile idp = LauncherAppState.getInstance().getInvariantDeviceProfile();
String gridSizeString = getPointString(idp.numColumns, idp.numRows); String gridSizeString = getPointString(idp.numColumns, idp.numRows);
String hotseatSizeString = getPointString(idp.numHotseatIcons, idp.hotseatAllAppsRank);
if (gridSizeString.equals(prefs.getString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, "")) && if (gridSizeString.equals(prefs.getString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, "")) &&
hotseatSizeString.equals(prefs.getString(KEY_MIGRATION_SRC_HOTSEAT_SIZE, ""))) { idp.numHotseatIcons != prefs.getInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, idp.numHotseatIcons)) {
// Skip if workspace and hotseat sizes have not changed. // Skip if workspace and hotseat sizes have not changed.
return true; return true;
} }
@@ -923,17 +916,13 @@ public class GridSizeMigrationTask {
HashSet validPackages = getValidPackages(context); HashSet validPackages = getValidPackages(context);
// Hotseat // Hotseat
Point srcHotseatSize = parsePoint(prefs.getString( int srcHotseatCount = prefs.getInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, idp.numHotseatIcons);
KEY_MIGRATION_SRC_HOTSEAT_SIZE, hotseatSizeString)); if (srcHotseatCount != idp.numHotseatIcons) {
if (srcHotseatSize.x != idp.numHotseatIcons ||
srcHotseatSize.y != idp.hotseatAllAppsRank) {
// Migrate hotseat. // Migrate hotseat.
dbChanged = new GridSizeMigrationTask(context, dbChanged = new GridSizeMigrationTask(context,
LauncherAppState.getInstance().getInvariantDeviceProfile(), LauncherAppState.getInstance().getInvariantDeviceProfile(),
validPackages, validPackages, srcHotseatCount, idp.numHotseatIcons).migrateHotseat();
srcHotseatSize.x, srcHotseatSize.y,
idp.numHotseatIcons, idp.hotseatAllAppsRank).migrateHotseat();
} }
// Grid size // Grid size
@@ -1014,7 +1003,7 @@ public class GridSizeMigrationTask {
// Save current configuration, so that the migration does not run again. // Save current configuration, so that the migration does not run again.
prefs.edit() prefs.edit()
.putString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, gridSizeString) .putString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, gridSizeString)
.putString(KEY_MIGRATION_SRC_HOTSEAT_SIZE, hotseatSizeString) .putInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, idp.numHotseatIcons)
.remove(KEY_MIGRATION_WIDGET_MINSIZE) .remove(KEY_MIGRATION_WIDGET_MINSIZE)
.apply(); .apply();
} }
+12 -5
View File
@@ -22,7 +22,10 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.android.launcher3.CellLayout; import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ShortcutAndWidgetContainer; import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.config.FeatureFlags;
import java.util.Arrays; import java.util.Arrays;
@@ -190,15 +193,17 @@ public class FocusLogic {
* in portrait orientation. In landscape, [(icon + hotseat) column count x (icon row count)] * in portrait orientation. In landscape, [(icon + hotseat) column count x (icon row count)]
*/ */
// TODO: get rid of the dynamic matrix creation // TODO: get rid of the dynamic matrix creation
public static int[][] createSparseMatrixWithHotseat(CellLayout iconLayout, public static int[][] createSparseMatrixWithHotseat(
CellLayout hotseatLayout, boolean isHotseatHorizontal, int allappsiconRank) { CellLayout iconLayout, CellLayout hotseatLayout, DeviceProfile dp) {
ViewGroup iconParent = iconLayout.getShortcutsAndWidgets(); ViewGroup iconParent = iconLayout.getShortcutsAndWidgets();
ViewGroup hotseatParent = hotseatLayout.getShortcutsAndWidgets(); ViewGroup hotseatParent = hotseatLayout.getShortcutsAndWidgets();
boolean moreIconsInHotseatThanWorkspace = isHotseatHorizontal ? boolean isHotseatHorizontal = !dp.isVerticalBarLayout();
hotseatLayout.getCountX() > iconLayout.getCountX() : boolean moreIconsInHotseatThanWorkspace = !FeatureFlags.NO_ALL_APPS_ICON &&
hotseatLayout.getCountY() > iconLayout.getCountY(); (isHotseatHorizontal
? hotseatLayout.getCountX() > iconLayout.getCountX()
: hotseatLayout.getCountY() > iconLayout.getCountY());
int m, n; int m, n;
if (isHotseatHorizontal) { if (isHotseatHorizontal) {
@@ -210,6 +215,7 @@ public class FocusLogic {
} }
int[][] matrix = createFullMatrix(m, n); int[][] matrix = createFullMatrix(m, n);
if (moreIconsInHotseatThanWorkspace) { if (moreIconsInHotseatThanWorkspace) {
int allappsiconRank = dp.inv.getAllAppsButtonRank();
if (isHotseatHorizontal) { if (isHotseatHorizontal) {
for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {
matrix[allappsiconRank][j] = ALL_APPS_COLUMN; matrix[allappsiconRank][j] = ALL_APPS_COLUMN;
@@ -229,6 +235,7 @@ public class FocusLogic {
int cx = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellX; int cx = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellX;
int cy = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellY; int cy = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellY;
if (moreIconsInHotseatThanWorkspace) { if (moreIconsInHotseatThanWorkspace) {
int allappsiconRank = dp.inv.getAllAppsButtonRank();
if (isHotseatHorizontal && cx >= allappsiconRank) { if (isHotseatHorizontal && cx >= allappsiconRank) {
// Add 1 to account for the All Apps button. // Add 1 to account for the All Apps button.
cx++; cx++;
@@ -33,4 +33,6 @@ public final class FeatureFlags {
// Feature flag to enable moving the QSB on the 0th screen of the workspace // Feature flag to enable moving the QSB on the 0th screen of the workspace
public static final boolean QSB_ON_FIRST_SCREEN = true; public static final boolean QSB_ON_FIRST_SCREEN = true;
// When enabled the all-apps icon is not added to the hotseat.
public static final boolean NO_ALL_APPS_ICON = true;
} }
@@ -58,7 +58,8 @@ public class GridSizeMigrationTaskTest extends ProviderTestCase2<TestLauncherPro
addItem(APPLICATION, 4, HOTSEAT, 0, 0), addItem(APPLICATION, 4, HOTSEAT, 0, 0),
}; };
new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, 5, 2, 3, 1) mIdp.numHotseatIcons = 3;
new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, 5, 3)
.migrateHotseat(); .migrateHotseat();
// First & last items are dropped as they have the least weight. // First & last items are dropped as they have the least weight.
verifyHotseat(hotseatItems[1], -1, hotseatItems[3]); verifyHotseat(hotseatItems[1], -1, hotseatItems[3]);
@@ -73,7 +74,8 @@ public class GridSizeMigrationTaskTest extends ProviderTestCase2<TestLauncherPro
addItem(10, 4, HOTSEAT, 0, 0), addItem(10, 4, HOTSEAT, 0, 0),
}; };
new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, 5, 2, 3, 1) mIdp.numHotseatIcons = 3;
new GridSizeMigrationTask(getMockContext(), mIdp, mValidPackages, 5, 3)
.migrateHotseat(); .migrateHotseat();
// First & third items are dropped as they have the least weight. // First & third items are dropped as they have the least weight.
verifyHotseat(hotseatItems[1], -1, hotseatItems[4]); verifyHotseat(hotseatItems[1], -1, hotseatItems[4]);