[2/2] OmniGears: allow config of long press recents
yeah - AOSP recents have double tap to last but thats
implemented in a horrible way that would be a shame
to be used also for OmniSwitch. So allow to switch
between splitscreen and last app on long press recents
Change-Id: Idb07cf5c2c2e73c8d5c1f241c478bbefbc7d3a18
diff --git a/res/values/custom_arrays.xml b/res/values/custom_arrays.xml
index 35f4b05..837eaab 100644
--- a/res/values/custom_arrays.xml
+++ b/res/values/custom_arrays.xml
@@ -444,4 +444,14 @@
<item>@string/SHORT_SMS_TEMP_APP_WHITELIST_DURATION</item>
<item>@string/SHORT_KEY_NOTIFICATION_WHITELIST_DURATION</item>
</string-array>
+
+ <string-array name="long_press_recents_action_entries" translatable="false">
+ <item>@string/long_press_recents_action_split</item>
+ <item>@string/long_press_recents_action_lastapp</item>
+ </string-array>
+
+ <string-array name="long_press_recents_action_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ </string-array>
</resources>
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index 8505c60..19e4c6b 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -212,7 +212,10 @@
<string name="omniswitch_dialog_running_new">OmniSwitch is currently not enabled. Please enable it in the app settings.</string>
<string name="omniswitch_dialog_unavail">OmniSwitch is not installed.</string>
<string name="omniswitch_title">Recents style</string>
-
+ <string name="long_press_recents_action_title">Long press recents action</string>
+ <string name="long_press_recents_action_split">Toggle splitscreen</string>
+ <string name="long_press_recents_action_lastapp">Toggle last app</string>
+
<string name="doze_brightness_level_title">Brightness level</string>
<!-- Lock screen config -->
diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml
index 56f5d7c..c6f5eb9 100644
--- a/res/xml/button_settings.xml
+++ b/res/xml/button_settings.xml
@@ -264,6 +264,13 @@
android:entryValues="@array/navbar_recents_style_values"
android:persistent="false"/>
+ <ListPreference
+ android:key="long_press_recents_action"
+ android:title="@string/long_press_recents_action_title"
+ android:entries="@array/long_press_recents_action_entries"
+ android:entryValues="@array/long_press_recents_action_values"
+ android:persistent="false"/>
+
<org.omnirom.omnigears.preference.SystemSettingSwitchPreference
android:key="button_back_kill_enable"
android:title="@string/button_back_kill_enable_title"
diff --git a/src/org/omnirom/omnigears/ButtonSettings.java b/src/org/omnirom/omnigears/ButtonSettings.java
index 0f3d259..33a3a17 100644
--- a/src/org/omnirom/omnigears/ButtonSettings.java
+++ b/src/org/omnirom/omnigears/ButtonSettings.java
@@ -96,6 +96,7 @@
private static final String KEYS_DISABLE_HW_KEY = "hardware_keys_disable";
private static final String NAVIGATION_BAR_RECENTS_STYLE = "navbar_recents_style";
private static final String BUTTON_BACK_KILL_TIMEOUT = "button_back_kill_timeout";
+ private static final String LONG_PRESS_RECENTS_ACTION = "long_press_recents_action";
// Available custom actions to perform on a key press.
// private static final int ACTION_NOTHING = 0;
@@ -151,6 +152,7 @@
// private PreferenceCategory mKeysAssistCategory;
private ListPreference mNavbarRecentsStyle;
private ListPreference mBackKillTimeout;
+ private ListPreference mLongPressRecentsAction;
@Override
protected int getMetricsCategory() {
@@ -471,6 +473,14 @@
mNavbarRecentsStyle.setSummary(mNavbarRecentsStyle.getEntry());
mNavbarRecentsStyle.setOnPreferenceChangeListener(this);
+ mLongPressRecentsAction = (ListPreference) findPreference(LONG_PRESS_RECENTS_ACTION);
+ int longPressRecentsAction = Settings.System.getInt(resolver,
+ Settings.System.BUTTON_LONG_PRESS_RECENTS, 0);
+
+ mLongPressRecentsAction.setValue(Integer.toString(longPressRecentsAction));
+ mLongPressRecentsAction.setSummary(mLongPressRecentsAction.getEntry());
+ mLongPressRecentsAction.setOnPreferenceChangeListener(this);
+
mBackKillTimeout = (ListPreference) findPreference(BUTTON_BACK_KILL_TIMEOUT);
final int backKillTimeoutDefault = res.getInteger(com.android.internal.R.integer.config_backKillTimeout);
final int backKillTimeout = Settings.System.getInt(resolver,
@@ -706,6 +716,12 @@
mBackKillTimeout.setSummary(mBackKillTimeout.getEntries()[index]);
Settings.System.putInt(getContentResolver(), Settings.System.BUTTON_BACK_KILL_TIMEOUT, value);
return true;
+ } else if (preference == mLongPressRecentsAction) {
+ int value = Integer.valueOf((String) newValue);
+ int index = mLongPressRecentsAction.findIndexOfValue((String) newValue);
+ mLongPressRecentsAction.setSummary(mLongPressRecentsAction.getEntries()[index]);
+ Settings.System.putInt(getContentResolver(), Settings.System.BUTTON_LONG_PRESS_RECENTS, value);
+ return true;
}
return false;
}