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

Commit e8a2f896 authored by Sam Mortimer's avatar Sam Mortimer Committed by Michael Bestas
Browse files

CMParts: Rename button action list handlers

initActionList(), handleActionListChange() and
handleSystemActionListChange() can be used as
general list preference handling functions without
change.  Remove "Action" from their names to
reflect this.

Change-Id: If62efba7ce2f490a152924a86da25dd30e25e8bb
parent 1dbebd03
Loading
Loading
Loading
Loading
+25 −25
Original line number Diff line number Diff line
@@ -239,11 +239,11 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                defaultHomeDoubleTapAction);

        // Navigation bar home long press
        mNavigationHomeLongPressAction = initActionList(KEY_NAVIGATION_HOME_LONG_PRESS,
        mNavigationHomeLongPressAction = initList(KEY_NAVIGATION_HOME_LONG_PRESS,
                homeLongPressAction);

        // Navigation bar home double tap
        mNavigationHomeDoubleTapAction = initActionList(KEY_NAVIGATION_HOME_DOUBLE_TAP,
        mNavigationHomeDoubleTapAction = initList(KEY_NAVIGATION_HOME_DOUBLE_TAP,
                homeDoubleTapAction);

        // Hide navigation bar home settings if we have a hardware home key
@@ -303,8 +303,8 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                mHomeAnswerCall = null;
            }

            mHomeLongPressAction = initActionList(KEY_HOME_LONG_PRESS, homeLongPressAction);
            mHomeDoubleTapAction = initActionList(KEY_HOME_DOUBLE_TAP, homeDoubleTapAction);
            mHomeLongPressAction = initList(KEY_HOME_LONG_PRESS, homeLongPressAction);
            mHomeDoubleTapAction = initList(KEY_HOME_DOUBLE_TAP, homeDoubleTapAction);

            hasAnyBindableKey = true;
        } else {
@@ -327,12 +327,12 @@ public class ButtonSettings extends SettingsPreferenceFragment implements

            Action pressAction = Action.fromSettings(resolver,
                    CMSettings.System.KEY_MENU_ACTION, Action.MENU);
            mMenuPressAction = initActionList(KEY_MENU_PRESS, pressAction);
            mMenuPressAction = initList(KEY_MENU_PRESS, pressAction);

            Action longPressAction = Action.fromSettings(resolver,
                        CMSettings.System.KEY_MENU_LONG_PRESS_ACTION,
                        hasAssistKey ? Action.NOTHING : Action.SEARCH);
            mMenuLongPressAction = initActionList(KEY_MENU_LONG_PRESS, longPressAction);
            mMenuLongPressAction = initList(KEY_MENU_LONG_PRESS, longPressAction);

            hasAnyBindableKey = true;
        } else {
@@ -346,11 +346,11 @@ public class ButtonSettings extends SettingsPreferenceFragment implements

            Action pressAction = Action.fromSettings(resolver,
                    CMSettings.System.KEY_ASSIST_ACTION, Action.SEARCH);
            mAssistPressAction = initActionList(KEY_ASSIST_PRESS, pressAction);
            mAssistPressAction = initList(KEY_ASSIST_PRESS, pressAction);

            Action longPressAction = Action.fromSettings(resolver,
                    CMSettings.System.KEY_ASSIST_LONG_PRESS_ACTION, Action.VOICE_SEARCH);
            mAssistLongPressAction = initActionList(KEY_ASSIST_LONG_PRESS, longPressAction);
            mAssistLongPressAction = initList(KEY_ASSIST_LONG_PRESS, longPressAction);

            hasAnyBindableKey = true;
        } else {
@@ -365,11 +365,11 @@ public class ButtonSettings extends SettingsPreferenceFragment implements

            Action pressAction = Action.fromSettings(resolver,
                    CMSettings.System.KEY_APP_SWITCH_ACTION, Action.APP_SWITCH);
            mAppSwitchPressAction = initActionList(KEY_APP_SWITCH_PRESS, pressAction);
            mAppSwitchPressAction = initList(KEY_APP_SWITCH_PRESS, pressAction);

            Action longPressAction = Action.fromSettings(resolver,
                    CMSettings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION, Action.SPLIT_SCREEN);
            mAppSwitchLongPressAction = initActionList(KEY_APP_SWITCH_LONG_PRESS, longPressAction);
            mAppSwitchLongPressAction = initList(KEY_APP_SWITCH_LONG_PRESS, longPressAction);

            hasAnyBindableKey = true;
        } else {
@@ -405,7 +405,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements

            int cursorControlAction = Settings.System.getInt(resolver,
                    Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0);
            mVolumeKeyCursorControl = initActionList(KEY_VOLUME_KEY_CURSOR_CONTROL,
            mVolumeKeyCursorControl = initList(KEY_VOLUME_KEY_CURSOR_CONTROL,
                    cursorControlAction);

            int swapVolumeKeys = CMSettings.System.getInt(getContentResolver(),
@@ -488,11 +488,11 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
        }
    }

    private ListPreference initActionList(String key, Action value) {
        return initActionList(key, value.ordinal());
    private ListPreference initList(String key, Action value) {
        return initList(key, value.ordinal());
    }

    private ListPreference initActionList(String key, int value) {
    private ListPreference initList(String key, int value) {
        ListPreference list = (ListPreference) getPreferenceScreen().findPreference(key);
        if (list == null) return null;
        list.setValue(Integer.toString(value));
@@ -566,14 +566,14 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
        return list;
    }

    private void handleActionListChange(ListPreference pref, Object newValue, String setting) {
    private void handleListChange(ListPreference pref, Object newValue, String setting) {
        String value = (String) newValue;
        int index = pref.findIndexOfValue(value);
        pref.setSummary(pref.getEntries()[index]);
        CMSettings.System.putInt(getContentResolver(), setting, Integer.valueOf(value));
    }

    private void handleSystemActionListChange(ListPreference pref, Object newValue, String setting) {
    private void handleSystemListChange(ListPreference pref, Object newValue, String setting) {
        String value = (String) newValue;
        int index = pref.findIndexOfValue(value);
        pref.setSummary(pref.getEntries()[index]);
@@ -584,40 +584,40 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        if (preference == mHomeLongPressAction ||
                preference == mNavigationHomeLongPressAction) {
            handleActionListChange((ListPreference) preference, newValue,
            handleListChange((ListPreference) preference, newValue,
                    CMSettings.System.KEY_HOME_LONG_PRESS_ACTION);
            return true;
        } else if (preference == mHomeDoubleTapAction ||
                preference == mNavigationHomeDoubleTapAction) {
            handleActionListChange((ListPreference) preference, newValue,
            handleListChange((ListPreference) preference, newValue,
                    CMSettings.System.KEY_HOME_DOUBLE_TAP_ACTION);
            return true;
        } else if (preference == mMenuPressAction) {
            handleActionListChange(mMenuPressAction, newValue,
            handleListChange(mMenuPressAction, newValue,
                    CMSettings.System.KEY_MENU_ACTION);
            return true;
        } else if (preference == mMenuLongPressAction) {
            handleActionListChange(mMenuLongPressAction, newValue,
            handleListChange(mMenuLongPressAction, newValue,
                    CMSettings.System.KEY_MENU_LONG_PRESS_ACTION);
            return true;
        } else if (preference == mAssistPressAction) {
            handleActionListChange(mAssistPressAction, newValue,
            handleListChange(mAssistPressAction, newValue,
                    CMSettings.System.KEY_ASSIST_ACTION);
            return true;
        } else if (preference == mAssistLongPressAction) {
            handleActionListChange(mAssistLongPressAction, newValue,
            handleListChange(mAssistLongPressAction, newValue,
                    CMSettings.System.KEY_ASSIST_LONG_PRESS_ACTION);
            return true;
        } else if (preference == mAppSwitchPressAction) {
            handleActionListChange(mAppSwitchPressAction, newValue,
            handleListChange(mAppSwitchPressAction, newValue,
                    CMSettings.System.KEY_APP_SWITCH_ACTION);
            return true;
        } else if (preference == mAppSwitchLongPressAction) {
            handleActionListChange(mAppSwitchLongPressAction, newValue,
            handleListChange(mAppSwitchLongPressAction, newValue,
                    CMSettings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION);
            return true;
        } else if (preference == mVolumeKeyCursorControl) {
            handleSystemActionListChange(mVolumeKeyCursorControl, newValue,
            handleSystemListChange(mVolumeKeyCursorControl, newValue,
                    Settings.System.VOLUME_KEY_CURSOR_CONTROL);
            return true;
        } else if (preference == mNavigationRecentsLongPressAction) {