Skip to content

Commit

Permalink
Merge remote-tracking branch 'up-10/dev' into 10-feature-request-chan…
Browse files Browse the repository at this point in the history
…ge-font
  • Loading branch information
asandikci committed Dec 6, 2024
2 parents 1f18744 + 7369b4d commit caaab12
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public String getPreferredFont(final Context context) {
return preferences.getString("preferred_font", getString(R.string.default_font_key));
}

// build the relevant font TypeFace
public void setUpFont(final String preferredFont) {
switch (preferredFont) {
case "Arial":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
initialSelectedContentCountry = org.schabi.newpipe.util.Localization
.getPreferredContentCountry(requireContext());
initialLanguage = defaultPreferences.getString(getString(R.string.app_language_key), "en");
//saving the initial font as system default
initialSelectedFont = defaultPreferences
.getString(getString(R.string.app_font_key), getString(R.string.default_font_key));
final Preference imageQualityPreference = requirePreference(R.string.image_quality_key);
Expand Down Expand Up @@ -82,6 +83,7 @@ public void onDestroy() {
.getPreferredContentCountry(requireContext());
final String selectedLanguage =
defaultPreferences.getString(getString(R.string.app_language_key), "en");
// getting the selectedFont from SharedPreference
final String selectedFont =
defaultPreferences.getString(getString(R.string.app_font_key), "Arial");
if (!selectedLocalization.equals(initialSelectedLocalization)
Expand All @@ -91,9 +93,13 @@ public void onDestroy() {
Toast.LENGTH_LONG).show();

NewPipe.setupLocalization(selectedLocalization, selectedContentCountry);
// checking if the font is changed from the initial
} else if ((!selectedFont.equals(initialSelectedFont))) {
// showing toast to prompt restarting app
Toast.makeText(requireContext(), R.string.font_changes_requires_app_restart,
Toast.LENGTH_LONG).show();

// saving the font selected into SharedPreference
final SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(requireContext());
final SharedPreferences.Editor editor = preferences.edit();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/content_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
app:useSimpleSummaryProvider="true" />

<ListPreference
android:defaultValue="@string/default_localization_key"
android:defaultValue="@string/default_font_key"
android:entries="@array/app_font_name"
android:entryValues="@array/app_font_code"
android:key="@string/app_font_key"
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

// the kotlin version might be different from NewPipe main
buildscript {
ext.kotlin_version = '1.9.25'
repositories {
Expand Down

0 comments on commit caaab12

Please sign in to comment.