From 32454d5f076511486cba7fa2bb4d8ab9aed3f966 Mon Sep 17 00:00:00 2001 From: Roman Birg Date: Thu, 19 Feb 2015 15:20:23 -0800 Subject: Settings: fix Vibrate on touch preference not working It was moved out of Other sounds, and never got hooked back up. Change-Id: Ibdc27be82d1fdad27e28d3dc20b245c6e81a125f Signed-off-by: Roman Birg --- .../settings/notification/OtherSoundSettings.java | 26 -------------------- .../settings/notification/SoundSettings.java | 28 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 28 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/settings/notification/OtherSoundSettings.java b/src/com/android/settings/notification/OtherSoundSettings.java index d49420c..55d2309 100644 --- a/src/com/android/settings/notification/OtherSoundSettings.java +++ b/src/com/android/settings/notification/OtherSoundSettings.java @@ -73,10 +73,8 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In private static final String KEY_DOCKING_SOUNDS = "docking_sounds"; private static final String KEY_VOLUME_ADJUST_SOUNDS = "volume_adjust_sounds"; private static final String KEY_TOUCH_SOUNDS = "touch_sounds"; - private static final String KEY_VIBRATE_ON_TOUCH = "vibrate_on_touch"; private static final String KEY_DOCK_AUDIO_MEDIA = "dock_audio_media"; private static final String KEY_EMERGENCY_TONE = "emergency_tone"; - private static final String KEY_VIBRATION_INTENSITY = "vibration_intensity"; private static final String KEY_POWER_NOTIFICATIONS = "power_notifications"; private static final String KEY_POWER_NOTIFICATIONS_VIBRATE = "power_notifications_vibrate"; @@ -137,23 +135,6 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In } }; - private static final SettingPref PREF_VIBRATE_ON_TOUCH = new SettingPref( - TYPE_SYSTEM, KEY_VIBRATE_ON_TOUCH, System.HAPTIC_FEEDBACK_ENABLED, DEFAULT_ON) { - @Override - public boolean isApplicable(Context context) { - return hasHaptic(context); - } - }; - - private static final SettingPref PREF_VIBRATION_INTENSITY = new SettingPref( - TYPE_SYSTEM, KEY_VIBRATION_INTENSITY, System.HAPTIC_FEEDBACK_ENABLED, DEFAULT_ON) { - @Override - public boolean isApplicable(Context context) { - return VibratorIntensity.isSupported(context); - } - }; - - private static final SettingPref PREF_DOCK_AUDIO_MEDIA = new SettingPref( TYPE_GLOBAL, KEY_DOCK_AUDIO_MEDIA, Global.DOCK_AUDIO_MEDIA_ENABLED, DEFAULT_DOCK_AUDIO_MEDIA, DOCK_AUDIO_MEDIA_DISABLED, DOCK_AUDIO_MEDIA_ENABLED) { @@ -206,10 +187,8 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In PREF_DOCKING_SOUNDS, PREF_VOLUME_ADJUST_SOUNDS, PREF_TOUCH_SOUNDS, - PREF_VIBRATE_ON_TOUCH, PREF_DOCK_AUDIO_MEDIA, PREF_EMERGENCY_TONE, - PREF_VIBRATION_INTENSITY, }; private final SettingsObserver mSettingsObserver = new SettingsObserver(); @@ -313,11 +292,6 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In return context.getResources().getBoolean(R.bool.has_dock_settings); } - private static boolean hasHaptic(Context context) { - final Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); - return vibrator != null && vibrator.hasVibrator(); - } - // === Callbacks === private final class SettingsObserver extends ContentObserver { diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java index f265bd3..aed746b 100644 --- a/src/com/android/settings/notification/SoundSettings.java +++ b/src/com/android/settings/notification/SoundSettings.java @@ -43,6 +43,7 @@ import android.os.Vibrator; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceCategory; +import android.preference.PreferenceScreen; import android.preference.SeekBarVolumizer; import android.preference.SwitchPreference; import android.preference.TwoStatePreference; @@ -61,6 +62,7 @@ import com.android.settings.Utils; import com.android.settings.hardware.VibratorIntensity; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; +import cyanogenmod.hardware.CMHardwareManager; import cyanogenmod.providers.CMSettings; import java.util.ArrayList; @@ -87,6 +89,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab private static final String KEY_NOTIFICATION_ACCESS = "manage_notification_access"; private static final String KEY_INCREASING_RING_VOLUME = "increasing_ring_volume"; private static final String KEY_VIBRATION_INTENSITY = "vibration_intensity"; + private static final String KEY_VIBRATE_ON_TOUCH = "vibrate_on_touch"; private static final String KEY_ZEN_ACCESS = "manage_zen_access"; private static final String KEY_ZEN_MODE = "zen_mode"; @@ -176,8 +179,9 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab volumes.removePreference(volumes.findPreference(KEY_RING_VOLUME)); } - if (!VibratorIntensity.isSupported(mContext)) { - removePreference(KEY_VIBRATION_INTENSITY); + CMHardwareManager hardware = CMHardwareManager.getInstance(mContext); + if (!hardware.isSupported(CMHardwareManager.FEATURE_VIBRATOR)) { + vibrate.removePreference(vibrate.findPreference(KEY_VIBRATION_INTENSITY)); } initRingtones(sounds); @@ -222,6 +226,11 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab mReceiver.register(false); } + @Override + public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { + return super.onPreferenceTreeClick(preferenceScreen, preference); + } + // === Volumes === private VolumeSeekBarPreference initVolumePreference(String key, int stream, int muteIcon) { @@ -584,6 +593,12 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { + private boolean mHasVibratorIntensity; + + @Override + public void prepare() { + super.prepare(); + } public List getXmlResourcesToIndex( Context context, boolean enabled) { @@ -602,6 +617,15 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab rt.add(KEY_WIFI_DISPLAY); rt.add(KEY_VIBRATE_WHEN_RINGING); } + Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); + if (vib == null || !vib.hasVibrator()) { + rt.add(KEY_VIBRATE); + } + CMHardwareManager hardware = CMHardwareManager.getInstance(context); + if (!hardware.isSupported(CMHardwareManager.FEATURE_VIBRATOR)) { + rt.add(KEY_VIBRATION_INTENSITY); + } + return rt; } }; -- cgit v1.1