Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
feat: force-vp9-codec integrations (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJeterLP authored Jul 12, 2022
1 parent 636fae6 commit 8a0029c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package app.revanced.integrations.patches;

import android.os.Build;

import app.revanced.integrations.settings.SettingsEnum;

public class ForceCodecPatch {

public static String getManufacturer() {
return SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? "samsung" : Build.MANUFACTURER;
}

public static String getModel() {
return SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? "SM-G920F" : Build.MODEL;
}

public static boolean shouldForceVP9() {
return SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean();
}


}
17 changes: 17 additions & 0 deletions app/src/main/java/app/revanced/integrations/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,22 @@ public static void setOldLayout(SharedPreferences sharedPreferences, String conf
}
LogHelper.debug("Settings", "setOldLayout: false");
}
public static boolean autoCaptions(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
Log.e("XGlobals", "Context is null, returning " + original + "!");
return original;
}
Boolean captions = Boolean.valueOf(original);
if (prefAutoCaptions.booleanValue()) {
captions = true;
}
if (debug.booleanValue()) {
Log.d("XGlobals", "autoCaptions: " + captions);
}
return captions.booleanValue();
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public enum SettingsEnum {

//Codec Override
CODEC_OVERRIDE_BOOLEAN("revanced_override_codec_enabled", true),
MANUFACTURER_OVERRIDE_STRING("revanced_override_codec_manufacturer", null),
MODEL_OVERRIDE_STRING("revanced_override_codec_model", null),

//Video Settings
OLD_STYLE_QUALITY_SETTINGS_BOOLEAN("revanced_use_old_style_quality_settings", true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.preference.EditTextPreference;
Expand All @@ -23,8 +22,8 @@
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.videoplayer.autorepeat.AutoRepeat;
import app.revanced.integrations.utils.ScreenSizeHelper;
import app.revanced.integrations.videoplayer.autorepeat.AutoRepeat;
import app.revanced.integrations.videoplayer.videourl.Copy;
import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp;

Expand All @@ -40,9 +39,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
private PreferenceScreen codecPreferenceScreen;
private Preference codecVP9;
private PreferenceScreen layoutSettingsPreferenceScreen;
private EditTextPreference manufacturerOverride;
private PreferenceScreen miscsPreferenceScreen;
private EditTextPreference modelOverride;
private SwitchPreference tabletMiniplayer;
private PreferenceScreen videoAdSettingsPreferenceScreen;
private PreferenceScreen videoSettingsPreferenceScreen;
Expand All @@ -61,26 +58,6 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
SharedPreferences.OnSharedPreferenceChangeListener listener = (sharedPreferences, str) -> {
if (str.equals(SettingsEnum.DEBUG_BOOLEAN.getPath())) {
SettingsEnum.DEBUG_BOOLEAN.setValue(((SwitchPreference) findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getPath())) {
if (((SwitchPreference) codecPreferenceScreen.findPreference(str)).isChecked()) {
SettingsEnum.MANUFACTURER_OVERRIDE_STRING.saveValue("samsung");
SettingsEnum.MODEL_OVERRIDE_STRING.saveValue("SM-G920F");
} else {
SettingsEnum.MANUFACTURER_OVERRIDE_STRING.saveValue(null);
SettingsEnum.MODEL_OVERRIDE_STRING.saveValue(null);
}
} else if (str.equals(SettingsEnum.MANUFACTURER_OVERRIDE_STRING.getPath())) {
EditTextPreference editTextPreference = (EditTextPreference) codecPreferenceScreen.findPreference(str);
if (editTextPreference != null) {
editTextPreference.setSummary(editTextPreference.getText());
SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue(editTextPreference.getText());
}
} else if (str.equals(SettingsEnum.MODEL_OVERRIDE_STRING.getPath())) {
EditTextPreference editTextPreference2 = (EditTextPreference) codecPreferenceScreen.findPreference(str);
if (editTextPreference2 != null) {
editTextPreference2.setSummary(editTextPreference2.getText());
SettingsEnum.MODEL_OVERRIDE_STRING.setValue(editTextPreference2.getText());
}
} else if (str.equals(SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.getPath())) {
SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) adsSettingsPreferenceScreen.findPreference(str)).isChecked());
if (ReVancedUtils.getContext() != null && settingsInitialized) {
Expand Down Expand Up @@ -210,16 +187,10 @@ public void onCreate(Bundle bundle) {
this.miscsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("misc_screen");
this.xSwipeControlPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("xfenster_screen");
this.vp9Override = (SwitchPreference) this.codecPreferenceScreen.findPreference("revanced_vp9_enabled");
this.manufacturerOverride = (EditTextPreference) this.codecPreferenceScreen.findPreference("override_manufacturer");
this.modelOverride = (EditTextPreference) this.codecPreferenceScreen.findPreference("override_model");
this.codecDefault = this.codecPreferenceScreen.findPreference("pref_default_override");
this.codecVP9 = this.codecPreferenceScreen.findPreference("pref_vp9_override");
this.tabletMiniplayer = (SwitchPreference) this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer");
AutoRepeatLinks();
EditTextPreference editTextPreference = this.manufacturerOverride;
editTextPreference.setSummary(editTextPreference.getText());
EditTextPreference editTextPreference2 = this.modelOverride;
editTextPreference2.setSummary(editTextPreference2.getText());
final ListPreference listPreference = (ListPreference) this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_quality_wifi");
final ListPreference listPreference2 = (ListPreference) this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_quality_mobile");
setListPreferenceData(listPreference, true);
Expand All @@ -244,12 +215,12 @@ public void onCreate(Bundle bundle) {
Preference findPreference = findPreference("pref_about_field");

this.codecDefault.setOnPreferenceClickListener(preference -> {
ReVancedSettingsFragment.this.changeCodec();
SettingsEnum.CODEC_OVERRIDE_BOOLEAN.saveValue(false);
return false;
});

this.codecVP9.setOnPreferenceClickListener(preference -> {
ReVancedSettingsFragment.this.changeCodec();
SettingsEnum.CODEC_OVERRIDE_BOOLEAN.saveValue(true);
return false;
});

Expand Down Expand Up @@ -318,29 +289,6 @@ private String getPackageName() {
return PACKAGE_NAME;
}

private void changeCodec() {
String manufacturer = null;
String model = null;

if (SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean()) {
manufacturer = "samsung";
model = "SM-G920F";
} else {
manufacturer = Build.MANUFACTURER;
model = Build.MODEL;
}

SettingsEnum.MANUFACTURER_OVERRIDE_STRING.saveValue(manufacturer);
SettingsEnum.MODEL_OVERRIDE_STRING.saveValue(model);

manufacturerOverride.setText(manufacturer);
modelOverride.setText(model);
EditTextPreference editTextPreference = this.manufacturerOverride;
editTextPreference.setSummary(editTextPreference.getText());
EditTextPreference editTextPreference2 = this.modelOverride;
editTextPreference2.setSummary(editTextPreference2.getText());
}

private void AutoRepeatLinks() {
boolean z = this.sharedPreferences.getBoolean("pref_auto_repeat_button", false);
SwitchPreference switchPreference = (SwitchPreference) this.miscsPreferenceScreen.findPreference("pref_auto_repeat");
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/xml/revanced_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
<PreferenceScreen android:title="@string/revanced_codec_override_title" android:key="revanced_override_codec">
<SwitchPreference android:title="@string/revanced_vp9_title" android:key="revanced_override_codec_enabled" android:defaultValue="true" android:summaryOn="@string/revanced_vp9_summary_on" android:summaryOff="@string/revanced_vp9_summary_off" />
<Preference android:persistent="false" android:title="@string/revanced_default_codec_title" android:selectable="true" android:key="revanced_override_codec_default" android:summary="@string/revanced_default_codec_summary" />
<EditTextPreference android:singleLine="true" android:title="@string/revanced_current_override_manufacturer" android:key="revanced_override_codec_manufacturer" />
<EditTextPreference android:singleLine="true" android:title="@string/revanced_current_override_model" android:key="revanced_override_codec_model" />
</PreferenceScreen>
<PreferenceScreen android:title="@string/revanced_video_settings_title" android:key="video_settings">
<SwitchPreference android:title="@string/revanced_old_style_quality_settings_title" android:key="revanced_use_old_style_quality_settings" android:defaultValue="true" android:summaryOn="@string/revanced_old_style_quality_settings_summary_on" android:summaryOff="@string/revanced_old_style_quality_settings_summary_off" />
Expand Down

0 comments on commit 8a0029c

Please sign in to comment.