mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-12 23:34:01 +00:00
Merge "Move SharedPreferences code to its own class." into tm-qpr-dev am: 3233010c5a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20446860 Change-Id: I397957b5d9584aebf4182930763a2c5ab6401073 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -50,8 +50,8 @@ import androidx.annotation.IntDef;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.views.ArrowTipView;
|
||||
import com.android.quickstep.util.AssistContentRequester;
|
||||
import com.android.quickstep.util.RecentsOrientedState;
|
||||
@@ -124,7 +124,7 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
|
||||
AssistContentRequester assistContentRequester) {
|
||||
super(taskThumbnailView);
|
||||
mFactoryContentRequester = assistContentRequester;
|
||||
mSharedPreferences = Utilities.getPrefs(mApplicationContext);
|
||||
mSharedPreferences = LauncherPrefs.getPrefs(mApplicationContext);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +151,7 @@ public final class TaskOverlayFactoryGo extends TaskOverlayFactory {
|
||||
boolean isAllowedByPolicy = mThumbnailView.isRealSnapshot() && !isManagedProfileTask;
|
||||
getActionsView().setCallbacks(new OverlayUICallbacksGoImpl(isAllowedByPolicy, task));
|
||||
mTaskPackageName = task.key.getPackageName();
|
||||
mSharedPreferences = Utilities.getPrefs(mApplicationContext);
|
||||
mSharedPreferences = LauncherPrefs.getPrefs(mApplicationContext);
|
||||
checkSettings();
|
||||
|
||||
if (!mAssistStructurePermitted || !mAssistScreenshotPermitted
|
||||
|
||||
@@ -30,7 +30,7 @@ import android.os.UserHandle;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.model.BgDataModel.FixedContainerItems;
|
||||
import com.android.launcher3.model.QuickstepModelDelegate.PredictorState;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
@@ -59,7 +59,7 @@ public class PredictionUpdateTask extends BaseModelUpdateTask {
|
||||
Context context = app.getContext();
|
||||
|
||||
// TODO: remove this
|
||||
Utilities.getDevicePrefs(context).edit()
|
||||
LauncherPrefs.getDevicePrefs(context).edit()
|
||||
.putBoolean(LAST_PREDICTION_ENABLED_STATE, !mTargets.isEmpty()).apply();
|
||||
|
||||
Set<UserHandle> usersForChangedShortcuts =
|
||||
|
||||
@@ -18,12 +18,12 @@ package com.android.launcher3.model;
|
||||
import static android.text.format.DateUtils.DAY_IN_MILLIS;
|
||||
import static android.text.format.DateUtils.formatElapsedTime;
|
||||
|
||||
import static com.android.launcher3.LauncherPrefs.getDevicePrefs;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PREDICTION;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
|
||||
import static com.android.launcher3.Utilities.getDevicePrefs;
|
||||
import static com.android.launcher3.hybridhotseat.HotseatPredictionModel.convertDataModelToAppTargetBundle;
|
||||
import static com.android.launcher3.model.PredictionHelper.getAppTargetFromItemInfo;
|
||||
import static com.android.launcher3.model.PredictionHelper.wrapAppTargetWithItemLocation;
|
||||
|
||||
@@ -26,8 +26,8 @@ import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.RevealOutlineAnimation;
|
||||
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
@@ -81,7 +81,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
|
||||
public StashedHandleViewController(TaskbarActivityContext activity,
|
||||
StashedHandleView stashedHandleView) {
|
||||
mActivity = activity;
|
||||
mPrefs = Utilities.getPrefs(mActivity);
|
||||
mPrefs = LauncherPrefs.getPrefs(mActivity);
|
||||
mStashedHandleView = stashedHandleView;
|
||||
mTaskbarStashedHandleAlpha = new MultiValueAlpha(mStashedHandleView, NUM_ALPHA_CHANNELS);
|
||||
mTaskbarStashedHandleAlpha.setUpdateVisibility(true);
|
||||
|
||||
@@ -42,6 +42,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import com.android.internal.jank.InteractionJankMonitor;
|
||||
import com.android.launcher3.Alarm;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimatorListeners;
|
||||
@@ -187,7 +188,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
|
||||
public TaskbarStashController(TaskbarActivityContext activity) {
|
||||
mActivity = activity;
|
||||
mPrefs = Utilities.getPrefs(mActivity);
|
||||
mPrefs = LauncherPrefs.getPrefs(mActivity);
|
||||
mSystemUiProxy = SystemUiProxy.INSTANCE.get(activity);
|
||||
if (isPhoneMode()) {
|
||||
// DeviceProfile's taskbar vars aren't initialized w/ the flag off
|
||||
|
||||
@@ -19,8 +19,8 @@ import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
|
||||
import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
@@ -62,7 +62,7 @@ public class TaskbarOverlayContext extends BaseTaskbarContext {
|
||||
mOverlayController = controllers.taskbarOverlayController;
|
||||
mDragController = new TaskbarDragController(this);
|
||||
mDragController.init(controllers);
|
||||
mOnboardingPrefs = new OnboardingPrefs<>(this, Utilities.getPrefs(this));
|
||||
mOnboardingPrefs = new OnboardingPrefs<>(this, LauncherPrefs.getPrefs(this));
|
||||
mDragLayer = new TaskbarOverlayDragLayer(this);
|
||||
|
||||
TaskbarStashController taskbarStashController = controllers.taskbarStashController;
|
||||
|
||||
@@ -18,11 +18,11 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.systemui.shared.plugins.PluginEnabler;
|
||||
|
||||
import androidx.preference.PreferenceDataStore;
|
||||
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.systemui.shared.plugins.PluginEnabler;
|
||||
|
||||
public class PluginEnablerImpl extends PreferenceDataStore implements PluginEnabler {
|
||||
|
||||
private static final String PREFIX_PLUGIN_ENABLED = "PLUGIN_ENABLED_";
|
||||
@@ -30,7 +30,7 @@ public class PluginEnablerImpl extends PreferenceDataStore implements PluginEnab
|
||||
final private SharedPreferences mSharedPrefs;
|
||||
|
||||
public PluginEnablerImpl(Context context) {
|
||||
mSharedPrefs = Utilities.getDevicePrefs(context);
|
||||
mSharedPrefs = LauncherPrefs.getDevicePrefs(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -69,6 +69,7 @@ import androidx.annotation.UiThread;
|
||||
|
||||
import com.android.app.viewcapture.ViewCapture;
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
@@ -479,7 +480,7 @@ public class TouchInteractionService extends Service
|
||||
}
|
||||
|
||||
// Reset home bounce seen on quick step enabled for first time
|
||||
SharedPreferences sharedPrefs = Utilities.getPrefs(this);
|
||||
SharedPreferences sharedPrefs = LauncherPrefs.getPrefs(this);
|
||||
if (!sharedPrefs.getBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)) {
|
||||
sharedPrefs.edit()
|
||||
.putBoolean(HAS_ENABLED_QUICKSTEP_ONCE, true)
|
||||
|
||||
@@ -28,8 +28,8 @@ import android.view.Window;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.quickstep.TouchInteractionService.TISBinder;
|
||||
import com.android.quickstep.interaction.TutorialController.TutorialType;
|
||||
@@ -63,7 +63,7 @@ public class GestureSandboxActivity extends FragmentActivity {
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.gesture_tutorial_activity);
|
||||
|
||||
mSharedPrefs = Utilities.getPrefs(this);
|
||||
mSharedPrefs = LauncherPrefs.getPrefs(this);
|
||||
mStatsLogManager = StatsLogManager.newInstance(getApplicationContext());
|
||||
|
||||
Bundle args = savedInstanceState == null ? getIntent().getExtras() : savedInstanceState;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.quickstep.logging;
|
||||
|
||||
import static com.android.launcher3.Utilities.getDevicePrefs;
|
||||
import static com.android.launcher3.Utilities.getPrefs;
|
||||
import static com.android.launcher3.LauncherPrefs.getDevicePrefs;
|
||||
import static com.android.launcher3.LauncherPrefs.getPrefs;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_SCREEN_SUGGESTIONS_DISABLED;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NOTIFICATION_DOT_DISABLED;
|
||||
|
||||
@@ -45,7 +45,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
@@ -139,7 +139,7 @@ public class RecentsOrientedState implements
|
||||
public RecentsOrientedState(Context context, BaseActivityInterface sizeStrategy,
|
||||
IntConsumer rotationChangeListener) {
|
||||
mContext = context;
|
||||
mSharedPrefs = Utilities.getPrefs(context);
|
||||
mSharedPrefs = LauncherPrefs.getPrefs(context);
|
||||
mOrientationListener = new OrientationEventListener(context) {
|
||||
@Override
|
||||
public void onOrientationChanged(int degrees) {
|
||||
|
||||
@@ -200,7 +200,8 @@ public class InvariantDeviceProfile {
|
||||
String gridName = getCurrentGridName(context);
|
||||
String newGridName = initGrid(context, gridName);
|
||||
if (!newGridName.equals(gridName)) {
|
||||
Utilities.getPrefs(context).edit().putString(KEY_IDP_GRID_NAME, newGridName).apply();
|
||||
LauncherPrefs.getPrefs(context).edit().putString(KEY_IDP_GRID_NAME, newGridName)
|
||||
.apply();
|
||||
}
|
||||
new DeviceGridState(this).writeToPrefs(context);
|
||||
|
||||
@@ -308,7 +309,7 @@ public class InvariantDeviceProfile {
|
||||
}
|
||||
|
||||
public static String getCurrentGridName(Context context) {
|
||||
return Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null);
|
||||
return LauncherPrefs.getPrefs(context).getString(KEY_IDP_GRID_NAME, null);
|
||||
}
|
||||
|
||||
private String initGrid(Context context, String gridName) {
|
||||
@@ -436,7 +437,7 @@ public class InvariantDeviceProfile {
|
||||
|
||||
public void setCurrentGrid(Context context, String gridName) {
|
||||
Context appContext = context.getApplicationContext();
|
||||
Utilities.getPrefs(appContext).edit().putString(KEY_IDP_GRID_NAME, gridName).apply();
|
||||
LauncherPrefs.getPrefs(appContext).edit().putString(KEY_IDP_GRID_NAME, gridName).apply();
|
||||
MAIN_EXECUTOR.execute(() -> onConfigChanged(appContext));
|
||||
}
|
||||
|
||||
|
||||
@@ -473,7 +473,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
|
||||
initDeviceProfile(idp);
|
||||
idp.addOnChangeListener(this);
|
||||
mSharedPrefs = Utilities.getPrefs(this);
|
||||
mSharedPrefs = LauncherPrefs.getPrefs(this);
|
||||
mIconCache = app.getIconCache();
|
||||
mAccessibilityDelegate = createAccessibilityDelegate();
|
||||
|
||||
@@ -1563,7 +1563,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
@Override
|
||||
public SharedPreferences getDevicePrefs() {
|
||||
return Utilities.getDevicePrefs(this);
|
||||
return LauncherPrefs.getDevicePrefs(this);
|
||||
}
|
||||
|
||||
public int getOrientation() {
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.android.launcher3;
|
||||
|
||||
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED;
|
||||
|
||||
import static com.android.launcher3.Utilities.getDevicePrefs;
|
||||
import static com.android.launcher3.LauncherPrefs.getDevicePrefs;
|
||||
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class LauncherAppState implements SafeCloseable {
|
||||
observer, MODEL_EXECUTOR.getHandler());
|
||||
mOnTerminateCallback.add(iconChangeTracker::close);
|
||||
MODEL_EXECUTOR.execute(observer::verifyIconChanged);
|
||||
SharedPreferences prefs = Utilities.getPrefs(mContext);
|
||||
SharedPreferences prefs = LauncherPrefs.getPrefs(mContext);
|
||||
prefs.registerOnSharedPreferenceChangeListener(observer);
|
||||
mOnTerminateCallback.add(
|
||||
() -> prefs.unregisterOnSharedPreferenceChangeListener(observer));
|
||||
|
||||
20
src/com/android/launcher3/LauncherPrefs.kt
Normal file
20
src/com/android/launcher3/LauncherPrefs.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.android.launcher3
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
||||
object LauncherPrefs {
|
||||
|
||||
@JvmStatic
|
||||
fun getPrefs(context: Context): SharedPreferences {
|
||||
// Use application context for shared preferences, so that we use a single cached instance
|
||||
return context.applicationContext.getSharedPreferences(
|
||||
LauncherFiles.SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getDevicePrefs(context: Context): SharedPreferences {
|
||||
// Use application context for shared preferences, so that we use a single cached instance
|
||||
return context.applicationContext.getSharedPreferences(
|
||||
LauncherFiles.DEVICE_PREFERENCES_KEY, Context.MODE_PRIVATE)
|
||||
}}
|
||||
@@ -374,7 +374,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
case LauncherSettings.Settings.METHOD_WAS_EMPTY_DB_CREATED : {
|
||||
Bundle result = new Bundle();
|
||||
result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE,
|
||||
Utilities.getPrefs(getContext()).getBoolean(
|
||||
LauncherPrefs.getPrefs(getContext()).getBoolean(
|
||||
mOpenHelper.getKey(EMPTY_DATABASE_CREATED), false));
|
||||
return result;
|
||||
}
|
||||
@@ -520,7 +520,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private void clearFlagEmptyDbCreated() {
|
||||
Utilities.getPrefs(getContext()).edit()
|
||||
LauncherPrefs.getPrefs(getContext()).edit()
|
||||
.remove(mOpenHelper.getKey(EMPTY_DATABASE_CREATED)).commit();
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
* 4) The default configuration for the particular device
|
||||
*/
|
||||
synchronized private void loadDefaultFavoritesIfNecessary() {
|
||||
SharedPreferences sp = Utilities.getPrefs(getContext());
|
||||
SharedPreferences sp = LauncherPrefs.getPrefs(getContext());
|
||||
|
||||
if (sp.getBoolean(mOpenHelper.getKey(EMPTY_DATABASE_CREATED), false)) {
|
||||
Log.d(TAG, "loading default workspace");
|
||||
@@ -738,7 +738,7 @@ public class LauncherProvider extends ContentProvider {
|
||||
*/
|
||||
protected void onEmptyDbCreated() {
|
||||
// Set the flag for empty DB
|
||||
Utilities.getPrefs(mContext).edit().putBoolean(getKey(EMPTY_DATABASE_CREATED), true)
|
||||
LauncherPrefs.getPrefs(mContext).edit().putBoolean(getKey(EMPTY_DATABASE_CREATED), true)
|
||||
.commit();
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,6 @@ public class SessionCommitReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
public static boolean isEnabled(Context context) {
|
||||
return Utilities.getPrefs(context).getBoolean(ADD_ICON_PREFERENCE_KEY, true);
|
||||
return LauncherPrefs.getPrefs(context).getBoolean(ADD_ICON_PREFERENCE_KEY, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.app.ActivityManager;
|
||||
import android.app.Person;
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
@@ -509,18 +508,6 @@ public final class Utilities {
|
||||
return spanned;
|
||||
}
|
||||
|
||||
public static SharedPreferences getPrefs(Context context) {
|
||||
// Use application context for shared preferences, so that we use a single cached instance
|
||||
return context.getApplicationContext().getSharedPreferences(
|
||||
LauncherFiles.SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static SharedPreferences getDevicePrefs(Context context) {
|
||||
// Use application context for shared preferences, so that we use a single cached instance
|
||||
return context.getApplicationContext().getSharedPreferences(
|
||||
LauncherFiles.DEVICE_PREFERENCES_KEY, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static boolean isWallpaperSupported(Context context) {
|
||||
return context.getSystemService(WallpaperManager.class).isWallpaperSupported();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ import com.android.launcher3.DragSource;
|
||||
import com.android.launcher3.DropTarget.DragObject;
|
||||
import com.android.launcher3.Insettable;
|
||||
import com.android.launcher3.InsettableFrameLayout;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
@@ -148,7 +149,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
|
||||
mWorkManager = new WorkProfileManager(
|
||||
mActivityContext.getSystemService(UserManager.class),
|
||||
this, Utilities.getPrefs(mActivityContext));
|
||||
this, LauncherPrefs.getPrefs(mActivityContext));
|
||||
mAH = Arrays.asList(null, null, null);
|
||||
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN));
|
||||
mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
|
||||
|
||||
@@ -26,8 +26,8 @@ import android.view.animation.AnimationUtils;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.model.StringCache;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class WorkEduCard extends FrameLayout implements
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startAnimation(mDismissAnim);
|
||||
Utilities.getPrefs(getContext()).edit().putInt(WorkProfileManager.KEY_WORK_EDU_STEP,
|
||||
LauncherPrefs.getPrefs(getContext()).edit().putInt(WorkProfileManager.KEY_WORK_EDU_STEP,
|
||||
1).apply();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.android.launcher3.graphics;
|
||||
|
||||
import static com.android.launcher3.Utilities.getPrefs;
|
||||
import static com.android.launcher3.LauncherPrefs.getPrefs;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.launcher3.util.Themes.KEY_THEMED_ICONS;
|
||||
import static com.android.launcher3.util.Themes.isThemedIconEnabled;
|
||||
|
||||
@@ -29,7 +29,7 @@ import android.content.SharedPreferences;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.logging.StatsLogManager.LauncherEvent;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -58,7 +58,7 @@ public class DeviceGridState implements Comparable<DeviceGridState> {
|
||||
}
|
||||
|
||||
public DeviceGridState(Context context) {
|
||||
SharedPreferences prefs = Utilities.getPrefs(context);
|
||||
SharedPreferences prefs = LauncherPrefs.getPrefs(context);
|
||||
mGridSizeString = prefs.getString(KEY_WORKSPACE_SIZE, "");
|
||||
mNumHotseat = prefs.getInt(KEY_HOTSEAT_COUNT, -1);
|
||||
mDeviceType = prefs.getInt(KEY_DEVICE_TYPE, TYPE_PHONE);
|
||||
@@ -90,7 +90,7 @@ public class DeviceGridState implements Comparable<DeviceGridState> {
|
||||
* Stores the device state to shared preferences
|
||||
*/
|
||||
public void writeToPrefs(Context context) {
|
||||
Utilities.getPrefs(context).edit()
|
||||
LauncherPrefs.getPrefs(context).edit()
|
||||
.putString(KEY_WORKSPACE_SIZE, mGridSizeString)
|
||||
.putInt(KEY_HOTSEAT_COUNT, mNumHotseat)
|
||||
.putInt(KEY_DEVICE_TYPE, mDeviceType)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.launcher3.pm;
|
||||
|
||||
import static com.android.launcher3.Utilities.getPrefs;
|
||||
import static com.android.launcher3.LauncherPrefs.getPrefs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
|
||||
@@ -36,6 +36,7 @@ import androidx.annotation.NonNull;
|
||||
import com.android.launcher3.AppWidgetsRestoredReceiver;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.LauncherProvider.DatabaseHelper;
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.Utilities;
|
||||
@@ -86,7 +87,7 @@ public class RestoreDbTask {
|
||||
|
||||
// Set is pending to false irrespective of the result, so that it doesn't get
|
||||
// executed again.
|
||||
Utilities.getPrefs(context).edit().remove(RESTORED_DEVICE_TYPE).commit();
|
||||
LauncherPrefs.getPrefs(context).edit().remove(RESTORED_DEVICE_TYPE).commit();
|
||||
|
||||
idp.reinitializeAfterRestore(context);
|
||||
}
|
||||
@@ -239,7 +240,7 @@ public class RestoreDbTask {
|
||||
}
|
||||
|
||||
// If restored from a single display backup, remove gaps between screenIds
|
||||
if (Utilities.getPrefs(context).getInt(RESTORED_DEVICE_TYPE, TYPE_PHONE)
|
||||
if (LauncherPrefs.getPrefs(context).getInt(RESTORED_DEVICE_TYPE, TYPE_PHONE)
|
||||
!= TYPE_MULTI_DISPLAY) {
|
||||
removeScreenIdGaps(db);
|
||||
}
|
||||
@@ -338,7 +339,7 @@ public class RestoreDbTask {
|
||||
}
|
||||
|
||||
public static boolean isPending(Context context) {
|
||||
return Utilities.getPrefs(context).contains(RESTORED_DEVICE_TYPE);
|
||||
return LauncherPrefs.getPrefs(context).contains(RESTORED_DEVICE_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,13 +347,13 @@ public class RestoreDbTask {
|
||||
*/
|
||||
public static void setPending(Context context) {
|
||||
FileLog.d(TAG, "Restore data received through full backup ");
|
||||
Utilities.getPrefs(context).edit()
|
||||
LauncherPrefs.getPrefs(context).edit()
|
||||
.putInt(RESTORED_DEVICE_TYPE, new DeviceGridState(context).getDeviceType())
|
||||
.commit();
|
||||
}
|
||||
|
||||
private void restoreAppWidgetIdsIfExists(Context context) {
|
||||
SharedPreferences prefs = Utilities.getPrefs(context);
|
||||
SharedPreferences prefs = LauncherPrefs.getPrefs(context);
|
||||
if (prefs.contains(APPWIDGET_OLD_IDS) && prefs.contains(APPWIDGET_IDS)) {
|
||||
LauncherWidgetHolder holder = new LauncherWidgetHolder(context);
|
||||
AppWidgetsRestoredReceiver.restoreAppWidgetIds(context,
|
||||
@@ -370,7 +371,7 @@ public class RestoreDbTask {
|
||||
|
||||
public static void setRestoredAppWidgetIds(Context context, @NonNull int[] oldIds,
|
||||
@NonNull int[] newIds) {
|
||||
Utilities.getPrefs(context).edit()
|
||||
LauncherPrefs.getPrefs(context).edit()
|
||||
.putString(APPWIDGET_OLD_IDS, IntArray.wrap(oldIds).toConcatString())
|
||||
.putString(APPWIDGET_IDS, IntArray.wrap(newIds).toConcatString())
|
||||
.commit();
|
||||
|
||||
@@ -43,8 +43,8 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.graphics.FragmentWithPreview;
|
||||
import com.android.launcher3.widget.util.WidgetSizes;
|
||||
@@ -200,7 +200,7 @@ public class QsbContainerView extends FrameLayout {
|
||||
Context context = getContext();
|
||||
AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
|
||||
|
||||
int widgetId = Utilities.getPrefs(context).getInt(mKeyWidgetId, -1);
|
||||
int widgetId = LauncherPrefs.getPrefs(context).getInt(mKeyWidgetId, -1);
|
||||
AppWidgetProviderInfo widgetInfo = widgetManager.getAppWidgetInfo(widgetId);
|
||||
boolean isWidgetBound = (widgetInfo != null) &&
|
||||
widgetInfo.provider.equals(mWidgetInfo.provider);
|
||||
@@ -244,7 +244,7 @@ public class QsbContainerView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void saveWidgetId(int widgetId) {
|
||||
Utilities.getPrefs(getContext()).edit().putInt(mKeyWidgetId, widgetId).apply();
|
||||
LauncherPrefs.getPrefs(getContext()).edit().putInt(mKeyWidgetId, widgetId).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,9 +35,9 @@ import com.android.launcher3.DropTarget;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherModel;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
|
||||
import com.android.launcher3.dragndrop.DragController;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
@@ -87,7 +87,7 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
|
||||
super.onCreate(savedInstanceState);
|
||||
mModel = LauncherAppState.getInstance(this).getModel();
|
||||
mDragController = new SecondaryDragController(this);
|
||||
mOnboardingPrefs = new OnboardingPrefs<>(this, Utilities.getPrefs(this));
|
||||
mOnboardingPrefs = new OnboardingPrefs<>(this, LauncherPrefs.getPrefs(this));
|
||||
mSecondaryDisplayPredictions = SecondaryDisplayPredictions.newInstance(this);
|
||||
if (getWindow().getDecorView().isAttachedToWindow()) {
|
||||
initUi();
|
||||
|
||||
@@ -59,8 +59,8 @@ import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.config.FlagTogglerPrefUi;
|
||||
import com.android.launcher3.secondarydisplay.SecondaryDisplayLauncher;
|
||||
@@ -392,7 +392,8 @@ public class DeveloperOptionsFragment extends PreferenceFragmentCompat {
|
||||
onboardingPref.setTitle(title);
|
||||
onboardingPref.setSummary("Tap to reset");
|
||||
onboardingPref.setOnPreferenceClickListener(preference -> {
|
||||
SharedPreferences.Editor sharedPrefsEdit = Utilities.getPrefs(getContext()).edit();
|
||||
SharedPreferences.Editor sharedPrefsEdit = LauncherPrefs.getPrefs(getContext())
|
||||
.edit();
|
||||
for (String key : keys) {
|
||||
sharedPrefsEdit.remove(key);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherFiles;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
@@ -113,7 +114,8 @@ public class SettingsActivity extends FragmentActivity
|
||||
// Display the fragment as the main content.
|
||||
fm.beginTransaction().replace(R.id.content_frame, f).commit();
|
||||
}
|
||||
Utilities.getPrefs(getApplicationContext()).registerOnSharedPreferenceChangeListener(this);
|
||||
LauncherPrefs.getPrefs(getApplicationContext())
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener,
|
||||
mIgnoreAutoRotateSettings = ignoreAutoRotateSettings;
|
||||
if (!mIgnoreAutoRotateSettings) {
|
||||
if (mSharedPrefs == null) {
|
||||
mSharedPrefs = Utilities.getPrefs(mActivity);
|
||||
mSharedPrefs = LauncherPrefs.getPrefs(mActivity);
|
||||
mSharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
mHomeRotationEnabled = mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.util.AttributeSet;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.icons.GraphicsUtils;
|
||||
@@ -73,7 +74,7 @@ public class Themes {
|
||||
* Returns true if workspace icon theming is enabled
|
||||
*/
|
||||
public static boolean isThemedIconEnabled(Context context) {
|
||||
return Utilities.getPrefs(context).getBoolean(KEY_THEMED_ICONS, false);
|
||||
return LauncherPrefs.getPrefs(context).getBoolean(KEY_THEMED_ICONS, false);
|
||||
}
|
||||
|
||||
public static String getDefaultBodyFont(Context context) {
|
||||
|
||||
Reference in New Issue
Block a user