mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-11-19 02:19:23 +01:00
feat: settings
patch
This commit is contained in:
parent
02e37c8e9f
commit
3e206967b7
@ -7,7 +7,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "app.revanced.integrations"
|
||||
minSdkVersion 23
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 32
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
@ -15,7 +15,7 @@ import app.revanced.integrations.utils.ReVancedUtils;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
|
||||
public class VideoQualityPatch {
|
||||
public static final int[] videoResolutions = {0, 144, 240, 360, 480, 720, 1080, 1440, 2160, 4320};
|
||||
|
||||
public static int selectedQuality1 = -2;
|
||||
private static Boolean newVideo = false;
|
||||
private static Boolean userChangedQuality = false;
|
||||
@ -24,7 +24,7 @@ public class VideoQualityPatch {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
if (isConnectedWifi(context)) {
|
||||
try {
|
||||
SharedPrefHelper.saveInt(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", defaultQuality);
|
||||
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", defaultQuality + "");
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(VideoQualityPatch.class, "Failed to change default WI-FI quality:" + ex);
|
||||
Toast.makeText(context, "Failed to change default WI-FI quality:", Toast.LENGTH_SHORT).show();
|
||||
@ -33,7 +33,7 @@ public class VideoQualityPatch {
|
||||
Toast.makeText(context, "Changing default Wi-Fi quality to: " + defaultQuality, Toast.LENGTH_SHORT).show();
|
||||
} else if (isConnectedMobile(context)) {
|
||||
try {
|
||||
SharedPrefHelper.saveInt(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", defaultQuality);
|
||||
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", defaultQuality + "");
|
||||
} catch (Exception ex) {
|
||||
LogHelper.debug(VideoQualityPatch.class, "Failed to change default mobile data quality" + ex);
|
||||
Toast.makeText(context, "Failed to change default mobile data quality", Toast.LENGTH_SHORT).show();
|
||||
|
@ -13,7 +13,7 @@ import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
public enum SettingsEnum {
|
||||
|
||||
//Codec Override
|
||||
CODEC_OVERRIDE("revanced_override_codec_enabled", true, ReturnType.BOOLEAN),
|
||||
CODEC_OVERRIDE("revanced_override_codec_enabled", false, ReturnType.BOOLEAN),
|
||||
|
||||
//Video Settings
|
||||
OLD_STYLE_QUALITY_SETTINGS("revanced_use_old_style_quality_settings", true, ReturnType.BOOLEAN),
|
||||
@ -24,37 +24,37 @@ public enum SettingsEnum {
|
||||
ENABLE_WHITELIST("revanced_whitelist_ads_enabled", false, ReturnType.BOOLEAN),
|
||||
|
||||
//Ad settings
|
||||
HOME_ADS_SHOWN("revanced_home_ads_enabled", false, ReturnType.BOOLEAN),
|
||||
VIDEO_ADS_SHOWN("revanced_video_ads_enabled", false, ReturnType.BOOLEAN),
|
||||
ADREMOVER_AD_REMOVAL("revanced_adremover_ad_removal", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_MERCHANDISE_REMOVAL("revanced_adremover_merchandise", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_COMMUNITY_POSTS_REMOVAL("revanced_adremover_community_posts_removal", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_COMPACT_BANNER_REMOVAL("revanced_adremover_compact_banner_removal", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_COMMENTS_REMOVAL("revanced_adremover_comments_removal", false, ReturnType.BOOLEAN),
|
||||
ADREMOVER_MOVIE_REMOVAL("revanced_adremover_movie", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_FEED_SURVEY_REMOVAL("revanced_adremover_feed_survey", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_SHORTS_SHELF("revanced_adremover_shorts_shelf", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_COMMUNITY_GUIDELINES("revanced_adremover_community_guidelines", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_EMERGENCY_BOX_REMOVAL("revanced_adremover_emergency_box_removal", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_INFO_PANEL_REMOVAL("revanced_adremover_info_panel", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_MEDICAL_PANEL_REMOVAL("revanced_adremover_medical_panel", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_PAID_CONTECT_REMOVAL("revanced_adremover_paid_content", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL("revanced_adremover_suggested", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_HIDE_SUGGESTIONS("revanced_adremover_hide_suggestions", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_HIDE_LATEST_POSTS("revanced_adremover_hide_latest_posts", true, ReturnType.BOOLEAN),
|
||||
ADREMOVER_HIDE_CHANNEL_GUIDELINES("revanced_adremover_hide_channel_guidelines", true, ReturnType.BOOLEAN),
|
||||
HOME_ADS_SHOWN("revanced_home_ads_enabled", false, ReturnType.BOOLEAN, true),
|
||||
VIDEO_ADS_SHOWN("revanced_video_ads_enabled", false, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_AD_REMOVAL("revanced_adremover_ad_removal", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_MERCHANDISE_REMOVAL("revanced_adremover_merchandise", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_COMMUNITY_POSTS_REMOVAL("revanced_adremover_community_posts_removal", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_COMPACT_BANNER_REMOVAL("revanced_adremover_compact_banner_removal", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_COMMENTS_REMOVAL("revanced_adremover_comments_removal", false, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_MOVIE_REMOVAL("revanced_adremover_movie", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_FEED_SURVEY_REMOVAL("revanced_adremover_feed_survey", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_SHORTS_SHELF("revanced_adremover_shorts_shelf", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_COMMUNITY_GUIDELINES("revanced_adremover_community_guidelines", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_EMERGENCY_BOX_REMOVAL("revanced_adremover_emergency_box_removal", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_INFO_PANEL_REMOVAL("revanced_adremover_info_panel", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_MEDICAL_PANEL_REMOVAL("revanced_adremover_medical_panel", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_PAID_CONTECT_REMOVAL("revanced_adremover_paid_content", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL("revanced_adremover_suggested", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_HIDE_SUGGESTIONS("revanced_adremover_hide_suggestions", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_HIDE_LATEST_POSTS("revanced_adremover_hide_latest_posts", true, ReturnType.BOOLEAN, true),
|
||||
ADREMOVER_HIDE_CHANNEL_GUIDELINES("revanced_adremover_hide_channel_guidelines", true, ReturnType.BOOLEAN, true),
|
||||
|
||||
//Layout settings
|
||||
REEL_BUTTON_SHOWN("revanced_reel_button_enabled", false, ReturnType.BOOLEAN),
|
||||
REEL_BUTTON_SHOWN("revanced_reel_button_enabled", false, ReturnType.BOOLEAN, true),
|
||||
INFO_CARDS_SHOWN("revanced_info_cards_enabled", false, ReturnType.BOOLEAN),
|
||||
BRANDING_SHOWN("revanced_branding_watermark_enabled", false, ReturnType.BOOLEAN),
|
||||
CAST_BUTTON_SHOWN("revanced_cast_button_enabled", false, ReturnType.BOOLEAN),
|
||||
AUTOPLAY_BUTTON_SHOWN("revanced_autoplay_button_enabled", false, ReturnType.BOOLEAN),
|
||||
CAST_BUTTON_SHOWN("revanced_cast_button_enabled", false, ReturnType.BOOLEAN, true),
|
||||
AUTOPLAY_BUTTON_SHOWN("revanced_autoplay_button_enabled", false, ReturnType.BOOLEAN, true),
|
||||
//ToDo: Not used atm, Patch missing
|
||||
USE_TABLET_MINIPLAYER("revanced_tablet_miniplayer", false, ReturnType.BOOLEAN),
|
||||
CREATE_BUTTON_SHOWN("revanced_create_button_enabled", false, ReturnType.BOOLEAN),
|
||||
USE_NEW_ACTIONBAR("revanced_new_actionbar", true, ReturnType.BOOLEAN),
|
||||
SHORTS_BUTTON_SHOWN("revanced_shorts_button_enabled", false, ReturnType.BOOLEAN),
|
||||
CREATE_BUTTON_SHOWN("revanced_create_button_enabled", false, ReturnType.BOOLEAN, true),
|
||||
USE_NEW_ACTIONBAR("revanced_new_actionbar", false, ReturnType.BOOLEAN, true),
|
||||
SHORTS_BUTTON_SHOWN("revanced_shorts_button_enabled", false, ReturnType.BOOLEAN, true),
|
||||
FULLSCREEN_PANELS_SHOWN("revanced_fullscreen_panels_enabled", false, ReturnType.BOOLEAN), //ToDo: Add to prefs
|
||||
|
||||
//Misc. Settings
|
||||
@ -81,7 +81,7 @@ public enum SettingsEnum {
|
||||
MAX_PLAYBACK_BUFFER_AFTER_REBUFFER("revanced_pref_buffer_for_playback_after_rebuffer_ms", 5000, ReturnType.INTEGER),
|
||||
|
||||
//ReVanced General Settings
|
||||
DEBUG("revanced_debug_enabled", false, ReturnType.BOOLEAN),
|
||||
DEBUG("revanced_debug_enabled", false, ReturnType.BOOLEAN, true),
|
||||
USE_DARK_THEME("app_theme_dark", false, ReturnType.BOOLEAN),
|
||||
|
||||
//RYD Settings
|
||||
@ -92,7 +92,7 @@ public enum SettingsEnum {
|
||||
SB_ENABLED("sb-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
|
||||
SB_SHOW_TOAST_WHEN_SKIP("show-toast", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
|
||||
SB_COUNT_SKIPS("count-skips", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
|
||||
SB_UUID("uuid", null, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.STRING),
|
||||
SB_UUID("uuid", "", SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.STRING),
|
||||
SB_ADJUST_NEW_SEGMENT_STEP("new-segment-step-accuracy", 150, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.INTEGER),
|
||||
SB_MIN_DURATION("sb-min-duration", 0F, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.FLOAT),
|
||||
SB_SEEN_GUIDELINES("sb-seen-gl", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
|
||||
@ -110,6 +110,7 @@ public enum SettingsEnum {
|
||||
private final Object defaultValue;
|
||||
private final SharedPrefHelper.SharedPrefNames sharedPref;
|
||||
private final ReturnType returnType;
|
||||
private final boolean rebootApp;
|
||||
|
||||
private Object value = null;
|
||||
|
||||
@ -118,6 +119,7 @@ public enum SettingsEnum {
|
||||
this.defaultValue = defaultValue;
|
||||
this.sharedPref = SharedPrefHelper.SharedPrefNames.YOUTUBE;
|
||||
this.returnType = returnType;
|
||||
this.rebootApp = false;
|
||||
}
|
||||
|
||||
SettingsEnum(String path, Object defaultValue, SharedPrefHelper.SharedPrefNames prefName, ReturnType returnType) {
|
||||
@ -125,6 +127,15 @@ public enum SettingsEnum {
|
||||
this.defaultValue = defaultValue;
|
||||
this.sharedPref = prefName;
|
||||
this.returnType = returnType;
|
||||
this.rebootApp = false;
|
||||
}
|
||||
|
||||
SettingsEnum(String path, Object defaultValue, ReturnType returnType, Boolean rebootApp) {
|
||||
this.path = path;
|
||||
this.defaultValue = defaultValue;
|
||||
this.sharedPref = SharedPrefHelper.SharedPrefNames.YOUTUBE;
|
||||
this.returnType = returnType;
|
||||
this.rebootApp = rebootApp;
|
||||
}
|
||||
|
||||
static {
|
||||
@ -136,36 +147,40 @@ public enum SettingsEnum {
|
||||
if (context == null) {
|
||||
Log.e("revanced: SettingsEnum", "Context returned null! Setings NOT initialized");
|
||||
} else {
|
||||
for (SettingsEnum setting : values()) {
|
||||
Object value = setting.getDefaultValue();
|
||||
try {
|
||||
for (SettingsEnum setting : values()) {
|
||||
Object value = setting.getDefaultValue();
|
||||
|
||||
//LogHelper is not initialized here
|
||||
Log.d("revanced: SettingsEnum", "Loading Setting: " + setting.name());
|
||||
//LogHelper is not initialized here
|
||||
Log.d("revanced: SettingsEnum", "Loading Setting: " + setting.name());
|
||||
|
||||
switch (setting.getReturnType()) {
|
||||
case FLOAT:
|
||||
value = SharedPrefHelper.getFloat(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (float) setting.getDefaultValue());
|
||||
break;
|
||||
case LONG:
|
||||
value = SharedPrefHelper.getLong(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (long) setting.getDefaultValue());
|
||||
break;
|
||||
case BOOLEAN:
|
||||
value = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (boolean) setting.getDefaultValue());
|
||||
break;
|
||||
case INTEGER:
|
||||
value = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (int) setting.getDefaultValue());
|
||||
break;
|
||||
case STRING:
|
||||
value = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (String) setting.getDefaultValue());
|
||||
break;
|
||||
default:
|
||||
LogHelper.printException(SettingsEnum.class, "Setting does not have a valid Type. Name is: " + setting.name());
|
||||
break;
|
||||
switch (setting.getReturnType()) {
|
||||
case FLOAT:
|
||||
value = SharedPrefHelper.getFloat(context, setting.sharedPref, setting.getPath(), (float) setting.getDefaultValue());
|
||||
break;
|
||||
case LONG:
|
||||
value = SharedPrefHelper.getLong(context, setting.sharedPref, setting.getPath(), (long) setting.getDefaultValue());
|
||||
break;
|
||||
case BOOLEAN:
|
||||
value = SharedPrefHelper.getBoolean(context, setting.sharedPref, setting.getPath(), (boolean) setting.getDefaultValue());
|
||||
break;
|
||||
case INTEGER:
|
||||
value = SharedPrefHelper.getInt(context, setting.sharedPref, setting.getPath(), (int) setting.getDefaultValue());
|
||||
break;
|
||||
case STRING:
|
||||
value = SharedPrefHelper.getString(context, setting.sharedPref, setting.getPath(), (String) setting.getDefaultValue());
|
||||
break;
|
||||
default:
|
||||
LogHelper.printException(SettingsEnum.class, "Setting does not have a valid Type. Name is: " + setting.name());
|
||||
break;
|
||||
}
|
||||
setting.setValue(value);
|
||||
|
||||
//LogHelper is not initialized here
|
||||
Log.d("revanced: SettingsEnum", "Loaded Setting: " + setting.name() + " Value: " + value);
|
||||
}
|
||||
setting.setValue(value);
|
||||
|
||||
//LogHelper is not initialized here
|
||||
Log.d("revanced: SettingsEnum", "Loaded Setting: " + setting.name() + " Value: " + value);
|
||||
} catch (Throwable th) {
|
||||
LogHelper.printException(SettingsEnum.class, "Error during load()!", th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,25 +202,10 @@ public enum SettingsEnum {
|
||||
public void saveValue(Object newValue) {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
if (context != null) {
|
||||
switch (getReturnType()) {
|
||||
case BOOLEAN:
|
||||
SharedPrefHelper.saveBoolean(context, sharedPref, getPath(), (Boolean) newValue);
|
||||
break;
|
||||
case INTEGER:
|
||||
SharedPrefHelper.saveInt(context, sharedPref, getPath(), (int) newValue);
|
||||
break;
|
||||
case STRING:
|
||||
SharedPrefHelper.saveString(context, sharedPref, getPath(), (String) newValue);
|
||||
break;
|
||||
case LONG:
|
||||
SharedPrefHelper.saveLong(context, sharedPref, getPath(), (Long) newValue);
|
||||
break;
|
||||
case FLOAT:
|
||||
SharedPrefHelper.saveFloat(context, sharedPref, getPath(), (Float) newValue);
|
||||
break;
|
||||
default:
|
||||
LogHelper.printException(SettingsEnum.class, "Setting does not have with a valid Type. Name is: " + name());
|
||||
break;
|
||||
if (returnType == ReturnType.BOOLEAN) {
|
||||
SharedPrefHelper.saveBoolean(context, sharedPref, path, (Boolean) newValue);
|
||||
} else {
|
||||
SharedPrefHelper.saveString(context, sharedPref, path, newValue + "");
|
||||
}
|
||||
value = newValue;
|
||||
} else {
|
||||
@ -245,4 +245,8 @@ public enum SettingsEnum {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
public boolean shouldRebootOnChange() {
|
||||
return rebootApp;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,112 +1,91 @@
|
||||
package app.revanced.integrations.settingsmenu;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.libraries.social.licenses.LicenseActivity;
|
||||
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
import app.revanced.integrations.utils.ThemeHelper;
|
||||
|
||||
/* loaded from: classes6.dex */
|
||||
public class ReVancedSettingActivity extends Activity {
|
||||
private static Context context;
|
||||
private boolean currentTheme;
|
||||
public class ReVancedSettingActivity {
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
this.currentTheme = ThemeHelper.isDarkTheme();
|
||||
if (currentTheme) {
|
||||
LogHelper.debug(ReVancedSettingActivity.class, "set Theme.YouTube.Settings.Dark");
|
||||
setTheme(getIdentifier("Theme.YouTube.Settings.Dark", "style"));
|
||||
} else {
|
||||
LogHelper.debug(ReVancedSettingActivity.class, "set Theme.YouTube.Settings");
|
||||
setTheme(getIdentifier("Theme.YouTube.Settings", "style"));
|
||||
}
|
||||
super.onCreate(bundle);
|
||||
setContentView(getIdentifier("xsettings_with_toolbar", "layout"));
|
||||
initImageButton(this.currentTheme);
|
||||
String dataString = getIntent().getDataString();
|
||||
if (dataString.equalsIgnoreCase("sponsorblock_settings")) {
|
||||
trySetTitle(getIdentifier("sb_settings", "string"));
|
||||
getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new SponsorBlockSettingsFragment()).commit();
|
||||
} else if (dataString.equalsIgnoreCase("ryd_settings")) {
|
||||
trySetTitle(getIdentifier("revanced_ryd_settings_title", "string"));
|
||||
getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new ReturnYouTubeDislikeSettingsFragment()).commit();
|
||||
} else {
|
||||
trySetTitle(getIdentifier("revanced_settings", "string"));
|
||||
getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new ReVancedSettingsFragment()).commit();
|
||||
}
|
||||
context = getApplicationContext();
|
||||
public static void setTheme(LicenseActivity base) {
|
||||
final var whiteTheme = "Theme.YouTube.Settings";
|
||||
final var darkTheme = "Theme.YouTube.Settings.Dark";
|
||||
|
||||
final var theme = ThemeHelper.isDarkTheme() ? darkTheme : whiteTheme;
|
||||
|
||||
LogHelper.debug(ReVancedSettingActivity.class, "Using theme: " + theme);
|
||||
base.setTheme(getIdentifier(theme, "style"));
|
||||
}
|
||||
|
||||
public static ImageButton getImageButton(ViewGroup viewGroup) {
|
||||
if (viewGroup == null) {
|
||||
return null;
|
||||
}
|
||||
int childCount = viewGroup.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = viewGroup.getChildAt(i);
|
||||
if (childAt instanceof ImageButton) {
|
||||
return (ImageButton) childAt;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void initializeSettings(LicenseActivity base) {
|
||||
base.setContentView(getIdentifier("xsettings_with_toolbar", "layout"));
|
||||
|
||||
public static TextView getTextView(ViewGroup viewGroup) {
|
||||
if (viewGroup == null) {
|
||||
return null;
|
||||
}
|
||||
int childCount = viewGroup.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = viewGroup.getChildAt(i);
|
||||
if (childAt instanceof TextView) {
|
||||
return (TextView) childAt;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int getIdentifier(String str, String str2) {
|
||||
Context appContext = ReVancedUtils.getContext();
|
||||
return appContext.getResources().getIdentifier(str, str2, appContext.getPackageName());
|
||||
}
|
||||
|
||||
private void trySetTitle(int i) {
|
||||
try {
|
||||
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(i);
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar title", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void trySetTitle(String str) {
|
||||
try {
|
||||
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(str);
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar title", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initImageButton(boolean z) {
|
||||
try {
|
||||
ImageButton imageButton = getImageButton((ViewGroup) findViewById(getIdentifier("toolbar", "id")));
|
||||
imageButton.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.theme.ReVancedSettingActivity.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
ReVancedSettingActivity.this.onBackPressed();
|
||||
}
|
||||
});
|
||||
imageButton.setImageDrawable(getResources().getDrawable(getIdentifier(z ? "quantum_ic_arrow_back_white_24" : "quantum_ic_arrow_back_grey600_24", "drawable"), null));
|
||||
ImageButton imageButton = getImageButton(base.findViewById(getIdentifier("toolbar", "id")));
|
||||
imageButton.setOnClickListener(view -> base.onBackPressed());
|
||||
imageButton.setImageDrawable(base.getResources().getDrawable(getIdentifier(ThemeHelper.isDarkTheme() ? "quantum_ic_arrow_back_white_24" : "quantum_ic_arrow_back_grey600_24", "drawable"), null));
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar click handler", e);
|
||||
}
|
||||
|
||||
PreferenceFragment preferenceFragment;
|
||||
String preferenceIdentifier;
|
||||
|
||||
String dataString = base.getIntent().getDataString();
|
||||
if (dataString.equalsIgnoreCase("sponsorblock_settings")) {
|
||||
preferenceIdentifier = "sb_settings";
|
||||
preferenceFragment = new SponsorBlockSettingsFragment();
|
||||
} else if (dataString.equalsIgnoreCase("ryd_settings")) {
|
||||
preferenceIdentifier = "revanced_ryd_settings_title";
|
||||
preferenceFragment = new ReturnYouTubeDislikeSettingsFragment();
|
||||
} else {
|
||||
preferenceIdentifier = "revanced_settings";
|
||||
preferenceFragment = new ReVancedSettingsFragment();
|
||||
}
|
||||
|
||||
try {
|
||||
var resourceIdentifier = getIdentifier(preferenceIdentifier, "string");
|
||||
getTextView(base.findViewById(getIdentifier("toolbar", "id"))).setText(resourceIdentifier);
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar title", e);
|
||||
}
|
||||
|
||||
base.getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), preferenceFragment).commit();
|
||||
}
|
||||
|
||||
public static <T extends View> T getView(Class<T> typeClass, ViewGroup viewGroup) {
|
||||
if (viewGroup == null) {
|
||||
return null;
|
||||
}
|
||||
int childCount = viewGroup.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = viewGroup.getChildAt(i);
|
||||
if (childAt.getClass() == typeClass) {
|
||||
return (T) childAt;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ImageButton getImageButton(ViewGroup viewGroup) {
|
||||
return getView(ImageButton.class, viewGroup);
|
||||
}
|
||||
|
||||
public static TextView getTextView(ViewGroup viewGroup) {
|
||||
return getView(TextView.class, viewGroup);
|
||||
}
|
||||
|
||||
private static int getIdentifier(String name, String defType) {
|
||||
Context appContext = ReVancedUtils.getContext();
|
||||
assert appContext != null;
|
||||
return appContext.getResources().getIdentifier(name, defType, appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ import android.preference.SwitchPreference;
|
||||
|
||||
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
@ -30,7 +33,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
|
||||
public static Class homeActivityClass;
|
||||
|
||||
private PreferenceScreen[] screens;
|
||||
private List<PreferenceScreen> screens;
|
||||
|
||||
private boolean Registered = false;
|
||||
private boolean settingsInitialized = false;
|
||||
@ -79,10 +82,14 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
} else if (pref instanceof ListPreference) {
|
||||
ListPreference listPref = (ListPreference) pref;
|
||||
if (setting == SettingsEnum.PREFERRED_VIDEO_SPEED) {
|
||||
Float value = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
|
||||
listPref.setDefaultValue(value);
|
||||
listPref.setSummary(videoSpeedEntries[listPref.findIndexOfValue(String.valueOf(value))]);
|
||||
SettingsEnum.PREFERRED_VIDEO_SPEED.setValue(value);
|
||||
try {
|
||||
String value = sharedPreferences.getString(setting.getPath(), setting.getDefaultValue() + "");
|
||||
listPref.setDefaultValue(value);
|
||||
listPref.setSummary(videoSpeedEntries[listPref.findIndexOfValue(String.valueOf(value))]);
|
||||
SettingsEnum.PREFERRED_VIDEO_SPEED.saveValue(value);
|
||||
} catch (Throwable th) {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Error setting value of speed" + th);
|
||||
}
|
||||
} else {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "No valid setting found: " + setting.toString());
|
||||
}
|
||||
@ -97,7 +104,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Setting cannot be handled! " + pref.toString());
|
||||
}
|
||||
|
||||
if (ReVancedUtils.getContext() != null && settingsInitialized) {
|
||||
if (ReVancedUtils.getContext() != null && settingsInitialized && setting.shouldRebootOnChange()) {
|
||||
rebootDialog(getActivity());
|
||||
}
|
||||
}
|
||||
@ -116,16 +123,18 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
this.settingsInitialized = sharedPreferences.getBoolean("revanced_initialized", false);
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this.listener);
|
||||
this.Registered = true;
|
||||
this.screens[0] = (PreferenceScreen) getPreferenceScreen().findPreference("codec_override");
|
||||
this.screens[1] = (PreferenceScreen) getPreferenceScreen().findPreference("video_settings");
|
||||
this.screens[2] = (PreferenceScreen) getPreferenceScreen().findPreference("video_ad_settings");
|
||||
this.screens[3] = (PreferenceScreen) getPreferenceScreen().findPreference("ad_settings");
|
||||
this.screens[4] = (PreferenceScreen) getPreferenceScreen().findPreference("layout_settings");
|
||||
this.screens[5] = (PreferenceScreen) getPreferenceScreen().findPreference("buffer_screen");
|
||||
this.screens[6] = (PreferenceScreen) getPreferenceScreen().findPreference("misc_screen");
|
||||
this.screens[7] = (PreferenceScreen) getPreferenceScreen().findPreference("swipe_screen");
|
||||
this.screens = new ArrayList<>();
|
||||
this.screens.add((PreferenceScreen) getPreferenceScreen().findPreference("codec_override"));
|
||||
this.screens.add((PreferenceScreen) getPreferenceScreen().findPreference("video_settings"));
|
||||
this.screens.add((PreferenceScreen) getPreferenceScreen().findPreference("video_ad_settings"));
|
||||
this.screens.add((PreferenceScreen) getPreferenceScreen().findPreference("ad_settings"));
|
||||
this.screens.add((PreferenceScreen) getPreferenceScreen().findPreference("layout_settings"));
|
||||
this.screens.add((PreferenceScreen) getPreferenceScreen().findPreference("buffer_screen"));
|
||||
this.screens.add((PreferenceScreen) getPreferenceScreen().findPreference("misc_screen"));
|
||||
this.screens.add((PreferenceScreen) getPreferenceScreen().findPreference("swipe_screen"));
|
||||
|
||||
final ListPreference listPreference3 = (ListPreference) screens[1].findPreference("pref_preferred_video_speed");
|
||||
|
||||
final ListPreference listPreference3 = (ListPreference) screens.get(1).findPreference("revanced_pref_video_speed");
|
||||
setSpeedListPreferenceData(listPreference3);
|
||||
|
||||
listPreference3.setOnPreferenceClickListener(preference -> {
|
||||
@ -136,7 +145,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
sharedPreferences.edit().putBoolean("revanced_initialized", true);
|
||||
this.settingsInitialized = true;
|
||||
} catch (Throwable th) {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Unable to retrieve resourceId for xfile_prefs", th);
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Error during onCreate()", th);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
SwitchPreference preference = new SwitchPreference(context);
|
||||
preferenceScreen.addPreference(preference);
|
||||
preference.setKey(SettingsEnum.SB_NEW_SEGMENT_ENABLED.getPath());
|
||||
preference.setDefaultValue(SettingsEnum.SB_NEW_SEGMENT_ENABLED.getBoolean());
|
||||
preference.setDefaultValue(SettingsEnum.SB_NEW_SEGMENT_ENABLED.getDefaultValue());
|
||||
preference.setChecked(SettingsEnum.SB_NEW_SEGMENT_ENABLED.getBoolean());
|
||||
preference.setTitle(str("enable_segmadding"));
|
||||
preference.setSummary(str("enable_segmadding_sum"));
|
||||
@ -99,7 +99,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
preference.setTitle(str("enable_voting"));
|
||||
preference.setSummary(str("enable_voting_sum"));
|
||||
preference.setKey(SettingsEnum.SB_VOTING_ENABLED.getPath());
|
||||
preference.setDefaultValue(SettingsEnum.SB_VOTING_ENABLED.getBoolean());
|
||||
preference.setDefaultValue(SettingsEnum.SB_VOTING_ENABLED.getDefaultValue());
|
||||
preference.setChecked(SettingsEnum.SB_VOTING_ENABLED.getBoolean());
|
||||
preferencesToDisableWhenSBDisabled.add(preference);
|
||||
}
|
||||
@ -231,7 +231,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
preference.setTitle(str("general_skiptoast"));
|
||||
preference.setSummary(str("general_skiptoast_sum"));
|
||||
preference.setKey(SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.getPath());
|
||||
preference.setDefaultValue(SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.getBoolean());
|
||||
preference.setDefaultValue(SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.getDefaultValue());
|
||||
preference.setOnPreferenceClickListener(preference12 -> {
|
||||
Toast.makeText(preference12.getContext(), str("skipped_sponsor"), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
@ -245,7 +245,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
preference.setTitle(str("general_skipcount"));
|
||||
preference.setSummary(str("general_skipcount_sum"));
|
||||
preference.setKey(SettingsEnum.SB_COUNT_SKIPS.getPath());
|
||||
preference.setDefaultValue(SettingsEnum.SB_COUNT_SKIPS.getBoolean());
|
||||
preference.setDefaultValue(SettingsEnum.SB_COUNT_SKIPS.getDefaultValue());
|
||||
preferencesToDisableWhenSBDisabled.add(preference);
|
||||
screen.addPreference(preference);
|
||||
}
|
||||
@ -255,7 +255,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
preference.setTitle(str("general_time_without_sb"));
|
||||
preference.setSummary(str("general_time_without_sb_sum"));
|
||||
preference.setKey(SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getPath());
|
||||
preference.setDefaultValue(SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getBoolean());
|
||||
preference.setDefaultValue(SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getDefaultValue());
|
||||
preferencesToDisableWhenSBDisabled.add(preference);
|
||||
screen.addPreference(preference);
|
||||
}
|
||||
@ -274,7 +274,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
preference.setTitle(str("general_browser_button"));
|
||||
preference.setSummary(str("general_browser_button_sum"));
|
||||
preference.setKey(SettingsEnum.SB_SHOW_BROWSER_BUTTON.getPath());
|
||||
preference.setDefaultValue(SettingsEnum.SB_SHOW_BROWSER_BUTTON.getBoolean());
|
||||
preference.setDefaultValue(SettingsEnum.SB_SHOW_BROWSER_BUTTON.getDefaultValue());
|
||||
preferencesToDisableWhenSBDisabled.add(preference);
|
||||
screen.addPreference(preference);
|
||||
}
|
||||
@ -285,7 +285,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
preference.setTitle(str("general_adjusting"));
|
||||
preference.setSummary(str("general_adjusting_sum"));
|
||||
preference.setKey(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getPath());
|
||||
preference.setDefaultValue(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getInt());
|
||||
preference.setDefaultValue(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getDefaultValue() + "");
|
||||
screen.addPreference(preference);
|
||||
preferencesToDisableWhenSBDisabled.add(preference);
|
||||
}
|
||||
@ -296,7 +296,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
preference.setTitle(str("general_min_duration"));
|
||||
preference.setSummary(str("general_min_duration_sum"));
|
||||
preference.setKey(SettingsEnum.SB_MIN_DURATION.getPath());
|
||||
preference.setDefaultValue(SettingsEnum.SB_MIN_DURATION.getFloat());
|
||||
preference.setDefaultValue(SettingsEnum.SB_MIN_DURATION.getDefaultValue() + "");
|
||||
screen.addPreference(preference);
|
||||
preferencesToDisableWhenSBDisabled.add(preference);
|
||||
}
|
||||
@ -306,7 +306,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
|
||||
preference.setTitle(str("general_uuid"));
|
||||
preference.setSummary(str("general_uuid_sum"));
|
||||
preference.setKey(SettingsEnum.SB_UUID.getPath());
|
||||
preference.setDefaultValue(SettingsEnum.SB_UUID.getString());
|
||||
preference.setDefaultValue(SettingsEnum.SB_UUID.getDefaultValue() + "");
|
||||
screen.addPreference(preference);
|
||||
preferencesToDisableWhenSBDisabled.add(preference);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package app.revanced.integrations.sponsorblock;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -7,6 +8,7 @@ import androidx.annotation.NonNull;
|
||||
import java.util.HashMap;
|
||||
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
|
||||
public class StringRef {
|
||||
private static Resources resources;
|
||||
@ -88,6 +90,9 @@ public class StringRef {
|
||||
@NonNull
|
||||
public String toString() {
|
||||
if (!resolved) {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
resources = context.getResources();
|
||||
packageName = context.getPackageName();
|
||||
resolved = true;
|
||||
if (resources != null) {
|
||||
final int identifier = resources.getIdentifier(value, "string", packageName);
|
||||
@ -95,6 +100,8 @@ public class StringRef {
|
||||
LogHelper.printException(StringRef.class, "Resource not found: " + value);
|
||||
else
|
||||
value = resources.getString(identifier);
|
||||
} else {
|
||||
LogHelper.printException(StringRef.class, "Could not resolve resources!");
|
||||
}
|
||||
}
|
||||
return value;
|
||||
|
@ -12,7 +12,6 @@ import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
import app.revanced.integrations.utils.SharedPrefHelper;
|
||||
|
||||
/* loaded from: classes6.dex */
|
||||
public class SwipeHelper {
|
||||
static FrameLayout _frameLayout;
|
||||
public static boolean isTabletMode;
|
||||
|
@ -151,7 +151,12 @@ public class SponsorBlockView {
|
||||
|
||||
private static void checkLayout() {
|
||||
if (inlineSponsorOverlay.getHeight() == 0) {
|
||||
View layout = SwipeHelper.nextGenWatchLayout.findViewById(getIdentifier("player_overlays", "id"));
|
||||
ViewGroup watchLayout = SwipeHelper.nextGenWatchLayout;
|
||||
if (watchLayout == null) {
|
||||
LogHelper.debug(SponsorBlockView.class, "nextGenWatchLayout is null!");
|
||||
return;
|
||||
}
|
||||
View layout = watchLayout.findViewById(getIdentifier("player_overlays", "id"));
|
||||
|
||||
if (layout == null) {
|
||||
LogHelper.debug(SponsorBlockView.class, "player_overlays was not found for SB");
|
||||
|
@ -14,21 +14,6 @@ public class SharedPrefHelper {
|
||||
sharedPreferences.edit().putBoolean(key, value).apply();
|
||||
}
|
||||
|
||||
public static void saveInt(Context context, SharedPrefNames prefName, String key, Integer value) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
sharedPreferences.edit().putInt(key, value).apply();
|
||||
}
|
||||
|
||||
public static void saveLong(Context context, SharedPrefNames prefName, String key, Long value) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
sharedPreferences.edit().putLong(key, value).apply();
|
||||
}
|
||||
|
||||
public static void saveFloat(Context context, SharedPrefNames prefName, String key, Float value) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
sharedPreferences.edit().putFloat(key, value).apply();
|
||||
}
|
||||
|
||||
public static String getString(Context context, SharedPrefNames prefName, String key, String _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
return (sharedPreferences.getString(key, _default));
|
||||
@ -41,17 +26,17 @@ public class SharedPrefHelper {
|
||||
|
||||
public static Long getLong(Context context, SharedPrefNames prefName, String key, Long _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
return sharedPreferences.getLong(key, _default);
|
||||
return Long.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
}
|
||||
|
||||
public static Float getFloat(Context context, SharedPrefNames prefName, String key, Float _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
return sharedPreferences.getFloat(key, _default);
|
||||
return Float.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
}
|
||||
|
||||
public static Integer getInt(Context context, SharedPrefNames prefName, String key, Integer _default) {
|
||||
SharedPreferences sharedPreferences = getPreferences(context, prefName);
|
||||
return sharedPreferences.getInt(key, _default);
|
||||
return Integer.valueOf(sharedPreferences.getString(key, _default + ""));
|
||||
}
|
||||
|
||||
public static SharedPreferences getPreferences(Context context, SharedPrefNames name) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package app.revanced.integrations.utils;
|
||||
|
||||
/* loaded from: classes6.dex */
|
||||
public class ThemeHelper {
|
||||
private static int themeValue;
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.google.android.libraries.social.licenses;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
// Dummy class
|
||||
public final class LicenseActivity extends Activity { }
|
||||
|
Loading…
Reference in New Issue
Block a user