Delete shared preference entry when user select default value
Change-Id: I3fbafd9024c26a99d87376f5d5e359e03988a30fmain
parent
58067bd952
commit
d99abf8cb1
|
@ -32,6 +32,7 @@ public final class SeekBarDialogPreference extends DialogPreference
|
|||
public int readValue(final String key);
|
||||
public int readDefaultValue(final String key);
|
||||
public void writeValue(final int value, final String key);
|
||||
public void writeDefaultValue(final String key);
|
||||
public void feedbackValue(final int value);
|
||||
}
|
||||
|
||||
|
@ -122,12 +123,16 @@ public final class SeekBarDialogPreference extends DialogPreference
|
|||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
super.onClick(dialog, which);
|
||||
final String key = getKey();
|
||||
if (which == DialogInterface.BUTTON_NEUTRAL) {
|
||||
setValue(clipValue(mValueProxy.readDefaultValue(getKey())), false /* fromUser */);
|
||||
setValue(clipValue(mValueProxy.readDefaultValue(key)), false /* fromUser */);
|
||||
mValueProxy.writeDefaultValue(key);
|
||||
return;
|
||||
}
|
||||
if (which != DialogInterface.BUTTON_NEGATIVE) {
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
setSummary(mValueView.getText());
|
||||
mValueProxy.writeValue(getClippedValueFromProgress(mSeekBar.getProgress()), getKey());
|
||||
mValueProxy.writeValue(getClippedValueFromProgress(mSeekBar.getProgress()), key);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -328,6 +328,11 @@ public final class SettingsFragment extends InputMethodSettingsFragment
|
|||
sp.edit().putInt(key, value).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDefaultValue(final String key) {
|
||||
sp.edit().remove(key).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readValue(final String key) {
|
||||
return Settings.readKeypressVibrationDuration(sp, res);
|
||||
|
@ -358,6 +363,11 @@ public final class SettingsFragment extends InputMethodSettingsFragment
|
|||
sp.edit().putInt(key, value).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDefaultValue(final String key) {
|
||||
sp.edit().remove(key).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readValue(final String key) {
|
||||
return Settings.readKeyLongpressTimeout(sp, res);
|
||||
|
@ -396,6 +406,11 @@ public final class SettingsFragment extends InputMethodSettingsFragment
|
|||
sp.edit().putFloat(key, getValueFromPercentage(value)).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDefaultValue(final String key) {
|
||||
sp.edit().remove(key).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readValue(final String key) {
|
||||
return getPercentageFromValue(Settings.readKeypressSoundVolume(sp, res));
|
||||
|
|
Loading…
Reference in New Issue