Skip to content

Commit caaab12

Browse files
committed
Merge remote-tracking branch 'up-10/dev' into 10-feature-request-change-font
2 parents 1f18744 + 7369b4d commit caaab12

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

app/src/main/java/org/schabi/newpipe/MainActivity.java

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ public String getPreferredFont(final Context context) {
204204
return preferences.getString("preferred_font", getString(R.string.default_font_key));
205205
}
206206

207+
// build the relevant font TypeFace
207208
public void setUpFont(final String preferredFont) {
208209
switch (preferredFont) {
209210
case "Arial":

app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
3939
initialSelectedContentCountry = org.schabi.newpipe.util.Localization
4040
.getPreferredContentCountry(requireContext());
4141
initialLanguage = defaultPreferences.getString(getString(R.string.app_language_key), "en");
42+
//saving the initial font as system default
4243
initialSelectedFont = defaultPreferences
4344
.getString(getString(R.string.app_font_key), getString(R.string.default_font_key));
4445
final Preference imageQualityPreference = requirePreference(R.string.image_quality_key);
@@ -82,6 +83,7 @@ public void onDestroy() {
8283
.getPreferredContentCountry(requireContext());
8384
final String selectedLanguage =
8485
defaultPreferences.getString(getString(R.string.app_language_key), "en");
86+
// getting the selectedFont from SharedPreference
8587
final String selectedFont =
8688
defaultPreferences.getString(getString(R.string.app_font_key), "Arial");
8789
if (!selectedLocalization.equals(initialSelectedLocalization)
@@ -91,9 +93,13 @@ public void onDestroy() {
9193
Toast.LENGTH_LONG).show();
9294

9395
NewPipe.setupLocalization(selectedLocalization, selectedContentCountry);
96+
// checking if the font is changed from the initial
9497
} else if ((!selectedFont.equals(initialSelectedFont))) {
98+
// showing toast to prompt restarting app
9599
Toast.makeText(requireContext(), R.string.font_changes_requires_app_restart,
96100
Toast.LENGTH_LONG).show();
101+
102+
// saving the font selected into SharedPreference
97103
final SharedPreferences preferences = PreferenceManager
98104
.getDefaultSharedPreferences(requireContext());
99105
final SharedPreferences.Editor editor = preferences.edit();

app/src/main/res/xml/content_settings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
app:useSimpleSummaryProvider="true" />
3535

3636
<ListPreference
37-
android:defaultValue="@string/default_localization_key"
37+
android:defaultValue="@string/default_font_key"
3838
android:entries="@array/app_font_name"
3939
android:entryValues="@array/app_font_code"
4040
android:key="@string/app_font_key"

build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

3-
// the kotlin version might be different from NewPipe main
43
buildscript {
54
ext.kotlin_version = '1.9.25'
65
repositories {

0 commit comments

Comments
 (0)