Move LauncherApplication's state and code to LauncherAppState.
This removes Launcher's static data and other state out of
the Application object. Now LauncherApplication (extends
Application) exists only to instantiate LauncherAppState.
Change-Id: I4e323bd78b77536b92054105536a55c0c2c19ba8
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 4c80b6b..f971a37 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -94,7 +94,7 @@
@Override
public boolean onCreate() {
mOpenHelper = new DatabaseHelper(getContext());
- ((LauncherApplication) getContext()).setLauncherProvider(this);
+ LauncherAppState.getInstance().setLauncherProvider(this);
return true;
}
@@ -210,7 +210,7 @@
* @param Should we load the old db for upgrade? first run only.
*/
synchronized public boolean shouldLoadOldDb() {
- String spKey = LauncherApplication.getSharedPreferencesKey();
+ String spKey = LauncherAppState.getSharedPreferencesKey();
SharedPreferences sp = getContext().getSharedPreferences(spKey, Context.MODE_PRIVATE);
boolean loadOldDb = false;
@@ -228,7 +228,7 @@
* @param workspaceResId that can be 0 to use default or non-zero for specific resource
*/
synchronized public void loadDefaultFavoritesIfNecessary(int origWorkspaceResId) {
- String spKey = LauncherApplication.getSharedPreferencesKey();
+ String spKey = LauncherAppState.getSharedPreferencesKey();
SharedPreferences sp = getContext().getSharedPreferences(spKey, Context.MODE_PRIVATE);
if (sp.getBoolean(DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED, false)) {
@@ -328,7 +328,7 @@
}
private void setFlagToLoadDefaultWorkspaceLater() {
- String spKey = LauncherApplication.getSharedPreferencesKey();
+ String spKey = LauncherAppState.getSharedPreferencesKey();
SharedPreferences sp = mContext.getSharedPreferences(spKey, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putBoolean(DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED, true);