diff --git a/app/src/main/java/com/limelight/preferences/SeekBarPreference.java b/app/src/main/java/com/limelight/preferences/SeekBarPreference.java index 38a5af22..64b60a47 100644 --- a/app/src/main/java/com/limelight/preferences/SeekBarPreference.java +++ b/app/src/main/java/com/limelight/preferences/SeekBarPreference.java @@ -14,6 +14,8 @@ import android.widget.LinearLayout; import android.widget.SeekBar; import android.widget.TextView; +import java.util.Locale; + // Based on a Stack Overflow example: http://stackoverflow.com/questions/1974193/slider-on-my-preferencescreen public class SeekBarPreference extends DialogPreference { @@ -30,6 +32,7 @@ public class SeekBarPreference extends DialogPreference private final int maxValue; private final int minValue; private final int stepSize; + private final int divisor; private int currentValue; public SeekBarPreference(Context context, AttributeSet attrs) { @@ -59,6 +62,7 @@ public class SeekBarPreference extends DialogPreference maxValue = attrs.getAttributeIntValue(ANDROID_SCHEMA_URL, "max", 100); minValue = attrs.getAttributeIntValue(SEEKBAR_SCHEMA_URL, "min", 1); stepSize = attrs.getAttributeIntValue(SEEKBAR_SCHEMA_URL, "step", 1); + divisor = attrs.getAttributeIntValue(SEEKBAR_SCHEMA_URL, "divisor", 1); } @Override @@ -101,7 +105,14 @@ public class SeekBarPreference extends DialogPreference return; } - String t = String.valueOf(value); + String t; + if (divisor != 1) { + float floatValue = roundedValue / (float)divisor; + t = String.format((Locale)null, "%.1f", floatValue); + } + else { + t = String.valueOf(value); + } valueText.setText(suffix == null ? t : t.concat(suffix.length() > 1 ? " "+suffix : suffix)); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa9d32d7..279b345f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -139,7 +139,7 @@ Increase for a smoother video stream. Decrease for better performance on lower end devices. Video bitrate Increase for better image quality. Decrease to improve performance on slower connections. - Kbps + Mbps Stretch video to full-screen Audio Settings diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 504d2947..510624c9 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -24,8 +24,9 @@ seekbar:min="500" seekbar:step="500" android:max="100000" + seekbar:divisor="1000" android:summary="@string/summary_seekbar_bitrate" - android:text="@string/suffix_seekbar_bitrate" + android:text="@string/suffix_seekbar_bitrate_mbps" android:title="@string/title_seekbar_bitrate" />