Split ring and notification vibration settings
Synchronize settings between sound and accessibility menus Bug: 116172311 Test: See accessibility vibration settings - ring and notification settings sould be separate. Try changing vibration settings in sound and accessibility menus - the settings should stay in sync. Change-Id: I515a7188cdf5a26a229ac8f08c6fcfe98e2f91a0
This commit is contained in:
@@ -26,6 +26,7 @@ import android.os.Handler;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -116,6 +117,11 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
|
||||
*/
|
||||
protected abstract String getVibrationIntensitySetting();
|
||||
|
||||
/**
|
||||
* Get the setting string of the vibration enabledness setting this preference is dealing with.
|
||||
*/
|
||||
protected abstract String getVibrationEnabledSetting();
|
||||
|
||||
/**
|
||||
* Get the default intensity for the desired setting.
|
||||
*/
|
||||
@@ -154,8 +160,13 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
|
||||
|
||||
@Override
|
||||
protected String getDefaultKey() {
|
||||
final int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
|
||||
int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
|
||||
getVibrationIntensitySetting(), getDefaultVibrationIntensity());
|
||||
final boolean vibrationEnabled = Settings.System.getInt(getContext().getContentResolver(),
|
||||
getVibrationEnabledSetting(), 1) == 1;
|
||||
if (!vibrationEnabled) {
|
||||
vibrationIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
|
||||
}
|
||||
for (VibrationIntensityCandidateInfo candidate : mCandidates.values()) {
|
||||
final boolean matchesIntensity = candidate.getIntensity() == vibrationIntensity;
|
||||
final boolean matchesOn = candidate.getKey().equals(KEY_INTENSITY_ON)
|
||||
@@ -174,8 +185,11 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
|
||||
Log.e(TAG, "Tried to set unknown intensity (key=" + key + ")!");
|
||||
return false;
|
||||
}
|
||||
Settings.System.putInt(getContext().getContentResolver(),
|
||||
getVibrationIntensitySetting(), candidate.getIntensity());
|
||||
if (candidate.getIntensity() != Vibrator.VIBRATION_INTENSITY_OFF ||
|
||||
TextUtils.isEmpty(getVibrationEnabledSetting())) {
|
||||
Settings.System.putInt(getContext().getContentResolver(),
|
||||
getVibrationIntensitySetting(), candidate.getIntensity());
|
||||
}
|
||||
onVibrationIntensitySelected(candidate.getIntensity());
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user