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

Commit 8b878db4 authored by Daisuke Miyakawa's avatar Daisuke Miyakawa
Browse files

Introduce new "vibrate when ringing"

We once removed "vibrate and ring" option with
I7168ed140266a7c754fb3d7209cf12e73041c306, while we still need
vibration setting which only affects Phone app.

This depends on I850d27629a75615647883fdaa2933f337c4824d1
See also I3a4ed2bd5e4bde05dfb97c7bb20b9284d1c6f13f for Phone app
side change.

Bug: 6036529
Change-Id: Idb0453e187f8025565d6744cd774613531e7cb8b
parent 95a893be
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1591,6 +1591,9 @@
    <string name="volume_notification_description">Notifications</string>
    <!-- Volume description for alarm volume -->
    <string name="volume_alarm_description">Alarms</string>
    <!-- Sound settings screen, setting option name checkbox. About vibration setting
         during incoming calls. [CHAR LIMIT=30] -->
    <string name="vibrate_when_ringing_title">Vibrate when ringing</string>

    <!-- Dock settings title, top level -->
    <string name="dock_settings">Dock</string>
+5 −0
Original line number Diff line number Diff line
@@ -58,6 +58,11 @@
            android:persistent="false"
            android:ringtoneType="notification" />

    <CheckBoxPreference
         android:key="vibrate_when_ringing"
         android:title="@string/vibrate_when_ringing_title"
         android:persistent="false" />

    <PreferenceCategory
            android:title="@string/sound_category_feedback_title"/>

+14 −3
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
    private static final int FALLBACK_EMERGENCY_TONE_VALUE = 0;

    private static final String KEY_SILENT_MODE = "silent_mode";
    private static final String KEY_VIBRATE = "vibrate_on_ring";
    private static final String KEY_VIBRATE = "vibrate_when_ringing";
    private static final String KEY_RING_VOLUME = "ring_volume";
    private static final String KEY_MUSICFX = "musicfx";
    private static final String KEY_DTMF_TONE = "dtmf_tone";
@@ -81,6 +81,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
    private static final int MSG_UPDATE_RINGTONE_SUMMARY = 1;
    private static final int MSG_UPDATE_NOTIFICATION_SUMMARY = 2;

    private CheckBoxPreference mVibrateWhenRinging;
    private ListPreference mSilentMode;
    private CheckBoxPreference mDtmfTone;
    private CheckBoxPreference mSoundEffects;
@@ -141,6 +142,11 @@ public class SoundSettings extends SettingsPreferenceFragment implements
            mSilentMode.setOnPreferenceChangeListener(this);
        }

        mVibrateWhenRinging = (CheckBoxPreference) findPreference(KEY_VIBRATE);
        mVibrateWhenRinging.setPersistent(false);
        mVibrateWhenRinging.setChecked(Settings.System.getInt(resolver,
                Settings.System.VIBRATE_WHEN_RINGING, 0) != 0);

        mDtmfTone = (CheckBoxPreference) findPreference(KEY_DTMF_TONE);
        mDtmfTone.setPersistent(false);
        mDtmfTone.setChecked(Settings.System.getInt(resolver,
@@ -161,7 +167,9 @@ public class SoundSettings extends SettingsPreferenceFragment implements
        mRingtonePreference = findPreference(KEY_RINGTONE);
        mNotificationPreference = findPreference(KEY_NOTIFICATION_SOUND);

        if (!((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).hasVibrator()) {
        Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        if (vibrator == null || !vibrator.hasVibrator()) {
            getPreferenceScreen().removePreference(mVibrateWhenRinging);
            getPreferenceScreen().removePreference(mHapticFeedback);
        }

@@ -294,7 +302,10 @@ public class SoundSettings extends SettingsPreferenceFragment implements

    @Override
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        if (preference == mDtmfTone) {
        if (preference == mVibrateWhenRinging) {
            Settings.System.putInt(getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING,
                    mVibrateWhenRinging.isChecked() ? 1 : 0);
        } else if (preference == mDtmfTone) {
            Settings.System.putInt(getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING,
                    mDtmfTone.isChecked() ? 1 : 0);