Skip to content

Commit

Permalink
created default_localization_key
Browse files Browse the repository at this point in the history
  • Loading branch information
B0pol committed Feb 16, 2020
1 parent 5b541cc commit e62e34f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void onCreate(Bundle savedInstanceState) {

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/org/schabi/newpipe/util/Localization.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public static String concatenateStrings(final List<String> strings) {
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);
Expand All @@ -93,8 +93,8 @@ public static org.schabi.newpipe.extractor.localization.Localization getPreferre
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);
Expand All @@ -104,7 +104,7 @@ public static Locale getPreferredLocale(Context context) {
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) {
Expand Down Expand Up @@ -236,7 +236,7 @@ public static Locale getAppLocale(Context context) {
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
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@
<string name="show_comments_key" translatable="false">show_comments</string>
<string name="stream_info_selected_tab_key" translatable="false">stream_info_selected_tab</string>
<string name="show_hold_to_append_key" translatable="false">show_hold_to_append</string>
<string name="default_language_value" translatable="false">system</string>
<string name="default_country_value" translatable="false">system</string>
<string name="content_language_key" translatable="false">content_language</string>
<string name="peertube_instance_setup_key" translatable="false">peertube_instance_setup</string>
<string name="peertube_selected_instance_key" translatable="false">peertube_selected_instance</string>
Expand Down Expand Up @@ -265,9 +263,11 @@
<string name="update_app_key" translatable="false">update_app_key</string>
<string name="update_pref_screen_key" translatable="false">update_pref_screen_key</string>

<!-- Localizations -->
<string name="default_localization_key" translatable="false">system</string>
<!-- alternatively, load these from some local android data store -->
<string-array name="language_codes" translatable="false">
<item>system</item>
<item>@string/default_localization_key</item>
<item>af</item>
<item>az</item>
<item>id</item>
Expand Down Expand Up @@ -680,7 +680,7 @@
</string-array>

<string-array name="country_codes" translatable="false">
<item>system</item>
<item>@string/default_localization_key</item>
<item>AF</item>
<item>AX</item>
<item>AL</item>
Expand Down Expand Up @@ -932,7 +932,7 @@

<!--The next two arrays are set to change the app language-->
<string-array name="app_language_code" translatable="false">
<item>system</item>
<item>@string/default_localization_key</item>
<item>ar</item>
<item>az</item>
<item>ast</item>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/xml/content_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ListPreference
app:iconSpaceReserved="false"
android:defaultValue="system"
android:defaultValue="@string/default_localization_key"
android:entries="@array/app_language_name"
android:entryValues="@array/app_language_code"
android:key="@string/app_language_key"
Expand All @@ -15,7 +15,7 @@

<ListPreference
app:iconSpaceReserved="false"
android:defaultValue="@string/default_language_value"
android:defaultValue="@string/default_localization_key"
android:entries="@array/language_names"
android:entryValues="@array/language_codes"
android:key="@string/content_language_key"
Expand All @@ -24,7 +24,7 @@

<ListPreference
app:iconSpaceReserved="false"
android:defaultValue="@string/default_country_value"
android:defaultValue="@string/default_localization_key"
android:entries="@array/country_names"
android:entryValues="@array/country_codes"
android:key="@string/content_country_key"
Expand Down

0 comments on commit e62e34f

Please sign in to comment.