Merge "Groundwork for runtime-toggleable feature flags" into ub-launcher3-master
This commit is contained in:
commit
f307b6032e
|
@ -16,10 +16,17 @@
|
|||
|
||||
package com.android.launcher3.config;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Defines a set of flags used to control various launcher behaviors
|
||||
*/
|
||||
public final class FeatureFlags extends BaseFlags {
|
||||
private static FeatureFlags instance = new FeatureFlags();
|
||||
|
||||
public static FeatureFlags getInstance(Context context) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private FeatureFlags() {}
|
||||
|
||||
|
|
|
@ -1752,12 +1752,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
|||
@Override
|
||||
public void bindScreens(ArrayList<Long> orderedScreenIds) {
|
||||
// Make sure the first screen is always at the start.
|
||||
if (FeatureFlags.QSB_ON_FIRST_SCREEN &&
|
||||
if (FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled() &&
|
||||
orderedScreenIds.indexOf(Workspace.FIRST_SCREEN_ID) != 0) {
|
||||
orderedScreenIds.remove(Workspace.FIRST_SCREEN_ID);
|
||||
orderedScreenIds.add(0, Workspace.FIRST_SCREEN_ID);
|
||||
LauncherModel.updateWorkspaceScreenOrder(this, orderedScreenIds);
|
||||
} else if (!FeatureFlags.QSB_ON_FIRST_SCREEN && orderedScreenIds.isEmpty()) {
|
||||
} else if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled()
|
||||
&& orderedScreenIds.isEmpty()) {
|
||||
// If there are no screens, we need to have an empty screen
|
||||
mWorkspace.addExtraEmptyScreen();
|
||||
}
|
||||
|
@ -1773,7 +1774,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
|||
int count = orderedScreenIds.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
long screenId = orderedScreenIds.get(i);
|
||||
if (!FeatureFlags.QSB_ON_FIRST_SCREEN || screenId != Workspace.FIRST_SCREEN_ID) {
|
||||
if (!FeatureFlags.getInstance(this).isQsbOnFirstScreenEnabled()
|
||||
|| screenId != Workspace.FIRST_SCREEN_ID) {
|
||||
// No need to bind the first screen, as its always bound.
|
||||
mWorkspace.insertNewWorkspaceScreenBeforeEmptyScreen(screenId);
|
||||
}
|
||||
|
|
|
@ -789,7 +789,7 @@ public class LauncherProvider extends ContentProvider {
|
|||
convertShortcutsToLauncherActivities(db);
|
||||
case 26:
|
||||
// QSB was moved to the grid. Clear the first row on screen 0.
|
||||
if (FeatureFlags.QSB_ON_FIRST_SCREEN &&
|
||||
if (FeatureFlags.getInstance(mContext).isQsbOnFirstScreenEnabled() &&
|
||||
!LauncherDbUtils.prepareScreenZeroToHostQsb(mContext, db)) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -479,7 +479,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
|||
* @param qsb an existing qsb to recycle or null.
|
||||
*/
|
||||
public void bindAndInitFirstWorkspaceScreen(View qsb) {
|
||||
if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {
|
||||
if (!FeatureFlags.getInstance(getContext()).isQsbOnFirstScreenEnabled()) {
|
||||
return;
|
||||
}
|
||||
// Add the first page
|
||||
|
@ -778,7 +778,9 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
|||
long id = mWorkspaceScreens.keyAt(i);
|
||||
CellLayout cl = mWorkspaceScreens.valueAt(i);
|
||||
// FIRST_SCREEN_ID can never be removed.
|
||||
if ((!FeatureFlags.QSB_ON_FIRST_SCREEN || id > FIRST_SCREEN_ID)
|
||||
boolean qsbFirstScreenEnabled =
|
||||
FeatureFlags.getInstance(getContext()).isQsbOnFirstScreenEnabled();
|
||||
if ((!qsbFirstScreenEnabled || id > FIRST_SCREEN_ID)
|
||||
&& cl.getShortcutsAndWidgets().getChildCount() == 0) {
|
||||
removeScreens.add(id);
|
||||
}
|
||||
|
|
|
@ -19,14 +19,16 @@ package com.android.launcher3.config;
|
|||
/**
|
||||
* Defines a set of flags used to control various launcher behaviors.
|
||||
*
|
||||
* All the flags should be defined here with appropriate default values. To override a value,
|
||||
* redefine it in {@link FeatureFlags}.
|
||||
* <p>All the flags should be defined here with appropriate default values.
|
||||
*
|
||||
* This class is kept package-private to prevent direct access.
|
||||
* <p>This class is kept package-private to prevent direct access.
|
||||
*/
|
||||
abstract class BaseFlags {
|
||||
|
||||
BaseFlags() {}
|
||||
private static final String TAG = "FeatureFlags";
|
||||
|
||||
BaseFlags() {
|
||||
}
|
||||
|
||||
public static final boolean IS_DOGFOOD_BUILD = false;
|
||||
public static final String AUTHORITY = "com.android.launcher3.settings".intern();
|
||||
|
@ -34,8 +36,10 @@ abstract class BaseFlags {
|
|||
// When enabled the promise icon is visible in all apps while installation an app.
|
||||
public static final boolean LAUNCHER3_PROMISE_APPS_IN_ALL_APPS = false;
|
||||
|
||||
// Feature flag to enable moving the QSB on the 0th screen of the workspace.
|
||||
public static final boolean QSB_ON_FIRST_SCREEN = true;
|
||||
/** Feature flag to enable moving the QSB on the 0th screen of the workspace. */
|
||||
public boolean isQsbOnFirstScreenEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
//Feature flag to enable pulling down navigation shade from workspace.
|
||||
public static final boolean PULL_DOWN_STATUS_BAR = true;
|
||||
|
|
|
@ -251,7 +251,9 @@ public class GridSizeMigrationTask {
|
|||
*/
|
||||
protected void migrateScreen(long screenId) {
|
||||
// If we are migrating the first screen, do not touch the first row.
|
||||
int startY = (FeatureFlags.QSB_ON_FIRST_SCREEN && screenId == Workspace.FIRST_SCREEN_ID)
|
||||
int startY =
|
||||
(FeatureFlags.getInstance(mContext).isQsbOnFirstScreenEnabled()
|
||||
&& screenId == Workspace.FIRST_SCREEN_ID)
|
||||
? 1 : 0;
|
||||
|
||||
ArrayList<DbEntry> items = loadWorkspaceEntries(screenId);
|
||||
|
|
|
@ -440,7 +440,8 @@ public class LoaderCursor extends CursorWrapper {
|
|||
if (item.screenId == Workspace.FIRST_SCREEN_ID) {
|
||||
// Mark the first row as occupied (if the feature is enabled)
|
||||
// in order to account for the QSB.
|
||||
screen.markCells(0, 0, countX + 1, 1, FeatureFlags.QSB_ON_FIRST_SCREEN);
|
||||
screen.markCells(0, 0, countX + 1, 1,
|
||||
FeatureFlags.getInstance(mContext).isQsbOnFirstScreenEnabled());
|
||||
}
|
||||
occupied.put(item.screenId, screen);
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ public class ImportDataTask {
|
|||
.getSerialNumberForUser(Process.myUserHandle()));
|
||||
|
||||
boolean createEmptyRowOnFirstScreen;
|
||||
if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
|
||||
if (FeatureFlags.getInstance(mContext).isQsbOnFirstScreenEnabled()) {
|
||||
try (Cursor c = mContext.getContentResolver().query(mOtherFavoritesUri, null,
|
||||
// get items on the first row of the first screen
|
||||
"profileId = ? AND container = -100 AND screen = ? AND cellY = 0",
|
||||
|
|
|
@ -213,7 +213,7 @@ public class QsbContainerView extends FrameLayout {
|
|||
}
|
||||
|
||||
public boolean isQsbEnabled() {
|
||||
return FeatureFlags.QSB_ON_FIRST_SCREEN;
|
||||
return FeatureFlags.getInstance(getContext()).isQsbOnFirstScreenEnabled();
|
||||
}
|
||||
|
||||
protected Bundle createBindOptions() {
|
||||
|
|
|
@ -16,10 +16,17 @@
|
|||
|
||||
package com.android.launcher3.config;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Defines a set of flags used to control various launcher behaviors
|
||||
*/
|
||||
public final class FeatureFlags extends BaseFlags {
|
||||
private static FeatureFlags instance = new FeatureFlags();
|
||||
|
||||
public static FeatureFlags getInstance(Context context) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private FeatureFlags() {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue