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:
Alexey Kuzmin
2018-12-10 11:58:06 +00:00
parent e5d530348c
commit 3c51e824eb
13 changed files with 207 additions and 28 deletions

View File

@@ -39,14 +39,16 @@ public abstract class VibrationIntensityPreferenceController extends BasePrefere
protected final Vibrator mVibrator;
private final SettingObserver mSettingsContentObserver;
private final String mSettingKey;
private final String mEnabledKey;
private Preference mPreference;
public VibrationIntensityPreferenceController(Context context, String prefkey,
String settingKey) {
String settingKey, String enabledKey) {
super(context, prefkey);
mVibrator = mContext.getSystemService(Vibrator.class);
mSettingKey = settingKey;
mEnabledKey = enabledKey;
mSettingsContentObserver = new SettingObserver(settingKey) {
@Override
public void onChange(boolean selfChange, Uri uri) {
@@ -78,7 +80,9 @@ public abstract class VibrationIntensityPreferenceController extends BasePrefere
public CharSequence getSummary() {
final int intensity = Settings.System.getInt(mContext.getContentResolver(),
mSettingKey, getDefaultIntensity());
return getIntensityString(mContext, intensity);
final boolean enabled = Settings.System.getInt(mContext.getContentResolver(),
mEnabledKey, 1) == 1;
return getIntensityString(mContext, enabled ? intensity : Vibrator.VIBRATION_INTENSITY_OFF);
}
public static CharSequence getIntensityString(Context context, int intensity) {