mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-11 01:40:59 +00:00
fixed preferred_player inconsistancy
This commit is contained in:
parent
c3ec9b2ad7
commit
9c7aa241e4
@ -5,7 +5,6 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
@ -13,7 +12,6 @@ import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -176,8 +174,10 @@ public class RouterActivity extends AppCompatActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
final String playerChoiceKey = preferences.getString(getString(R.string.preferred_player_key), getString(R.string.preferred_player_default));
|
||||
final String alwaysAskKey = getString(R.string.always_ask_player_key);
|
||||
final String playerChoiceKey = preferences.getString(
|
||||
getString(R.string.preferred_open_action_key),
|
||||
getString(R.string.preferred_open_action_default));
|
||||
final String alwaysAskKey = getString(R.string.always_ask_open_action_key);
|
||||
|
||||
if (playerChoiceKey.equals(alwaysAskKey)) {
|
||||
showDialog();
|
||||
@ -196,7 +196,7 @@ public class RouterActivity extends AppCompatActivity {
|
||||
final RadioGroup radioGroup = rootLayout.findViewById(android.R.id.list);
|
||||
|
||||
final AdapterChoiceItem[] choices = {
|
||||
new AdapterChoiceItem(getString(R.string.info_screen_key), getString(R.string.show_info),
|
||||
new AdapterChoiceItem(getString(R.string.show_info_key), getString(R.string.show_info),
|
||||
resolveResourceIdFromAttr(themeWrapper, R.attr.info)),
|
||||
new AdapterChoiceItem(getString(R.string.video_player_key), getString(R.string.video_player),
|
||||
resolveResourceIdFromAttr(themeWrapper, R.attr.play)),
|
||||
@ -214,7 +214,7 @@ public class RouterActivity extends AppCompatActivity {
|
||||
handleChoice(choice.key);
|
||||
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
preferences.edit().putString(getString(R.string.preferred_player_key), choice.key).apply();
|
||||
preferences.edit().putString(getString(R.string.preferred_open_action_key), choice.key).apply();
|
||||
}
|
||||
};
|
||||
|
||||
@ -257,7 +257,7 @@ public class RouterActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
if (selectedRadioPosition == -1) {
|
||||
final String lastSelectedPlayer = preferences.getString(getString(R.string.preferred_player_last_selected_key), null);
|
||||
final String lastSelectedPlayer = preferences.getString(getString(R.string.preferred_open_action_last_selected_key), null);
|
||||
if (!TextUtils.isEmpty(lastSelectedPlayer)) {
|
||||
for (int i = 0; i < choices.length; i++) {
|
||||
AdapterChoiceItem c = choices[i];
|
||||
@ -288,12 +288,16 @@ public class RouterActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void handleChoice(final String playerChoiceKey) {
|
||||
if (Arrays.asList(getResources().getStringArray(R.array.preferred_player_values_list)).contains(playerChoiceKey)) {
|
||||
if (Arrays.asList(getResources()
|
||||
.getStringArray(R.array.preferred_open_action_values_list))
|
||||
.contains(playerChoiceKey)) {
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit()
|
||||
.putString(getString(R.string.preferred_player_last_selected_key), playerChoiceKey).apply();
|
||||
.putString(getString(R.string.preferred_open_action_last_selected_key),
|
||||
playerChoiceKey).apply();
|
||||
}
|
||||
|
||||
if (playerChoiceKey.equals(getString(R.string.popup_player_key)) && !PermissionHelper.isPopupEnabled(this)) {
|
||||
if (playerChoiceKey.equals(getString(R.string.popup_player_key))
|
||||
&& !PermissionHelper.isPopupEnabled(this)) {
|
||||
PermissionHelper.showPopupEnablementToast(this);
|
||||
finish();
|
||||
return;
|
||||
@ -301,7 +305,7 @@ public class RouterActivity extends AppCompatActivity {
|
||||
|
||||
// stop and bypass FetcherService if InfoScreen was selected since
|
||||
// StreamDetailFragment can fetch data itself
|
||||
if(playerChoiceKey.equals(getString(R.string.info_screen_key))) {
|
||||
if(playerChoiceKey.equals(getString(R.string.show_info_key))) {
|
||||
disposables.add(Observable
|
||||
.fromCallable(() -> NavigationHelper.getIntentByLink(this, currentUrl))
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -150,28 +150,30 @@
|
||||
|
||||
<string name="default_file_charset_value" translatable="false">@string/charset_most_special_characters_value</string>
|
||||
|
||||
<!-- Preferred player -->
|
||||
<string name="preferred_player_key" translatable="false">preferred_player_key</string>
|
||||
<string name="preferred_player_default" translatable="false">@string/always_ask_player_key</string>
|
||||
<string name="preferred_player_last_selected_key" translatable="false">preferred_player_last_selected</string>
|
||||
<!-- Preferred action on open (open from external app) -->
|
||||
<string name="preferred_open_action_key" translatable="false">preferred_open_action_key</string>
|
||||
<string name="preferred_open_action_default" translatable="false">@string/always_ask_open_action_key</string>
|
||||
<string name="preferred_open_action_last_selected_key" translatable="false">preferred_open_action_last_selected</string>
|
||||
|
||||
<string name="info_screen_key" translatable="false">info_screen</string>
|
||||
<string name="show_info_key" translatable="false">show_info</string>
|
||||
<string name="video_player_key" translatable="false">video_player</string>
|
||||
<string name="background_player_key" translatable="false">background_player</string>
|
||||
<string name="popup_player_key" translatable="false">popup_player</string>
|
||||
<string name="always_ask_player_key" translatable="false">always_ask_player</string>
|
||||
<string name="always_ask_open_action_key" translatable="false">always_ask_player</string>
|
||||
|
||||
<string-array name="preferred_player_description_list" translatable="false">
|
||||
<string-array name="preferred_open_action_description_list" translatable="false">
|
||||
<item>@string/show_info</item>
|
||||
<item>@string/video_player</item>
|
||||
<item>@string/background_player</item>
|
||||
<item>@string/popup_player</item>
|
||||
<item>@string/always_ask_player</item>
|
||||
<item>@string/always_ask_open_action</item>
|
||||
</string-array>
|
||||
<string-array name="preferred_player_values_list" translatable="false">
|
||||
<string-array name="preferred_open_action_values_list" translatable="false">
|
||||
<item>@string/show_info_key</item>
|
||||
<item>@string/video_player_key</item>
|
||||
<item>@string/background_player_key</item>
|
||||
<item>@string/popup_player_key</item>
|
||||
<item>@string/always_ask_player_key</item>
|
||||
<item>@string/always_ask_open_action_key</item>
|
||||
</string-array>
|
||||
|
||||
<!-- alternatively, load these from some local android data store -->
|
||||
|
@ -376,7 +376,7 @@
|
||||
<string name="video_player">Video player</string>
|
||||
<string name="background_player">Background player</string>
|
||||
<string name="popup_player">Popup player</string>
|
||||
<string name="always_ask_player">Always ask</string>
|
||||
<string name="always_ask_open_action">Always ask</string>
|
||||
|
||||
<string name="preferred_player_fetcher_notification_title">Getting info…</string>
|
||||
<string name="preferred_player_fetcher_notification_message">"The requested content is loading"</string>
|
||||
|
@ -75,10 +75,10 @@
|
||||
android:title="@string/settings_category_player_behavior_title">
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/preferred_player_default"
|
||||
android:entries="@array/preferred_player_description_list"
|
||||
android:entryValues="@array/preferred_player_values_list"
|
||||
android:key="@string/preferred_player_key"
|
||||
android:defaultValue="@string/preferred_open_action_default"
|
||||
android:entries="@array/preferred_open_action_description_list"
|
||||
android:entryValues="@array/preferred_open_action_values_list"
|
||||
android:key="@string/preferred_open_action_key"
|
||||
android:summary="%s"
|
||||
android:title="@string/preferred_player_settings_title"/>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user