Cherish: User toggle for streaming apps [2/2]

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Joey Huab
2022-02-10 23:02:20 +09:00
committed by Hưng Phan
parent 4537e0bb8c
commit 77180c6bd9
3 changed files with 39 additions and 11 deletions

View File

@@ -704,5 +704,10 @@
<!-- Notch: Full screen apps --> <!-- Notch: Full screen apps -->
<string name="display_cutout_force_fullscreen_title">Full screen apps</string> <string name="display_cutout_force_fullscreen_title">Full screen apps</string>
<string name="display_cutout_force_fullscreen_summary">Force apps to ignore notch space</string> <string name="display_cutout_force_fullscreen_summary">Force apps to ignore notch space</string>
<!-- Higher quality streams for known streaming apps -->
<string name="use_stream_spoof_title">Higher quality streams</string>
<string name="use_stream_spoof_summary">Enable Higher quality streams on Amazon Prime, Disney+, Hotstar, and Netflix. (Mileage will vary per-device)</string>
<string name="stream_spoof_toast">Restart the streaming app for it to take effect</string>
</resources> </resources>

View File

@@ -36,8 +36,7 @@
android:title="@string/display_cutout_force_fullscreen_title" android:title="@string/display_cutout_force_fullscreen_title"
android:summary="@string/display_cutout_force_fullscreen_summary" android:summary="@string/display_cutout_force_fullscreen_summary"
android:fragment="com.cherish.settings.fragments.DisplayCutoutForceFullscreenSettings" android:fragment="com.cherish.settings.fragments.DisplayCutoutForceFullscreenSettings"
settings:controller="com.cherish.settings.fragments.DisplayCutoutForceFullscreenPreferenceController" settings:controller="com.cherish.settings.fragments.DisplayCutoutForceFullscreenPreferenceController" />
app:allowDividerAbove="true" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference <com.cherish.settings.preferences.SystemSettingSwitchPreference
@@ -45,6 +44,13 @@
android:title="@string/use_photos_spoof_title" android:title="@string/use_photos_spoof_title"
android:summary="@string/use_photos_spoof_summary" android:summary="@string/use_photos_spoof_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="false" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="use_stream_spoof"
android:title="@string/use_stream_spoof_title"
android:summary="@string/use_stream_spoof_summary"
android:defaultValue="true"
android:persistent="false" /> android:persistent="false" />
<PreferenceCategory <PreferenceCategory

View File

@@ -46,10 +46,13 @@ import java.util.List;
public class MiscSettings extends SettingsPreferenceFragment implements public class MiscSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener { OnPreferenceChangeListener {
private static final String KEY_SPOOF = "use_photos_spoof"; private static final String KEY_PHOTOS_SPOOF = "use_photos_spoof";
private static final String SYS_SPOOF = "persist.sys.photo"; private static final String KEY_STREAM_SPOOF = "use_stream_spoof";
private static final String SYS_PHOTOS_SPOOF = "persist.sys.photo";
private static final String SYS_STREAM_SPOOF = "persist.sys.stream";
private SwitchPreference mSpoof; private SwitchPreference mPhotosSpoof;
private SwitchPreference mStreamSpoof;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@@ -60,10 +63,15 @@ public class MiscSettings extends SettingsPreferenceFragment implements
final PreferenceScreen prefSet = getPreferenceScreen(); final PreferenceScreen prefSet = getPreferenceScreen();
final String useSpoof = SystemProperties.get(SYS_SPOOF, "1"); final String usePhotosSpoof = SystemProperties.get(SYS_PHOTOS_SPOOF, "1");
mSpoof = (SwitchPreference) findPreference(KEY_SPOOF); mPhotosSpoof = (SwitchPreference) findPreference(KEY_PHOTOS_SPOOF);
mSpoof.setChecked("1".equals(useSpoof)); mPhotosSpoof.setChecked("1".equals(usePhotosSpoof));
mSpoof.setOnPreferenceChangeListener(this); mPhotosSpoof.setOnPreferenceChangeListener(this);
final String useStreamSpoof = SystemProperties.get(SYS_STREAM_SPOOF, "1");
mStreamSpoof = (SwitchPreference) findPreference(KEY_STREAM_SPOOF);
mStreamSpoof.setChecked("1".equals(useStreamSpoof));
mStreamSpoof.setOnPreferenceChangeListener(this);
Resources res = null; Resources res = null;
Context ctx = getContext(); Context ctx = getContext();
@@ -79,15 +87,24 @@ public class MiscSettings extends SettingsPreferenceFragment implements
@Override @Override
public boolean onPreferenceChange(Preference preference, Object objValue) { public boolean onPreferenceChange(Preference preference, Object objValue) {
if (preference == mSpoof) { if (preference == mPhotosSpoof) {
boolean value = (Boolean) objValue; boolean value = (Boolean) objValue;
Settings.System.putInt(getActivity().getContentResolver(), Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.USE_PHOTOS_SPOOF, value ? 1 : 0); Settings.System.USE_PHOTOS_SPOOF, value ? 1 : 0);
SystemProperties.set(SYS_SPOOF, value ? "1" : "0"); SystemProperties.set(SYS_PHOTOS_SPOOF, value ? "1" : "0");
Toast.makeText(getActivity(), Toast.makeText(getActivity(),
(R.string.photos_spoof_toast), (R.string.photos_spoof_toast),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
return true; return true;
} else if (preference == mStreamSpoof) {
boolean value = (Boolean) objValue;
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.USE_STREAM_SPOOF, value ? 1 : 0);
SystemProperties.set(SYS_STREAM_SPOOF, value ? "1" : "0");
Toast.makeText(getActivity(),
(R.string.stream_spoof_toast),
Toast.LENGTH_LONG).show();
return true;
} }
return false; return false;
} }