Merge "Set default value of gridName to current grid name in GridOptionsProvider" into ub-launcher3-master

This commit is contained in:
Tracy Zhou
2020-03-19 02:17:19 +00:00
committed by Android (Google) Code Review
2 changed files with 11 additions and 4 deletions
@@ -32,8 +32,11 @@ public class PreviewSurfaceRenderer {
/** Handle a received surface view request. */
public static void render(Context context, Bundle bundle) {
final String gridName = bundle.getString("name");
String gridName = bundle.getString("name");
bundle.remove("name");
if (gridName == null) {
gridName = InvariantDeviceProfile.getCurrentGridName(context);
}
final InvariantDeviceProfile idp = new InvariantDeviceProfile(context, gridName);
MAIN_EXECUTOR.execute(() -> {
@@ -162,9 +162,7 @@ public class InvariantDeviceProfile {
"PreviewContext is passed into this IDP constructor");
}
String gridName = Utilities.getPrefs(context).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false)
? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null)
: null;
String gridName = getCurrentGridName(context);
initGrid(context, gridName);
mConfigMonitor = new ConfigMonitor(context,
APPLY_CONFIG_AT_RUNTIME.get() ? this::onConfigChanged : this::killProcess);
@@ -188,6 +186,12 @@ public class InvariantDeviceProfile {
initGrid(context, null, new Info(display));
}
public static String getCurrentGridName(Context context) {
return Utilities.getPrefs(context).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false)
? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null)
: null;
}
/**
* Retrieve system defined or RRO overriden icon shape.
*/