am 500b1f41: Merge "Get value text from ValueProxy"
* commit '500b1f410d65e461e667f72564d4c1579c26d1ac': Get value text from ValueProxymain
commit
6451fd3543
|
@ -439,7 +439,6 @@
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="SeekBarDialogPreference">
|
<declare-styleable name="SeekBarDialogPreference">
|
||||||
<attr name="valueFormatText" format="reference" />
|
|
||||||
<attr name="maxValue" format="integer" />
|
<attr name="maxValue" format="integer" />
|
||||||
<attr name="minValue" format="integer" />
|
<attr name="minValue" format="integer" />
|
||||||
<attr name="stepValue" format="integer" />
|
<attr name="stepValue" format="integer" />
|
||||||
|
|
|
@ -170,14 +170,12 @@
|
||||||
<com.android.inputmethod.latin.SeekBarDialogPreference
|
<com.android.inputmethod.latin.SeekBarDialogPreference
|
||||||
android:key="pref_key_longpress_timeout"
|
android:key="pref_key_longpress_timeout"
|
||||||
android:title="@string/prefs_key_longpress_timeout_settings"
|
android:title="@string/prefs_key_longpress_timeout_settings"
|
||||||
latin:valueFormatText="@string/abbreviation_unit_milliseconds"
|
|
||||||
latin:minValue="@integer/config_min_longpress_timeout"
|
latin:minValue="@integer/config_min_longpress_timeout"
|
||||||
latin:maxValue="@integer/config_max_longpress_timeout"
|
latin:maxValue="@integer/config_max_longpress_timeout"
|
||||||
latin:stepValue="@integer/config_longpress_timeout_step" />
|
latin:stepValue="@integer/config_longpress_timeout_step" />
|
||||||
<com.android.inputmethod.latin.SeekBarDialogPreference
|
<com.android.inputmethod.latin.SeekBarDialogPreference
|
||||||
android:key="pref_vibration_duration_settings"
|
android:key="pref_vibration_duration_settings"
|
||||||
android:title="@string/prefs_keypress_vibration_duration_settings"
|
android:title="@string/prefs_keypress_vibration_duration_settings"
|
||||||
latin:valueFormatText="@string/abbreviation_unit_milliseconds"
|
|
||||||
latin:maxValue="@integer/config_max_vibration_duration" />
|
latin:maxValue="@integer/config_max_vibration_duration" />
|
||||||
<com.android.inputmethod.latin.SeekBarDialogPreference
|
<com.android.inputmethod.latin.SeekBarDialogPreference
|
||||||
android:key="pref_keypress_sound_volume"
|
android:key="pref_keypress_sound_volume"
|
||||||
|
|
|
@ -33,10 +33,10 @@ public final class SeekBarDialogPreference extends DialogPreference
|
||||||
public int readDefaultValue(final String key);
|
public int readDefaultValue(final String key);
|
||||||
public void writeValue(final int value, final String key);
|
public void writeValue(final int value, final String key);
|
||||||
public void writeDefaultValue(final String key);
|
public void writeDefaultValue(final String key);
|
||||||
|
public String getValueText(final int value);
|
||||||
public void feedbackValue(final int value);
|
public void feedbackValue(final int value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int mValueFormatResId;
|
|
||||||
private final int mMaxValue;
|
private final int mMaxValue;
|
||||||
private final int mMinValue;
|
private final int mMinValue;
|
||||||
private final int mStepValue;
|
private final int mStepValue;
|
||||||
|
@ -50,7 +50,6 @@ public final class SeekBarDialogPreference extends DialogPreference
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
final TypedArray a = context.obtainStyledAttributes(
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.SeekBarDialogPreference, 0, 0);
|
attrs, R.styleable.SeekBarDialogPreference, 0, 0);
|
||||||
mValueFormatResId = a.getResourceId(R.styleable.SeekBarDialogPreference_valueFormatText, 0);
|
|
||||||
mMaxValue = a.getInt(R.styleable.SeekBarDialogPreference_maxValue, 0);
|
mMaxValue = a.getInt(R.styleable.SeekBarDialogPreference_maxValue, 0);
|
||||||
mMinValue = a.getInt(R.styleable.SeekBarDialogPreference_minValue, 0);
|
mMinValue = a.getInt(R.styleable.SeekBarDialogPreference_minValue, 0);
|
||||||
mStepValue = a.getInt(R.styleable.SeekBarDialogPreference_stepValue, 0);
|
mStepValue = a.getInt(R.styleable.SeekBarDialogPreference_stepValue, 0);
|
||||||
|
@ -60,15 +59,8 @@ public final class SeekBarDialogPreference extends DialogPreference
|
||||||
|
|
||||||
public void setInterface(final ValueProxy proxy) {
|
public void setInterface(final ValueProxy proxy) {
|
||||||
mValueProxy = proxy;
|
mValueProxy = proxy;
|
||||||
setSummary(getValueText(clipValue(proxy.readValue(getKey()))));
|
final int value = mValueProxy.readValue(getKey());
|
||||||
}
|
setSummary(mValueProxy.getValueText(value));
|
||||||
|
|
||||||
private String getValueText(final int value) {
|
|
||||||
if (mValueFormatResId == 0) {
|
|
||||||
return Integer.toString(value);
|
|
||||||
} else {
|
|
||||||
return getContext().getString(mValueFormatResId, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,16 +93,11 @@ public final class SeekBarDialogPreference extends DialogPreference
|
||||||
return clipValue(getValueFromProgress(progress));
|
return clipValue(getValueFromProgress(progress));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setValue(final int value, final boolean fromUser) {
|
|
||||||
mValueView.setText(getValueText(value));
|
|
||||||
if (!fromUser) {
|
|
||||||
mSeekBar.setProgress(getProgressFromValue(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBindDialogView(final View view) {
|
protected void onBindDialogView(final View view) {
|
||||||
setValue(clipValue(mValueProxy.readValue(getKey())), false /* fromUser */);
|
final int value = mValueProxy.readValue(getKey());
|
||||||
|
mValueView.setText(mValueProxy.getValueText(value));
|
||||||
|
mSeekBar.setProgress(getProgressFromValue(clipValue(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -125,13 +112,15 @@ public final class SeekBarDialogPreference extends DialogPreference
|
||||||
super.onClick(dialog, which);
|
super.onClick(dialog, which);
|
||||||
final String key = getKey();
|
final String key = getKey();
|
||||||
if (which == DialogInterface.BUTTON_NEUTRAL) {
|
if (which == DialogInterface.BUTTON_NEUTRAL) {
|
||||||
setValue(clipValue(mValueProxy.readDefaultValue(key)), false /* fromUser */);
|
final int value = mValueProxy.readDefaultValue(key);
|
||||||
|
setSummary(mValueProxy.getValueText(value));
|
||||||
mValueProxy.writeDefaultValue(key);
|
mValueProxy.writeDefaultValue(key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
setSummary(mValueView.getText());
|
final int value = getClippedValueFromProgress(mSeekBar.getProgress());
|
||||||
mValueProxy.writeValue(getClippedValueFromProgress(mSeekBar.getProgress()), key);
|
setSummary(mValueProxy.getValueText(value));
|
||||||
|
mValueProxy.writeValue(value, key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +128,11 @@ public final class SeekBarDialogPreference extends DialogPreference
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(final SeekBar seekBar, final int progress,
|
public void onProgressChanged(final SeekBar seekBar, final int progress,
|
||||||
final boolean fromUser) {
|
final boolean fromUser) {
|
||||||
setValue(getClippedValueFromProgress(progress), fromUser);
|
final int value = getClippedValueFromProgress(progress);
|
||||||
|
mValueView.setText(mValueProxy.getValueText(value));
|
||||||
|
if (!fromUser) {
|
||||||
|
mSeekBar.setProgress(getProgressFromValue(value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -364,6 +364,11 @@ public final class SettingsFragment extends InputMethodSettingsFragment
|
||||||
public void feedbackValue(final int value) {
|
public void feedbackValue(final int value) {
|
||||||
AudioAndHapticFeedbackManager.getInstance().vibrate(value);
|
AudioAndHapticFeedbackManager.getInstance().vibrate(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValueText(final int value) {
|
||||||
|
return res.getString(R.string.abbreviation_unit_milliseconds, value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,6 +400,11 @@ public final class SettingsFragment extends InputMethodSettingsFragment
|
||||||
return Settings.readDefaultKeyLongpressTimeout(res);
|
return Settings.readDefaultKeyLongpressTimeout(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValueText(final int value) {
|
||||||
|
return res.getString(R.string.abbreviation_unit_milliseconds, value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void feedbackValue(final int value) {}
|
public void feedbackValue(final int value) {}
|
||||||
});
|
});
|
||||||
|
@ -438,6 +448,11 @@ public final class SettingsFragment extends InputMethodSettingsFragment
|
||||||
return getPercentageFromValue(Settings.readDefaultKeypressSoundVolume(res));
|
return getPercentageFromValue(Settings.readDefaultKeypressSoundVolume(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValueText(final int value) {
|
||||||
|
return Integer.toString(value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void feedbackValue(final int value) {
|
public void feedbackValue(final int value) {
|
||||||
am.playSoundEffect(
|
am.playSoundEffect(
|
||||||
|
|
Loading…
Reference in New Issue