[2/2] OmniGears: allow config of long press home
Change-Id: Ie74dc492b8b8a59438e61be8c5fff7894bc7d582
diff --git a/res/values/custom_arrays.xml b/res/values/custom_arrays.xml
index 87aa59f..46dd69a 100644
--- a/res/values/custom_arrays.xml
+++ b/res/values/custom_arrays.xml
@@ -434,11 +434,31 @@
<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>
+ <item>@string/keys_action_last_app</item>
</string-array>
<string-array name="long_press_recents_action_values" translatable="false">
<item>0</item>
<item>1</item>
</string-array>
+
+ <string-array name="long_press_home_action_entries" translatable="false">
+ <item>@string/keys_action_nothing</item>
+ <item>@string/keys_action_recents</item>
+ <item>@string/keys_action_assist</item>
+ <item>@string/keys_action_menu</item>
+ <item>@string/long_press_recents_action_split</item>
+ <item>@string/keys_action_last_app</item>
+ <item>@string/keys_action_sleep</item>
+ </string-array>
+
+ <string-array name="long_press_home_action_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ <item>4</item>
+ <item>5</item>
+ <item>6</item>
+ </string-array>
</resources>
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index 9e282f7..584f09a 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -216,7 +216,9 @@
<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="long_press_home_action_title">Long press home action</string>
+ <string name="keys_action_recents">Recents</string>
+ <string name="keys_action_assist">Launch assist</string>
<string name="doze_brightness_level_title">Brightness level</string>
diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml
index c6f5eb9..dd94581 100644
--- a/res/xml/button_settings.xml
+++ b/res/xml/button_settings.xml
@@ -115,6 +115,20 @@
android:title="@string/keys_enable_custom_title"
android:persistent="false" />-->
+ <org.omnirom.omnigears.preference.SystemSettingSwitchPreference
+ android:key="button_back_kill_enable"
+ android:title="@string/button_back_kill_enable_title"
+ android:summary="@string/button_back_kill_enable_summary"
+ android:defaultValue="false"/>
+
+ <ListPreference
+ android:key="button_back_kill_timeout"
+ android:title="@string/button_back_kill_timeout_title"
+ android:entries="@array/button_back_kill_timeout_entries"
+ android:entryValues="@array/button_back_kill_timeout_values"
+ android:persistent="false"
+ android:dependency="button_back_kill_enable"/>
+
</PreferenceCategory>
<!--
<PreferenceCategory
@@ -271,19 +285,12 @@
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"
- android:summary="@string/button_back_kill_enable_summary"
- android:defaultValue="false"/>
-
<ListPreference
- android:key="button_back_kill_timeout"
- android:title="@string/button_back_kill_timeout_title"
- android:entries="@array/button_back_kill_timeout_entries"
- android:entryValues="@array/button_back_kill_timeout_values"
- android:persistent="false"
- android:dependency="button_back_kill_enable"/>
+ android:key="long_press_home_action"
+ android:title="@string/long_press_home_action_title"
+ android:entries="@array/long_press_home_action_entries"
+ android:entryValues="@array/long_press_home_action_values"
+ android:persistent="false"/>
<PreferenceScreen
android:key="global_actions"
diff --git a/src/org/omnirom/omnigears/ButtonSettings.java b/src/org/omnirom/omnigears/ButtonSettings.java
index 33a3a17..51bc89f 100644
--- a/src/org/omnirom/omnigears/ButtonSettings.java
+++ b/src/org/omnirom/omnigears/ButtonSettings.java
@@ -97,6 +97,7 @@
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";
+ private static final String LONG_PRESS_HOME_ACTION = "long_press_home_action";
// Available custom actions to perform on a key press.
// private static final int ACTION_NOTHING = 0;
@@ -153,6 +154,7 @@
private ListPreference mNavbarRecentsStyle;
private ListPreference mBackKillTimeout;
private ListPreference mLongPressRecentsAction;
+ private ListPreference mLongPressHomeAction;
@Override
protected int getMetricsCategory() {
@@ -463,6 +465,15 @@
boolean harwareKeysDisable = Settings.System.getInt(resolver,
Settings.System.HARDWARE_KEYS_DISABLE, 0) == 1;
mDisabkeHWKeys.setChecked(harwareKeysDisable);
+
+ 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,
+ Settings.System.BUTTON_BACK_KILL_TIMEOUT, backKillTimeoutDefault);
+
+ mBackKillTimeout.setValue(Integer.toString(backKillTimeout));
+ mBackKillTimeout.setSummary(mBackKillTimeout.getEntry());
+ mBackKillTimeout.setOnPreferenceChangeListener(this);
}
mNavbarRecentsStyle = (ListPreference) findPreference(NAVIGATION_BAR_RECENTS_STYLE);
@@ -481,14 +492,15 @@
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,
- Settings.System.BUTTON_BACK_KILL_TIMEOUT, backKillTimeoutDefault);
+ // for navbar devices default is always assist LONG_PRESS_HOME_ASSIST = 2
+ int defaultLongPressOnHomeBehavior = (deviceKeys == 0) ? 2 : res.getInteger(com.android.internal.R.integer.config_longPressOnHomeBehavior);
+ mLongPressHomeAction = (ListPreference) findPreference(LONG_PRESS_HOME_ACTION);
+ int longPressHomeAction = Settings.System.getInt(resolver,
+ Settings.System.BUTTON_LONG_PRESS_HOME, defaultLongPressOnHomeBehavior);
- mBackKillTimeout.setValue(Integer.toString(backKillTimeout));
- mBackKillTimeout.setSummary(mBackKillTimeout.getEntry());
- mBackKillTimeout.setOnPreferenceChangeListener(this);
+ mLongPressHomeAction.setValue(Integer.toString(longPressHomeAction));
+ mLongPressHomeAction.setSummary(mLongPressHomeAction.getEntry());
+ mLongPressHomeAction.setOnPreferenceChangeListener(this);
// final PreferenceCategory headsethookCategory =
// (PreferenceCategory) prefScreen.findPreference(CATEGORY_HEADSETHOOK);
@@ -722,6 +734,12 @@
mLongPressRecentsAction.setSummary(mLongPressRecentsAction.getEntries()[index]);
Settings.System.putInt(getContentResolver(), Settings.System.BUTTON_LONG_PRESS_RECENTS, value);
return true;
+ } else if (preference == mLongPressHomeAction) {
+ int value = Integer.valueOf((String) newValue);
+ int index = mLongPressHomeAction.findIndexOfValue((String) newValue);
+ mLongPressHomeAction.setSummary(mLongPressHomeAction.getEntries()[index]);
+ Settings.System.putInt(getContentResolver(), Settings.System.BUTTON_LONG_PRESS_HOME, value);
+ return true;
}
return false;
}