mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Migrate existing 4x5 and 4x4 grid users to a new 4x5 grid.
Due to the dogfood 4x5 grid using the wrong db, there may
be some rearranging of items.
The goal is to completely remove the old 4x4 and 4x5 grid,
but first we need to silently migrate users to the new grid.
We still need to keep the old grids in the device profile
so we hide them from the Styles & Wallpaper app.
We also need to reset and remove the ENABLE_FOUR_COLUMN feature
flag from the UI.
- Added TODO to remove this logic in the tracking doc
Bug: 183965808
Bug: 175329686
Test: have old 4x4 or 4x5 grid set up
install apk with these changes
confirm that we are now using the new grid and the
other grid options are inaccessible to the user
Change-Id: I81a91b8415effbe0bf7ba722f11ab44a4169e3df
This commit is contained in:
committed by
Jonathan Miranda
parent
78f5a8c6ab
commit
ec1277eec1
@@ -132,6 +132,9 @@
|
||||
<attr name="isScalable" format="boolean" />
|
||||
<attr name="devicePaddingId" format="reference" />
|
||||
|
||||
<!-- whether the grid option is shown to the user -->
|
||||
<attr name="visible" format="boolean" />
|
||||
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="DevicePadding">
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.launcher3;
|
||||
import static android.animation.ValueAnimator.areAnimatorsEnabled;
|
||||
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_FOUR_COLUMNS;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -602,7 +601,7 @@ public class CellLayout extends ViewGroup {
|
||||
if (child instanceof BubbleTextView) {
|
||||
BubbleTextView bubbleChild = (BubbleTextView) child;
|
||||
bubbleChild.setTextVisibility(mContainerType != HOTSEAT);
|
||||
if (ENABLE_FOUR_COLUMNS.get()) {
|
||||
if (mActivity.getDeviceProfile().isScalableGrid) {
|
||||
bubbleChild.setCenterVertically(mContainerType != HOTSEAT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,6 +626,8 @@ public class InvariantDeviceProfile {
|
||||
private final boolean isScalable;
|
||||
private final int devicePaddingId;
|
||||
|
||||
public final boolean visible;
|
||||
|
||||
private final SparseArray<TypedValue> extraAttrs;
|
||||
|
||||
public GridOption(Context context, AttributeSet attrs) {
|
||||
@@ -652,6 +654,8 @@ public class InvariantDeviceProfile {
|
||||
devicePaddingId = a.getResourceId(
|
||||
R.styleable.GridDisplayOption_devicePaddingId, 0);
|
||||
|
||||
visible = a.getBoolean(R.styleable.GridDisplayOption_visible, true);
|
||||
|
||||
a.recycle();
|
||||
|
||||
extraAttrs = Themes.createValueMap(context, attrs,
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
|
||||
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
|
||||
import static com.android.launcher3.InvariantDeviceProfile.KEY_MIGRATION_SRC_HOTSEAT_COUNT;
|
||||
import static com.android.launcher3.InvariantDeviceProfile.KEY_MIGRATION_SRC_WORKSPACE_SIZE;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_FOUR_COLUMNS;
|
||||
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -37,10 +40,10 @@ import com.android.launcher3.notification.NotificationListener;
|
||||
import com.android.launcher3.pm.InstallSessionHelper;
|
||||
import com.android.launcher3.pm.InstallSessionTracker;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.Preconditions;
|
||||
import com.android.launcher3.util.SafeCloseable;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.launcher3.util.SimpleBroadcastReceiver;
|
||||
import com.android.launcher3.widget.custom.CustomWidgetManager;
|
||||
|
||||
@@ -122,6 +125,34 @@ public class LauncherAppState {
|
||||
mContext = context;
|
||||
|
||||
mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(context);
|
||||
|
||||
// b/175329686 Temporary logic to gracefully migrate group of users to the new 4x5 grid.
|
||||
String gridName = InvariantDeviceProfile.getCurrentGridName(context);
|
||||
if (ENABLE_FOUR_COLUMNS.get()
|
||||
|| "reasonable".equals(gridName)
|
||||
|| ENABLE_FOUR_COLUMNS.key.equals(gridName)) {
|
||||
// Reset flag and remove it from developer options to prevent it from being enabled
|
||||
// again.
|
||||
ENABLE_FOUR_COLUMNS.reset(context);
|
||||
FeatureFlags.removeFlag(ENABLE_FOUR_COLUMNS);
|
||||
|
||||
// Force migration code to run
|
||||
Utilities.getPrefs(context).edit()
|
||||
.remove(KEY_MIGRATION_SRC_HOTSEAT_COUNT)
|
||||
.remove(KEY_MIGRATION_SRC_WORKSPACE_SIZE)
|
||||
.apply();
|
||||
|
||||
// We make an empty call here to ensure the database is created with the old IDP grid,
|
||||
// so that when we set the new grid the migration can proceeds as expected.
|
||||
LauncherSettings.Settings.call(context.getContentResolver(), "");
|
||||
|
||||
String newGridName = "practical";
|
||||
Utilities.getPrefs(mContext).edit().putString("idp_grid_name", newGridName).commit();
|
||||
mInvariantDeviceProfile.setCurrentGrid(context, "practical");
|
||||
} else {
|
||||
FeatureFlags.removeFlag(ENABLE_FOUR_COLUMNS);
|
||||
}
|
||||
|
||||
mIconCache = new IconCache(mContext, mInvariantDeviceProfile, iconCacheFileName);
|
||||
mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache);
|
||||
mModel = new LauncherModel(context, this, mIconCache, new AppFilter(mContext));
|
||||
|
||||
@@ -15,6 +15,7 @@ public class LauncherFiles {
|
||||
private static final String XML = ".xml";
|
||||
|
||||
public static final String LAUNCHER_DB = "launcher.db";
|
||||
public static final String LAUNCHER_4_BY_5_DB = "launcher_4_by_5.db";
|
||||
public static final String LAUNCHER_4_BY_4_DB = "launcher_4_by_4.db";
|
||||
public static final String LAUNCHER_3_BY_3_DB = "launcher_3_by_3.db";
|
||||
public static final String LAUNCHER_2_BY_2_DB = "launcher_2_by_2.db";
|
||||
@@ -30,6 +31,7 @@ public class LauncherFiles {
|
||||
|
||||
public static final List<String> ALL_FILES = Collections.unmodifiableList(Arrays.asList(
|
||||
LAUNCHER_DB,
|
||||
LAUNCHER_4_BY_5_DB,
|
||||
LAUNCHER_4_BY_4_DB,
|
||||
LAUNCHER_3_BY_3_DB,
|
||||
LAUNCHER_2_BY_2_DB,
|
||||
|
||||
@@ -187,7 +187,7 @@ public final class FeatureFlags {
|
||||
"EXPANDED_SMARTSPACE", false, "Expands smartspace height to two rows. "
|
||||
+ "Any apps occupying the first row will be removed from workspace.");
|
||||
|
||||
public static final BooleanFlag ENABLE_FOUR_COLUMNS = new DeviceFlag(
|
||||
public static final DeviceFlag ENABLE_FOUR_COLUMNS = new DeviceFlag(
|
||||
"ENABLE_FOUR_COLUMNS", false, "Uses 4 columns in launcher grid."
|
||||
+ "Warning: This will permanently alter your home screen items and is not reversible.");
|
||||
|
||||
@@ -227,6 +227,12 @@ public final class FeatureFlags {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeFlag(DebugFlag flag) {
|
||||
synchronized (sDebugFlags) {
|
||||
sDebugFlags.remove(flag);
|
||||
}
|
||||
}
|
||||
|
||||
static List<DebugFlag> getDebugFlags() {
|
||||
synchronized (sDebugFlags) {
|
||||
return new ArrayList<>(sDebugFlags);
|
||||
@@ -304,6 +310,15 @@ public final class FeatureFlags {
|
||||
.getBoolean(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets value to default value.
|
||||
*/
|
||||
public void reset(Context context) {
|
||||
mCurrentValue = defaultValue;
|
||||
context.getSharedPreferences(FLAGS_PREF_NAME, Context.MODE_PRIVATE)
|
||||
.edit().putBoolean(key, defaultValue).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StringBuilder appendProps(StringBuilder src) {
|
||||
return super.appendProps(src).append(", mCurrentValue=").append(mCurrentValue);
|
||||
|
||||
@@ -90,7 +90,10 @@ public class GridCustomizationsProvider extends ContentProvider {
|
||||
parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
|
||||
if ((type == XmlPullParser.START_TAG)
|
||||
&& GridOption.TAG_NAME.equals(parser.getName())) {
|
||||
result.add(new GridOption(getContext(), Xml.asAttributeSet(parser)));
|
||||
GridOption option = new GridOption(getContext(), Xml.asAttributeSet(parser));
|
||||
if (option.visible) {
|
||||
result.add(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException | XmlPullParserException e) {
|
||||
|
||||
Reference in New Issue
Block a user