From 87eb5ac785614212b64fd211426d37a35ff2bcc2 Mon Sep 17 00:00:00 2001 From: Vivian Tran Date: Sun, 27 Oct 2024 14:52:19 +1100 Subject: [PATCH 1/2] make change to kotlin version for allowing gradle to build --- app/src/main/res/xml/content_settings.xml | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index 091db46644..9aefaf9bc9 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -34,7 +34,7 @@ app:useSimpleSummaryProvider="true" /> Date: Sun, 27 Oct 2024 18:10:00 +1100 Subject: [PATCH 2/2] put in comments --- app/src/main/java/org/schabi/newpipe/MainActivity.java | 1 + .../schabi/newpipe/settings/ContentSettingsFragment.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index d581dd31f7..90b69b86f1 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -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": diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index bddfe24210..33a8dd88fd 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -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); @@ -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) @@ -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();