From efb8ea4c2556329587b0891235033ff502826d8e Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 5 Oct 2018 16:31:23 +0200 Subject: [PATCH] make local settings be live updated --- .../settings/ContentSettingsFragment.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 5c54fa735..82604f7da 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -17,6 +17,8 @@ import com.nononsenseapps.filepicker.Utils; import com.nostra13.universalimageloader.core.ImageLoader; import org.schabi.newpipe.R; +import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.FilePickerActivityHelper; @@ -106,6 +108,20 @@ public class ContentSettingsFragment extends BasePreferenceFragment { startActivityForResult(i, REQUEST_EXPORT_PATH); return true; }); + + Preference setPreferredLanguage = findPreference(getString(R.string.content_language_key)); + setPreferredLanguage.setOnPreferenceChangeListener((Preference p, Object newLanguage) -> { + Localization oldLocal = org.schabi.newpipe.util.Localization.getPreferredExtractorLocal(getActivity()); + NewPipe.setLocalization(new Localization(oldLocal.getCountry(), (String) newLanguage)); + return true; + }); + + Preference setPreferredCountry = findPreference(getString(R.string.content_country_key)); + setPreferredCountry.setOnPreferenceChangeListener((Preference p, Object newCountry) -> { + Localization oldLocal = org.schabi.newpipe.util.Localization.getPreferredExtractorLocal(getActivity()); + NewPipe.setLocalization(new Localization((String) newCountry, oldLocal.getLanguage())); + return true; + }); } @Override