Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32734c4c authored by Roman Birg's avatar Roman Birg
Browse files

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: default avatarRoman Birg <roman@cyngn.com>
parent 117967eb
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -115,12 +115,10 @@
                android:persistent="false" />

        <!-- Vibrate on touch -->
        <SwitchPreference
                android:key="vibrate_on_touch"
        <com.android.settings.cyanogenmod.SystemSettingSwitchPreference
                android:key="haptic_feedback_enabled"
                android:title="@string/vibrate_on_touch_title"
                android:switchTextOff=""
                android:switchTextOn=""
                android:persistent="false" />
                android:defaultValue="true"/>

        <!-- CMHW vibration intensity -->
        <com.android.settings.hardware.VibratorIntensity
+23 −2
Original line number Diff line number Diff line
@@ -35,6 +35,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;
@@ -76,7 +77,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 int SAMPLE_CUTOFF = 2000;  // manually cap sample playback at 2 seconds

@@ -138,7 +139,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
        }

        if (!VibratorIntensity.isSupported()) {
            removePreference(KEY_VIBRATION_INTENSITY);
            vibrate.removePreference(vibrate.findPreference(KEY_VIBRATION_INTENSITY));
        }

        initRingtones(sounds);
@@ -165,6 +166,11 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
        mSettingsObserver.register(false);
    }

    @Override
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    }

    // === Volumes ===

    private VolumeSeekBarPreference initVolumePreference(String key, int stream) {
@@ -461,6 +467,13 @@ 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();
            mHasVibratorIntensity = VibratorIntensity.isSupported();
        }

        public List<SearchIndexableResource> getXmlResourcesToIndex(
                Context context, boolean enabled) {
@@ -478,6 +491,14 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab
                rt.add(KEY_PHONE_RINGTONE);
                rt.add(KEY_VIBRATE_WHEN_RINGING);
            }
            Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
            if (vib == null || !vib.hasVibrator()) {
                rt.add(KEY_VIBRATE);
            }
            if (!mHasVibratorIntensity) {
                rt.add(KEY_VIBRATION_INTENSITY);
            }

            return rt;
        }
    };
+0 −26
Original line number Diff line number Diff line
@@ -70,10 +70,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";
@@ -131,23 +129,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();
        }
    };


    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) {
@@ -199,10 +180,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();
@@ -296,11 +275,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 {