Reduce default speeds to every .1 instead of every .05 so user doesn't have to do a lot of unchecking. Also, be consistant about where float or double is used and be consistent about which context is used for UserPreferences.
This commit is contained in:
parent
ad3e8d8bfe
commit
0a607117d6
|
@ -59,7 +59,27 @@
|
||||||
<item>1.85</item>
|
<item>1.85</item>
|
||||||
<item>1.90</item>
|
<item>1.90</item>
|
||||||
<item>1.95</item>
|
<item>1.95</item>
|
||||||
<item>2.0</item>
|
<item>2.00</item>
|
||||||
|
<item>2.10</item>
|
||||||
|
<item>2.20</item>
|
||||||
|
<item>2.30</item>
|
||||||
|
<item>2.40</item>
|
||||||
|
<item>2.50</item>
|
||||||
|
<item>2.60</item>
|
||||||
|
<item>2.70</item>
|
||||||
|
<item>2.80</item>
|
||||||
|
<item>2.90</item>
|
||||||
|
<item>3.00</item>
|
||||||
|
<item>3.10</item>
|
||||||
|
<item>3.20</item>
|
||||||
|
<item>3.30</item>
|
||||||
|
<item>3.40</item>
|
||||||
|
<item>3.50</item>
|
||||||
|
<item>3.60</item>
|
||||||
|
<item>3.70</item>
|
||||||
|
<item>3.80</item>
|
||||||
|
<item>3.90</item>
|
||||||
|
<item>4.00</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="autodl_select_networks_default_entries">
|
<string-array name="autodl_select_networks_default_entries">
|
||||||
|
|
|
@ -428,8 +428,7 @@ public class AudioplayerActivity extends MediaplayerActivity {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UserPreferences.setPlaybackSpeed(AudioplayerActivity.this,
|
UserPreferences.setPlaybackSpeed(newSpeed);
|
||||||
newSpeed);
|
|
||||||
controller.setPlaybackSpeed(Float.parseFloat(newSpeed));
|
controller.setPlaybackSpeed(Float.parseFloat(newSpeed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,8 +85,7 @@ public class VariableSpeedDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UserPreferences.setPlaybackSpeedArray(context,
|
UserPreferences.setPlaybackSpeedArray(newSpeedValues);
|
||||||
newSpeedValues);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,8 @@ package de.danoeh.antennapod.preferences;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -89,6 +91,7 @@ public class UserPreferences implements
|
||||||
createNoMediaFile();
|
createNoMediaFile();
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
.registerOnSharedPreferenceChangeListener(instance);
|
.registerOnSharedPreferenceChangeListener(instance);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadPreferences() {
|
private void loadPreferences() {
|
||||||
|
@ -145,17 +148,25 @@ public class UserPreferences implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] readPlaybackSpeedArray(String valueFromPrefs) {
|
private String[] readPlaybackSpeedArray(String valueFromPrefs) {
|
||||||
String[] playbackSpeeds = null;
|
String[] selectedSpeeds = null;
|
||||||
// If this preference hasn't been set yet, return all options
|
// If this preference hasn't been set yet, return the default options
|
||||||
if (valueFromPrefs == null) {
|
if (valueFromPrefs == null) {
|
||||||
playbackSpeeds = context.getResources().getStringArray(
|
String[] allSpeeds = context.getResources().getStringArray(
|
||||||
R.array.playback_speed_values);
|
R.array.playback_speed_values);
|
||||||
|
List<String> speedList = new LinkedList<String>();
|
||||||
|
for (String speedStr : allSpeeds) {
|
||||||
|
float speed = Float.parseFloat(speedStr);
|
||||||
|
if (speed < 2.0001 && speed * 10 % 1 == 0) {
|
||||||
|
speedList.add(speedStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selectedSpeeds = speedList.toArray(new String[speedList.size()]);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
JSONArray jsonArray = new JSONArray(valueFromPrefs);
|
JSONArray jsonArray = new JSONArray(valueFromPrefs);
|
||||||
playbackSpeeds = new String[jsonArray.length()];
|
selectedSpeeds = new String[jsonArray.length()];
|
||||||
for (int i = 0; i < jsonArray.length(); i++) {
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
playbackSpeeds[i] = jsonArray.getString(i);
|
selectedSpeeds[i] = jsonArray.getString(i);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
Log.e(TAG,
|
Log.e(TAG,
|
||||||
|
@ -163,7 +174,7 @@ public class UserPreferences implements
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return playbackSpeeds;
|
return selectedSpeeds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void instanceAvailable() {
|
private static void instanceAvailable() {
|
||||||
|
@ -299,24 +310,19 @@ public class UserPreferences implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPlaybackSpeed(Context context, String speed) {
|
public static void setPlaybackSpeed(String speed) {
|
||||||
SharedPreferences prefs = PreferenceManager
|
PreferenceManager.getDefaultSharedPreferences(instance.context).edit()
|
||||||
.getDefaultSharedPreferences(context.getApplicationContext());
|
.putString(PREF_PLAYBACK_SPEED, speed).apply();
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
editor.putString(PREF_PLAYBACK_SPEED, speed);
|
|
||||||
editor.apply();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPlaybackSpeedArray(Context context, String[] speeds) {
|
public static void setPlaybackSpeedArray(String[] speeds) {
|
||||||
SharedPreferences prefs = PreferenceManager
|
|
||||||
.getDefaultSharedPreferences(context.getApplicationContext());
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
for (String speed : speeds) {
|
for (String speed : speeds) {
|
||||||
jsonArray.put(speed);
|
jsonArray.put(speed);
|
||||||
}
|
}
|
||||||
editor.putString(PREF_PLAYBACK_SPEED_ARRAY, jsonArray.toString());
|
PreferenceManager.getDefaultSharedPreferences(instance.context).edit()
|
||||||
editor.apply();
|
.putString(PREF_PLAYBACK_SPEED_ARRAY, jsonArray.toString())
|
||||||
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAutodownloadSelectedNetworks(Context context,
|
public static void setAutodownloadSelectedNetworks(Context context,
|
||||||
|
|
Loading…
Reference in New Issue