Enable Sonic by default

This commit is contained in:
Martin Fietz 2016-01-16 10:58:33 +01:00
parent 6d6a8d2fcd
commit bfac8f71a8
3 changed files with 40 additions and 41 deletions

View File

@ -24,14 +24,15 @@ public class VariableSpeedDialog {
private static final String TAG = VariableSpeedDialog.class.getSimpleName();
private static final Intent playStoreIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.falconware.prestissimo"));
Uri.parse("market://details?id=com.falconware.prestissimo"));
private VariableSpeedDialog() {
}
public static void showDialog(final Context context) {
if (org.antennapod.audio.MediaPlayer.isPrestoLibraryInstalled(context)
|| UserPreferences.useSonic()) {
|| UserPreferences.useSonic()
|| Build.VERSION.SDK_INT >= 23) {
showSpeedSelectorDialog(context);
} else {
showGetPluginDialog(context);
@ -42,10 +43,16 @@ public class VariableSpeedDialog {
MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
builder.title(R.string.no_playback_plugin_title);
builder.content(R.string.no_playback_plugin_or_sonic_msg);
builder.positiveText(R.string.download_plugin_label);
builder.negativeText(R.string.enable_sonic);
builder.positiveText(R.string.enable_sonic);
builder.negativeText(R.string.download_plugin_label);
builder.neutralText(R.string.close_label);
builder.onPositive((dialog, which) -> {
if (Build.VERSION.SDK_INT >= 16) { // just to be safe
UserPreferences.enableSonic(true);
showSpeedSelectorDialog(context);
}
});
builder.onNegative((dialog, which) -> {
try {
context.startActivity(playStoreIntent);
} catch (ActivityNotFoundException e) {
@ -53,18 +60,13 @@ public class VariableSpeedDialog {
Log.e(TAG, Log.getStackTraceString(e));
}
});
builder.onNegative((dialog, which) -> {
if (Build.VERSION.SDK_INT >= 16) { // just to be safe
UserPreferences.enableSonic(true);
showSpeedSelectorDialog(context);
}
});
builder.forceStacking(true);
MaterialDialog dialog = builder.show();
if(!IntentUtils.isCallable(context.getApplicationContext(), playStoreIntent)) {
if (Build.VERSION.SDK_INT < 16) {
View pos = dialog.getActionButton(DialogAction.POSITIVE);
pos.setEnabled(false);
}
if (Build.VERSION.SDK_INT < 16) {
if(!IntentUtils.isCallable(context.getApplicationContext(), playStoreIntent)) {
View pos = dialog.getActionButton(DialogAction.NEGATIVE);
pos.setEnabled(false);
}
@ -87,29 +89,29 @@ public class VariableSpeedDialog {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.set_playback_speed_label);
builder.setMultiChoiceItems(R.array.playback_speed_values,
speedChecked, (dialog, which, isChecked) -> {
speedChecked[which] = isChecked;
});
speedChecked, (dialog, which, isChecked) -> {
speedChecked[which] = isChecked;
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.setPositiveButton(android.R.string.ok,
(dialog, which) -> {
int choiceCount = 0;
for (int i = 0; i < speedChecked.length; i++) {
if (speedChecked[i]) {
choiceCount++;
}
(dialog, which) -> {
int choiceCount = 0;
for (int i = 0; i < speedChecked.length; i++) {
if (speedChecked[i]) {
choiceCount++;
}
String[] newSpeedValues = new String[choiceCount];
int newSpeedIndex = 0;
for (int i = 0; i < speedChecked.length; i++) {
if (speedChecked[i]) {
newSpeedValues[newSpeedIndex++] = speedValues[i];
}
}
String[] newSpeedValues = new String[choiceCount];
int newSpeedIndex = 0;
for (int i = 0; i < speedChecked.length; i++) {
if (speedChecked[i]) {
newSpeedValues[newSpeedIndex++] = speedValues[i];
}
}
UserPreferences.setPlaybackSpeedArray(newSpeedValues);
UserPreferences.setPlaybackSpeedArray(newSpeedValues);
});
});
builder.create().show();
}

View File

@ -74,6 +74,12 @@
</PreferenceCategory>
<PreferenceCategory android:title="@string/playback_pref">
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:defaultValue="true"
android:enabled="false"
android:key="prefSonic"
android:summary="@string/pref_sonic_message"
android:title="@string/pref_sonic_title"/>
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:defaultValue="true"
android:enabled="true"
@ -263,14 +269,5 @@
android:title="@string/crash_report_title"
android:summary="@string/crash_report_sum"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/experimental_pref">
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:defaultValue="false"
android:enabled="false"
android:key="prefSonic"
android:summary="@string/pref_sonic_message"
android:title="@string/pref_sonic_title"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@ -267,7 +267,7 @@
<!-- Variable Speed -->
<string name="download_plugin_label">Download Plugin</string>
<string name="no_playback_plugin_title">Plugin Not Installed</string>
<string name="no_playback_plugin_or_sonic_msg">For variable speed playback to work, you have to install a third party library or enable the experimental Sonic player [Android 4.1+].\n\nTap \'Download Plugin\' to download a free plugin from the Play Store.\n\nAny problems found using this plugin are not the responsibility of AntennaPod and should be reported to the plugin owner.</string>
<string name="no_playback_plugin_or_sonic_msg">For variable speed playback to work, we recommend to enable the built-in Sonic mediaplayer [Android 4.1+].\n\nAlternatively, you can download the third party plugin <i>Prestissimo</i> from the Play Store.\nAny problems with Prestissimo are not the responsibility of AntennaPod and should be reported to the plugin owner.</string>
<string name="set_playback_speed_label">Playback Speeds</string>
<string name="enable_sonic">Enable Sonic</string>
@ -380,7 +380,7 @@
<string name="send_email">Send e-mail</string>
<string name="experimental_pref">Experimental</string>
<string name="pref_sonic_title">Sonic media player</string>
<string name="pref_sonic_message">Use built-in sonic media player as a replacement for Prestissimo</string>
<string name="pref_sonic_message">Use built-in sonic media player as a replacement for Android\'s native mediaplayer and Prestissimo</string>
<string name="pref_current_value">Current value: %1$s</string>
<!-- Auto-Flattr dialog -->