diff options
Diffstat (limited to 'src/com/android/launcher3/settings/SettingsActivity.java')
-rw-r--r-- | src/com/android/launcher3/settings/SettingsActivity.java | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java index 8d2db78c7..b2520e366 100644 --- a/src/com/android/launcher3/settings/SettingsActivity.java +++ b/src/com/android/launcher3/settings/SettingsActivity.java @@ -24,12 +24,10 @@ import static com.android.launcher3.states.RotationHelper.getAllowRotationDefaul import static com.android.launcher3.util.SecureSettingsObserver.newNotificationSettingsObserver; import android.app.Activity; +import android.app.ActivityManager; import android.app.DialogFragment; import android.app.Fragment; -import android.content.ComponentName; -import android.content.Context; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; +import android.content.Intent; import android.os.Bundle; import android.provider.Settings; import android.text.TextUtils; @@ -48,6 +46,9 @@ import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.graphics.GridOptionsProvider; +import com.android.launcher3.lineage.LineageLauncherCallbacks; +import com.android.launcher3.lineage.LineageUtils; +import com.android.launcher3.lineage.trust.TrustAppsActivity; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; import com.android.launcher3.util.SecureSettingsObserver; @@ -55,8 +56,7 @@ import com.android.launcher3.util.SecureSettingsObserver; * Settings activity for Launcher. Currently implements the following setting: Allow rotation */ public class SettingsActivity extends Activity - implements OnPreferenceStartFragmentCallback, OnPreferenceStartScreenCallback, - SharedPreferences.OnSharedPreferenceChangeListener{ + implements OnPreferenceStartFragmentCallback, OnPreferenceStartScreenCallback { private static final String DEVELOPER_OPTIONS_KEY = "pref_developer_options"; private static final String FLAGS_PREFERENCE_KEY = "flag_toggler"; @@ -70,7 +70,8 @@ public class SettingsActivity extends Activity private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 600; public static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted"; - public static final String GRID_OPTIONS_PREFERENCE_KEY = "pref_grid_options"; + public static final String KEY_MINUS_ONE = "pref_enable_minus_one"; + public static final String KEY_TRUST_APPS = "pref_trust_apps"; @Override protected void onCreate(Bundle savedInstanceState) { @@ -90,28 +91,6 @@ public class SettingsActivity extends Activity .replace(android.R.id.content, f) .commit(); } - Utilities.getPrefs(getApplicationContext()).registerOnSharedPreferenceChangeListener(this); - } - @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - if (GRID_OPTIONS_PREFERENCE_KEY.equals(key)) { - - final ComponentName cn = new ComponentName(getApplicationContext(), - GridOptionsProvider.class); - Context c = getApplicationContext(); - int oldValue = c.getPackageManager().getComponentEnabledSetting(cn); - int newValue; - if (Utilities.getPrefs(c).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false)) { - newValue = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; - } else { - newValue = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; - } - - if (oldValue != newValue) { - c.getPackageManager().setComponentEnabledSetting(cn, newValue, - PackageManager.DONT_KILL_APP); - } - } } private boolean startFragment(String fragment, Bundle args, String key) { @@ -198,6 +177,7 @@ public class SettingsActivity extends Activity switch (preference.getKey()) { case NOTIFICATION_DOTS_PREFERENCE_KEY: if (!Utilities.ATLEAST_OREO || + getContext().getSystemService(ActivityManager.class).isLowRamDevice() || !getResources().getBoolean(R.bool.notification_dots_enabled)) { return false; } @@ -233,10 +213,21 @@ public class SettingsActivity extends Activity // Show if plugins are enabled or flag UI is enabled. return FeatureFlags.showFlagTogglerUi(getContext()) || PluginManagerWrapper.hasPlugins(getContext()); - case GRID_OPTIONS_PREFERENCE_KEY: - return Utilities.isDevelopersOptionsEnabled(getContext()) && - Utilities.IS_DEBUG_DEVICE && - Utilities.existsStyleWallpapers(getContext()); + + case KEY_MINUS_ONE: + return LineageUtils.hasPackageInstalled(getActivity(), + LineageLauncherCallbacks.SEARCH_PACKAGE); + + case KEY_TRUST_APPS: + preference.setOnPreferenceClickListener(p -> { + LineageUtils.showLockScreen(getActivity(), + getString(R.string.trust_apps_manager_name), () -> { + Intent intent = new Intent(getActivity(), TrustAppsActivity.class); + startActivity(intent); + }); + return true; + }); + return true; } return true; |