From 80a7e5a3deb409a47e47f60e9e2b391508410e0e Mon Sep 17 00:00:00 2001 From: Franco Date: Tue, 27 Jan 2015 20:26:18 -0300 Subject: Settings: Add touchscreen hovering support Change-Id: I5e8d607cb7530e4e1addaf545f520f672cdc5c10 --- res/values/cm_strings.xml | 4 ++++ res/xml/language_settings.xml | 6 +++++ .../InputMethodAndLanguageSettings.java | 27 +++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index ab05bab..1708090 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -539,4 +539,8 @@ %s is not installed + + + Touchscreen hovering + Allows you to hover the screen like a mouse in web browsers, remote desktops, etc diff --git a/res/xml/language_settings.xml b/res/xml/language_settings.xml index 94aa73b..5cd619d 100644 --- a/res/xml/language_settings.xml +++ b/res/xml/language_settings.xml @@ -104,6 +104,12 @@ android:summary="@string/high_touch_sensitivity_summary" android:defaultValue="false" /> + + diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java index bc50d4f..f796ed8 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java +++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java @@ -75,6 +75,7 @@ import java.util.Locale; import java.util.TreeSet; import org.cyanogenmod.hardware.HighTouchSensitivity; +import org.cyanogenmod.hardware.TouchscreenHovering; public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener, InputManager.InputDeviceListener, @@ -87,8 +88,9 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment private static final String KEY_USER_DICTIONARY_SETTINGS = "key_user_dictionary_settings"; private static final String KEY_POINTER_SETTINGS_CATEGORY = "pointer_settings_category"; private static final String KEY_PREVIOUSLY_ENABLED_SUBTYPES = "previously_enabled_subtypes"; - private static final String KEY_TRACKPAD_SETTINGS = "gesture_pad_settings"; private static final String KEY_HIGH_TOUCH_SENSITIVITY = "high_touch_sensitivity"; + private static final String KEY_TOUCHSCREEN_HOVERING = "touchscreen_hovering"; + private static final String KEY_TRACKPAD_SETTINGS = "gesture_pad_settings"; private static final String KEY_STYLUS_GESTURES = "stylus_gestures"; private static final String KEY_STYLUS_ICON_ENABLED = "stylus_icon_enabled"; @@ -99,6 +101,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment private ListPreference mShowInputMethodSelectorPref; private SwitchPreference mStylusIconEnabled; private SwitchPreference mHighTouchSensitivity; + private SwitchPreference mTouchscreenHovering; private PreferenceCategory mKeyboardSettingsCategory; private PreferenceCategory mHardKeyboardCategory; private PreferenceCategory mGameControllerCategory; @@ -184,6 +187,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment mStylusIconEnabled = (SwitchPreference) findPreference(KEY_STYLUS_ICON_ENABLED); mHighTouchSensitivity = (SwitchPreference) findPreference(KEY_HIGH_TOUCH_SENSITIVITY); + mTouchscreenHovering = (SwitchPreference) findPreference(KEY_TOUCHSCREEN_HOVERING); + if (pointerSettingsCategory != null) { if (!getResources().getBoolean(com.android.internal.R.bool.config_stylusGestures)) { pointerSettingsCategory.removePreference(mStylusGestures); @@ -197,6 +202,15 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment mHighTouchSensitivity.setChecked(HighTouchSensitivity.isEnabled()); } + if (!isTouchscreenHoveringSupported()) { + pointerSettingsCategory.removePreference(mTouchscreenHovering); + mTouchscreenHovering = null; + } else { + mTouchscreenHovering.setChecked(TouchscreenHovering.isEnabled()); + } + + Utils.updatePreferenceToSpecificActivityFromMetaDataOrRemove(getActivity(), + pointerSettingsCategory, KEY_TRACKPAD_SETTINGS); if (pointerSettingsCategory.getPreferenceCount() == 0) { getPreferenceScreen().removePreference(pointerSettingsCategory); } @@ -391,6 +405,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } } else if (preference == mHighTouchSensitivity) { return HighTouchSensitivity.setEnabled(mHighTouchSensitivity.isChecked()); + } else if (preference == mTouchscreenHovering) { + return TouchscreenHovering.setEnabled(mTouchscreenHovering.isChecked()); } return super.onPreferenceTreeClick(preferenceScreen, preference); } @@ -677,6 +693,15 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } } + private static boolean isTouchscreenHoveringSupported() { + try { + return TouchscreenHovering.isSupported(); + } catch (NoClassDefFoundError e) { + // Hardware abstraction framework not installed + return false; + } + } + private static boolean haveInputDeviceWithVibrator() { final int[] devices = InputDevice.getDeviceIds(); for (int i = 0; i < devices.length; i++) { -- cgit v1.1