[1/2] OmniGears: Configure headset hook
Whether or not to allo headset hook to launch voice commands
Useful with headset control programs
PS3: Whitespace
PS4: Rebase
PS5: android:persistant
Change-Id: I48f9f9853987b30038360472c140b33e2b2f5d2a
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index 6383601..a830544 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -158,6 +158,9 @@
<string name="button_volume_keys_title">Volume</string>
<string name="button_volume_wake_title">Volume button wake</string>
<string name="button_volume_wake_summary">Pressing a volume button will wake your device</string>
+ <string name="button_headsethook_title">Headset</string>
+ <string name="button_headsethook_launch_voice_title">Headset launches voice</string>
+ <string name="button_headsethook_launch_voice_summary">Pressing the headset button will launch voice controls</string>
<!-- Network speed -->
<string name="show_network_speed">Network speed indicator</string>
diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml
index 38ea732..cdbe159 100644
--- a/res/xml/button_settings.xml
+++ b/res/xml/button_settings.xml
@@ -187,4 +187,16 @@
android:dependency="keys_enable_custom" />
</PreferenceCategory>
+ <PreferenceCategory
+ android:key="button_headsethook"
+ android:title="@string/button_headsethook_title" >
+
+ <CheckBoxPreference
+ android:key="button_headsethook_launch_voice"
+ android:title="@string/button_headsethook_launch_voice_title"
+ android:summary="@string/button_headsethook_launch_voice_summary"
+ android:persistent="false" />
+
+ </PreferenceCategory>
+
</PreferenceScreen>
diff --git a/src/org/omnirom/omnigears/ButtonSettings.java b/src/org/omnirom/omnigears/ButtonSettings.java
index 00ae2d2..d73b6e3 100644
--- a/src/org/omnirom/omnigears/ButtonSettings.java
+++ b/src/org/omnirom/omnigears/ButtonSettings.java
@@ -71,6 +71,8 @@
private static final String BUTTON_VOLUME_WAKE = "button_volume_wake_screen";
private static final String BUTTON_VOLUME_DEFAULT = "button_volume_default_screen";
+ private static final String CATEGORY_HEADSETHOOK = "button_headsethook";
+ private static final String BUTTON_HEADSETHOOK_LAUNCH_VOICE = "button_headsethook_launch_voice";
private static final String KEYS_CATEGORY_BINDINGS = "keys_bindings";
private static final String KEYS_ENABLE_CUSTOM = "keys_enable_custom";
@@ -121,6 +123,7 @@
private ListPreference mAppSwitchLongPressAction;
private Map<String, Integer> mKeySettings = new HashMap<String, Integer>();
private ListPreference mVolumeDefault;
+ private CheckBoxPreference mHeadsetHookLaunchVoice;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -358,6 +361,13 @@
Settings.System.HARDWARE_KEY_REBINDING, 0) == 1));
mEnableCustomBindings.setOnPreferenceChangeListener(this);
}
+
+ final PreferenceCategory headsethookCategory =
+ (PreferenceCategory) prefScreen.findPreference(CATEGORY_HEADSETHOOK);
+
+ mHeadsetHookLaunchVoice = (CheckBoxPreference) findPreference(BUTTON_HEADSETHOOK_LAUNCH_VOICE);
+ mHeadsetHookLaunchVoice.setChecked(Settings.System.getInt(resolver,
+ Settings.System.HEADSETHOOK_LAUNCH_VOICE, 1) == 1);
}
@Override
@@ -368,6 +378,14 @@
Settings.System.VOLUME_WAKE_SCREEN, checked ? 1:0);
return true;
}
+ else if (preference == mHeadsetHookLaunchVoice) {
+ boolean checked = ((CheckBoxPreference)preference).isChecked();
+ Settings.System.putInt(getActivity().getContentResolver(),
+ Settings.System.HEADSETHOOK_LAUNCH_VOICE, checked ? 1:0);
+
+ return true;
+ }
+
return super.onPreferenceTreeClick(preferenceScreen, preference);
}