diff --git a/app/build.gradle b/app/build.gradle index 652fed8aed..c1ef59da0d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,7 +33,7 @@ android { } dependencies { - implementation 'androidx.annotation:annotation:1.3.0' - implementation "androidx.constraintlayout:constraintlayout:2.1.4" + compileOnly 'androidx.annotation:annotation:1.3.0' + compileOnly 'androidx.constraintlayout:constraintlayout:2.1.4' } diff --git a/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java b/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java index d61065b7e3..5caf74c4cf 100644 --- a/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java +++ b/app/src/main/java/app/revanced/integrations/adremover/AdRemoverAPI.java @@ -49,12 +49,12 @@ public static void HideViewWithLayout1dp(View view) { * @param view */ public static void hideCreateButton(View view) { - String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: shown" : "Create button: hidden"; + String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: Shown" : "Create button: Hidden"; LogHelper.debug("HideCreateButton", message); - if (!SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) { - view.setVisibility(View.GONE); - } else { + if (SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) { view.setVisibility(View.VISIBLE); + } else { + view.setVisibility(View.GONE); } } diff --git a/app/src/main/java/app/revanced/integrations/adremover/LithoAdRemoval.java b/app/src/main/java/app/revanced/integrations/adremover/LithoAdRemoval.java index c19ab8051d..e4cd5ac6c5 100644 --- a/app/src/main/java/app/revanced/integrations/adremover/LithoAdRemoval.java +++ b/app/src/main/java/app/revanced/integrations/adremover/LithoAdRemoval.java @@ -5,8 +5,6 @@ import androidx.annotation.RequiresApi; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -15,12 +13,12 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; -import app.revanced.integrations.settings.Settings; public class LithoAdRemoval { private static boolean getBoolean(String key, boolean _default) { - return SharedPrefHelper.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), SharedPrefHelper.SharedPrefNames.YOUTUBE, key, _default); + return SharedPrefHelper.getBoolean(Objects.requireNonNull(ReVancedUtils.getContext()), SharedPrefHelper.SharedPrefNames.YOUTUBE, key, _default); } private static boolean isExperimentalInfoPanelRemoval() { diff --git a/app/src/main/java/app/revanced/integrations/adremover/whitelist/Whitelist.java b/app/src/main/java/app/revanced/integrations/adremover/whitelist/Whitelist.java index 6b86d11ab2..786e6308b1 100644 --- a/app/src/main/java/app/revanced/integrations/adremover/whitelist/Whitelist.java +++ b/app/src/main/java/app/revanced/integrations/adremover/whitelist/Whitelist.java @@ -10,8 +10,6 @@ import android.widget.Toast; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -22,16 +20,16 @@ import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.settings.Settings; import app.revanced.integrations.sponsorblock.player.ChannelModel; import app.revanced.integrations.sponsorblock.player.VideoInformation; import app.revanced.integrations.utils.ObjectSerializer; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; public class Whitelist { private static final String TAG = "VI - Whitelisting"; - private static final Map> whitelistMap = parseWhitelist(YouTubeTikTokRoot_Application.getAppContext()); - private static final Map enabledMap = parseEnabledMap(YouTubeTikTokRoot_Application.getAppContext()); + private static final Map> whitelistMap = parseWhitelist(ReVancedUtils.getContext()); + private static final Map enabledMap = parseEnabledMap(ReVancedUtils.getContext()); private Whitelist() { } diff --git a/app/src/main/java/app/revanced/integrations/adremover/whitelist/requests/WhitelistRequester.java b/app/src/main/java/app/revanced/integrations/adremover/whitelist/requests/WhitelistRequester.java index 329f1f84d5..e3116f9ba7 100644 --- a/app/src/main/java/app/revanced/integrations/adremover/whitelist/requests/WhitelistRequester.java +++ b/app/src/main/java/app/revanced/integrations/adremover/whitelist/requests/WhitelistRequester.java @@ -6,6 +6,8 @@ import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; import android.view.View; import android.widget.ImageView; import android.widget.Toast; @@ -17,7 +19,6 @@ import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; -import app.revanced.integrations.settings.Settings; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.sponsorblock.player.ChannelModel; import app.revanced.integrations.adremover.whitelist.Whitelist; @@ -38,7 +39,7 @@ public static void addChannelToWhitelist(WhitelistType whitelistType, View view, connection.setDoOutput(true); connection.setConnectTimeout(2 * 1000); - String versionName = Settings.getVersionName(context); + String versionName = getVersionName(context); String jsonInputString = "{\"context\": {\"client\": { \"clientName\": \"Android\", \"clientVersion\": \"" + versionName + "\" } }, \"videoId\": \"" + currentVideoId + "\"}"; try (OutputStream os = connection.getOutputStream()) { byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8); @@ -88,4 +89,15 @@ private static HttpURLConnection getConnectionFromRoute(Route route, String... p private static JSONObject getJSONObject(HttpURLConnection connection) throws Exception { return Requester.getJSONObject(connection); } + + private static String getVersionName(Context context) { + try { + PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); + String version = pInfo.versionName; + return (version); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + return ("17.24.34"); + } } \ No newline at end of file diff --git a/app/src/main/java/app/revanced/integrations/patches/AutoRepeatPatch.java b/app/src/main/java/app/revanced/integrations/patches/AutoRepeatPatch.java new file mode 100644 index 0000000000..1c9e3de100 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/AutoRepeatPatch.java @@ -0,0 +1,12 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public class AutoRepeatPatch { + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1hLl71Mm3oAtgTjNvsYZi3CUutCPx2gjS/view?usp=sharing for where it needs to be used. + public static boolean shouldAutoRepeat() { + return SettingsEnum.PREFERRED_AUTO_REPEAT_BOOLEAN.getBoolean(); + } +} diff --git a/app/src/main/java/app/revanced/integrations/patches/BrandingWaterMarkPatch.java b/app/src/main/java/app/revanced/integrations/patches/BrandingWaterMarkPatch.java new file mode 100644 index 0000000000..b735861c16 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/BrandingWaterMarkPatch.java @@ -0,0 +1,12 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.adremover.AdRemoverAPI; +import app.revanced.integrations.settings.SettingsEnum; + +public class BrandingWaterMarkPatch { + + //Used by: app.revanced.patches.youtube.layout.watermark.patch.HideWatermarkPatch + public static boolean isBrandingWatermarkShown() { + return SettingsEnum.BRANDING_SHOWN_BOOLEAN.getBoolean(); + } +} diff --git a/app/src/main/java/app/revanced/integrations/patches/HDRMaxBrightnessPatch.java b/app/src/main/java/app/revanced/integrations/patches/HDRMaxBrightnessPatch.java new file mode 100644 index 0000000000..f96e7fbae8 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/HDRMaxBrightnessPatch.java @@ -0,0 +1,15 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.videoswipecontrols.helpers.BrightnessHelper; + +public class HDRMaxBrightnessPatch { + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1rIJzsaMQouH_2__EcVY5Dg6l7ji9vsyP/view?usp=sharing for where it needs to be used. + public static float getHDRBrightness(float original) { + if (!SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.getBoolean()) return original; + return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() ? BrightnessHelper.getBrightness() : -1.0f; + } + +} diff --git a/app/src/main/java/app/revanced/integrations/patches/MiniplayerOverridePatch.java b/app/src/main/java/app/revanced/integrations/patches/MiniplayerOverridePatch.java new file mode 100644 index 0000000000..50cfafde4b --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/MiniplayerOverridePatch.java @@ -0,0 +1,14 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public class MiniplayerOverridePatch { + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1G7jn2EdWgNls0Htgs-wPPjjObZL1emzK/view?usp=sharing + //And https://drive.google.com/file/d/1-QlgSiKzqQ5lHXQnvRUpijk0GH9T1Sn7/view?usp=sharing + // for where it needs to be used. + public static boolean getTabletMiniplayerOverride() { + return SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.getBoolean(); + } +} diff --git a/app/src/main/java/app/revanced/integrations/patches/NewActionbarPatch.java b/app/src/main/java/app/revanced/integrations/patches/NewActionbarPatch.java new file mode 100644 index 0000000000..9fc5546806 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/NewActionbarPatch.java @@ -0,0 +1,13 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public class NewActionbarPatch { + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1Jg2WK9wwSABCiIcqclzhedy3J3RCf3Hn/view?usp=sharing for where it needs to be used. + public static boolean getNewActionBar() { + return SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.getBoolean(); + } + +} diff --git a/app/src/main/java/app/revanced/integrations/patches/OverrideCodecPatch.java b/app/src/main/java/app/revanced/integrations/patches/OverrideCodecPatch.java new file mode 100644 index 0000000000..78e8963509 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/OverrideCodecPatch.java @@ -0,0 +1,13 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public class OverrideCodecPatch { + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/14d2R-5JF97gOZggoobVEVazPWbORbZVp/view?usp=sharing for where it needs to be used. + public static boolean isOverrideCodedUsed() { + return SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean(); + } + +} diff --git a/app/src/main/java/app/revanced/integrations/patches/VideoBufferPatch.java b/app/src/main/java/app/revanced/integrations/patches/VideoBufferPatch.java new file mode 100644 index 0000000000..430d822a6a --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/VideoBufferPatch.java @@ -0,0 +1,26 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.settings.SettingsEnum; + +public class VideoBufferPatch { + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1LSZZX4NgBIlN0dDCzyI7cECtgbXVg_1j/view?usp=sharing for where it needs to be used. + public static int getMaxBuffer(int original) { + return SettingsEnum.MAX_BUFFER_INTEGER.getInt(); + } + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1gIUqPIMq-XP-edT_9wQN1RbmVnk9tJN8/view?usp=sharing for where it needs to be used. + public static int getPlaybackBuffer(int original) { + return SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.getInt(); + } + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1ywL7SxvWrBIIbuZ1YoUIKdZM-U8H_w-p/view?usp=sharing for where it needs to be used. + public static int getReBuffer(int original) { + return SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.getInt(); + } + + +} diff --git a/app/src/main/java/app/revanced/integrations/patches/VideoQualityPatch.java b/app/src/main/java/app/revanced/integrations/patches/VideoQualityPatch.java new file mode 100644 index 0000000000..d931c46651 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/VideoQualityPatch.java @@ -0,0 +1,17 @@ +package app.revanced.integrations.patches; + +import app.revanced.integrations.videoplayer.videosettings.VideoQuality; + +public class VideoQualityPatch { + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1goodaU0JWrO9BAOUn6El-Id1SNuMGHR9/view?usp=sharing for where it needs to be used. + public static int setVideoQuality(Object[] qualities, int quality, Object qInterface) { + return VideoQuality.setVideoQuality(qualities, quality, qInterface); + } + + //See https://drive.google.com/file/d/1_cgCf603XKk4gEbbsmWGtndNt5UJ0np7/view?usp=sharing for usage + public static void userChangedQuality() { + VideoQuality.userChangedQuality(); + } +} diff --git a/app/src/main/java/app/revanced/integrations/patches/VideoSwipeControlsPatch.java b/app/src/main/java/app/revanced/integrations/patches/VideoSwipeControlsPatch.java new file mode 100644 index 0000000000..64e2a7f99d --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/VideoSwipeControlsPatch.java @@ -0,0 +1,51 @@ +package app.revanced.integrations.patches; + +import android.content.Context; +import android.view.MotionEvent; +import android.view.ViewConfiguration; +import android.view.ViewGroup; + +import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.sponsorblock.player.PlayerType; +import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.SwipeHelper; +import app.revanced.integrations.videoswipecontrols.SwipeControlAPI; + +public class VideoSwipeControlsPatch { + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1FTPRrp6NcIF5LC_ByST1a0wcNoGKcAYS/view?usp=sharing for where it needs to be used. + public static void InitializeFensterController(Context context, ViewGroup viewGroup, ViewConfiguration viewConfiguration) { + SwipeControlAPI.InitializeFensterController(context, viewGroup, viewConfiguration); + } + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1Q9TIDDKvc-nQuJWLmCh7jx3ohxPdFIrZ/view?usp=sharing + //And https://drive.google.com/file/d/1byP5SItks9MYB3fDVC39xH_6nBbaH9NY/view?usp=sharing + // for where it needs to be used. + public static boolean FensterTouchEvent(MotionEvent motionEvent) { + return SwipeControlAPI.FensterTouchEvent(motionEvent); + } + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1qKmaX4yzAjzYM6T5uUiRtbMxk2zJlwtd/view?usp=sharing for where it needs to be used. + public static boolean isSwipeControlBrightnessEnabled() { + return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean(); + } + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1TMQxs0ul2_p5_GomE-3J1QWO__M189Da/view?usp=sharing for where it needs to be used. + public static void PlayerTypeChanged(PlayerType playerType) { + SwipeControlAPI.PlayerTypeChanged(playerType); + } + + //ToDo: Write Patch for it. + //See https://drive.google.com/file/d/1EoVAyqWOMGUDCovuDb27yeQJBk_CyKsY/view?usp=sharing for where it needs to be used. + public static boolean isSwipeControlEnabled() { + if (ReVancedUtils.getPlayerType() != null && ReVancedUtils.getPlayerType() == PlayerType.WATCH_WHILE_FULLSCREEN && !SwipeHelper.IsControlsShown()) { + return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() || SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean(); + } + return false; + } + +} diff --git a/app/src/main/java/app/revanced/integrations/ryd/ReturnYouTubeDislikes.java b/app/src/main/java/app/revanced/integrations/ryd/ReturnYouTubeDislikes.java index e7a88c61a7..d9f804cdda 100644 --- a/app/src/main/java/app/revanced/integrations/ryd/ReturnYouTubeDislikes.java +++ b/app/src/main/java/app/revanced/integrations/ryd/ReturnYouTubeDislikes.java @@ -12,13 +12,12 @@ import android.view.View; import android.widget.TextView; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import java.util.Locale; import java.util.Objects; import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.ryd.requests.RYDRequester; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; public class ReturnYouTubeDislikes { @@ -34,7 +33,7 @@ public class ReturnYouTubeDislikes { private static CompactDecimalFormat compactNumberFormatter; static { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); isEnabled = SharedPrefHelper.getBoolean(Objects.requireNonNull(context), SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false); if (isEnabled) { registration = new Registration(context); @@ -54,10 +53,10 @@ public class ReturnYouTubeDislikes { public static void onEnabledChange(boolean enabled) { isEnabled = enabled; if (registration == null) { - registration = new Registration(YouTubeTikTokRoot_Application.getAppContext()); + registration = new Registration(ReVancedUtils.getContext()); } if (voting == null) { - voting = new Voting(YouTubeTikTokRoot_Application.getAppContext(), registration); + voting = new Voting(ReVancedUtils.getContext(), registration); } } @@ -176,7 +175,7 @@ public static void trySetDislikes(String dislikeCount) { } private static void handleOnClick(View view, boolean previousState) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); if (!isEnabled || SharedPrefHelper.getBoolean(Objects.requireNonNull(context), SharedPrefHelper.SharedPrefNames.YOUTUBE, "user_signed_out", true)) return; diff --git a/app/src/main/java/app/revanced/integrations/ryd/dialog/Dialogs.java b/app/src/main/java/app/revanced/integrations/ryd/dialog/Dialogs.java index c754f8d618..0997c1db08 100644 --- a/app/src/main/java/app/revanced/integrations/ryd/dialog/Dialogs.java +++ b/app/src/main/java/app/revanced/integrations/ryd/dialog/Dialogs.java @@ -15,8 +15,6 @@ import android.net.Uri; import android.os.Build; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.utils.SharedPrefHelper; import app.revanced.integrations.utils.ReVancedUtils; @@ -28,7 +26,7 @@ public static void showDialogsAtStartup(Activity activity) { } private static void rydFirstRun(Activity activity) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false); boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, false); @@ -82,7 +80,7 @@ private static void rydFirstRun(Activity activity) { } private static void sbFirstRun(Activity activity) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false); boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, false); diff --git a/app/src/main/java/app/revanced/integrations/settings/Settings.java b/app/src/main/java/app/revanced/integrations/settings/Settings.java index 5525608f51..2ab8054bb0 100644 --- a/app/src/main/java/app/revanced/integrations/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/settings/Settings.java @@ -1,310 +1,11 @@ package app.revanced.integrations.settings; -import android.app.Activity; -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.SharedPreferences; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.res.Resources; -import android.os.Build; -import android.view.MotionEvent; -import android.view.ViewConfiguration; -import android.view.ViewGroup; - -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - -import java.util.Objects; - -import app.revanced.integrations.sponsorblock.player.PlayerType; -import app.revanced.integrations.sponsorblock.SponsorBlockUtils; -import app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView; -import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.utils.SharedPrefHelper; -import app.revanced.integrations.videoswipecontrols.FensterGestureController; -import app.revanced.integrations.videoswipecontrols.XFenster; -import app.revanced.integrations.utils.SwipeHelper; -import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout; - public class Settings { - private static Object AutoRepeatClass; - private static PlayerType env; - private static FensterGestureController fensterGestureController; - - public static Boolean userChangedQuality = false; - public static Boolean userChangedSpeed = false; - public static Boolean newVideo = false; - public static Boolean newVideoSpeed = false; - - public static String getManufacturer() { - String manufacturer = SettingsEnum.MANUFACTURER_OVERRIDE_STRING.getString(); - if (manufacturer == null || manufacturer.isEmpty()) { - manufacturer = Build.MANUFACTURER; - } - LogHelper.debug("Settings", "getManufacturer: " + manufacturer); - return manufacturer; - } - - public static String getModel() { - String model = SettingsEnum.MODEL_OVERRIDE_STRING.getString(); - if (model == null || model.isEmpty()) { - model = Build.MODEL; - } - LogHelper.debug("Settings", "getModel: " + model); - return model; - } - - public static String getStringByName(Context context, String name) { - try { - Resources res = context.getResources(); - return res.getString(res.getIdentifier(name, "string", context.getPackageName())); - } catch (Throwable exception) { - LogHelper.printException("Settings", "Resource not found.", exception); - return ""; - } - } - - public static void CheckForMicroG(Activity activity) { - AlertDialog.Builder builder; - if (!appInstalledOrNot("com.mgoogle.android.gms")) { - LogHelper.debug("XDebug", "Custom MicroG installation undetected"); - if (Build.VERSION.SDK_INT >= 21) { - builder = new AlertDialog.Builder(activity, 16974374); - } else { - builder = new AlertDialog.Builder(activity); - } - builder.setTitle("Someone is not reading...").setMessage("You didn't install the MicroG as instructed, you can't login without it.\n\nInstall it and try again.").setPositiveButton("Close", new DialogInterface.OnClickListener() { // from class: app.revanced.integrations.settings.Settings.1 - @Override // android.content.DialogInterface.OnClickListener - public void onClick(DialogInterface dialog, int id) { - } - }).show(); - } else { - LogHelper.debug("XDebug", "Custom MicroG installation detected"); - } - } - - public static boolean isFensterEnabled() { - if (env != null && env == PlayerType.WATCH_WHILE_FULLSCREEN && !SwipeHelper.IsControlsShown()) { - return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() || SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean(); - } - return false; - } - - public static boolean isWatchWhileFullScreen() { - if (env == null) { - return false; - } - return env.toString().equals("WATCH_WHILE_FULLSCREEN"); - } - - private static boolean appInstalledOrNot(String uri) { - try { - PackageManager pm = getContext().getPackageManager(); - pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); - return true; - } catch (PackageManager.NameNotFoundException e) { - return false; - } - } - - public static String getVersionName(Context context) { - try { - PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); - String version = pInfo.versionName; - return (version); - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } - - return ("17.23.35"); - } - - public static String getPackageName() { - Context context = YouTubeTikTokRoot_Application.getAppContext(); - if (context == null) { - LogHelper.printException("Settings", "Context is null, returning com.google.android.youtube!"); - return "com.google.android.youtube"; - } - String PACKAGE_NAME = context.getPackageName(); - LogHelper.debug("Settings", "getPackageName: " + PACKAGE_NAME); - - return PACKAGE_NAME; - } - - public static int getOverrideWidth(int original) { - int compatibility = SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? 2160 : original; - return compatibility; - } - - public static int getOverrideHeight(int original) { - int compatibility = SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? 3840 : original; - return compatibility; - } - - public static Context getContext() { - Context context = YouTubeTikTokRoot_Application.getAppContext(); - if (context != null) { - LogHelper.debug("Settings", "getContext"); - return context; - } else { - LogHelper.printException("Settings", "Context is null, returning null!"); - return null; - } - } - - public static void setOldLayout(SharedPreferences sharedPreferences, String config, long timeStamp) { - if (!SettingsEnum.OLD_LAYOUT_XFILE_ENABLED_BOOLEAN.getBoolean()) { - sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group", config).putLong("com.google.android.libraries.youtube.innertube.cold_stored_timestamp", timeStamp).apply(); - LogHelper.debug("Settings", "setOldLayout: true"); - return; - } - - if (sharedPreferences.contains("com.google.android.libraries.youtube.innertube.cold_config_group")) { - sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group_backup", sharedPreferences.getString("com.google.android.libraries.youtube.innertube.cold_config_group", null)).remove("com.google.android.libraries.youtube.innertube.cold_config_group").apply(); - } - LogHelper.debug("Settings", "setOldLayout: false"); - } - - public static void NewVideoStarted() { - newVideo = true; - newVideoSpeed = true; - LogHelper.debug("Settings", "New video started!"); - } - - public static void InitializeFensterController(Context context, ViewGroup viewGroup, ViewConfiguration viewConfiguration) { - fensterGestureController = new FensterGestureController(); - fensterGestureController.setFensterEventsListener(new XFenster(context, viewGroup), context, viewConfiguration); - LogHelper.debug("Settings", "XFenster initialized"); - } - - public static boolean FensterTouchEvent(MotionEvent motionEvent) { - if (fensterGestureController == null) { - LogHelper.debug("Settings", "fensterGestureController is null"); - return false; - } else if (motionEvent == null) { - LogHelper.debug("Settings", "motionEvent is null"); - return false; - } else if (!SwipeHelper.IsControlsShown()) { - return fensterGestureController.onTouchEvent(motionEvent); - } else { - LogHelper.debug("Settings", "skipping onTouchEvent dispatching because controls are shown."); - return false; - } - } - - public static void PlayerTypeChanged(PlayerType playerType) { - LogHelper.debug("XDebug", playerType.toString()); - if (env != playerType) { - if (playerType == PlayerType.WATCH_WHILE_FULLSCREEN) { - EnableXFenster(); - } else { - DisableXFenster(); - } - if (playerType == PlayerType.WATCH_WHILE_SLIDING_MINIMIZED_MAXIMIZED || playerType == PlayerType.WATCH_WHILE_MINIMIZED || playerType == PlayerType.WATCH_WHILE_PICTURE_IN_PICTURE) { - NewSegmentHelperLayout.hide(); - } - SponsorBlockView.playerTypeChanged(playerType); - SponsorBlockUtils.playerTypeChanged(playerType); - } - env = playerType; - } - - public static void EnableXFenster() { - if (SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() || SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean()) { - FensterGestureController fensterGestureController2 = fensterGestureController; - fensterGestureController2.TouchesEnabled = true; - ((XFenster) fensterGestureController2.listener).enable(SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean(), SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean()); - } - } - - public static void DisableXFenster() { - FensterGestureController fensterGestureController2 = fensterGestureController; - fensterGestureController2.TouchesEnabled = false; - ((XFenster) fensterGestureController2.listener).disable(); - } - - /*public static boolean autoCaptions(boolean original) { - ReadSettings(); - if (!settingsInitialized.booleanValue()) { - LogHelper.printException("Settings", "Context is null, returning " + original + "!"); - return original; - } - Boolean captions = Boolean.valueOf(original); - if (prefAutoCaptions.booleanValue()) { - captions = true; - } - LogHelper.debug("Settings", "autoCaptions: " + captions); - return captions.booleanValue(); - } - - public static boolean getOverride(boolean original) { - ReadSettings(); - if (!settingsInitialized.booleanValue()) { - LogHelper.printException("Settings", "Context is null, returning " + original + "!"); - return original; - } - Boolean compatibility = Boolean.valueOf(original); - if (overrideCodec.booleanValue()) { - compatibility = true; - } - LogHelper.debug("Settings", "getOverride: " + compatibility); - - return compatibility.booleanValue(); - } - - public static int getCommentsLocation(int original) { - ReadSettings(); - if (!settingsInitialized.booleanValue()) { - LogHelper.printException("Settings", "Context is null, returning " + original + "!"); - return original; - } else if (!commentsLocation.booleanValue()) { - return original; - } else { - LogHelper.debug("Settings", "getCommentsLocation: Moving comments back down"); - return 3; - } - } - - public static boolean getTabletMiniplayerOverride(boolean original) { - ReadSettings(); - if (!settingsInitialized.booleanValue()) { - LogHelper.printException("Settings", "Context is null, returning " + original + "!"); - return original; - } else if (!tabletMiniplayer.booleanValue()) { - return original; - } else { - LogHelper.debug("Settings", "getTabletMiniplayerOverride: Using tablet miniplayer"); - return true; - } - } - - public static boolean getNewActionBar(boolean original) { - ReadSettings(); - if (!settingsInitialized.booleanValue()) { - LogHelper.printException("Settings", "Context is null, returning " + original + "!"); - return original; - } else if (!newActionBar.booleanValue()) { - return original; - } else { - LogHelper.debug("Settings", "getNewActionBar: Enabled"); - return true; - } - }*/ + //Methods not used in latest Vanced source code, can be useful for future patches /* - public static boolean getNewActionBarNegated(boolean original) { - ReadSettings(); - if (!settingsInitialized.booleanValue()) { - LogHelper.printException("Settings", "Context is null, returning " + original + "!"); - return original; - } else if (!newActionBar.booleanValue()) { - return original; - } else { - LogHelper.debug("Settings", "getNewActionBar: Enabled"); - return false; - } - } + + private static Object AutoRepeatClass; public static boolean getVerticalZoomToFit(boolean original) { ReadSettings(); @@ -358,35 +59,17 @@ public static boolean accessibilitySeek(boolean original) { return seek.booleanValue(); } - public static boolean shouldAutoRepeat() { - return SettingsEnum.PREFERRED_AUTO_REPEAT_BOOLEAN.getBoolean(); - } - - public static float getHDRBrightness(float original) { - if (!SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.getBoolean()) return original; - return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() ? BrightnessHelper.getBrightness() : -1.0f; - } - - public static int getMaxBuffer(int original) { - return SettingsEnum.MAX_BUFFER_INTEGER.getInt(); - } - - - - public static int getPlaybackBuffer(int original) { - return SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.getInt(); - } - */ - -/* - public static int getReBuffer(int original) { - return SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.getInt(); - } + public static void setOldLayout(SharedPreferences sharedPreferences, String config, long timeStamp) { + if (!SettingsEnum.OLD_LAYOUT_XFILE_ENABLED_BOOLEAN.getBoolean()) { + sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group", config).putLong("com.google.android.libraries.youtube.innertube.cold_stored_timestamp", timeStamp).apply(); + LogHelper.debug("Settings", "setOldLayout: true"); + return; + } - public static boolean isFensterBrightnessEnabled() { - return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean(); + if (sharedPreferences.contains("com.google.android.libraries.youtube.innertube.cold_config_group")) { + sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group_backup", sharedPreferences.getString("com.google.android.libraries.youtube.innertube.cold_config_group", null)).remove("com.google.android.libraries.youtube.innertube.cold_config_group").apply(); + } + LogHelper.debug("Settings", "setOldLayout: false"); } */ - - } diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index 45f2989b64..114b313913 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -2,9 +2,8 @@ import android.content.Context; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; public enum SettingsEnum { @@ -12,38 +11,34 @@ public enum SettingsEnum { DEBUG_BOOLEAN("debug_xfile_enabled", false), MANUFACTURER_OVERRIDE_STRING("override_manufacturer", null), MODEL_OVERRIDE_STRING("override_model", null), - CODEC_OVERRIDE_BOOLEAN("override_resolution_xfile_enabled", false), + CODEC_OVERRIDE_BOOLEAN("override_resolution_xfile_enabled", true), PREFERRED_RESOLUTION_WIFI_INTEGER("pref_video_quality_wifi", -2), PREFERRED_RESOLUTION_MOBILE_INTEGER("pref_video_quality_mobile", -2), PREFERRED_VIDEO_SPEED_FLOAT("pref_video_speed", -2.0f), - PREFERRED_AUTO_CAPTIONS_BOOLEAN("pref_auto_captions", false), PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER("pref_minimized_video_preview", -2), - PREFERRED_AUTO_REPEAT_BOOLEAN("pref_auto_repeat", false), + PREFERRED_AUTO_REPEAT_BOOLEAN("pref_auto_repeat", true), HOME_ADS_SHOWN_BOOLEAN("home_ads_enabled", false), VIDEO_ADS_SHOWN_BOOLEAN("video_ads_enabled", false), REEL_BUTTON_SHOWN_BOOLEAN("reel_button_enabled", false), SHORTS_BUTTON_SHOWN_BOOLEAN("shorts_button_enabled", false), CAST_BUTTON_SHOWN_BOOLEAN("cast_button_enabled", false), - CREATE_BUTTON_SHOWN_BOOLEAN("xfile_create_button_hidden", true), - SUGGESTIONS_SHOWN_BOOLEAN("info_card_suggestions_enabled", true), - INFO_CARDS_SHOWN_BOOLEAN("info_cards_enabled", true), - BRANDING_SHOWN_BOOLEAN("branding_watermark_enabled", true), + CREATE_BUTTON_SHOWN_BOOLEAN("xfile_create_button_enabled", false), + SUGGESTIONS_SHOWN_BOOLEAN("info_card_suggestions_enabled", false), + INFO_CARDS_SHOWN_BOOLEAN("info_cards_enabled", false), + BRANDING_SHOWN_BOOLEAN("branding_watermark_enabled", false), USE_TABLET_MINIPLAYER_BOOLEAN("tablet_miniplayer", false), - CHANGE_COMMENT_LOCATION_BOOLEAN("comments_location", false), USE_NEW_ACTIONBAR_BOOLEAN("xfile_new_actionbar", false), - USE_VERTICAL_ZOOM_TO_FIT_BOOLEAN("xfile_zoom_to_fit_vertical", false), USE_DARK_THEME_BOOLEAN("app_theme_dark", false), - ACCESSIBILITY_SEEK_BOOLEAN("xfile_accessibility_seek_buttons", false), - USE_HDR_BRIGHTNESS_BOOLEAN("pref_hdr_autobrightness", false), - ENABLE_SWIPE_BRIGHTNESS_BOOLEAN("pref_xfenster_brightness", false), - ENABLE_SWIPE_VOLUME_BOOLEAN("pref_xfenster_volume", false), + USE_HDR_BRIGHTNESS_BOOLEAN("pref_hdr_autobrightness", true), + ENABLE_SWIPE_BRIGHTNESS_BOOLEAN("pref_xfenster_brightness", true), + ENABLE_SWIPE_VOLUME_BOOLEAN("pref_xfenster_volume", true), SWIPE_THRESHOLD_INTEGER("pref_xfenster_swipe_threshold", 30), SWIPE_PADDING_TOP_INTEGER("pref_xfenster_swipe_padding_top", 50), + SWIPE_USE_TABLET_MODE("pref_xfenster_tablet", false), MAX_BUFFER_INTEGER("pref_max_buffer_ms", 120000), PLAYBACK_MAX_BUFFER_INTEGER("pref_buffer_for_playback_ms", 2500), MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER("pref_buffer_for_playback_after_rebuffer_ms", 5000), OLD_STYLE_QUALITY_SETTINGS_BOOLEAN("old_style_quality_settings", true), - OLD_LAYOUT_XFILE_ENABLED_BOOLEAN("old_layout_xfile_enabled", false), TAP_SEEKING_ENABLED_BOOLEAN("xfile_enable_tap_seeking", true), ; @@ -61,8 +56,8 @@ public enum SettingsEnum { public static void loadSettings() { if (loaded) return; - Context context; - if ((context = YouTubeTikTokRoot_Application.getAppContext()) != null) { + Context context = ReVancedUtils.getContext(); + if (context != null) { for (SettingsEnum setting : values()) { Object value = null; if (setting.name().endsWith("BOOLEAN")) { @@ -98,8 +93,8 @@ public void setValue(Object newValue) { public void saveValue(Object newValue) { loadSettings(); - Context context; - if ((context = YouTubeTikTokRoot_Application.getAppContext()) != null) { + Context context = ReVancedUtils.getContext(); + if (context != null) { if (name().endsWith("BOOLEAN")) { SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Boolean) newValue); } else if (name().endsWith("INTEGER")) { @@ -113,6 +108,7 @@ public void saveValue(Object newValue) { } else { LogHelper.printException("SettingsEnum", "Setting does not end with a valid Type. Name is: " + name()); } + value = newValue; } else { LogHelper.printException("SettingsEnum", "Context on SaveValue is null!"); } @@ -151,11 +147,11 @@ public Float getFloat() { return (Float) value; } - private Object getDefaultValue() { + public Object getDefaultValue() { return defaultValue; } - private String getPath() { + public String getPath() { return path; } diff --git a/app/src/main/java/app/revanced/integrations/settings/XSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settings/XSettingsFragment.java deleted file mode 100644 index f6ab0c7e7f..0000000000 --- a/app/src/main/java/app/revanced/integrations/settings/XSettingsFragment.java +++ /dev/null @@ -1,611 +0,0 @@ -package app.revanced.integrations.settings; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.preference.EditTextPreference; -import android.preference.ListPreference; -import android.preference.Preference; -import android.preference.PreferenceFragment; -import android.preference.PreferenceScreen; -import android.preference.SwitchPreference; -import android.widget.Toast; - -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - -import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.videoplayer.autorepeat.AutoRepeat; -import app.revanced.integrations.videoswipecontrols.FensterGestureListener; -import app.revanced.integrations.videoplayer.settings.XReboot; -import app.revanced.integrations.utils.ScreenSizeHelper; -import app.revanced.integrations.utils.SwipeHelper; -import app.revanced.integrations.videoplayer.videourl.Copy; -import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp; -import app.revanced.integrations.BuildConfig; - -/* loaded from: classes6.dex */ -public class XSettingsFragment extends PreferenceFragment { - - // YouTubePlayerOverlaysLayout.overlayContext - public static Context overlayContext; - // Shell_HomeActivity.class - public static Class homeActivityClass; - private Toast toast; - private PreferenceScreen adsSettingsPreferenceScreen; - private PreferenceScreen bufferSettingsPreferenceScreen; - private Preference codecDefault; - private Preference codecHDRH; - private Preference codecHDRS; - private PreferenceScreen codecPreferenceScreen; - private Preference codecVP9; - private PreferenceScreen layoutSettingsPreferenceScreen; - private EditTextPreference manufacturerOverride; - private PreferenceScreen miscsPreferenceScreen; - private EditTextPreference modelOverride; - public SharedPreferences sharedPreferences; - private SwitchPreference tabletComments; - private SwitchPreference tabletMiniplayer; - private PreferenceScreen videoAdSettingsPreferenceScreen; - private PreferenceScreen videoSettingsPreferenceScreen; - private SwitchPreference vp9Override; - private PreferenceScreen xFensterPreferenceScreen; - private boolean Registered = false; - CharSequence[] videoQualityEntries = {"Auto", "144p", "240p", "360p", "480p", "720p", "1080p", "1440p", "2160p"}; - CharSequence[] videoQualityentryValues = {"-2", "144", "240", "360", "480", "720", "1080", "1440", "2160"}; - CharSequence[] minimizedVideoEntries = {"Auto", "Video only", "Video with controls"}; - CharSequence[] minimizedVideoentryValues = {"-2", "0", "1"}; - CharSequence[] videoSpeedEntries = {"Auto", "0.25x", "0.5x", "0.75x", "Normal", "1.25x", "1.5x", "1.75x", "2x"}; - CharSequence[] videoSpeedentryValues = {"-2", "0.25", "0.5", "0.75", BuildConfig.VERSION_NAME, "1.25", "1.5", "1.75", "2.0"}; - CharSequence[] buttonLocationEntries = {"None", "In player", "Under player", "Both"}; - CharSequence[] buttonLocationentryValues = {"NONE", "PLAYER", "BUTTON_BAR", "BOTH"}; - private long PreviousClick = 0; - private int clicks = 0; - private final int neededClicks = 5; - private boolean hiddenMenuOpened = false; - private boolean settingsInitialized = false; - // from class: app.revanced.integrations.settings.XSettingsFragment.9 -// android.content.SharedPreferences.OnSharedPreferenceChangeListener - SharedPreferences.OnSharedPreferenceChangeListener listener = (sharedPreferences, str) -> { - if ("debug_xfile_enabled".equals(str)) { - SettingsEnum.DEBUG_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.findPreference("debug_xfile_enabled")).isChecked()); - } else if ("vp9_xfile_enabled".equals(str)) { - if (((SwitchPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("vp9_xfile_enabled")).isChecked()) { - sharedPreferences.edit().putString("override_manufacturer", "samsung").apply(); - sharedPreferences.edit().putString("override_model", "SM-G920F").apply(); - SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue("samsung"); - SettingsEnum.MODEL_OVERRIDE_STRING.setValue("SM-G920F"); - return; - } - sharedPreferences.edit().remove("override_manufacturer").apply(); - sharedPreferences.edit().remove("override_model").apply(); - SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue(null); - SettingsEnum.MODEL_OVERRIDE_STRING.setValue(null); - } else if ("override_manufacturer".equals(str)) { - EditTextPreference editTextPreference = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_manufacturer"); - if (editTextPreference != null) { - editTextPreference.setSummary(editTextPreference.getText()); - SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue(editTextPreference.getText()); - } - } else if ("override_model".equals(str)) { - EditTextPreference editTextPreference2 = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_model"); - if (editTextPreference2 != null) { - editTextPreference2.setSummary(editTextPreference2.getText()); - SettingsEnum.MODEL_OVERRIDE_STRING.setValue(editTextPreference2.getText()); - } - } else if ("home_ads_enabled".equals(str)) { - SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("home_ads_enabled")).isChecked()); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("video_ads_enabled".equals(str)) { - SettingsEnum.VIDEO_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("video_ads_enabled")).isChecked()); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("reel_enabled".equals(str)) { - SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("reel_enabled")).isChecked()); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("info_card_suggestions_enabled".equals(str)) { - SettingsEnum.SUGGESTIONS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("info_card_suggestions_enabled")).isChecked()); - } else if ("info_cards_enabled".equals(str)) { - SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("info_cards_enabled")).isChecked()); - } else if ("branding_watermark_enabled".equals(str)) { - SettingsEnum.BRANDING_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("branding_watermark_enabled")).isChecked()); - } else if ("cast_button_enabled".equals(str)) { - SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("cast_button_enabled")).isChecked()); - } else if ("tablet_miniplayer".equals(str)) { - SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer")).isChecked()); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("comments_location".equals(str)) { - SwitchPreference switchPreference = (SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("comments_location"); - SettingsEnum.CHANGE_COMMENT_LOCATION_BOOLEAN.setValue(switchPreference.isChecked()); - SwipeHelper.isTabletMode = switchPreference.isChecked(); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("xfile_create_button_hidden".equals(str)) { - SwitchPreference switchPreference = (SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_create_button_hidden"); - SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.setValue(switchPreference.isChecked()); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("xfile_new_actionbar".equals(str)) { - SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_new_actionbar")).isChecked()); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("xfile_zoom_to_fit_vertical".equals(str)) { - SettingsEnum.USE_VERTICAL_ZOOM_TO_FIT_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_zoom_to_fit_vertical")).isChecked()); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("pref_minimized_video_preview".equals(str)) { - ListPreference listPreference = (ListPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("pref_minimized_video_preview"); - String string = sharedPreferences.getString("pref_minimized_video_preview", "-2"); - listPreference.setDefaultValue(string); - listPreference.setSummary(XSettingsFragment.this.minimizedVideoEntries[listPreference.findIndexOfValue(string)]); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("xfile_accessibility_seek_buttons".equals(str)) { - SettingsEnum.ACCESSIBILITY_SEEK_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_accessibility_seek_buttons")).isChecked()); - } else if ("override_resolution_xfile_enabled".equals(str)) { - SettingsEnum.CODEC_OVERRIDE_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.findPreference("override_resolution_xfile_enabled")).isChecked()); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("pref_auto_captions".equals(str)) { - SettingsEnum.PREFERRED_AUTO_CAPTIONS_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.findPreference("pref_auto_captions")).isChecked()); - if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - } else if ("pref_preferred_video_quality_wifi".equals(str)) { - ListPreference listPreference2 = (ListPreference) XSettingsFragment.this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_quality_wifi"); - String string2 = sharedPreferences.getString("pref_preferred_video_quality_wifi", "-2"); - listPreference2.setDefaultValue(string2); - listPreference2.setSummary(XSettingsFragment.this.videoQualityEntries[listPreference2.findIndexOfValue(string2)]); - SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.setValue(Integer.parseInt(string2)); - } else if ("pref_preferred_video_quality_mobile".equals(str)) { - ListPreference listPreference3 = (ListPreference) XSettingsFragment.this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_quality_mobile"); - String string3 = sharedPreferences.getString("pref_preferred_video_quality_mobile", "-2"); - listPreference3.setDefaultValue(string3); - listPreference3.setSummary(XSettingsFragment.this.videoQualityEntries[listPreference3.findIndexOfValue(string3)]); - SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.setValue(Integer.parseInt(string3)); - } else if ("pref_preferred_video_speed".equals(str)) { - ListPreference listPreference4 = (ListPreference) XSettingsFragment.this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_speed"); - String string4 = sharedPreferences.getString("pref_preferred_video_speed", "-2"); - listPreference4.setDefaultValue(string4); - listPreference4.setSummary(XSettingsFragment.this.videoSpeedEntries[listPreference4.findIndexOfValue(string4)]); - SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.setValue(Float.parseFloat(string4)); - } else if ("pref_max_buffer_ms".equals(str)) { - EditTextPreference editTextPreference3 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_max_buffer_ms"); - if (editTextPreference3 != null) { - editTextPreference3.setSummary(editTextPreference3.getText()); - SettingsEnum.MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference3.getText())); - } - } else if ("pref_buffer_for_playback_ms".equals(str)) { - EditTextPreference editTextPreference4 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_buffer_for_playback_ms"); - if (editTextPreference4 != null) { - editTextPreference4.setSummary(editTextPreference4.getText()); - SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference4.getText())); - } - } else if ("pref_buffer_for_playback_after_rebuffer_ms".equals(str)) { - EditTextPreference editTextPreference5 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_buffer_for_playback_after_rebuffer_ms"); - if (editTextPreference5 != null) { - editTextPreference5.setSummary(editTextPreference5.getText()); - SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference5.getText())); - } - } else if ("pref_auto_repeat_button".equals(str)) { - XSettingsFragment.this.AutoRepeatLinks(); - } else if ("pref_auto_repeat".equals(str)) { - AutoRepeat.changeSelected(sharedPreferences.getBoolean("pref_auto_repeat", false), true); - } else if ("pref_copy_video_url_timestamp_button_list".equals(str)) { - CopyWithTimeStamp.refreshShouldBeShown(); - } else if ("pref_copy_video_url_button_list".equals(str)) { - Copy.refreshShouldBeShown(); - } else if ("pref_hdr_autobrightness".equals(str)) { - SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.miscsPreferenceScreen.findPreference("pref_hdr_autobrightness")).isChecked()); - } else if ("pref_xfenster_brightness".equals(str)) { - SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_brightness")).isChecked()); - } else if ("pref_xfenster_volume".equals(str)) { - SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_volume")).isChecked()); - } else if ("pref_xfenster_tablet".equals(str)) { - SwipeHelper.isTabletMode = ((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_tablet")).isChecked(); - } else if ("pref_xfenster_swipe_threshold".equals(str)) { - EditTextPreference editTextPreference6 = (EditTextPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_swipe_threshold"); - if (editTextPreference6 != null) { - editTextPreference6.setSummary(editTextPreference6.getText()); - try { - FensterGestureListener.SWIPE_THRESHOLD = Integer.parseInt(editTextPreference6.getText()); - } catch (NumberFormatException unused) { - FensterGestureListener.SWIPE_THRESHOLD = 0; - } - } - } else if ("pref_xfenster_swipe_padding_top".equals(str)) { - EditTextPreference editTextPreference7 = (EditTextPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_swipe_padding_top"); - if (editTextPreference7 != null) { - editTextPreference7.setSummary(editTextPreference7.getText()); - try { - FensterGestureListener.TOP_PADDING = Integer.parseInt(editTextPreference7.getText()); - } catch (NumberFormatException unused2) { - FensterGestureListener.TOP_PADDING = 20; - } - } - } else if ("vanced_ryd_enabled".equals(str) && Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) { - XReboot.RebootDialog(XSettingsFragment.this.getActivity()); - } - }; - - static /* synthetic */ int access$308(XSettingsFragment xSettingsFragment) { - int i = xSettingsFragment.clicks; - xSettingsFragment.clicks = i + 1; - return i; - } - - @SuppressLint("ResourceType") - @Override // android.preference.PreferenceFragment, android.app.Fragment - public void onCreate(Bundle bundle) { - super.onCreate(bundle); - getPreferenceManager().setSharedPreferencesName("youtube"); - try { - int identifier = getResources().getIdentifier("xfile_prefs", "xml", Settings.getPackageName()); - - addPreferencesFromResource(identifier); - String stringByName = Settings.getStringByName(getActivity(), "quality_auto"); - this.videoQualityEntries[0] = stringByName; - this.minimizedVideoEntries[0] = stringByName; - this.videoSpeedEntries[0] = stringByName; - String stringByName2 = Settings.getStringByName(getActivity(), "pref_subtitles_scale_normal"); - if (stringByName2.equals("")) { - this.videoSpeedEntries[4] = "Normal"; - } else { - this.videoSpeedEntries[4] = stringByName2; - } - this.minimizedVideoEntries[1] = Settings.getStringByName(getActivity(), "xfile_miniplayer_style_video"); - this.minimizedVideoEntries[2] = Settings.getStringByName(getActivity(), "xfile_miniplayer_style_video_controls"); - SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences(); - this.sharedPreferences = sharedPreferences; - this.settingsInitialized = sharedPreferences.getBoolean("xfile_initialized", false); - this.sharedPreferences.registerOnSharedPreferenceChangeListener(this.listener); - this.Registered = true; - this.hiddenMenuOpened = this.sharedPreferences.getBoolean("xfile_hiddenMenu_enabled", false); - this.codecPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("codec_override"); - this.videoSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("video_settings"); - this.videoAdSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("video_ad_settings"); - this.adsSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("ad_settings"); - this.layoutSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("layout_settings"); - this.bufferSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("buffer_screen"); - this.miscsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("misc_screen"); - this.xFensterPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("xfenster_screen"); - this.vp9Override = (SwitchPreference) this.codecPreferenceScreen.findPreference("vp9_xfile_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.codecHDRH = this.codecPreferenceScreen.findPreference("pref_hdrhardware_override"); - this.codecHDRS = this.codecPreferenceScreen.findPreference("pref_hdrsoftware_override"); - this.tabletMiniplayer = (SwitchPreference) this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer"); - this.tabletComments = (SwitchPreference) this.layoutSettingsPreferenceScreen.findPreference("comments_location"); - AutoRepeatLinks(); - EditTextPreference editTextPreference = this.manufacturerOverride; - editTextPreference.setSummary(editTextPreference.getText()); - EditTextPreference editTextPreference2 = this.modelOverride; - editTextPreference2.setSummary(editTextPreference2.getText()); - CheckHiddenMenuStatus(); - 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); - setListPreferenceData(listPreference2, false); - // from class: app.revanced.integrations.settings.XSettingsFragment.1 -// android.preference.Preference.OnPreferenceClickListener - listPreference.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.setListPreferenceData(listPreference, true); - return false; - }); - // from class: app.revanced.integrations.settings.XSettingsFragment.2 -// android.preference.Preference.OnPreferenceClickListener - listPreference2.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.setListPreferenceData(listPreference2, false); - return false; - }); - final ListPreference listPreference3 = (ListPreference) this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_speed"); - setSpeedListPreferenceData(listPreference3); - // from class: app.revanced.integrations.settings.XSettingsFragment.3 -// android.preference.Preference.OnPreferenceClickListener - listPreference3.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.setSpeedListPreferenceData(listPreference3); - return false; - }); - Preference findPreference = findPreference("pref_about_field"); - final String stringByName3 = Settings.getStringByName(getActivity(), "xfile_hiddenmenu_open"); - final String stringByName4 = Settings.getStringByName(getActivity(), "xfile_hiddenmenu_opened"); - final String str = " " + Settings.getStringByName(getActivity(), "xfile_hiddenmenu_needed"); - // from class: app.revanced.integrations.settings.XSettingsFragment.4 -// android.preference.Preference.OnPreferenceClickListener - findPreference.setOnPreferenceClickListener(preference -> { - if (XSettingsFragment.this.hiddenMenuOpened) { - if (XSettingsFragment.this.toast != null) { - XSettingsFragment.this.toast.cancel(); - } - XSettingsFragment.this.toast = Toast.makeText(Settings.getContext(), stringByName3, Toast.LENGTH_SHORT); - XSettingsFragment.this.toast.show(); - return false; - } - long currentTimeMillis = System.currentTimeMillis() - XSettingsFragment.this.PreviousClick; - XSettingsFragment.this.PreviousClick = System.currentTimeMillis(); - if (currentTimeMillis / 1000 < 2) { - XSettingsFragment.access$308(XSettingsFragment.this); - int i = XSettingsFragment.this.neededClicks - XSettingsFragment.this.clicks; - if (XSettingsFragment.this.toast != null) { - XSettingsFragment.this.toast.cancel(); - } - if (i <= 0) { - XSettingsFragment.this.toast = Toast.makeText(Settings.getContext(), stringByName4, Toast.LENGTH_SHORT); - XSettingsFragment.this.hiddenMenuOpened = true; - XSettingsFragment.this.sharedPreferences.edit().putBoolean("xfile_hiddenMenu_enabled", true).apply(); - XSettingsFragment.this.CheckHiddenMenuStatus(); - } else { - XSettingsFragment xSettingsFragment = XSettingsFragment.this; - Context context = Settings.getContext(); - xSettingsFragment.toast = Toast.makeText(context, i + str, Toast.LENGTH_SHORT); - } - XSettingsFragment.this.toast.show(); - } else { - XSettingsFragment.this.clicks = 0; - } - return false; - }); - // from class: app.revanced.integrations.settings.XSettingsFragment.5 -// android.preference.Preference.OnPreferenceClickListener - this.codecDefault.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.ChangeCodec(preference); - return false; - }); - // from class: app.revanced.integrations.settings.XSettingsFragment.6 -// android.preference.Preference.OnPreferenceClickListener - this.codecVP9.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.ChangeCodec(preference); - return false; - }); - // from class: app.revanced.integrations.settings.XSettingsFragment.7 -// android.preference.Preference.OnPreferenceClickListener - this.codecHDRH.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.ChangeCodec(preference); - return false; - }); - // from class: app.revanced.integrations.settings.XSettingsFragment.8 -// android.preference.Preference.OnPreferenceClickListener - this.codecHDRS.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.ChangeCodec(preference); - return false; - }); - if (ScreenSizeHelper.isTablet(YouTubeTikTokRoot_Application.getAppContext())) { - if (this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer") != null) { - this.layoutSettingsPreferenceScreen.removePreference(this.tabletMiniplayer); - } - if (this.layoutSettingsPreferenceScreen.findPreference("comments_location") != null) { - this.layoutSettingsPreferenceScreen.removePreference(this.tabletComments); - } - } - this.sharedPreferences.edit().putBoolean("xfile_initialized", true); - this.settingsInitialized = true; - } catch (Throwable th) { - LogHelper.printException("XSettingsFragment", "Unable to retrieve resourceId for xfile_prefs", th); - } - } - - /* JADX INFO: Access modifiers changed from: private */ - public void ChangeCodec(Preference preference) { - String key = preference.getKey(); - char c = 65535; - switch (key.hashCode()) { - case -1420246871: - if (key.equals("pref_hdrhardware_override")) { - c = 0; - break; - } - break; - case -350518296: - if (key.equals("pref_vp9_override")) { - c = 1; - break; - } - break; - case 1613958090: - if (key.equals("pref_hdrsoftware_override")) { - c = 2; - break; - } - break; - } - String str = "samsung"; - String str2 = null; - switch (c) { - case 0: - str2 = "SM-G955W"; - break; - case 1: - str2 = "SM-G920F"; - break; - case 2: - str = "Google"; - str2 = "Pixel XL"; - break; - default: - str = null; - break; - } - if (str != null) { - this.sharedPreferences.edit().putString("override_manufacturer", str).apply(); - } else { - this.sharedPreferences.edit().remove("override_manufacturer").apply(); - } - if (str2 != null) { - this.sharedPreferences.edit().putString("override_model", str2).apply(); - } else { - this.sharedPreferences.edit().remove("override_model").apply(); - } - this.manufacturerOverride.setText(str); - this.modelOverride.setText(str2); - EditTextPreference editTextPreference = this.manufacturerOverride; - editTextPreference.setSummary(editTextPreference.getText()); - EditTextPreference editTextPreference2 = this.modelOverride; - editTextPreference2.setSummary(editTextPreference2.getText()); - } - - /* JADX INFO: Access modifiers changed from: private */ - public void CheckHiddenMenuStatus() { - if (this.hiddenMenuOpened) { - if (this.codecPreferenceScreen.findPreference("vp9_xfile_enabled") != null) { - this.codecPreferenceScreen.removePreference(this.vp9Override); - } - if (this.codecPreferenceScreen.findPreference("override_manufacturer") == null) { - this.codecPreferenceScreen.addPreference(this.manufacturerOverride); - EditTextPreference editTextPreference = this.manufacturerOverride; - editTextPreference.setSummary(editTextPreference.getText()); - } - if (this.codecPreferenceScreen.findPreference("override_model") == null) { - this.codecPreferenceScreen.addPreference(this.modelOverride); - EditTextPreference editTextPreference2 = this.modelOverride; - editTextPreference2.setSummary(editTextPreference2.getText()); - } - if (this.codecPreferenceScreen.findPreference("pref_default_override") == null) { - this.codecPreferenceScreen.addPreference(this.codecDefault); - // from class: app.revanced.integrations.settings.XSettingsFragment.10 -// android.preference.Preference.OnPreferenceClickListener - this.codecDefault.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.ChangeCodec(preference); - return false; - }); - } - if (this.codecPreferenceScreen.findPreference("pref_vp9_override") == null) { - this.codecPreferenceScreen.addPreference(this.codecVP9); - // from class: app.revanced.integrations.settings.XSettingsFragment.11 -// android.preference.Preference.OnPreferenceClickListener - this.codecVP9.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.ChangeCodec(preference); - return false; - }); - } - if (this.codecPreferenceScreen.findPreference("pref_hdrhardware_override") == null) { - this.codecPreferenceScreen.addPreference(this.codecHDRH); - // from class: app.revanced.integrations.settings.XSettingsFragment.12 -// android.preference.Preference.OnPreferenceClickListener - this.codecHDRH.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.ChangeCodec(preference); - return false; - }); - } - if (this.codecPreferenceScreen.findPreference("pref_hdrsoftware_override") == null) { - this.codecPreferenceScreen.addPreference(this.codecHDRS); - // from class: app.revanced.integrations.settings.XSettingsFragment.13 -// android.preference.Preference.OnPreferenceClickListener - this.codecHDRS.setOnPreferenceClickListener(preference -> { - XSettingsFragment.this.ChangeCodec(preference); - return false; - }); - return; - } - return; - } - if (this.codecPreferenceScreen.findPreference("vp9_xfile_enabled") == null) { - this.codecPreferenceScreen.addPreference(this.vp9Override); - } - if (this.codecPreferenceScreen.findPreference("override_manufacturer") != null) { - this.codecPreferenceScreen.removePreference(this.manufacturerOverride); - } - if (this.codecPreferenceScreen.findPreference("override_model") != null) { - this.codecPreferenceScreen.removePreference(this.modelOverride); - } - if (this.codecPreferenceScreen.findPreference("pref_default_override") != null) { - this.codecPreferenceScreen.removePreference(this.codecDefault); - } - if (this.codecPreferenceScreen.findPreference("pref_vp9_override") != null) { - this.codecPreferenceScreen.removePreference(this.codecVP9); - } - if (this.codecPreferenceScreen.findPreference("pref_hdrhardware_override") != null) { - this.codecPreferenceScreen.removePreference(this.codecHDRH); - } - if (this.codecPreferenceScreen.findPreference("pref_hdrsoftware_override") != null) { - this.codecPreferenceScreen.removePreference(this.codecHDRS); - } - } - - /* JADX INFO: Access modifiers changed from: private */ - public void AutoRepeatLinks() { - boolean z = this.sharedPreferences.getBoolean("pref_auto_repeat_button", false); - SwitchPreference switchPreference = (SwitchPreference) this.miscsPreferenceScreen.findPreference("pref_auto_repeat"); - if (switchPreference == null) { - return; - } - if (z) { - switchPreference.setEnabled(false); - AutoRepeat.isAutoRepeatBtnEnabled = true; - return; - } - switchPreference.setEnabled(true); - AutoRepeat.isAutoRepeatBtnEnabled = false; - } - - protected void setListPreferenceData(ListPreference listPreference, boolean z) { - listPreference.setEntries(this.videoQualityEntries); - listPreference.setEntryValues(this.videoQualityentryValues); - String string = this.sharedPreferences.getString(z ? "pref_preferred_video_quality_wifi" : "pref_preferred_video_quality_mobile", "-2"); - if (listPreference.getValue() == null) { - listPreference.setValue(string); - } - listPreference.setSummary(this.videoQualityEntries[listPreference.findIndexOfValue(string)]); - } - - protected void setMinimizedListPreferenceData(ListPreference listPreference) { - listPreference.setEntries(this.minimizedVideoEntries); - listPreference.setEntryValues(this.minimizedVideoentryValues); - String string = this.sharedPreferences.getString("pref_minimized_video_preview", "-2"); - if (listPreference.getValue() == null) { - listPreference.setValue(string); - } - listPreference.setSummary(this.minimizedVideoEntries[listPreference.findIndexOfValue(string)]); - } - - protected void setSpeedListPreferenceData(ListPreference listPreference) { - listPreference.setEntries(this.videoSpeedEntries); - listPreference.setEntryValues(this.videoSpeedentryValues); - String string = this.sharedPreferences.getString("pref_preferred_video_speed", "-2"); - if (listPreference.getValue() == null) { - listPreference.setValue(string); - } - listPreference.setSummary(this.videoSpeedEntries[listPreference.findIndexOfValue(string)]); - } - - protected void setCopyLinkListPreferenceData(ListPreference listPreference, String str) { - listPreference.setEntries(this.buttonLocationEntries); - listPreference.setEntryValues(this.buttonLocationentryValues); - String string = this.sharedPreferences.getString(str, "NONE"); - if (listPreference.getValue() == null) { - listPreference.setValue(string); - } - listPreference.setSummary(this.buttonLocationEntries[listPreference.findIndexOfValue(string)]); - } - - private void RestartApplication() { - Intent launchIntentForPackage = getActivity().getBaseContext().getPackageManager().getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName()); - launchIntentForPackage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(launchIntentForPackage); - getActivity().finish(); - } - - @Override // android.preference.PreferenceFragment, android.app.Fragment - public void onDestroy() { - if (this.Registered) { - this.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this.listener); - this.Registered = false; - } - super.onDestroy(); - } -} diff --git a/app/src/main/java/app/revanced/integrations/ryd/RYDFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/RYDSettingsFragment.java similarity index 95% rename from app/src/main/java/app/revanced/integrations/ryd/RYDFragment.java rename to app/src/main/java/app/revanced/integrations/settingsmenu/RYDSettingsFragment.java index 4fd034af24..154ac16b2d 100644 --- a/app/src/main/java/app/revanced/integrations/ryd/RYDFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/RYDSettingsFragment.java @@ -1,4 +1,4 @@ -package app.revanced.integrations.ryd; +package app.revanced.integrations.settingsmenu; import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED; import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN; @@ -15,11 +15,12 @@ import android.preference.PreferenceScreen; import android.preference.SwitchPreference; +import app.revanced.integrations.ryd.ReturnYouTubeDislikes; import app.revanced.integrations.settings.Settings; import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.SharedPrefHelper; -public class RYDFragment extends PreferenceFragment { +public class RYDSettingsFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java new file mode 100644 index 0000000000..e5a1b5dc29 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/ReVancedSettingsFragment.java @@ -0,0 +1,421 @@ +package app.revanced.integrations.settingsmenu; + +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlarmManager; +import android.app.AlertDialog; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.os.Process; +import android.preference.EditTextPreference; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.PreferenceFragment; +import android.preference.PreferenceScreen; +import android.preference.SwitchPreference; + +import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; + +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.videoswipecontrols.SwipeGestureListener; +import app.revanced.integrations.utils.ScreenSizeHelper; +import app.revanced.integrations.videoplayer.videourl.Copy; +import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp; + +public class ReVancedSettingsFragment extends PreferenceFragment { + + public static Context overlayContext; + public static Class homeActivityClass; + + private SharedPreferences sharedPreferences; + private PreferenceScreen adsSettingsPreferenceScreen; + private PreferenceScreen bufferSettingsPreferenceScreen; + private Preference codecDefault; + 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; + private SwitchPreference vp9Override; + private PreferenceScreen xSwipeControlPreferenceScreen; + private boolean Registered = false; + private boolean settingsInitialized = false; + + private final CharSequence[] videoQualityEntries = {"Auto", "144p", "240p", "360p", "480p", "720p", "1080p", "1440p", "2160p"}; + private final CharSequence[] videoQualityentryValues = {"-2", "144", "240", "360", "480", "720", "1080", "1440", "2160"}; + private final CharSequence[] minimizedVideoEntries = {"Auto", "Video only", "Video with controls"}; + private final CharSequence[] minimizedVideoentryValues = {"-2", "0", "1"}; + private final CharSequence[] videoSpeedEntries = {"Auto", "0.25x", "0.5x", "0.75x", "Normal", "1.25x", "1.5x", "1.75x", "2x", "3x", "4x", "5x"}; + private final CharSequence[] videoSpeedentryValues = {"-2", "0.25", "0.5", "0.75", "1.0", "1.25", "1.5", "1.75", "2.0", "3.0", "4.0", "5.0"}; + private final CharSequence[] buttonLocationEntries = {"None", "In player", "Under player", "Both"}; + private final CharSequence[] buttonLocationentryValues = {"NONE", "PLAYER", "BUTTON_BAR", "BOTH"}; + + 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) { + rebootDialog(getActivity()); + } + } else if (str.equals(SettingsEnum.VIDEO_ADS_SHOWN_BOOLEAN.getPath())) { + SettingsEnum.VIDEO_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) adsSettingsPreferenceScreen.findPreference(str)).isChecked()); + if (ReVancedUtils.getContext() != null && settingsInitialized) { + rebootDialog(getActivity()); + } + } else if (str.equals(SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.getPath())) { + SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked()); + if (ReVancedUtils.getContext() != null && settingsInitialized) { + rebootDialog(getActivity()); + } + } else if (str.equals(SettingsEnum.SUGGESTIONS_SHOWN_BOOLEAN.getPath())) { + SettingsEnum.SUGGESTIONS_SHOWN_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked()); + } else if (str.equals(SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.getPath())) { + SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked()); + } else if (str.equals(SettingsEnum.BRANDING_SHOWN_BOOLEAN.getPath())) { + SettingsEnum.BRANDING_SHOWN_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked()); + } else if (str.equals(SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.getPath())) { + SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked()); + } else if (str.equals(SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.getPath())) { + SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked()); + if (ReVancedUtils.getContext() != null && settingsInitialized) { + rebootDialog(getActivity()); + } + } else if (str.equals(SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getPath())) { + SwitchPreference switchPreference = (SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str); + SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.setValue(switchPreference.isChecked()); + if (ReVancedUtils.getContext() != null && settingsInitialized) { + rebootDialog(getActivity()); + } + } else if (str.equals(SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.getPath())) { + SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked()); + if (ReVancedUtils.getContext() != null && settingsInitialized) { + rebootDialog(getActivity()); + } + } else if (str.equals(SettingsEnum.PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER.getPath())) { + ListPreference listPreference = (ListPreference) layoutSettingsPreferenceScreen.findPreference(str); + int index = SettingsEnum.PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER.getInt(); + listPreference.setDefaultValue(SettingsEnum.PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER.getDefaultValue()); + listPreference.setSummary(minimizedVideoEntries[listPreference.findIndexOfValue(String.valueOf(index))]); + if (ReVancedUtils.getContext() != null && settingsInitialized) { + rebootDialog(getActivity()); + } + } else if (str.equals(SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getPath())) { + SettingsEnum.CODEC_OVERRIDE_BOOLEAN.setValue(((SwitchPreference) findPreference(str)).isChecked()); + if (ReVancedUtils.getContext() != null && settingsInitialized) { + rebootDialog(getActivity()); + } + } else if (str.equals(SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.getPath())) { + ListPreference listPreference2 = (ListPreference) videoSettingsPreferenceScreen.findPreference(str); + int index = SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.getInt(); + listPreference2.setDefaultValue(index); + listPreference2.setSummary(videoQualityEntries[listPreference2.findIndexOfValue(String.valueOf(index))]); + SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.setValue(index); + } else if (str.equals(SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.getPath())) { + ListPreference listPreference2 = (ListPreference) videoSettingsPreferenceScreen.findPreference(str); + int index = SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.getInt(); + listPreference2.setDefaultValue(index); + listPreference2.setSummary(videoQualityEntries[listPreference2.findIndexOfValue(String.valueOf(index))]); + SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.setValue(index); + } else if (str.equals(SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getPath())) { + ListPreference listPreference4 = (ListPreference) videoSettingsPreferenceScreen.findPreference(str); + Float value = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat(); + listPreference4.setDefaultValue(value); + listPreference4.setSummary(videoSpeedEntries[listPreference4.findIndexOfValue(String.valueOf(value))]); + SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.setValue(value); + } else if (str.equals(SettingsEnum.MAX_BUFFER_INTEGER.getPath())) { + EditTextPreference editTextPreference3 = (EditTextPreference) bufferSettingsPreferenceScreen.findPreference(str); + if (editTextPreference3 != null) { + editTextPreference3.setSummary(editTextPreference3.getText()); + SettingsEnum.MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference3.getText())); + } + } else if (str.equals(SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.getPath())) { + EditTextPreference editTextPreference4 = (EditTextPreference) ReVancedSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference(str); + if (editTextPreference4 != null) { + editTextPreference4.setSummary(editTextPreference4.getText()); + SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference4.getText())); + } + } else if (str.equals(SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.getPath())) { + EditTextPreference editTextPreference5 = (EditTextPreference) ReVancedSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference(str); + if (editTextPreference5 != null) { + editTextPreference5.setSummary(editTextPreference5.getText()); + SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference5.getText())); + } + } else if (str.equals(SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.getPath())) { + SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.setValue(((SwitchPreference) miscsPreferenceScreen.findPreference(str)).isChecked()); + } else if (str.equals(SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getPath())) { + SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.setValue(((SwitchPreference) xSwipeControlPreferenceScreen.findPreference(str)).isChecked()); + } else if (str.equals(SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getPath())) { + SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.setValue(((SwitchPreference) xSwipeControlPreferenceScreen.findPreference(str)).isChecked()); + } else if (str.equals(SettingsEnum.SWIPE_USE_TABLET_MODE.getPath())) { + SettingsEnum.SWIPE_USE_TABLET_MODE.setValue(((SwitchPreference) xSwipeControlPreferenceScreen.findPreference(str)).isChecked()); + } else if (str.equals(SettingsEnum.SWIPE_THRESHOLD_INTEGER.getPath())) { + EditTextPreference editTextPreference6 = (EditTextPreference) xSwipeControlPreferenceScreen.findPreference(str); + if (editTextPreference6 != null) { + int val = 0; + editTextPreference6.setSummary(editTextPreference6.getText()); + try { + val = Integer.parseInt(editTextPreference6.getText()); + } catch (NumberFormatException unused) { + val = 0; + } + SwipeGestureListener.SWIPE_THRESHOLD = val; + SettingsEnum.SWIPE_THRESHOLD_INTEGER.setValue(val); + } + } else if (str.equals(SettingsEnum.SWIPE_PADDING_TOP_INTEGER.getPath())) { + EditTextPreference editTextPreference6 = (EditTextPreference) xSwipeControlPreferenceScreen.findPreference(str); + if (editTextPreference6 != null) { + int val = 0; + editTextPreference6.setSummary(editTextPreference6.getText()); + try { + val = Integer.parseInt(editTextPreference6.getText()); + } catch (NumberFormatException unused) { + val = 0; + } + SwipeGestureListener.TOP_PADDING = val; + SettingsEnum.SWIPE_PADDING_TOP_INTEGER.setValue(val); + } + } else if ("vanced_ryd_enabled".equals(str) && ReVancedUtils.getContext() != null && settingsInitialized) { + rebootDialog(ReVancedSettingsFragment.this.getActivity()); + } else if (str.equals("pref_auto_repeat_button")) { + AutoRepeatLinks(); + } else if ("pref_auto_repeat".equals(str)) { + AutoRepeat.changeSelected(sharedPreferences.getBoolean("pref_auto_repeat", false), true); + } else if ("pref_copy_video_url_timestamp_button_list".equals(str)) { + CopyWithTimeStamp.refreshShouldBeShown(); + } else if ("pref_copy_video_url_button_list".equals(str)) { + Copy.refreshShouldBeShown(); + } + }; + + @SuppressLint("ResourceType") + @Override // android.preference.PreferenceFragment, android.app.Fragment + public void onCreate(Bundle bundle) { + super.onCreate(bundle); + getPreferenceManager().setSharedPreferencesName("youtube"); + try { + int identifier = getResources().getIdentifier("xfile_prefs", "xml", getPackageName()); + + addPreferencesFromResource(identifier); + String stringByName = ReVancedUtils.getStringByName(getActivity(), "quality_auto"); + this.videoQualityEntries[0] = stringByName; + this.minimizedVideoEntries[0] = stringByName; + this.videoSpeedEntries[0] = stringByName; + String stringByName2 = ReVancedUtils.getStringByName(getActivity(), "pref_subtitles_scale_normal"); + if (stringByName2.equals("")) { + this.videoSpeedEntries[4] = "Normal"; + } else { + this.videoSpeedEntries[4] = stringByName2; + } + this.minimizedVideoEntries[1] = ReVancedUtils.getStringByName(getActivity(), "xfile_miniplayer_style_video"); + this.minimizedVideoEntries[2] = ReVancedUtils.getStringByName(getActivity(), "xfile_miniplayer_style_video_controls"); + SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences(); + this.sharedPreferences = sharedPreferences; + this.settingsInitialized = sharedPreferences.getBoolean("xfile_initialized", false); + this.sharedPreferences.registerOnSharedPreferenceChangeListener(this.listener); + this.Registered = true; + this.codecPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("codec_override"); + this.videoSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("video_settings"); + this.videoAdSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("video_ad_settings"); + this.adsSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("ad_settings"); + this.layoutSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("layout_settings"); + this.bufferSettingsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("buffer_screen"); + this.miscsPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("misc_screen"); + this.xSwipeControlPreferenceScreen = (PreferenceScreen) getPreferenceScreen().findPreference("xfenster_screen"); + this.vp9Override = (SwitchPreference) this.codecPreferenceScreen.findPreference("vp9_xfile_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); + setListPreferenceData(listPreference2, false); + + listPreference.setOnPreferenceClickListener(preference -> { + ReVancedSettingsFragment.this.setListPreferenceData(listPreference, true); + return false; + }); + + listPreference2.setOnPreferenceClickListener(preference -> { + ReVancedSettingsFragment.this.setListPreferenceData(listPreference2, false); + return false; + }); + final ListPreference listPreference3 = (ListPreference) this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_speed"); + setSpeedListPreferenceData(listPreference3); + + listPreference3.setOnPreferenceClickListener(preference -> { + ReVancedSettingsFragment.this.setSpeedListPreferenceData(listPreference3); + return false; + }); + Preference findPreference = findPreference("pref_about_field"); + + this.codecDefault.setOnPreferenceClickListener(preference -> { + ReVancedSettingsFragment.this.ChangeCodec(preference); + return false; + }); + + this.codecVP9.setOnPreferenceClickListener(preference -> { + ReVancedSettingsFragment.this.ChangeCodec(preference); + return false; + }); + + if (ScreenSizeHelper.isTablet(ReVancedUtils.getContext())) { + if (this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer") != null) { + this.layoutSettingsPreferenceScreen.removePreference(this.tabletMiniplayer); + } + } + + + this.sharedPreferences.edit().putBoolean("xfile_initialized", true); + this.settingsInitialized = true; + } catch (Throwable th) { + LogHelper.printException("XSettingsFragment", "Unable to retrieve resourceId for xfile_prefs", th); + } + } + + @Override // android.preference.PreferenceFragment, android.app.Fragment + public void onDestroy() { + if (this.Registered) { + this.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this.listener); + this.Registered = false; + } + super.onDestroy(); + } + + protected void setListPreferenceData(ListPreference listPreference, boolean z) { + listPreference.setEntries(this.videoQualityEntries); + listPreference.setEntryValues(this.videoQualityentryValues); + String string = this.sharedPreferences.getString(z ? "pref_preferred_video_quality_wifi" : "pref_preferred_video_quality_mobile", "-2"); + if (listPreference.getValue() == null) { + listPreference.setValue(string); + } + listPreference.setSummary(this.videoQualityEntries[listPreference.findIndexOfValue(string)]); + } + + protected void setMinimizedListPreferenceData(ListPreference listPreference) { + listPreference.setEntries(this.minimizedVideoEntries); + listPreference.setEntryValues(this.minimizedVideoentryValues); + String string = this.sharedPreferences.getString("pref_minimized_video_preview", "-2"); + if (listPreference.getValue() == null) { + listPreference.setValue(string); + } + listPreference.setSummary(this.minimizedVideoEntries[listPreference.findIndexOfValue(string)]); + } + + protected void setSpeedListPreferenceData(ListPreference listPreference) { + listPreference.setEntries(this.videoSpeedEntries); + listPreference.setEntryValues(this.videoSpeedentryValues); + String string = this.sharedPreferences.getString("pref_preferred_video_speed", "-2"); + if (listPreference.getValue() == null) { + listPreference.setValue(string); + } + listPreference.setSummary(this.videoSpeedEntries[listPreference.findIndexOfValue(string)]); + } + + protected void setCopyLinkListPreferenceData(ListPreference listPreference, String str) { + listPreference.setEntries(this.buttonLocationEntries); + listPreference.setEntryValues(this.buttonLocationentryValues); + String string = this.sharedPreferences.getString(str, "NONE"); + if (listPreference.getValue() == null) { + listPreference.setValue(string); + } + listPreference.setSummary(this.buttonLocationEntries[listPreference.findIndexOfValue(string)]); + } + + private String getPackageName() { + Context context = YouTubeTikTokRoot_Application.getAppContext(); + if (context == null) { + LogHelper.printException("Settings", "Context is null, returning com.google.android.youtube!"); + return "com.google.android.youtube"; + } + String PACKAGE_NAME = context.getPackageName(); + LogHelper.debug("Settings", "getPackageName: " + PACKAGE_NAME); + + return PACKAGE_NAME; + } + + private void ChangeCodec(Preference preference) { + String manufacturer = null; + String model = null; + + String key = preference.getKey(); + if (key.equals("pref_vp9_override")) { + manufacturer = "samsung"; + model = "SM-G920F"; + } + + 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"); + if (switchPreference == null) { + return; + } + if (z) { + switchPreference.setEnabled(false); + AutoRepeat.isAutoRepeatBtnEnabled = true; + return; + } + switchPreference.setEnabled(true); + AutoRepeat.isAutoRepeatBtnEnabled = false; + } + + private void reboot(Activity activity, Class homeActivityClass) { + int intent; + intent = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE; + ((AlarmManager) activity.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME, 1500L, PendingIntent.getActivity(activity, 0, new Intent(activity, homeActivityClass), intent)); + Process.killProcess(Process.myPid()); + } + + private void rebootDialog(final Activity activity) { + new AlertDialog.Builder(activity).setMessage(ReVancedUtils.getStringByName(activity, "pref_refresh_config")).setPositiveButton(ReVancedUtils.getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> reboot(activity, ReVancedSettingsFragment.homeActivityClass)).setNegativeButton(ReVancedUtils.getStringByName(activity, "sign_in_cancel"), null).show(); + } + +} diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockPreferenceFragment.java b/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java similarity index 98% rename from app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockPreferenceFragment.java rename to app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java index 1611ccc781..63b91f41de 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockPreferenceFragment.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/SponsorBlockSettingsFragment.java @@ -1,4 +1,4 @@ -package app.revanced.integrations.sponsorblock; +package app.revanced.integrations.settingsmenu; import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_API_URL; import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP; @@ -50,12 +50,14 @@ import app.revanced.integrations.adremover.whitelist.WhitelistType; import app.revanced.integrations.settings.Settings; import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.sponsorblock.SponsorBlockSettings; +import app.revanced.integrations.sponsorblock.SponsorBlockUtils; import app.revanced.integrations.utils.SharedPrefHelper; import app.revanced.integrations.sponsorblock.objects.EditTextListPreference; import app.revanced.integrations.sponsorblock.requests.SBRequester; @SuppressWarnings({"unused", "deprecation"}) // injected -public class SponsorBlockPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { +public class SponsorBlockSettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public static final DecimalFormat FORMATTER = new DecimalFormat("#,###,###"); public static final String SAVED_TEMPLATE = "%dh %.1f %s"; private static final APIURLChangeListener API_URL_CHANGE_LISTENER = new APIURLChangeListener(); diff --git a/app/src/main/java/app/revanced/integrations/theme/XSettingActivity.java b/app/src/main/java/app/revanced/integrations/settingsmenu/XSettingActivity.java similarity index 80% rename from app/src/main/java/app/revanced/integrations/theme/XSettingActivity.java rename to app/src/main/java/app/revanced/integrations/settingsmenu/XSettingActivity.java index d85650e0ee..222169f5e7 100644 --- a/app/src/main/java/app/revanced/integrations/theme/XSettingActivity.java +++ b/app/src/main/java/app/revanced/integrations/settingsmenu/XSettingActivity.java @@ -1,4 +1,4 @@ -package app.revanced.integrations.theme; +package app.revanced.integrations.settingsmenu; import android.app.Activity; import android.content.Context; @@ -9,24 +9,19 @@ import android.widget.ImageButton; import android.widget.TextView; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.settings.XSettingsFragment; -import app.revanced.integrations.ryd.RYDFragment; -import app.revanced.integrations.sponsorblock.SponsorBlockPreferenceFragment; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.ThemeHelper; /* loaded from: classes6.dex */ public class XSettingActivity extends Activity { private static Context context; - boolean currentTheme; + private boolean currentTheme; @Override // android.app.Activity protected void onCreate(Bundle bundle) { - boolean isDarkTheme = ThemeHelper.isDarkTheme(); - this.currentTheme = isDarkTheme; - if (isDarkTheme) { + this.currentTheme = ThemeHelper.isDarkTheme(); + if (currentTheme) { LogHelper.debug("XSettingsActivity", "set Theme.YouTube.Settings.Dark"); setTheme(getIdentifier("Theme.YouTube.Settings.Dark", "style")); } else { @@ -39,48 +34,17 @@ protected void onCreate(Bundle bundle) { String dataString = getIntent().getDataString(); if (dataString.equalsIgnoreCase("sponsorblock_settings")) { trySetTitle(getIdentifier("sb_settings", "string")); - getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new SponsorBlockPreferenceFragment()).commit(); + getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new SponsorBlockSettingsFragment()).commit(); } else if (dataString.equalsIgnoreCase("ryd_settings")) { trySetTitle(getIdentifier("vanced_ryd_settings_title", "string")); - getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new RYDFragment()).commit(); + getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new RYDSettingsFragment()).commit(); } else { trySetTitle(getIdentifier("xfile_settings", "string")); - getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new XSettingsFragment()).commit(); + getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new ReVancedSettingsFragment()).commit(); } context = getApplicationContext(); } - private void trySetTitle(int i) { - try { - getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(i); - } catch (Exception e) { - LogHelper.printException("XSettingsActivity", "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("XSettingsActivity", "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.XSettingActivity.1 - @Override // android.view.View.OnClickListener - public void onClick(View view) { - XSettingActivity.this.onBackPressed(); - } - }); - imageButton.setImageDrawable(getResources().getDrawable(getIdentifier(z ? "quantum_ic_arrow_back_white_24" : "quantum_ic_arrow_back_grey600_24", "drawable"))); - } catch (Exception e) { - LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar click handler", e); - } - } - public static ImageButton getImageButton(ViewGroup viewGroup) { if (viewGroup == null) { return null; @@ -110,16 +74,39 @@ public static TextView getTextView(ViewGroup viewGroup) { } private static int getIdentifier(String str, String str2) { - Context appContext = YouTubeTikTokRoot_Application.getAppContext(); + Context appContext = ReVancedUtils.getContext(); return appContext.getResources().getIdentifier(str, str2, appContext.getPackageName()); } - public static Context getAppContext() { - Context context2 = context; - if (context2 != null) { - return context2; + private void trySetTitle(int i) { + try { + getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(i); + } catch (Exception e) { + LogHelper.printException("XSettingsActivity", "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("XSettingsActivity", "Couldn't set Toolbar title", e); } - LogHelper.printException("WatchWhileActivity", "Context is null!"); - return null; } + + 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.XSettingActivity.1 + @Override // android.view.View.OnClickListener + public void onClick(View view) { + XSettingActivity.this.onBackPressed(); + } + }); + imageButton.setImageDrawable(getResources().getDrawable(getIdentifier(z ? "quantum_ic_arrow_back_white_24" : "quantum_ic_arrow_back_grey600_24", "drawable"))); + } catch (Exception e) { + LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar click handler", e); + } + } + } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/PlayerController.java b/app/src/main/java/app/revanced/integrations/sponsorblock/PlayerController.java index 8e61fb2dd2..d359630e8d 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/PlayerController.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/PlayerController.java @@ -16,8 +16,6 @@ import android.view.View; import android.view.ViewGroup; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -30,6 +28,7 @@ import app.revanced.integrations.adremover.whitelist.Whitelist; import app.revanced.integrations.sponsorblock.objects.SponsorSegment; import app.revanced.integrations.sponsorblock.requests.SBRequester; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; @SuppressLint({"LongLogTag"}) @@ -66,7 +65,7 @@ public static void setCurrentVideoId(final String videoId) { return; } - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); if (context == null) { LogHelper.printException("PlayerController", "context is null"); return; @@ -274,7 +273,7 @@ public void run() { private static void sendViewRequestAsync(final long millis, final SponsorSegment segment) { if (segment.category != SponsorBlockSettings.SegmentInfo.UNSUBMITTED) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); if (context != null) { long newSkippedTime = skippedTime + (segment.end - segment.start); SharedPrefHelper.saveInt(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS, skippedSegments + 1); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/ShieldButton.java b/app/src/main/java/app/revanced/integrations/sponsorblock/ShieldButton.java index 6c664a1793..e57bc10490 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/ShieldButton.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/ShieldButton.java @@ -8,14 +8,13 @@ import android.widget.ImageView; import android.widget.RelativeLayout; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import java.lang.ref.WeakReference; import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength; import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime; import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; public class ShieldButton { static RelativeLayout _youtubeControlsLayout; @@ -101,16 +100,16 @@ static boolean shouldBeShown() { //region Helpers private static int getIdentifier(String name, String defType) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); return context.getResources().getIdentifier(name, defType, context.getPackageName()); } private static int getInteger(String name) { - return YouTubeTikTokRoot_Application.getAppContext().getResources().getInteger(getIdentifier(name, "integer")); + return ReVancedUtils.getContext().getResources().getInteger(getIdentifier(name, "integer")); } private static Animation getAnimation(String name) { - return AnimationUtils.loadAnimation(YouTubeTikTokRoot_Application.getAppContext(), getIdentifier(name, "anim")); + return AnimationUtils.loadAnimation(ReVancedUtils.getContext(), getIdentifier(name, "anim")); } //endregion } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/SkipSegmentView.java b/app/src/main/java/app/revanced/integrations/sponsorblock/SkipSegmentView.java index 3ae1865e56..6151b250d6 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SkipSegmentView.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SkipSegmentView.java @@ -6,10 +6,9 @@ import android.widget.Toast; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.sponsorblock.objects.SponsorSegment; +import app.revanced.integrations.utils.ReVancedUtils; import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.hideSkipButton; import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.showSkipButton; @@ -36,7 +35,7 @@ public static void notifySkipped(SponsorSegment segment) { } lastNotifiedSegment = segment; String skipMessage = segment.category.skipMessage.toString(); - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); if (VERBOSE) LogHelper.debug("SkipSegmentView", String.format("notifySkipped; message=%s", skipMessage)); diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java index d6709f2f54..e79b581fb9 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/SponsorBlockUtils.java @@ -7,8 +7,8 @@ import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength; import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime; import static app.revanced.integrations.sponsorblock.PlayerController.sponsorSegmentsOfCurrentVideo; -import static app.revanced.integrations.sponsorblock.SponsorBlockPreferenceFragment.FORMATTER; -import static app.revanced.integrations.sponsorblock.SponsorBlockPreferenceFragment.SAVED_TEMPLATE; +import static app.revanced.integrations.settingsmenu.SponsorBlockSettingsFragment.FORMATTER; +import static app.revanced.integrations.settingsmenu.SponsorBlockSettingsFragment.SAVED_TEMPLATE; import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_API_URL; import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_SERVER_URL; import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_API_URL; diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/VotingButton.java b/app/src/main/java/app/revanced/integrations/sponsorblock/VotingButton.java index bd1a8580b5..9c0ea3e615 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/VotingButton.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/VotingButton.java @@ -8,14 +8,13 @@ import android.widget.ImageView; import android.widget.RelativeLayout; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import java.lang.ref.WeakReference; import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength; import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime; import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; public class VotingButton { static RelativeLayout _youtubeControlsLayout; @@ -99,16 +98,16 @@ static boolean shouldBeShown() { //region Helpers private static int getIdentifier(String name, String defType) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); return context.getResources().getIdentifier(name, defType, context.getPackageName()); } private static int getInteger(String name) { - return YouTubeTikTokRoot_Application.getAppContext().getResources().getInteger(getIdentifier(name, "integer")); + return ReVancedUtils.getContext().getResources().getInteger(getIdentifier(name, "integer")); } private static Animation getAnimation(String name) { - return AnimationUtils.loadAnimation(YouTubeTikTokRoot_Application.getAppContext(), getIdentifier(name, "anim")); + return AnimationUtils.loadAnimation(ReVancedUtils.getContext(), getIdentifier(name, "anim")); } //endregion } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/player/VideoHelpers.java b/app/src/main/java/app/revanced/integrations/sponsorblock/player/VideoHelpers.java index 65e4622463..d66121c4cd 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/player/VideoHelpers.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/player/VideoHelpers.java @@ -3,11 +3,10 @@ import android.content.Context; import android.widget.Toast; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import static app.revanced.integrations.sponsorblock.StringRef.str; import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; public class VideoHelpers { @@ -35,9 +34,9 @@ private static void generateVideoUrl(boolean appendTimeStamp) { LogHelper.debug("VideoHelpers", "Video URL: " + videoUrl); - setClipboard(YouTubeTikTokRoot_Application.getAppContext(), videoUrl); + setClipboard(ReVancedUtils.getContext(), videoUrl); - Toast.makeText(YouTubeTikTokRoot_Application.getAppContext(), str("share_copy_url_success"), Toast.LENGTH_SHORT).show(); + Toast.makeText(ReVancedUtils.getContext(), str("share_copy_url_success"), Toast.LENGTH_SHORT).show(); } catch (Exception ex) { LogHelper.printException("VideoHelpers", "Couldn't generate video url", ex); } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SponsorBlockView.java b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SponsorBlockView.java index 259947c331..9b317104d2 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SponsorBlockView.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SponsorBlockView.java @@ -6,12 +6,11 @@ import android.view.ViewGroup; import android.widget.RelativeLayout; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import java.lang.ref.WeakReference; import app.revanced.integrations.sponsorblock.player.PlayerType; import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SwipeHelper; public class SponsorBlockView { @@ -68,9 +67,9 @@ public static void playerTypeChanged(PlayerType playerType) { } private static void addView() { - inlineSponsorOverlay = new RelativeLayout(YouTubeTikTokRoot_Application.getAppContext()); + inlineSponsorOverlay = new RelativeLayout(ReVancedUtils.getContext()); setLayoutParams(inlineSponsorOverlay); - LayoutInflater.from(YouTubeTikTokRoot_Application.getAppContext()).inflate(getIdentifier("inline_sponsor_overlay", "layout"), inlineSponsorOverlay); + LayoutInflater.from(ReVancedUtils.getContext()).inflate(getIdentifier("inline_sponsor_overlay", "layout"), inlineSponsorOverlay); _youtubeOverlaysLayout.addView(inlineSponsorOverlay, _youtubeOverlaysLayout.getChildCount() - 2); @@ -165,7 +164,7 @@ private static void checkLayout() { } private static int getIdentifier(String name, String defType) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); return context.getResources().getIdentifier(name, defType, context.getPackageName()); } } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SponsorBlockVoting.java b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SponsorBlockVoting.java index b974a0f94e..01a860f71f 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SponsorBlockVoting.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/player/ui/SponsorBlockVoting.java @@ -5,8 +5,6 @@ import android.view.ViewGroup; import android.widget.Toast; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.utils.ReVancedUtils; public class SponsorBlockVoting extends SlimButton { @@ -23,6 +21,6 @@ private void initialize() { @Override public void onClick(View view) { - Toast.makeText(YouTubeTikTokRoot_Application.getAppContext(), "Nothing atm", Toast.LENGTH_SHORT).show(); + Toast.makeText(ReVancedUtils.getContext(), "Nothing atm", Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/app/revanced/integrations/sponsorblock/requests/SBRequester.java b/app/src/main/java/app/revanced/integrations/sponsorblock/requests/SBRequester.java index 703446f039..f414ca0e15 100644 --- a/app/src/main/java/app/revanced/integrations/sponsorblock/requests/SBRequester.java +++ b/app/src/main/java/app/revanced/integrations/sponsorblock/requests/SBRequester.java @@ -13,8 +13,6 @@ import android.preference.PreferenceCategory; import android.widget.Toast; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import org.json.JSONArray; import org.json.JSONObject; @@ -33,6 +31,7 @@ import app.revanced.integrations.sponsorblock.SponsorBlockUtils.VoteOption; import app.revanced.integrations.sponsorblock.objects.SponsorSegment; import app.revanced.integrations.sponsorblock.objects.UserStats; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; public class SBRequester { @@ -209,7 +208,7 @@ public static void runVipCheck() { SponsorBlockSettings.vip = vip; SponsorBlockSettings.lastVipCheck = now; - SharedPreferences.Editor edit = SharedPrefHelper.getPreferences(YouTubeTikTokRoot_Application.getAppContext(), SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit(); + SharedPreferences.Editor edit = SharedPrefHelper.getPreferences(ReVancedUtils.getContext(), SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit(); edit.putString(SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK, String.valueOf(now)); edit.putBoolean(SponsorBlockSettings.PREFERENCES_KEY_IS_VIP, vip); edit.apply(); diff --git a/app/src/main/java/app/revanced/integrations/utils/Globals.java b/app/src/main/java/app/revanced/integrations/utils/Globals.java deleted file mode 100644 index b1416f2367..0000000000 --- a/app/src/main/java/app/revanced/integrations/utils/Globals.java +++ /dev/null @@ -1,18 +0,0 @@ -package app.revanced.integrations.utils; - -import android.content.Context; - -import app.revanced.integrations.utils.LogHelper; - - -public class Globals { - public static Context context; - - public static Context getAppContext() { - if (context != null) { - return context; - } - LogHelper.printException("Globals", "Context is null!"); - return null; - } -} \ No newline at end of file diff --git a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java b/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java index bdf351ea44..92d2d34165 100644 --- a/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java +++ b/app/src/main/java/app/revanced/integrations/utils/ReVancedUtils.java @@ -1,24 +1,116 @@ package app.revanced.integrations.utils; +import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; -import android.content.SharedPreferences; -import android.content.pm.PackageInfo; +import android.content.DialogInterface; import android.content.pm.PackageManager; +import android.content.res.Resources; +import android.os.Build; import android.os.Handler; import android.os.Looper; import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; -import java.security.SecureRandom; +import app.revanced.integrations.sponsorblock.player.PlayerType; public class ReVancedUtils { + private static PlayerType env; + + //Used by Integrations patch + public static Context context; + //Used by Integrations patch + public static Context getAppContext() { + if (context != null) { + return context; + } + LogHelper.printException("Globals", "Context is null!"); + return null; + } + + public static String getStringByName(Context context, String name) { + try { + Resources res = context.getResources(); + return res.getString(res.getIdentifier(name, "string", context.getPackageName())); + } catch (Throwable exception) { + LogHelper.printException("Settings", "Resource not found.", exception); + return ""; + } + } + + public static void setPlayerType(PlayerType type) { + env = type; + } + + public static PlayerType getPlayerType() { + return env; + } + public static int getIdentifier(String name, String defType) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = getContext(); return context.getResources().getIdentifier(name, defType, context.getPackageName()); } public static void runOnMainThread(Runnable runnable) { new Handler(Looper.getMainLooper()).post(runnable); } + + public static void CheckForMicroG(Activity activity) { + AlertDialog.Builder builder; + if (!appInstalledOrNot("com.mgoogle.android.gms")) { + LogHelper.debug("XDebug", "Custom MicroG installation undetected"); + if (Build.VERSION.SDK_INT >= 21) { + builder = new AlertDialog.Builder(activity, 16974374); + } else { + builder = new AlertDialog.Builder(activity); + } + builder.setTitle("Someone is not reading...").setMessage("You didn't install the MicroG as instructed, you can't login without it.\n\nInstall it and try again.").setPositiveButton("Close", new DialogInterface.OnClickListener() { // from class: app.revanced.integrations.settings.Settings.1 + @Override // android.content.DialogInterface.OnClickListener + public void onClick(DialogInterface dialog, int id) { + } + }).show(); + } else { + LogHelper.debug("XDebug", "Custom MicroG installation detected"); + } + } + + private static boolean appInstalledOrNot(String uri) { + try { + PackageManager pm = getContext().getPackageManager(); + pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); + return true; + } catch (PackageManager.NameNotFoundException e) { + return false; + } + } + + public static Context getContext() { + Context context = YouTubeTikTokRoot_Application.getAppContext(); + if (context != null) { + return context; + } else { + LogHelper.printException("Settings", "Context is null, returning null!"); + return null; + } + } + + //Not used atm + /*public static String getManufacturer() { + String manufacturer = SettingsEnum.MANUFACTURER_OVERRIDE_STRING.getString(); + if (manufacturer == null || manufacturer.isEmpty()) { + manufacturer = Build.MANUFACTURER; + } + LogHelper.debug("Settings", "getManufacturer: " + manufacturer); + return manufacturer; + } + + public static String getModel() { + String model = SettingsEnum.MODEL_OVERRIDE_STRING.getString(); + if (model == null || model.isEmpty()) { + model = Build.MODEL; + } + LogHelper.debug("Settings", "getModel: " + model); + return model; + }*/ } \ No newline at end of file diff --git a/app/src/main/java/app/revanced/integrations/utils/SwipeHelper.java b/app/src/main/java/app/revanced/integrations/utils/SwipeHelper.java index 1f0768c222..b203ee3750 100644 --- a/app/src/main/java/app/revanced/integrations/utils/SwipeHelper.java +++ b/app/src/main/java/app/revanced/integrations/utils/SwipeHelper.java @@ -7,9 +7,7 @@ import android.view.ViewGroup; import android.widget.FrameLayout; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - -import app.revanced.integrations.settings.Settings; +import app.revanced.integrations.sponsorblock.player.PlayerType; /* loaded from: classes6.dex */ public class SwipeHelper { @@ -20,7 +18,7 @@ public class SwipeHelper { public static void SetFrameLayout(Object obj) { try { _frameLayout = (FrameLayout) obj; - Context appContext = YouTubeTikTokRoot_Application.getAppContext(); + Context appContext = ReVancedUtils.getContext(); if (ScreenSizeHelper.isTablet(appContext) || SharedPrefHelper.getBoolean(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"pref_xfenster_tablet", false)) { isTabletMode = true; } @@ -56,7 +54,7 @@ public static boolean IsControlsShown() { private static void refreshLayout() { View findViewById; try { - if (Settings.isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) { + if (isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) { _frameLayout = (FrameLayout) findViewById.getParent(); LogHelper.debug("Settings", "related_endscreen_results refreshed"); } @@ -65,6 +63,14 @@ private static void refreshLayout() { } } + + private static boolean isWatchWhileFullScreen() { + if (ReVancedUtils.getPlayerType() == null) { + return false; + } + return ReVancedUtils.getPlayerType() == PlayerType.WATCH_WHILE_FULLSCREEN; + } + private static String getViewMessage(View view) { try { String resourceName = view.getResources() != null ? view.getId() != 0 ? view.getResources().getResourceName(view.getId()) : "no_id" : "no_resources"; @@ -75,7 +81,7 @@ private static String getViewMessage(View view) { } private static int getIdentifier() { - Context appContext = YouTubeTikTokRoot_Application.getAppContext(); + Context appContext = ReVancedUtils.getContext(); assert appContext != null; return appContext.getResources().getIdentifier("related_endscreen_results", "id", appContext.getPackageName()); } diff --git a/app/src/main/java/app/revanced/integrations/utils/ThemeHelper.java b/app/src/main/java/app/revanced/integrations/utils/ThemeHelper.java index 6c5c0b4daa..0aefdf5236 100644 --- a/app/src/main/java/app/revanced/integrations/utils/ThemeHelper.java +++ b/app/src/main/java/app/revanced/integrations/utils/ThemeHelper.java @@ -2,15 +2,11 @@ import android.os.Build; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import java.util.Objects; -import app.revanced.integrations.utils.LogHelper; - /* loaded from: classes6.dex */ public class ThemeHelper { - static int themeValue; + private static int themeValue; public static void setTheme(int value) { themeValue = value; @@ -26,11 +22,4 @@ public static boolean isDarkTheme() { return themeValue == 1; } - public static boolean isNightDarkMode() { - return (Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()).getResources().getConfiguration().uiMode & 48) == 32; - } - - public static boolean isAbovePie() { - return Build.VERSION.SDK_INT > 28; - } } diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/autorepeat/AutoRepeat.java b/app/src/main/java/app/revanced/integrations/videoplayer/autorepeat/AutoRepeat.java index dcfaaec157..287dd4dafd 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/autorepeat/AutoRepeat.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/autorepeat/AutoRepeat.java @@ -9,10 +9,9 @@ import androidx.constraintlayout.widget.ConstraintLayout; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; import app.revanced.integrations.videoplayer.videourl.Copy; import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp; @@ -106,7 +105,7 @@ public static void changeSelected(boolean selected, boolean onlyView) { } private static boolean shouldBeSelected() { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); if (context == null) { LogHelper.printException("AutoRepeat", "ChangeSelected - context is null!"); return false; @@ -115,12 +114,12 @@ private static boolean shouldBeSelected() { } private static void setSelected(boolean selected) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_auto_repeat", selected); } private static boolean shouldBeShown() { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); if (context == null) { LogHelper.printException("AutoRepeat", "ChangeSelected - context is null!"); return false; @@ -129,17 +128,17 @@ private static boolean shouldBeShown() { } private static int getIdentifier(String name, String defType) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); return context.getResources().getIdentifier(name, defType, context.getPackageName()); } private static int getInteger(String name) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); return context.getResources().getInteger(getIdentifier(name, "integer")); } private static Animation getAnimation(String name) { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); return AnimationUtils.loadAnimation(context, getIdentifier(name, "anim")); } } diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/settings/XReboot.java b/app/src/main/java/app/revanced/integrations/videoplayer/settings/XReboot.java deleted file mode 100644 index 8aa47a4c62..0000000000 --- a/app/src/main/java/app/revanced/integrations/videoplayer/settings/XReboot.java +++ /dev/null @@ -1,33 +0,0 @@ -package app.revanced.integrations.videoplayer.settings; - -import android.app.Activity; -import android.app.AlarmManager; -import android.app.AlertDialog; -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; -import android.os.Process; - -import app.revanced.integrations.settings.Settings; -import app.revanced.integrations.settings.XSettingsFragment; - -/* loaded from: classes6.dex */ -public class XReboot { - - /** - * @param homeActivityClass Shell_HomeActivity.class - */ - static void Reboot(Activity activity, Class homeActivityClass) { - int intent; - intent = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE; - ((AlarmManager) activity.getSystemService(Context.ALARM_SERVICE)).setExact(AlarmManager.ELAPSED_REALTIME, 1500L, PendingIntent.getActivity(activity, 0, new Intent(activity, homeActivityClass), intent)); - Process.killProcess(Process.myPid()); - } - - /* JADX INFO: Access modifiers changed from: package-private */ - public static void RebootDialog(final Activity activity) { - // from class: app.revanced.integrations.videoplayer.settings.XReboot.1 - // android.content.DialogInterface.OnClickListenerXSettingsFragment.homeActivityClass - new AlertDialog.Builder(activity).setMessage(Settings.getStringByName(activity, "pref_refresh_config")).setPositiveButton(Settings.getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> XReboot.Reboot(activity, XSettingsFragment.homeActivityClass)).setNegativeButton(Settings.getStringByName(activity, "sign_in_cancel"), null).show(); - } -} diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoQuality.java b/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoQuality.java index 3c67e1fba8..e1eda9ad3c 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoQuality.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoQuality.java @@ -3,11 +3,9 @@ import android.content.Context; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.settings.SettingsEnum; import app.revanced.integrations.utils.LogHelper; -import app.revanced.integrations.settings.Settings; +import app.revanced.integrations.utils.ReVancedUtils; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -16,38 +14,41 @@ /* loaded from: classes6.dex */ public class VideoQuality { - static final int[] videoResolutions = {0, 144, 240, 360, 480, 720, 1080, 1440, 2160}; + public static final int[] videoResolutions = {0, 144, 240, 360, 480, 720, 1080, 1440, 2160}; + private static Boolean userChangedQuality = false; + private static Boolean newVideo = false; + public static void userChangedQuality() { - Settings.userChangedQuality = true; - Settings.newVideo = false; + userChangedQuality = true; + newVideo = false; } public static int setVideoQuality(Object[] qualities, int quality, Object qInterface) { int preferredQuality; Field[] fields; - if (!Settings.newVideo || Settings.userChangedQuality || qInterface == null) { - if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && Settings.userChangedQuality) { - LogHelper.debug("Settings - quality", "Skipping quality change because user changed it: " + quality); + if (!newVideo || userChangedQuality || qInterface == null) { + if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && userChangedQuality) { + LogHelper.debug("VideoQuality", "Skipping quality change because user changed it: " + quality); } - Settings.userChangedQuality = false; + userChangedQuality = false; return quality; } - Settings.newVideo = false; - LogHelper.debug("Settings - quality", "Quality: " + quality); - Context context = YouTubeTikTokRoot_Application.getAppContext(); + newVideo = false; + LogHelper.debug("VideoQuality", "Quality: " + quality); + Context context = ReVancedUtils.getContext(); if (context == null) { - LogHelper.printException("Settings", "Context is null or settings not initialized, returning quality: " + quality); + LogHelper.printException("VideoQuality", "Context is null or settings not initialized, returning quality: " + quality); return quality; } if (Connectivity.isConnectedWifi(context)) { preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.getInt(); - LogHelper.debug("Settings", "Wi-Fi connection detected, preferred quality: " + preferredQuality); + LogHelper.debug("VideoQuality", "Wi-Fi connection detected, preferred quality: " + preferredQuality); } else if (Connectivity.isConnectedMobile(context)) { preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.getInt(); - LogHelper.debug("Settings", "Mobile data connection detected, preferred quality: " + preferredQuality); + LogHelper.debug("VideoQuality", "Mobile data connection detected, preferred quality: " + preferredQuality); } else { - LogHelper.debug("Settings", "No Internet connection!"); + LogHelper.debug("VideoQuality", "No Internet connection!"); return quality; } if (preferredQuality == -2) { @@ -71,7 +72,7 @@ public static int setVideoQuality(Object[] qualities, int quality, Object qInter Collections.sort(iStreamQualities); int index = 0; for (int streamQuality2 : iStreamQualities) { - LogHelper.debug("Settings - qualities", "Quality at index " + index + ": " + streamQuality2); + LogHelper.debug("VideoQuality", "Quality at index " + index + ": " + streamQuality2); index++; } for (Integer iStreamQuality : iStreamQualities) { @@ -84,15 +85,15 @@ public static int setVideoQuality(Object[] qualities, int quality, Object qInter return quality; } int qualityIndex = iStreamQualities.indexOf(quality); - LogHelper.debug("Settings", "Index of quality " + quality + " is " + qualityIndex); + LogHelper.debug("VideoQuality", "Index of quality " + quality + " is " + qualityIndex); try { Class cl = qInterface.getClass(); Method m = cl.getMethod("x", Integer.TYPE); m.invoke(qInterface, iStreamQualities.get(qualityIndex)); - LogHelper.debug("Settings", "Quality changed to: " + qualityIndex); + LogHelper.debug("VideoQuality", "Quality changed to: " + qualityIndex); return qualityIndex; } catch (Exception ex) { - LogHelper.printException("Settings", "Failed to set quality", ex); + LogHelper.printException("VideoQuality", "Failed to set quality", ex); return qualityIndex; } } diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoSpeed.java b/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoSpeed.java index 3e0e3b0f57..dc8f10e6a1 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoSpeed.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/videosettings/VideoSpeed.java @@ -14,14 +14,16 @@ /* loaded from: classes6.dex */ public class VideoSpeed { public static final float[] videoSpeeds = {0.25f, 0.5f, 0.75f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 3.0f, 4.0f, 5.0f}; + private static Boolean userChangedSpeed = false; + private static Boolean newVideoSpeed = false; public static int DefaultSpeed(Object[] speeds, int speed, Object qInterface) { int speed2; Exception e; - if (!Settings.newVideoSpeed) { + if (!newVideoSpeed) { return speed; } - Settings.newVideoSpeed = false; + newVideoSpeed = false; LogHelper.debug("Settings - speeds", "Speed: " + speed); float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat(); LogHelper.debug("Settings", "Preferred speed: " + preferredSpeed); @@ -90,31 +92,26 @@ public static int DefaultSpeed(Object[] speeds, int speed, Object qInterface) { } public static void userChangedSpeed() { - Settings.userChangedSpeed = true; - Settings.newVideoSpeed = false; + userChangedSpeed = true; + newVideoSpeed = false; } - private static float getSpeedByIndex(int index) { - if (index == -2) { - return 1.0f; - } - try { - return videoSpeeds[index]; - } catch (Exception e) { - return 1.0f; - } + + public static void NewVideoStarted() { + newVideoSpeed = true; + LogHelper.debug("VideoSpeed", "New video started!"); } public static float getSpeedValue(Object[] speeds, int speed) { int i = 0; - if (!Settings.newVideoSpeed || Settings.userChangedSpeed) { - if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && Settings.userChangedSpeed) { + if (!newVideoSpeed || userChangedSpeed) { + if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && userChangedSpeed) { LogHelper.debug("Settings - speeds", "Skipping speed change because user changed it: " + speed); } - Settings.userChangedSpeed = false; + userChangedSpeed = false; return -1.0f; } - Settings.newVideoSpeed = false; + newVideoSpeed = false; LogHelper.debug("Settings - speeds", "Speed: " + speed); float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat(); LogHelper.debug("Settings", "Preferred speed: " + preferredSpeed); @@ -170,4 +167,16 @@ public static float getSpeedValue(Object[] speeds, int speed) { LogHelper.debug("Settings", "Speed changed to: " + newSpeedIndex); return getSpeedByIndex(newSpeedIndex); } + + private static float getSpeedByIndex(int index) { + if (index == -2) { + return 1.0f; + } + try { + return videoSpeeds[index]; + } catch (Exception e) { + return 1.0f; + } + } + } diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/videourl/Copy.java b/app/src/main/java/app/revanced/integrations/videoplayer/videourl/Copy.java index 27429293af..c430c8d90e 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/videourl/Copy.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/videourl/Copy.java @@ -8,10 +8,9 @@ import androidx.constraintlayout.widget.ConstraintLayout; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.sponsorblock.player.VideoHelpers; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; import java.lang.ref.WeakReference; @@ -82,7 +81,7 @@ public static void refreshShouldBeShown() { } private static boolean shouldBeShown() { - Context appContext = YouTubeTikTokRoot_Application.getAppContext(); + Context appContext = ReVancedUtils.getContext(); if (appContext == null) { LogHelper.printException("CopyButton", "shouldBeShown - context is null!"); return false; @@ -95,15 +94,15 @@ private static boolean shouldBeShown() { } private static int getIdentifier(String str, String str2) { - Context appContext = YouTubeTikTokRoot_Application.getAppContext(); + Context appContext = ReVancedUtils.getContext(); return appContext.getResources().getIdentifier(str, str2, appContext.getPackageName()); } private static int getInteger(String str) { - return YouTubeTikTokRoot_Application.getAppContext().getResources().getInteger(getIdentifier(str, "integer")); + return ReVancedUtils.getContext().getResources().getInteger(getIdentifier(str, "integer")); } private static Animation getAnimation(String str) { - return AnimationUtils.loadAnimation(YouTubeTikTokRoot_Application.getAppContext(), getIdentifier(str, "anim")); + return AnimationUtils.loadAnimation(ReVancedUtils.getContext(), getIdentifier(str, "anim")); } } diff --git a/app/src/main/java/app/revanced/integrations/videoplayer/videourl/CopyWithTimeStamp.java b/app/src/main/java/app/revanced/integrations/videoplayer/videourl/CopyWithTimeStamp.java index a1cc082b15..307962772d 100644 --- a/app/src/main/java/app/revanced/integrations/videoplayer/videourl/CopyWithTimeStamp.java +++ b/app/src/main/java/app/revanced/integrations/videoplayer/videourl/CopyWithTimeStamp.java @@ -9,10 +9,9 @@ import androidx.constraintlayout.widget.ConstraintLayout; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.utils.LogHelper; import app.revanced.integrations.sponsorblock.player.VideoHelpers; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.utils.SharedPrefHelper; import java.lang.ref.WeakReference; @@ -85,7 +84,7 @@ public static void refreshShouldBeShown() { } private static boolean shouldBeShown() { - Context appContext = YouTubeTikTokRoot_Application.getAppContext(); + Context appContext = ReVancedUtils.getContext(); if (appContext == null) { LogHelper.printException("CopyButtonWithTimeStamp", "shouldBeShown - context is null!"); return false; @@ -99,15 +98,15 @@ private static boolean shouldBeShown() { } private static int getIdentifier(String str, String str2) { - Context appContext = YouTubeTikTokRoot_Application.getAppContext(); + Context appContext = ReVancedUtils.getContext(); return appContext.getResources().getIdentifier(str, str2, appContext.getPackageName()); } private static int getInteger(String str) { - return YouTubeTikTokRoot_Application.getAppContext().getResources().getInteger(getIdentifier(str, "integer")); + return ReVancedUtils.getContext().getResources().getInteger(getIdentifier(str, "integer")); } private static Animation getAnimation(String str) { - return AnimationUtils.loadAnimation(YouTubeTikTokRoot_Application.getAppContext(), getIdentifier(str, "anim")); + return AnimationUtils.loadAnimation(ReVancedUtils.getContext(), getIdentifier(str, "anim")); } } diff --git a/app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeControlAPI.java b/app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeControlAPI.java new file mode 100644 index 0000000000..6fc58a160d --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeControlAPI.java @@ -0,0 +1,73 @@ +package app.revanced.integrations.videoswipecontrols; + +import android.content.Context; +import android.view.MotionEvent; +import android.view.ViewConfiguration; +import android.view.ViewGroup; + +import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout; +import app.revanced.integrations.sponsorblock.SponsorBlockUtils; +import app.revanced.integrations.sponsorblock.player.PlayerType; +import app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView; +import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; +import app.revanced.integrations.utils.SwipeHelper; + +public class SwipeControlAPI { + + private static SwipeGestureController swipeGestureController; + + public static void InitializeFensterController(Context context, ViewGroup viewGroup, ViewConfiguration viewConfiguration) { + swipeGestureController = new SwipeGestureController(); + swipeGestureController.setFensterEventsListener(new XSwipe(context, viewGroup), context, viewConfiguration); + LogHelper.debug("Settings", "XFenster initialized"); + } + + public static boolean FensterTouchEvent(MotionEvent motionEvent) { + if (swipeGestureController == null) { + LogHelper.debug("Settings", "fensterGestureController is null"); + return false; + } else if (motionEvent == null) { + LogHelper.debug("Settings", "motionEvent is null"); + return false; + } else if (!SwipeHelper.IsControlsShown()) { + return swipeGestureController.onTouchEvent(motionEvent); + } else { + LogHelper.debug("Settings", "skipping onTouchEvent dispatching because controls are shown."); + return false; + } + } + + public static void PlayerTypeChanged(PlayerType playerType) { + LogHelper.debug("XDebug", playerType.toString()); + if (ReVancedUtils.getPlayerType() != playerType) { + if (playerType == PlayerType.WATCH_WHILE_FULLSCREEN) { + EnableSwipeControl(); + } else { + DisableSwipeControl(); + } + if (playerType == PlayerType.WATCH_WHILE_SLIDING_MINIMIZED_MAXIMIZED || playerType == PlayerType.WATCH_WHILE_MINIMIZED || playerType == PlayerType.WATCH_WHILE_PICTURE_IN_PICTURE) { + NewSegmentHelperLayout.hide(); + } + SponsorBlockView.playerTypeChanged(playerType); + SponsorBlockUtils.playerTypeChanged(playerType); + } + ReVancedUtils.setPlayerType(playerType); + } + + private static void EnableSwipeControl() { + if (SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() || SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean()) { + SwipeGestureController swipeGestureController2 = swipeGestureController; + swipeGestureController2.TouchesEnabled = true; + ((XSwipe) swipeGestureController2.listener).enable(SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean(), SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean()); + } + } + + private static void DisableSwipeControl() { + SwipeGestureController swipeGestureController2 = swipeGestureController; + swipeGestureController2.TouchesEnabled = false; + ((XSwipe) swipeGestureController2.listener).disable(); + } + +} diff --git a/app/src/main/java/app/revanced/integrations/videoswipecontrols/FensterEventsListener.java b/app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeEventsListener.java similarity index 91% rename from app/src/main/java/app/revanced/integrations/videoswipecontrols/FensterEventsListener.java rename to app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeEventsListener.java index d21d84e855..6c6e361061 100644 --- a/app/src/main/java/app/revanced/integrations/videoswipecontrols/FensterEventsListener.java +++ b/app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeEventsListener.java @@ -3,7 +3,7 @@ import android.view.MotionEvent; /* loaded from: classes6.dex */ -public interface FensterEventsListener { +public interface SwipeEventsListener { void onDown(MotionEvent motionEvent); void onHorizontalScroll(MotionEvent motionEvent, float f); diff --git a/app/src/main/java/app/revanced/integrations/videoswipecontrols/FensterGestureController.java b/app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeGestureController.java similarity index 76% rename from app/src/main/java/app/revanced/integrations/videoswipecontrols/FensterGestureController.java rename to app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeGestureController.java index 4d8a8b9a02..c093a97c35 100644 --- a/app/src/main/java/app/revanced/integrations/videoswipecontrols/FensterGestureController.java +++ b/app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeGestureController.java @@ -8,10 +8,10 @@ import app.revanced.integrations.utils.LogHelper; /* loaded from: classes6.dex */ -public class FensterGestureController { +public class SwipeGestureController { public boolean TouchesEnabled = false; private GestureDetector gestureDetector; - public FensterEventsListener listener; + public SwipeEventsListener listener; public boolean onTouchEvent(MotionEvent event) { if (event == null || !this.TouchesEnabled || event.getPointerCount() > 1) { @@ -24,8 +24,8 @@ public boolean onTouchEvent(MotionEvent event) { return this.gestureDetector.onTouchEvent(event); } - public void setFensterEventsListener(FensterEventsListener listener, Context context, ViewConfiguration viewConfiguration) { + public void setFensterEventsListener(SwipeEventsListener listener, Context context, ViewConfiguration viewConfiguration) { this.listener = listener; - this.gestureDetector = new GestureDetector(context, new FensterGestureListener(listener, viewConfiguration)); + this.gestureDetector = new GestureDetector(context, new SwipeGestureListener(listener, viewConfiguration)); } } diff --git a/app/src/main/java/app/revanced/integrations/videoswipecontrols/FensterGestureListener.java b/app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeGestureListener.java similarity index 94% rename from app/src/main/java/app/revanced/integrations/videoswipecontrols/FensterGestureListener.java rename to app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeGestureListener.java index 448a284e84..2d2be79496 100644 --- a/app/src/main/java/app/revanced/integrations/videoswipecontrols/FensterGestureListener.java +++ b/app/src/main/java/app/revanced/integrations/videoswipecontrols/SwipeGestureListener.java @@ -7,14 +7,14 @@ import app.revanced.integrations.utils.LogHelper; /* loaded from: classes6.dex */ -public class FensterGestureListener implements GestureDetector.OnGestureListener { +public class SwipeGestureListener implements GestureDetector.OnGestureListener { private boolean ignoreScroll = false; - private final FensterEventsListener listener; + private final SwipeEventsListener listener; private final int minFlingVelocity; public static int SWIPE_THRESHOLD = 0; public static int TOP_PADDING = 20; - public FensterGestureListener(FensterEventsListener listener, ViewConfiguration viewConfiguration) { + public SwipeGestureListener(SwipeEventsListener listener, ViewConfiguration viewConfiguration) { this.listener = listener; this.minFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity(); } diff --git a/app/src/main/java/app/revanced/integrations/videoswipecontrols/XFenster.java b/app/src/main/java/app/revanced/integrations/videoswipecontrols/XSwipe.java similarity index 96% rename from app/src/main/java/app/revanced/integrations/videoswipecontrols/XFenster.java rename to app/src/main/java/app/revanced/integrations/videoswipecontrols/XSwipe.java index ee41bf88d5..cc73154dd4 100644 --- a/app/src/main/java/app/revanced/integrations/videoswipecontrols/XFenster.java +++ b/app/src/main/java/app/revanced/integrations/videoswipecontrols/XSwipe.java @@ -7,16 +7,15 @@ import android.view.View; import android.view.ViewGroup; -import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; - import app.revanced.integrations.utils.LogHelper; +import app.revanced.integrations.utils.ReVancedUtils; import app.revanced.integrations.videoswipecontrols.seekbar.BrightnessSeekBar; import app.revanced.integrations.videoswipecontrols.seekbar.VolumeSeekBar; import app.revanced.integrations.utils.SwipeHelper; -import app.revanced.integrations.settings.XSettingsFragment; +import app.revanced.integrations.settingsmenu.ReVancedSettingsFragment; /* loaded from: classes6.dex */ -public class XFenster implements FensterEventsListener { +public class XSwipe implements SwipeEventsListener { public static final int ONE_FINGER = 1; Handler handler; float mBrightnessDownPos; @@ -36,7 +35,7 @@ public class XFenster implements FensterEventsListener { BrightnessSeekBar mBrightness = new BrightnessSeekBar(); VolumeSeekBar mVolume = new VolumeSeekBar(); - public XFenster(Context context, ViewGroup viewGroup) { + public XSwipe(Context context, ViewGroup viewGroup) { this.mViewGroup = viewGroup; this.mBrightness.initialise(context, viewGroup); this.mVolume.initialise(context, viewGroup); @@ -153,8 +152,8 @@ public void hideNotifications() { // from class: app.revanced.integrations.videoplayer.Fenster.XFenster.1 // java.lang.Runnable this.handler.postDelayed(() -> { - XFenster.this.mVolume.hide(); - XFenster.this.mBrightness.hide(); + XSwipe.this.mVolume.hide(); + XSwipe.this.mBrightness.hide(); }, 2000L); } @@ -265,7 +264,7 @@ private void checkPlayerOverlaysView() { View layout = SwipeHelper.nextGenWatchLayout.findViewById(getIdentifier()); if (layout != null) { this.mViewGroup = (ViewGroup) layout; - this.mBrightness.refreshViewGroup(this.mViewGroup, XSettingsFragment.overlayContext); + this.mBrightness.refreshViewGroup(this.mViewGroup, ReVancedSettingsFragment.overlayContext); this.mVolume.refreshViewGroup(this.mViewGroup); LogHelper.debug("Settings", "player_overlays refreshed"); } else { @@ -278,7 +277,7 @@ private void checkPlayerOverlaysView() { } private static int getIdentifier() { - Context context = YouTubeTikTokRoot_Application.getAppContext(); + Context context = ReVancedUtils.getContext(); assert context != null; return context.getResources().getIdentifier("player_overlays", "id", context.getPackageName()); }