diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-10-20 10:37:15 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-10-20 10:37:15 -0700 |
commit | f912beb2ee4b75af1fe8c710d6948b9737fed531 (patch) | |
tree | a8e5ae80d822105c36ff218b739b735a4d5ba9f6 /src/com/android | |
parent | 38ac73a095c99c18ca31b8d9cd14959a762928b7 (diff) | |
parent | fe3db428abc07d253b816bf70d6820a8339becbc (diff) | |
download | packages_apps_Trebuchet-f912beb2ee4b75af1fe8c710d6948b9737fed531.tar.gz packages_apps_Trebuchet-f912beb2ee4b75af1fe8c710d6948b9737fed531.tar.bz2 packages_apps_Trebuchet-f912beb2ee4b75af1fe8c710d6948b9737fed531.zip |
resolve merge conflicts of fe3db428ab to ub-launcher3-master.
Change-Id: Icc60a61f621fefe9db67b178921e62f7d72d7e5a
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher3/InstallShortcutReceiver.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherAppState.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherClings.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherProvider.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher3/compat/UserManagerCompatVL.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/model/MigrateFromRestoreTask.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher3/testing/ToggleWeightWatcher.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher3/util/TestingUtils.java | 5 |
10 files changed, 32 insertions, 64 deletions
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java index 3fc8fc0a9..9a7519323 100644 --- a/src/com/android/launcher3/InstallShortcutReceiver.java +++ b/src/com/android/launcher3/InstallShortcutReceiver.java @@ -92,8 +92,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver { if (packageNames.isEmpty()) { return; } - String spKey = LauncherAppState.getSharedPreferencesKey(); - SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); + SharedPreferences sp = Utilities.getPrefs(context); synchronized(sLock) { Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) { @@ -176,9 +175,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver { LauncherAppState app = LauncherAppState.getInstance(); boolean launcherNotLoaded = app.getModel().getCallback() == null; - String spKey = LauncherAppState.getSharedPreferencesKey(); - SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); - addToInstallQueue(sp, info); + addToInstallQueue(Utilities.getPrefs(context), info); if (!mUseInstallQueue && !launcherNotLoaded) { flushInstallQueue(context); } @@ -192,8 +189,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver { flushInstallQueue(context); } static void flushInstallQueue(Context context) { - String spKey = LauncherAppState.getSharedPreferencesKey(); - SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); + SharedPreferences sp = Utilities.getPrefs(context); ArrayList<PendingInstallShortcutInfo> installQueue = getAndClearInstallQueue(sp, context); if (!installQueue.isEmpty()) { Iterator<PendingInstallShortcutInfo> iter = installQueue.iterator(); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index fd208dba9..3897d9e85 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -414,8 +414,7 @@ public class Launcher extends Activity app.getInvariantDeviceProfile().landscapeProfile : app.getInvariantDeviceProfile().portraitProfile; - mSharedPrefs = getSharedPreferences(LauncherAppState.getSharedPreferencesKey(), - Context.MODE_PRIVATE); + mSharedPrefs = Utilities.getPrefs(this); mIsSafeModeEnabled = getPackageManager().isSafeMode(); mModel = app.setLauncher(this); mIconCache = app.getIconCache(); @@ -3596,12 +3595,10 @@ public class Launcher extends Activity opts.putAll(mLauncherCallbacks.getAdditionalSearchWidgetOptions()); } - SharedPreferences sp = getSharedPreferences( - LauncherAppState.getSharedPreferencesKey(), MODE_PRIVATE); - int widgetId = sp.getInt(QSB_WIDGET_ID, -1); + int widgetId = mSharedPrefs.getInt(QSB_WIDGET_ID, -1); AppWidgetProviderInfo widgetInfo = mAppWidgetManager.getAppWidgetInfo(widgetId); if (!searchProvider.provider.flattenToString().equals( - sp.getString(QSB_WIDGET_PROVIDER, null)) + mSharedPrefs.getString(QSB_WIDGET_PROVIDER, null)) || (widgetInfo == null) || !widgetInfo.provider.equals(searchProvider.provider)) { // A valid widget is not already bound. @@ -3619,7 +3616,7 @@ public class Launcher extends Activity widgetId = -1; } - sp.edit() + mSharedPrefs.edit() .putInt(QSB_WIDGET_ID, widgetId) .putString(QSB_WIDGET_PROVIDER, searchProvider.provider.flattenToString()) .commit(); diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index 3b207a9cf..f0e34e513 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -161,10 +161,6 @@ public class LauncherAppState { return sLauncherProvider.get(); } - public static String getSharedPreferencesKey() { - return LauncherFiles.SHARED_PREFERENCES_KEY; - } - public WidgetPreviewLoader getWidgetCache() { return mWidgetCache; } diff --git a/src/com/android/launcher3/LauncherClings.java b/src/com/android/launcher3/LauncherClings.java index 43d05a659..cffcbf27f 100644 --- a/src/com/android/launcher3/LauncherClings.java +++ b/src/com/android/launcher3/LauncherClings.java @@ -75,9 +75,7 @@ class LauncherClings implements OnClickListener, OnKeyListener { LauncherModel.LOADER_FLAG_CLEAR_WORKSPACE | LauncherModel.LOADER_FLAG_MIGRATE_SHORTCUTS); // Set the flag to skip the folder cling - String spKey = LauncherAppState.getSharedPreferencesKey(); - SharedPreferences sp = mLauncher.getSharedPreferences(spKey, Context.MODE_PRIVATE); - SharedPreferences.Editor editor = sp.edit(); + SharedPreferences.Editor editor = Utilities.getPrefs(mLauncher).edit(); editor.putBoolean(Launcher.USER_HAS_MIGRATED, true); editor.apply(); // Disable the migration cling @@ -279,9 +277,7 @@ class LauncherClings implements OnClickListener, OnKeyListener { } public static void synchonouslyMarkFirstRunClingDismissed(Context ctx) { - SharedPreferences prefs = ctx.getSharedPreferences( - LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); - SharedPreferences.Editor editor = prefs.edit(); + SharedPreferences.Editor editor = Utilities.getPrefs(ctx).edit(); editor.putBoolean(WORKSPACE_CLING_DISMISSED_KEY, true); editor.commit(); } diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java index 0c5671314..230bedb21 100644 --- a/src/com/android/launcher3/LauncherProvider.java +++ b/src/com/android/launcher3/LauncherProvider.java @@ -257,17 +257,13 @@ public class LauncherProvider extends ContentProvider { case LauncherSettings.Settings.METHOD_GET_BOOLEAN: { Bundle result = new Bundle(); result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE, - getContext().getSharedPreferences( - LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE) - .getBoolean(arg, extras.getBoolean( - LauncherSettings.Settings.EXTRA_DEFAULT_VALUE))); + Utilities.getPrefs(getContext()).getBoolean(arg, extras.getBoolean( + LauncherSettings.Settings.EXTRA_DEFAULT_VALUE))); return result; } case LauncherSettings.Settings.METHOD_SET_BOOLEAN: { boolean value = extras.getBoolean(LauncherSettings.Settings.EXTRA_VALUE); - getContext().getSharedPreferences( - LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE) - .edit().putBoolean(arg, value).apply(); + Utilities.getPrefs(getContext()).edit().putBoolean(arg, value).apply(); if (mListener != null) { mListener.onSettingsChanged(arg, value); } @@ -343,11 +339,7 @@ public class LauncherProvider extends ContentProvider { } public void clearFlagEmptyDbCreated() { - String spKey = LauncherAppState.getSharedPreferencesKey(); - getContext().getSharedPreferences(spKey, Context.MODE_PRIVATE) - .edit() - .remove(EMPTY_DATABASE_CREATED) - .commit(); + Utilities.getPrefs(getContext()).edit().remove(EMPTY_DATABASE_CREATED).commit(); } /** @@ -358,8 +350,7 @@ public class LauncherProvider extends ContentProvider { * 4) The default configuration for the particular device */ synchronized public void loadDefaultFavoritesIfNecessary() { - String spKey = LauncherAppState.getSharedPreferencesKey(); - SharedPreferences sp = getContext().getSharedPreferences(spKey, Context.MODE_PRIVATE); + SharedPreferences sp = Utilities.getPrefs(getContext()); if (sp.getBoolean(EMPTY_DATABASE_CREATED, false)) { Log.d(TAG, "loading default workspace"); @@ -635,15 +626,11 @@ public class LauncherProvider extends ContentProvider { } private void setFlagJustLoadedOldDb() { - String spKey = LauncherAppState.getSharedPreferencesKey(); - SharedPreferences sp = mContext.getSharedPreferences(spKey, Context.MODE_PRIVATE); - sp.edit().putBoolean(EMPTY_DATABASE_CREATED, false).commit(); + Utilities.getPrefs(mContext).edit().putBoolean(EMPTY_DATABASE_CREATED, false).commit(); } private void setFlagEmptyDbCreated() { - String spKey = LauncherAppState.getSharedPreferencesKey(); - SharedPreferences sp = mContext.getSharedPreferences(spKey, Context.MODE_PRIVATE); - sp.edit().putBoolean(EMPTY_DATABASE_CREATED, true).commit(); + Utilities.getPrefs(mContext).edit().putBoolean(EMPTY_DATABASE_CREATED, true).commit(); } @Override diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 24975ac1a..9c8128488 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -140,9 +140,8 @@ public final class Utilities { } public static boolean isAllowRotationPrefEnabled(Context context) { - SharedPreferences sharedPrefs = context.getSharedPreferences( - LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); - boolean allowRotationPref = sharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, false); + boolean allowRotationPref = getPrefs(context) + .getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, false); return sForceEnableRotation || allowRotationPref; } @@ -801,4 +800,9 @@ public final class Utilities { public static int longCompare(long lhs, long rhs) { return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1); } + + public static SharedPreferences getPrefs(Context context) { + return context.getSharedPreferences( + LauncherFiles.SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE); + } } diff --git a/src/com/android/launcher3/compat/UserManagerCompatVL.java b/src/com/android/launcher3/compat/UserManagerCompatVL.java index 9df7f5aa5..c53d702b7 100644 --- a/src/com/android/launcher3/compat/UserManagerCompatVL.java +++ b/src/com/android/launcher3/compat/UserManagerCompatVL.java @@ -24,7 +24,6 @@ import android.content.pm.PackageManager; import android.os.Build; import android.os.UserHandle; -import com.android.launcher3.LauncherAppState; import com.android.launcher3.Utilities; import com.android.launcher3.util.LongArrayMap; @@ -98,8 +97,7 @@ public class UserManagerCompatVL extends UserManagerCompatV17 { if (Utilities.ATLEAST_MARSHMALLOW) { return mUserManager.getUserCreationTime(user.getUser()); } - SharedPreferences prefs = mContext.getSharedPreferences( - LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); + SharedPreferences prefs = Utilities.getPrefs(mContext); String key = USER_CREATION_TIME_KEY + getSerialNumberForUser(user); if (!prefs.contains(key)) { prefs.edit().putLong(key, System.currentTimeMillis()).apply(); diff --git a/src/com/android/launcher3/model/MigrateFromRestoreTask.java b/src/com/android/launcher3/model/MigrateFromRestoreTask.java index ba33b02ce..786ab6009 100644 --- a/src/com/android/launcher3/model/MigrateFromRestoreTask.java +++ b/src/com/android/launcher3/model/MigrateFromRestoreTask.java @@ -71,7 +71,7 @@ public class MigrateFromRestoreTask { public MigrateFromRestoreTask(Context context) { mContext = context; - SharedPreferences prefs = prefs(context); + SharedPreferences prefs = Utilities.getPrefs(context); Point sourceSize = parsePoint(prefs.getString(KEY_MIGRATION_SOURCE_SIZE, "")); mSrcX = sourceSize.x; mSrcY = sourceSize.y; @@ -745,23 +745,19 @@ public class MigrateFromRestoreTask { public static void markForMigration(Context context, int srcX, int srcY, HashSet<String> widgets) { - prefs(context).edit() + Utilities.getPrefs(context).edit() .putString(KEY_MIGRATION_SOURCE_SIZE, srcX + "," + srcY) .putStringSet(KEY_MIGRATION_WIDGET_MINSIZE, widgets) .apply(); } public static boolean shouldRunTask(Context context) { - return !TextUtils.isEmpty(prefs(context).getString(KEY_MIGRATION_SOURCE_SIZE, "")); + return !TextUtils.isEmpty(Utilities.getPrefs(context).getString(KEY_MIGRATION_SOURCE_SIZE, "")); } public static void clearFlags(Context context) { - prefs(context).edit().remove(KEY_MIGRATION_SOURCE_SIZE) + Utilities.getPrefs(context).edit().remove(KEY_MIGRATION_SOURCE_SIZE) .remove(KEY_MIGRATION_WIDGET_MINSIZE).commit(); } - private static SharedPreferences prefs(Context context) { - return context.getSharedPreferences(LauncherAppState.getSharedPreferencesKey(), - Context.MODE_PRIVATE); - } } diff --git a/src/com/android/launcher3/testing/ToggleWeightWatcher.java b/src/com/android/launcher3/testing/ToggleWeightWatcher.java index 15e55eea6..e08ec3aca 100644 --- a/src/com/android/launcher3/testing/ToggleWeightWatcher.java +++ b/src/com/android/launcher3/testing/ToggleWeightWatcher.java @@ -1,13 +1,13 @@ package com.android.launcher3.testing; import android.app.Activity; -import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; +import com.android.launcher3.Utilities; import com.android.launcher3.util.TestingUtils; public class ToggleWeightWatcher extends Activity { @@ -16,8 +16,7 @@ public class ToggleWeightWatcher extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - String spKey = LauncherAppState.getSharedPreferencesKey(); - SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_PRIVATE); + SharedPreferences sp = Utilities.getPrefs(this); boolean show = sp.getBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, true); show = !show; diff --git a/src/com/android/launcher3/util/TestingUtils.java b/src/com/android/launcher3/util/TestingUtils.java index 39b80463d..665c37175 100644 --- a/src/com/android/launcher3/util/TestingUtils.java +++ b/src/com/android/launcher3/util/TestingUtils.java @@ -13,6 +13,7 @@ import com.android.launcher3.CustomAppWidget; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import java.util.HashMap; @@ -39,9 +40,7 @@ public class TestingUtils { public static void addWeightWatcher(Launcher launcher) { if (MEMORY_DUMP_ENABLED) { - String spKey = LauncherAppState.getSharedPreferencesKey(); - SharedPreferences sp = launcher.getSharedPreferences(spKey, Context.MODE_PRIVATE); - boolean show = sp.getBoolean(SHOW_WEIGHT_WATCHER, true); + boolean show = Utilities.getPrefs(launcher).getBoolean(SHOW_WEIGHT_WATCHER, true); int id = launcher.getResources().getIdentifier("zzz_weight_watcher", "layout", launcher.getPackageName()); |