Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45cb6a87 authored by Jon Miranda's avatar Jon Miranda
Browse files

Check for developer option on resuming settings activity.

Test: Turn system dev option off, check pref is gone in home settings
      Turn system dev option on, check pref is visible in home settings

Change-Id: I71d90aa5840571e908228552e498ab3a82a3352d
parent 036b5854
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ public class SettingsActivity extends FragmentActivity
        private String mHighLightKey;
        private boolean mPreferenceHighlighted = false;
        private NotificationDotsPreference mNotificationSettingsChangedListener;
        private Preference mDeveloperOptionPref;

        @Override
        public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
@@ -202,18 +203,37 @@ public class SettingsActivity extends FragmentActivity
                    return FeatureFlags.showFlagTogglerUi(getContext());

                case DEVELOPER_OPTIONS_KEY:
                    // Show if plugins are enabled or flag UI is enabled.
                    return FeatureFlags.showFlagTogglerUi(getContext()) ||
                            PluginManagerWrapper.hasPlugins(getContext());
                    mDeveloperOptionPref = preference;
                    return updateDeveloperOption();
            }

            return true;
        }

        /**
         * Show if plugins are enabled or flag UI is enabled.
         * @return True if we should show the preference option.
         */
        private boolean updateDeveloperOption() {
            boolean showPreference = FeatureFlags.showFlagTogglerUi(getContext())
                    || PluginManagerWrapper.hasPlugins(getContext());
            if (mDeveloperOptionPref != null) {
                mDeveloperOptionPref.setEnabled(showPreference);
                if (showPreference) {
                    getPreferenceScreen().addPreference(mDeveloperOptionPref);
                } else {
                    getPreferenceScreen().removePreference(mDeveloperOptionPref);
                }
            }
            return showPreference;
        }

        @Override
        public void onResume() {
            super.onResume();

            updateDeveloperOption();

            if (isAdded() && !mPreferenceHighlighted) {
                PreferenceHighlighter highlighter = createHighlighter();
                if (highlighter != null) {