diff --git a/app/src/brave/java/org/schabi/newpipe/settings/BraveVideoAudioSettingsBaseFragment.java b/app/src/brave/java/org/schabi/newpipe/settings/BraveVideoAudioSettingsBaseFragment.java new file mode 100644 index 00000000000..abde4ec72b5 --- /dev/null +++ b/app/src/brave/java/org/schabi/newpipe/settings/BraveVideoAudioSettingsBaseFragment.java @@ -0,0 +1,4 @@ +package org.schabi.newpipe.settings; + +public abstract class BraveVideoAudioSettingsBaseFragment extends BraveBasePreferenceFragment { +} diff --git a/app/src/braveConscrypt/java/org/schabi/newpipe/settings/BraveVideoAudioSettingsBaseFragment.java b/app/src/braveConscrypt/java/org/schabi/newpipe/settings/BraveVideoAudioSettingsBaseFragment.java new file mode 100644 index 00000000000..abde4ec72b5 --- /dev/null +++ b/app/src/braveConscrypt/java/org/schabi/newpipe/settings/BraveVideoAudioSettingsBaseFragment.java @@ -0,0 +1,4 @@ +package org.schabi.newpipe.settings; + +public abstract class BraveVideoAudioSettingsBaseFragment extends BraveBasePreferenceFragment { +} diff --git a/app/src/braveLegacy/java/org/schabi/newpipe/BraveApp.java b/app/src/braveLegacy/java/org/schabi/newpipe/BraveApp.java index d6bce1372e0..79c145bb9d2 100644 --- a/app/src/braveLegacy/java/org/schabi/newpipe/BraveApp.java +++ b/app/src/braveLegacy/java/org/schabi/newpipe/BraveApp.java @@ -4,6 +4,7 @@ import android.os.Build; import org.conscrypt.Conscrypt; +import org.schabi.newpipe.settings.BraveVideoAudioSettingsBaseFragment; import org.schabi.newpipe.util.BraveTLSSocketFactory; import java.security.Security; @@ -24,6 +25,8 @@ public void onCreate() { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { BraveTLSSocketFactory.setAsDefault(); } + + makeConfigOptionsSuitableForFlavor(); } /** @@ -41,4 +44,8 @@ public void onCreate() { public static Context getAppContext() { return appContext; } + + private void makeConfigOptionsSuitableForFlavor() { + BraveVideoAudioSettingsBaseFragment.makeConfigOptionsSuitableForFlavor(getAppContext()); + } } diff --git a/app/src/braveLegacy/java/org/schabi/newpipe/settings/BraveVideoAudioSettingsBaseFragment.java b/app/src/braveLegacy/java/org/schabi/newpipe/settings/BraveVideoAudioSettingsBaseFragment.java new file mode 100644 index 00000000000..ebcf40859bf --- /dev/null +++ b/app/src/braveLegacy/java/org/schabi/newpipe/settings/BraveVideoAudioSettingsBaseFragment.java @@ -0,0 +1,70 @@ +package org.schabi.newpipe.settings; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Build; + +import org.schabi.newpipe.R; + +import androidx.preference.ListPreference; +import androidx.preference.PreferenceManager; + + +public abstract class BraveVideoAudioSettingsBaseFragment extends BraveBasePreferenceFragment { + + public static void makeConfigOptionsSuitableForFlavor(final Context context) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + return; + } + + final SharedPreferences prefs = + PreferenceManager.getDefaultSharedPreferences(context); + + // make sure seekbar thumbnail stuff is *not* set to high quality as it + // consumes to much memory which gives OutOfMemoryError Exception on Kitkat + // -> so default to low quality + // -> TODO long run fix the bug of the seekbar_preview_thumbnail implementation + final String seekBarOption = prefs.getString(context.getString( + R.string.seekbar_preview_thumbnail_key), null + ); + if ((null == seekBarOption) || (seekBarOption.equals( + context.getString(R.string.seekbar_preview_thumbnail_high_quality)))) { + prefs.edit().putString( + context.getString(R.string.seekbar_preview_thumbnail_key), + context.getString(R.string.seekbar_preview_thumbnail_low_quality)).apply(); + } + } + + @Override + protected void manipulateCreatedPreferenceOptions() { + super.manipulateCreatedPreferenceOptions(); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + return; + } + + setListPreferenceData(); + } + + private void setListPreferenceData() { + final ListPreference lp = (ListPreference) findPreference( + getString(R.string.seekbar_preview_thumbnail_key)); + + final CharSequence[] entries = { + getString(R.string.low_quality_smaller), + getString(R.string.dont_show) + }; + + final CharSequence[] entryValues = { + getString(R.string.seekbar_preview_thumbnail_low_quality), + getString(R.string.seekbar_preview_thumbnail_none) + }; + + lp.setEntries(entries); + lp.setEntryValues(entryValues); + // default value has to be set in BraveApp via the static + // method makeConfigOptionsSuitableForFlavor() + //lp.setDefaultValue(getString(R.string.seekbar_preview_thumbnail_low_quality)); + //lp.setValueIndex(0); + } +} diff --git a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java index a1f563724ee..4a1e2499e43 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java @@ -19,7 +19,7 @@ import java.util.LinkedList; import java.util.List; -public class VideoAudioSettingsFragment extends BasePreferenceFragment { +public class VideoAudioSettingsFragment extends BraveVideoAudioSettingsBaseFragment { private SharedPreferences.OnSharedPreferenceChangeListener listener; @Override