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

Commit 25055540 authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

cmparts: Add split screen to button behaviors

Change-Id: I9ff3df6da975b6ee56358b960192611e080acba6
parent 613dfd6f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@
        <item>@string/hardware_keys_action_launch_camera</item>
        <item>@string/hardware_keys_action_sleep</item>
        <item>@string/hardware_keys_action_last_app</item>
        <item>@string/hardware_keys_action_split_screen</item>
    </string-array>

    <string-array name="hardware_keys_action_values" translatable="false">
@@ -73,6 +74,7 @@
        <item>6</item>
        <item>7</item>
        <item>8</item>
        <item>9</item>
    </string-array>

    <string-array name="power_menu_actions_array" translatable="false">
+1 −0
Original line number Diff line number Diff line
@@ -181,6 +181,7 @@
    <string name="hardware_keys_action_launch_camera">Launch camera</string>
    <string name="hardware_keys_action_sleep">Turn screen off</string>
    <string name="hardware_keys_action_last_app">Last app</string>
    <string name="hardware_keys_action_split_screen">Split screen</string>
    <string name="camera_sleep_on_release_title">Screen peek</string>
    <string name="camera_sleep_on_release_summary">A half press will keep the screen on only while the button is held down</string>
    <string name="camera_launch_title">Launch camera</string>
+48 −38
Original line number Diff line number Diff line
@@ -90,15 +90,29 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    // Available custom actions to perform on a key press.
    // Must match values for KEY_HOME_LONG_PRESS_ACTION in:
    // frameworks/base/core/java/android/provider/Settings.java
    private static final int ACTION_NOTHING = 0;
    private static final int ACTION_MENU = 1;
    private static final int ACTION_APP_SWITCH = 2;
    private static final int ACTION_SEARCH = 3;
    private static final int ACTION_VOICE_SEARCH = 4;
    private static final int ACTION_IN_APP_SEARCH = 5;
    private static final int ACTION_LAUNCH_CAMERA = 6;
    private static final int ACTION_SLEEP = 7;
    private static final int ACTION_LAST_APP = 8;
    private enum Action {
        NOTHING,
        MENU,
        APP_SWITCH,
        SEARCH,
        VOICE_SEARCH,
        IN_APP_SEARCH,
        LAUNCH_CAMERA,
        SLEEP,
        LAST_APP,
        SPLIT_SCREEN;

        public static Action fromIntSafe(int id) {
            if (id < NOTHING.ordinal() || id > Action.values().length) {
                return NOTHING;
            }
            return Action.values()[id];
        }

        public static Action fromSettings(ContentResolver cr, String setting, Action def) {
            return fromIntSafe(CMSettings.System.getInt(cr, setting, def.ordinal()));
        }
    }

    // Masks for checking presence of hardware keys.
    // Must match values in frameworks/base/core/res/res/values/config.xml
@@ -264,26 +278,18 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                mHomeAnswerCall = null;
            }

            int defaultLongPressAction = res.getInteger(
                    com.android.internal.R.integer.config_longPressOnHomeBehavior);
            if (defaultLongPressAction < ACTION_NOTHING ||
                    defaultLongPressAction > ACTION_LAST_APP) {
                defaultLongPressAction = ACTION_NOTHING;
            }
            Action defaultLongPressAction = Action.fromIntSafe(res.getInteger(
                    com.android.internal.R.integer.config_longPressOnHomeBehavior));

            int defaultDoubleTapAction = res.getInteger(
                    com.android.internal.R.integer.config_doubleTapOnHomeBehavior);
            if (defaultDoubleTapAction < ACTION_NOTHING ||
                    defaultDoubleTapAction > ACTION_LAST_APP) {
                defaultDoubleTapAction = ACTION_NOTHING;
            }
            Action defaultDoubleTapAction = Action.fromIntSafe(res.getInteger(
                    com.android.internal.R.integer.config_doubleTapOnHomeBehavior));

            int longPressAction = CMSettings.System.getInt(resolver,
            Action longPressAction = Action.fromSettings(resolver,
                    CMSettings.System.KEY_HOME_LONG_PRESS_ACTION,
                    defaultLongPressAction);
            mHomeLongPressAction = initActionList(KEY_HOME_LONG_PRESS, longPressAction);

            int doubleTapAction = CMSettings.System.getInt(resolver,
            Action doubleTapAction = Action.fromSettings(resolver,
                    CMSettings.System.KEY_HOME_DOUBLE_TAP_ACTION,
                    defaultDoubleTapAction);
            mHomeDoubleTapAction = initActionList(KEY_HOME_DOUBLE_TAP, doubleTapAction);
@@ -307,13 +313,13 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                menuCategory.removePreference(findPreference(CMSettings.System.MENU_WAKE_SCREEN));
            }

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

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

            hasAnyBindableKey = true;
@@ -326,12 +332,12 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                assistCategory.removePreference(findPreference(CMSettings.System.ASSIST_WAKE_SCREEN));
            }

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

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

            hasAnyBindableKey = true;
@@ -345,12 +351,12 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                        CMSettings.System.APP_SWITCH_WAKE_SCREEN));
            }

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

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

            hasAnyBindableKey = true;
@@ -465,6 +471,10 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
        }
    }

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

    private ListPreference initActionList(String key, int value) {
        ListPreference list = (ListPreference) getPreferenceScreen().findPreference(key);
        if (list == null) return null;
@@ -483,7 +493,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                CMSettings.Secure.RECENTS_LONG_PRESS_ACTIVITY);
        ComponentName targetComponent = null;
        if (componentString == null) {
            list.setSummary(getString(R.string.hardware_keys_action_last_app));
            list.setSummary(getString(R.string.hardware_keys_action_split_screen));
        } else {
            targetComponent = ComponentName.unflattenFromString(componentString);
        }
@@ -496,7 +506,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                PackageManager.MATCH_DEFAULT_ONLY);
        if (recentsActivities.size() == 0) {
            // No entries available, disable
            list.setSummary(getString(R.string.hardware_keys_action_last_app));
            list.setSummary(getString(R.string.hardware_keys_action_split_screen));
            CMSettings.Secure.putString(getContentResolver(),
                    CMSettings.Secure.RECENTS_LONG_PRESS_ACTIVITY, null);
            list.setEnabled(false);
@@ -506,7 +516,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
        CharSequence[] entries = new CharSequence[recentsActivities.size() + 1];
        CharSequence[] values = new CharSequence[recentsActivities.size() + 1];
        // First entry is always default last app
        entries[0] = getString(R.string.hardware_keys_action_last_app);
        entries[0] = getString(R.string.hardware_keys_action_split_screen);
        values[0] = "";
        list.setValue(values[0].toString());
        int i = 1;