From e62e34fd5cef0a265946b99bbb3e020ea6dbf39a Mon Sep 17 00:00:00 2001 From: bopol Date: Sat, 15 Feb 2020 16:29:46 +0100 Subject: [PATCH] created default_localization_key --- app/build.gradle | 2 +- .../fragments/list/search/SearchFragment.java | 2 +- .../newpipe/settings/VideoAudioSettingsFragment.java | 1 + .../java/org/schabi/newpipe/util/Localization.java | 12 ++++++------ app/src/main/res/values/settings_keys.xml | 10 +++++----- app/src/main/res/xml/content_settings.xml | 6 +++--- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9f23bffcf..77b27f50a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,7 +63,7 @@ dependencies { exclude module: 'support-annotations' }) - implementation 'com.github.B0pol:NewPipeExtractor:a9c6beec1434f4edd4197fb655e5327bae94cc92' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:fc9f031' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.23.0' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index f2e8aa244..fcb3eafa7 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -190,7 +190,7 @@ public class SearchFragment SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); isSuggestionsEnabled = preferences.getBoolean(getString(R.string.show_search_suggestions_key), true); - contentCountry = preferences.getString(getString(R.string.content_country_key), getString(R.string.default_country_value)); + contentCountry = preferences.getString(getString(R.string.content_country_key), getString(R.string.default_localization_key)); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java index 21560ee55..e5f49e2e8 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java @@ -21,6 +21,7 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment { public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + //initializing R.array.seek_duration_description to display the translation of seconds String[] durationsDescriptions = getResources().getStringArray(R.array.seek_duration_description); String[] durationsValues = getResources().getStringArray(R.array.seek_duration_value); int currentDurationValue; diff --git a/app/src/main/java/org/schabi/newpipe/util/Localization.java b/app/src/main/java/org/schabi/newpipe/util/Localization.java index b24298f4e..cd66ec3c2 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -83,8 +83,8 @@ public class Localization { public static org.schabi.newpipe.extractor.localization.Localization getPreferredLocalization(final Context context) { final String contentLanguage = PreferenceManager .getDefaultSharedPreferences(context) - .getString(context.getString(R.string.content_language_key), context.getString(R.string.default_language_value)); - if (contentLanguage.equals("system")) { + .getString(context.getString(R.string.content_language_key), context.getString(R.string.default_localization_key)); + if (contentLanguage.equals(context.getString(R.string.default_localization_key))) { return org.schabi.newpipe.extractor.localization.Localization.fromLocale(Locale.getDefault()); } return org.schabi.newpipe.extractor.localization.Localization.fromLocalizationCode(contentLanguage); @@ -93,8 +93,8 @@ public class Localization { public static ContentCountry getPreferredContentCountry(final Context context) { final String contentCountry = PreferenceManager .getDefaultSharedPreferences(context) - .getString(context.getString(R.string.content_country_key), context.getString(R.string.default_country_value)); - if (contentCountry.equals("system")) { + .getString(context.getString(R.string.content_country_key), context.getString(R.string.default_localization_key)); + if (contentCountry.equals(context.getString(R.string.default_localization_key))) { return new ContentCountry(Locale.getDefault().getCountry()); } return new ContentCountry(contentCountry); @@ -104,7 +104,7 @@ public class Localization { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); String languageCode = sp.getString(context.getString(R.string.content_language_key), - context.getString(R.string.default_language_value)); + context.getString(R.string.default_localization_key)); try { if (languageCode.length() == 2) { @@ -236,7 +236,7 @@ public class Localization { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String lang = prefs.getString(context.getString(R.string.app_language_key), "en"); Locale loc; - if (lang.equals("system")) { + if (lang.equals(context.getString(R.string.default_localization_key))) { loc = Locale.getDefault(); } else if (lang.matches(".*-.*")) { //to differentiate different versions of the language diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 05a7416f0..fba5546c1 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -161,8 +161,6 @@ show_comments stream_info_selected_tab show_hold_to_append - system - system content_language peertube_instance_setup peertube_selected_instance @@ -265,9 +263,11 @@ update_app_key update_pref_screen_key + + system - system + @string/default_localization_key af az id @@ -680,7 +680,7 @@ - system + @string/default_localization_key AF AX AL @@ -932,7 +932,7 @@ - system + @string/default_localization_key ar az ast diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index 197c14487..8fe8a66af 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -6,7 +6,7 @@