mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +01:00
Roidmi: Fix frequency configuration on some non-english languages
This commit is contained in:
parent
887c3bf8ca
commit
b0648dcc09
@ -484,8 +484,8 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
View frequency_picker_view = inflater.inflate(R.layout.dialog_frequency_picker, null);
|
final View frequency_picker_view = inflater.inflate(R.layout.dialog_frequency_picker, null);
|
||||||
builder.setTitle(R.string.preferences_fm_frequency);
|
builder.setTitle(R.string.preferences_fm_frequency);
|
||||||
final float[] fm_presets = new float[3];
|
final float[] fm_presets = new float[3];
|
||||||
|
|
||||||
@ -533,9 +533,8 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
button_presets[index].setOnClickListener(new View.OnClickListener() {
|
button_presets[index].setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
float frequency = Float.parseFloat(String.format(Locale.getDefault(), "%.1f", fm_presets[index]));
|
final float frequency = fm_presets[index];
|
||||||
device.setExtraInfo("fm_frequency", frequency);
|
device.setExtraInfo("fm_frequency", fm_presets[index]);
|
||||||
// Trim to 1 decimal place, discard the rest
|
|
||||||
fmFrequencyLabel.setText(String.format(Locale.getDefault(), "%.1f", (float) frequency));
|
fmFrequencyLabel.setText(String.format(Locale.getDefault(), "%.1f", (float) frequency));
|
||||||
GBApplication.deviceService().onSetFmFrequency(frequency);
|
GBApplication.deviceService().onSetFmFrequency(frequency);
|
||||||
alert[0].dismiss();
|
alert[0].dismiss();
|
||||||
@ -544,8 +543,7 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
button_presets[index].setOnLongClickListener(new View.OnLongClickListener() {
|
button_presets[index].setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View view) {
|
public boolean onLongClick(View view) {
|
||||||
float frequency = (float) (frequency_decimal_picker.getValue() + (0.1 * frequency_fraction_picker.getValue()));
|
final float frequency = (float) (frequency_decimal_picker.getValue() + (0.1 * frequency_fraction_picker.getValue()));
|
||||||
frequency = Float.parseFloat(String.format(Locale.getDefault(), "%.1f", frequency));
|
|
||||||
fm_presets[index] = frequency;
|
fm_presets[index] = frequency;
|
||||||
button_presets[index].setText(String.valueOf(frequency));
|
button_presets[index].setText(String.valueOf(frequency));
|
||||||
SharedPreferences.Editor editor = GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()).edit();
|
SharedPreferences.Editor editor = GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()).edit();
|
||||||
@ -558,9 +556,9 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float frequency = (float) device.getExtraInfo("fm_frequency");
|
final float frequency = (float) device.getExtraInfo("fm_frequency");
|
||||||
int decimal = (int) frequency;
|
final int decimal = (int) frequency;
|
||||||
int fraction = Math.round((frequency - decimal) * 10);
|
final int fraction = Math.round((frequency - decimal) * 10);
|
||||||
frequency_decimal_picker.setValue(decimal);
|
frequency_decimal_picker.setValue(decimal);
|
||||||
picker_listener.onValueChange(frequency_decimal_picker, frequency_decimal_picker.getValue(), decimal);
|
picker_listener.onValueChange(frequency_decimal_picker, frequency_decimal_picker.getValue(), decimal);
|
||||||
frequency_fraction_picker.setValue(fraction);
|
frequency_fraction_picker.setValue(fraction);
|
||||||
@ -572,7 +570,6 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
float frequency = (float) (frequency_decimal_picker.getValue() + (0.1 * frequency_fraction_picker.getValue()));
|
float frequency = (float) (frequency_decimal_picker.getValue() + (0.1 * frequency_fraction_picker.getValue()));
|
||||||
frequency = Float.parseFloat(String.format(Locale.getDefault(), "%.1f", frequency));
|
|
||||||
if (frequency < FREQ_MIN || frequency > FREQ_MAX) {
|
if (frequency < FREQ_MIN || frequency > FREQ_MAX) {
|
||||||
new AlertDialog.Builder(context)
|
new AlertDialog.Builder(context)
|
||||||
.setTitle(R.string.pref_invalid_frequency_title)
|
.setTitle(R.string.pref_invalid_frequency_title)
|
||||||
@ -584,7 +581,7 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
|
|||||||
.show();
|
.show();
|
||||||
} else {
|
} else {
|
||||||
device.setExtraInfo("fm_frequency", frequency);
|
device.setExtraInfo("fm_frequency", frequency);
|
||||||
fmFrequencyLabel.setText(String.format(Locale.getDefault(), "%.1f", (float) device.getExtraInfo("fm_frequency")));
|
fmFrequencyLabel.setText(String.format(Locale.getDefault(), "%.1f", frequency));
|
||||||
GBApplication.deviceService().onSetFmFrequency(frequency);
|
GBApplication.deviceService().onSetFmFrequency(frequency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user