Merge "Loading internal default layout if partner layout fails to load" into ub-now-queens
This commit is contained in:
@@ -322,29 +322,34 @@ public class LauncherProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean usingExternallyProvidedLayout = loader != null;
|
||||||
if (loader == null) {
|
if (loader == null) {
|
||||||
loader = new DefaultLayoutParser(getContext(), mOpenHelper.mAppWidgetHost,
|
loader = getDefaultLayoutParser();
|
||||||
mOpenHelper, getContext().getResources(), getDefaultWorkspaceResourceId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate favorites table with initial favorites
|
// Populate favorites table with initial favorites
|
||||||
SharedPreferences.Editor editor = sp.edit().remove(EMPTY_DATABASE_CREATED);
|
if ((mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), loader) <= 0)
|
||||||
mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(), loader);
|
&& usingExternallyProvidedLayout) {
|
||||||
editor.commit();
|
// Unable to load external layout. Cleanup and load the internal layout.
|
||||||
|
createEmptyDB();
|
||||||
|
mOpenHelper.loadFavorites(mOpenHelper.getWritableDatabase(),
|
||||||
|
getDefaultLayoutParser());
|
||||||
|
}
|
||||||
|
sp.edit().remove(EMPTY_DATABASE_CREATED).commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DefaultLayoutParser getDefaultLayoutParser() {
|
||||||
|
int defaultLayout = LauncherAppState.getInstance()
|
||||||
|
.getDynamicGrid().getDeviceProfile().defaultLayoutId;
|
||||||
|
return new DefaultLayoutParser(getContext(), mOpenHelper.mAppWidgetHost,
|
||||||
|
mOpenHelper, getContext().getResources(), defaultLayout);
|
||||||
|
}
|
||||||
|
|
||||||
public void migrateLauncher2Shortcuts() {
|
public void migrateLauncher2Shortcuts() {
|
||||||
mOpenHelper.migrateLauncher2Shortcuts(mOpenHelper.getWritableDatabase(),
|
mOpenHelper.migrateLauncher2Shortcuts(mOpenHelper.getWritableDatabase(),
|
||||||
Uri.parse(getContext().getString(R.string.old_launcher_provider_uri)));
|
Uri.parse(getContext().getString(R.string.old_launcher_provider_uri)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getDefaultWorkspaceResourceId() {
|
|
||||||
LauncherAppState app = LauncherAppState.getInstance();
|
|
||||||
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
|
|
||||||
return grid.defaultLayoutId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static interface ContentValuesCallback {
|
private static interface ContentValuesCallback {
|
||||||
public void onRow(ContentValues values);
|
public void onRow(ContentValues values);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user