From a12709d243fc981da42e8ebfe5742e48195e70e8 Mon Sep 17 00:00:00 2001
From: she11sh0cked <22623152+she11sh0cked@users.noreply.github.com>
Date: Fri, 25 Mar 2022 11:20:56 +0100
Subject: [PATCH] feat: implement missing classes
---
integrations/AndroidManifest.xml | 3 +
.../youtube/Autorepeat/AutoRepeat.java | 160 ++
.../fi/razerman/youtube/Connectivity.java | 67 +
.../fi/razerman/youtube/Fenster/Coverage.java | 8 +
.../Fenster/FensterEventsListener.java | 24 +
.../Fenster/FensterGestureController.java | 33 +
.../Fenster/FensterGestureListener.java | 128 ++
.../Fenster/Helpers/BrightnessHelper.java | 54 +
.../razerman/youtube/Fenster/Orientation.java | 7 +
.../Fenster/Seekbar/BrightnessSeekBar.java | 133 ++
.../Fenster/Seekbar/VolumeSeekBar.java | 124 ++
.../fi/razerman/youtube/Fenster/XFenster.java | 307 ++++
.../fi/razerman/youtube/Helpers/ColorRef.java | 67 +
.../razerman/youtube/Helpers/NullCheck.java | 10 +
.../razerman/youtube/Helpers/SharedPrefs.java | 49 +
.../youtube/Helpers/XScreenSizeHelpers.java | 14 +
.../youtube/Helpers/XSharedPrefs.java | 22 +
.../youtube/Helpers/XSwipeHelper.java | 78 +-
.../youtube/Helpers/XThemeHelpers.java | 43 +
.../fi/razerman/youtube/VideoUrl/Copy.java | 117 ++
.../youtube/VideoUrl/CopyWithTimeStamp.java | 118 ++
.../java/fi/razerman/youtube/XAdRemover.java | 234 +++
.../java/fi/razerman/youtube/XDebug.java | 431 +++++
.../java/fi/razerman/youtube/XGlobals.java | 1381 ++++++++++++++++-
.../java/fi/razerman/youtube/XJson.java | 65 +
.../java/fi/razerman/youtube/XReboot.java | 29 +
.../java/fi/razerman/youtube/XRecreate.java | 18 +
.../java/fi/razerman/youtube/XRefresher.java | 25 +
.../fi/razerman/youtube/XSettingActivity.java | 122 ++
.../razerman/youtube/XSettingsFragment.java | 607 ++++++++
.../java/fi/razerman/youtube/XTheme.java | 165 ++
.../youtube/litho/LithoAdRemoval.java | 212 +++
.../preferences/BooleanPreferences.java | 22 +
.../youtube/videosettings/VideoQuality.java | 108 ++
.../youtube/videosettings/VideoSpeed.java | 198 +++
.../pl/jakubweg/SponsorBlockSettings.java | 4 +-
36 files changed, 5180 insertions(+), 7 deletions(-)
create mode 100644 integrations/java/fi/razerman/youtube/Autorepeat/AutoRepeat.java
create mode 100644 integrations/java/fi/razerman/youtube/Connectivity.java
create mode 100644 integrations/java/fi/razerman/youtube/Fenster/Coverage.java
create mode 100644 integrations/java/fi/razerman/youtube/Fenster/FensterEventsListener.java
create mode 100644 integrations/java/fi/razerman/youtube/Fenster/FensterGestureController.java
create mode 100644 integrations/java/fi/razerman/youtube/Fenster/FensterGestureListener.java
create mode 100644 integrations/java/fi/razerman/youtube/Fenster/Helpers/BrightnessHelper.java
create mode 100644 integrations/java/fi/razerman/youtube/Fenster/Orientation.java
create mode 100644 integrations/java/fi/razerman/youtube/Fenster/Seekbar/BrightnessSeekBar.java
create mode 100644 integrations/java/fi/razerman/youtube/Fenster/Seekbar/VolumeSeekBar.java
create mode 100644 integrations/java/fi/razerman/youtube/Fenster/XFenster.java
create mode 100644 integrations/java/fi/razerman/youtube/Helpers/ColorRef.java
create mode 100644 integrations/java/fi/razerman/youtube/Helpers/NullCheck.java
create mode 100644 integrations/java/fi/razerman/youtube/Helpers/SharedPrefs.java
create mode 100644 integrations/java/fi/razerman/youtube/Helpers/XScreenSizeHelpers.java
create mode 100644 integrations/java/fi/razerman/youtube/Helpers/XSharedPrefs.java
create mode 100644 integrations/java/fi/razerman/youtube/Helpers/XThemeHelpers.java
create mode 100644 integrations/java/fi/razerman/youtube/VideoUrl/Copy.java
create mode 100644 integrations/java/fi/razerman/youtube/VideoUrl/CopyWithTimeStamp.java
create mode 100644 integrations/java/fi/razerman/youtube/XAdRemover.java
create mode 100644 integrations/java/fi/razerman/youtube/XDebug.java
create mode 100644 integrations/java/fi/razerman/youtube/XJson.java
create mode 100644 integrations/java/fi/razerman/youtube/XReboot.java
create mode 100644 integrations/java/fi/razerman/youtube/XRecreate.java
create mode 100644 integrations/java/fi/razerman/youtube/XRefresher.java
create mode 100644 integrations/java/fi/razerman/youtube/XSettingActivity.java
create mode 100644 integrations/java/fi/razerman/youtube/XSettingsFragment.java
create mode 100644 integrations/java/fi/razerman/youtube/XTheme.java
create mode 100644 integrations/java/fi/razerman/youtube/litho/LithoAdRemoval.java
create mode 100644 integrations/java/fi/razerman/youtube/preferences/BooleanPreferences.java
create mode 100644 integrations/java/fi/razerman/youtube/videosettings/VideoQuality.java
create mode 100644 integrations/java/fi/razerman/youtube/videosettings/VideoSpeed.java
diff --git a/integrations/AndroidManifest.xml b/integrations/AndroidManifest.xml
index 7609a74cd..328d7e1aa 100644
--- a/integrations/AndroidManifest.xml
+++ b/integrations/AndroidManifest.xml
@@ -1,4 +1,7 @@
+
+
+
\ No newline at end of file
diff --git a/integrations/java/fi/razerman/youtube/Autorepeat/AutoRepeat.java b/integrations/java/fi/razerman/youtube/Autorepeat/AutoRepeat.java
new file mode 100644
index 000000000..f52b13edf
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Autorepeat/AutoRepeat.java
@@ -0,0 +1,160 @@
+package fi.razerman.youtube.Autorepeat;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.util.Log;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+
+import androidx.constraintlayout.widget.ConstraintLayout;
+
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.VideoUrl.Copy;
+import fi.razerman.youtube.VideoUrl.CopyWithTimeStamp;
+import fi.razerman.youtube.XGlobals;
+import java.lang.ref.WeakReference;
+
+/* loaded from: classes6.dex */
+public class AutoRepeat {
+ static WeakReference _autoRepeatBtn = new WeakReference<>(null);
+ static ConstraintLayout _constraintLayout;
+ static int fadeDurationFast;
+ static int fadeDurationScheduled;
+ static Animation fadeIn;
+ static Animation fadeOut;
+ public static boolean isAutoRepeatBtnEnabled;
+ static boolean isShowing;
+
+ public static void initializeAutoRepeat(Object constraintLayout) {
+ try {
+ if (XGlobals.debug) {
+ Log.d("AutoRepeat", "initializing auto repeat");
+ }
+ CopyWithTimeStamp.initializeCopyButtonWithTimeStamp(constraintLayout);
+ Copy.initializeCopyButton(constraintLayout);
+ _constraintLayout = (ConstraintLayout) constraintLayout;
+ isAutoRepeatBtnEnabled = shouldBeShown();
+ ImageView imageView = _constraintLayout.findViewById(getIdentifier("autoreplay_button", "id"));
+ if (XGlobals.debug && imageView == null) {
+ Log.d("AutoRepeat", "Couldn't find imageView with tag \"autoreplay_button\"");
+ }
+ if (imageView != null) {
+ imageView.setSelected(shouldBeSelected());
+ imageView.setOnClickListener(new View.OnClickListener() { // from class: fi.razerman.youtube.Autorepeat.AutoRepeat.1
+ @Override // android.view.View.OnClickListener
+ public void onClick(View v) {
+ if (XGlobals.debug) {
+ Log.d("AutoRepeat", "Auto repeat button clicked");
+ }
+ AutoRepeat.changeSelected(!v.isSelected());
+ }
+ });
+ _autoRepeatBtn = new WeakReference<>(imageView);
+ fadeDurationFast = getInteger("fade_duration_fast");
+ fadeDurationScheduled = getInteger("fade_duration_scheduled");
+ fadeIn = getAnimation("fade_in");
+ fadeIn.setDuration(fadeDurationFast);
+ fadeOut = getAnimation("fade_out");
+ fadeOut.setDuration(fadeDurationScheduled);
+ isShowing = true;
+ changeVisibility(false);
+ }
+ } catch (Exception ex) {
+ Log.e("XError", "Unable to set FrameLayout", ex);
+ }
+ }
+
+ public static void changeVisibility(boolean visible) {
+ CopyWithTimeStamp.changeVisibility(visible);
+ Copy.changeVisibility(visible);
+ if (isShowing != visible) {
+ isShowing = visible;
+ ImageView iView = _autoRepeatBtn.get();
+ if (_constraintLayout != null && iView != null) {
+ if (visible && isAutoRepeatBtnEnabled) {
+ if (XGlobals.debug) {
+ Log.d("AutoRepeat", "Fading in");
+ }
+ iView.setVisibility(View.VISIBLE);
+ iView.startAnimation(fadeIn);
+ } else if (iView.getVisibility() == View.VISIBLE) {
+ if (XGlobals.debug) {
+ Log.d("AutoRepeat", "Fading out");
+ }
+ iView.startAnimation(fadeOut);
+ iView.setVisibility(View.GONE);
+ }
+ }
+ }
+ }
+
+ public static void changeSelected(boolean selected) {
+ changeSelected(selected, false);
+ }
+
+ public static void changeSelected(boolean selected, boolean onlyView) {
+ ImageView iView = _autoRepeatBtn.get();
+ if (_constraintLayout != null && iView != null) {
+ if (XGlobals.debug) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Changing selected state to: ");
+ sb.append(selected ? "SELECTED" : "NONE");
+ Log.d("AutoRepeat", sb.toString());
+ }
+ iView.setSelected(selected);
+ if (!onlyView) {
+ setSelected(selected);
+ }
+ }
+ }
+
+ private static boolean shouldBeSelected() {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("AutoRepeat", "ChangeSelected - context is null!");
+ return false;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ return sharedPreferences.getBoolean("pref_auto_repeat", false);
+ }
+
+ private static void setSelected(boolean selected) {
+ try {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("AutoRepeat", "ChangeSelected - context is null!");
+ return;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ sharedPreferences.edit().putBoolean("pref_auto_repeat", selected).apply();
+ } catch (Exception ignored) {
+ }
+ }
+
+ private static boolean shouldBeShown() {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("AutoRepeat", "ChangeSelected - context is null!");
+ return false;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ return sharedPreferences.getBoolean("pref_auto_repeat_button", false);
+ }
+
+ private static int getIdentifier(String name, String defType) {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ return context.getResources().getIdentifier(name, defType, context.getPackageName());
+ }
+
+ private static int getInteger(String name) {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ return context.getResources().getInteger(getIdentifier(name, "integer"));
+ }
+
+ private static Animation getAnimation(String name) {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ return AnimationUtils.loadAnimation(context, getIdentifier(name, "anim"));
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Connectivity.java b/integrations/java/fi/razerman/youtube/Connectivity.java
new file mode 100644
index 000000000..fd81162ef
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Connectivity.java
@@ -0,0 +1,67 @@
+package fi.razerman.youtube;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+
+/* loaded from: classes6.dex */
+public class Connectivity {
+ public static NetworkInfo getNetworkInfo(Context context) {
+ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ return cm.getActiveNetworkInfo();
+ }
+
+ public static boolean isConnected(Context context) {
+ NetworkInfo info = getNetworkInfo(context);
+ return info != null && info.isConnected();
+ }
+
+ public static boolean isConnectedWifi(Context context) {
+ NetworkInfo info = getNetworkInfo(context);
+ return info != null && info.isConnected() && info.getType() == 1;
+ }
+
+ public static boolean isConnectedMobile(Context context) {
+ NetworkInfo info = getNetworkInfo(context);
+ return info != null && info.isConnected() && info.getType() == 0;
+ }
+
+ public static boolean isConnectedFast(Context context) {
+ NetworkInfo info = getNetworkInfo(context);
+ return info != null && info.isConnected() && isConnectionFast(info.getType(), info.getSubtype());
+ }
+
+ public static boolean isConnectionFast(int type, int subType) {
+ if (type == 1) {
+ return true;
+ }
+ if (type != 0) {
+ return false;
+ }
+ switch (subType) {
+ case 1:
+ return false;
+ case 2:
+ return false;
+ case 3:
+ case 5:
+ case 6:
+ case 8:
+ case 9:
+ case 10:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ return true;
+ case 4:
+ return false;
+ case 7:
+ return false;
+ case 11:
+ return false;
+ default:
+ return false;
+ }
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Fenster/Coverage.java b/integrations/java/fi/razerman/youtube/Fenster/Coverage.java
new file mode 100644
index 000000000..c590f7b58
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Fenster/Coverage.java
@@ -0,0 +1,8 @@
+package fi.razerman.youtube.Fenster;
+
+/* loaded from: classes6.dex */
+public enum Coverage {
+ FULL,
+ RIGHT,
+ LEFT
+}
diff --git a/integrations/java/fi/razerman/youtube/Fenster/FensterEventsListener.java b/integrations/java/fi/razerman/youtube/Fenster/FensterEventsListener.java
new file mode 100644
index 000000000..6001112f2
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Fenster/FensterEventsListener.java
@@ -0,0 +1,24 @@
+package fi.razerman.youtube.Fenster;
+
+import android.view.MotionEvent;
+
+/* loaded from: classes6.dex */
+public interface FensterEventsListener {
+ void onDown(MotionEvent motionEvent);
+
+ void onHorizontalScroll(MotionEvent motionEvent, float f);
+
+ void onSwipeBottom();
+
+ void onSwipeLeft();
+
+ void onSwipeRight();
+
+ void onSwipeTop();
+
+ void onTap();
+
+ void onUp();
+
+ void onVerticalScroll(MotionEvent motionEvent, float f);
+}
diff --git a/integrations/java/fi/razerman/youtube/Fenster/FensterGestureController.java b/integrations/java/fi/razerman/youtube/Fenster/FensterGestureController.java
new file mode 100644
index 000000000..363b2f0fc
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Fenster/FensterGestureController.java
@@ -0,0 +1,33 @@
+package fi.razerman.youtube.Fenster;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.GestureDetector;
+import android.view.MotionEvent;
+import android.view.ViewConfiguration;
+import fi.razerman.youtube.XGlobals;
+
+/* loaded from: classes6.dex */
+public class FensterGestureController {
+ public boolean TouchesEnabled = false;
+ private GestureDetector gestureDetector;
+ public FensterEventsListener listener;
+
+ public boolean onTouchEvent(MotionEvent event) {
+ if (event == null || !this.TouchesEnabled || event.getPointerCount() > 1) {
+ return false;
+ }
+ if (event.getAction() == 1) {
+ this.listener.onUp();
+ if (XGlobals.debug) {
+ Log.i("TouchTest", "Touch up");
+ }
+ }
+ return this.gestureDetector.onTouchEvent(event);
+ }
+
+ public void setFensterEventsListener(FensterEventsListener listener, Context context, ViewConfiguration viewConfiguration) {
+ this.listener = listener;
+ this.gestureDetector = new GestureDetector(context, new FensterGestureListener(listener, viewConfiguration));
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Fenster/FensterGestureListener.java b/integrations/java/fi/razerman/youtube/Fenster/FensterGestureListener.java
new file mode 100644
index 000000000..cfad4f72e
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Fenster/FensterGestureListener.java
@@ -0,0 +1,128 @@
+package fi.razerman.youtube.Fenster;
+
+import android.util.Log;
+import android.view.GestureDetector;
+import android.view.MotionEvent;
+import android.view.ViewConfiguration;
+import fi.razerman.youtube.XGlobals;
+
+/* loaded from: classes6.dex */
+public class FensterGestureListener implements GestureDetector.OnGestureListener {
+ public static final String TAG = "FensterGestureListener";
+ private boolean ignoreScroll = false;
+ private final FensterEventsListener listener;
+ private final int minFlingVelocity;
+ public static int SWIPE_THRESHOLD = 0;
+ public static int TOP_PADDING = 20;
+
+ public FensterGestureListener(FensterEventsListener listener, ViewConfiguration viewConfiguration) {
+ this.listener = listener;
+ this.minFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
+ }
+
+ @Override // android.view.GestureDetector.OnGestureListener
+ public boolean onSingleTapUp(MotionEvent e) {
+ this.listener.onTap();
+ return false;
+ }
+
+ @Override // android.view.GestureDetector.OnGestureListener
+ public void onLongPress(MotionEvent e) {
+ if (XGlobals.debug) {
+ Log.i(TAG, "Long Press");
+ }
+ }
+
+ @Override // android.view.GestureDetector.OnGestureListener
+ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
+ if (XGlobals.debug) {
+ Log.i(TAG, "Scroll");
+ }
+ if (e1 == null || e2 == null) {
+ if (e1 == null && XGlobals.debug) {
+ Log.d("XDebug", "e1 is null");
+ }
+ if (e2 == null && XGlobals.debug) {
+ Log.d("XDebug", "e2 is null");
+ }
+ return false;
+ } else if (this.ignoreScroll) {
+ if (XGlobals.debug) {
+ Log.i(TAG, "Scroll ignored");
+ }
+ return false;
+ } else {
+ float deltaY = e2.getY() - e1.getY();
+ float deltaX = e2.getX() - e1.getX();
+ if (Math.abs(deltaX) > Math.abs(deltaY)) {
+ if (Math.abs(deltaX) > SWIPE_THRESHOLD) {
+ this.listener.onHorizontalScroll(e2, deltaX);
+ if (deltaX > 0.0f) {
+ if (XGlobals.debug) {
+ Log.i(TAG, "Slide right");
+ }
+ } else if (XGlobals.debug) {
+ Log.i(TAG, "Slide left");
+ }
+ }
+ } else if (Math.abs(deltaY) > SWIPE_THRESHOLD) {
+ this.listener.onVerticalScroll(e2, deltaY);
+ if (deltaY > 0.0f) {
+ if (XGlobals.debug) {
+ Log.i(TAG, "Slide down");
+ }
+ } else if (XGlobals.debug) {
+ Log.i(TAG, "Slide up");
+ }
+ }
+ return false;
+ }
+ }
+
+ @Override // android.view.GestureDetector.OnGestureListener
+ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
+ if (XGlobals.debug) {
+ Log.i(TAG, "Fling");
+ }
+ try {
+ float diffY = e2.getY() - e1.getY();
+ float diffX = e2.getX() - e1.getX();
+ if (Math.abs(diffX) > Math.abs(diffY)) {
+ if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > this.minFlingVelocity) {
+ if (diffX > 0.0f) {
+ this.listener.onSwipeRight();
+ } else {
+ this.listener.onSwipeLeft();
+ }
+ }
+ } else if (Math.abs(diffY) > SWIPE_THRESHOLD && Math.abs(velocityY) > this.minFlingVelocity) {
+ if (diffY > 0.0f) {
+ this.listener.onSwipeBottom();
+ } else {
+ this.listener.onSwipeTop();
+ }
+ }
+ return true;
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override // android.view.GestureDetector.OnGestureListener
+ public void onShowPress(MotionEvent e) {
+ if (XGlobals.debug) {
+ Log.i(TAG, "Show Press");
+ }
+ }
+
+ @Override // android.view.GestureDetector.OnGestureListener
+ public boolean onDown(MotionEvent e) {
+ if (XGlobals.debug) {
+ Log.i(TAG, "Down - x: " + e.getX() + " y: " + e.getY());
+ }
+ this.ignoreScroll = e.getY() <= TOP_PADDING;
+ this.listener.onDown(e);
+ return false;
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Fenster/Helpers/BrightnessHelper.java b/integrations/java/fi/razerman/youtube/Fenster/Helpers/BrightnessHelper.java
new file mode 100644
index 000000000..ca9fd24b3
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Fenster/Helpers/BrightnessHelper.java
@@ -0,0 +1,54 @@
+package fi.razerman.youtube.Fenster.Helpers;
+
+import android.app.Activity;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.WindowManager;
+import fi.razerman.youtube.XGlobals;
+
+/* loaded from: classes6.dex */
+public class BrightnessHelper {
+ static Context bContext;
+
+ public static float getBrightness() {
+ Context context = bContext;
+ if (context == null) {
+ return -1.0f;
+ }
+ return ((Activity) context).getWindow().getAttributes().screenBrightness;
+ }
+
+ public static int getBrightness(Context context) {
+ bContext = context;
+ return (int) (((Activity) context).getWindow().getAttributes().screenBrightness * 100.0f);
+ }
+
+ public static void setBrightness(Context context, int brightness) {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "Setting brightness: " + brightness);
+ }
+ float bright = brightness / 100.0f;
+ WindowManager.LayoutParams lp = ((Activity) context).getWindow().getAttributes();
+ lp.screenBrightness = bright;
+ ((Activity) context).getWindow().setAttributes(lp);
+ }
+
+ public static void setBrightness2(Context context, int brightness) {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "Setting brightness: " + brightness);
+ }
+ ContentResolver cResolver = context.getContentResolver();
+ Settings.System.putInt(cResolver, "screen_brightness", brightness);
+ }
+
+ public static int getBrightness2(Context context) {
+ ContentResolver cResolver = context.getContentResolver();
+ try {
+ return Settings.System.getInt(cResolver, "screen_brightness");
+ } catch (Settings.SettingNotFoundException e) {
+ return 0;
+ }
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Fenster/Orientation.java b/integrations/java/fi/razerman/youtube/Fenster/Orientation.java
new file mode 100644
index 000000000..55ed73002
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Fenster/Orientation.java
@@ -0,0 +1,7 @@
+package fi.razerman.youtube.Fenster;
+
+/* loaded from: classes6.dex */
+public enum Orientation {
+ HORIZONTAL,
+ VERTICAL
+}
diff --git a/integrations/java/fi/razerman/youtube/Fenster/Seekbar/BrightnessSeekBar.java b/integrations/java/fi/razerman/youtube/Fenster/Seekbar/BrightnessSeekBar.java
new file mode 100644
index 000000000..39e780e0e
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Fenster/Seekbar/BrightnessSeekBar.java
@@ -0,0 +1,133 @@
+package fi.razerman.youtube.Fenster.Seekbar;
+
+import android.content.Context;
+import android.os.Handler;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import com.google.android.apps.youtube.app.common.player.overlay.YouTubePlayerOverlaysLayout;
+import fi.razerman.youtube.Fenster.Helpers.BrightnessHelper;
+import fi.razerman.youtube.Helpers.SharedPrefs;
+import fi.razerman.youtube.XGlobals;
+
+/* loaded from: classes6.dex */
+public class BrightnessSeekBar {
+ public static final int MAX_BRIGHTNESS = 100;
+ public static final int MIN_BRIGHTNESS = 0;
+ public static final String TAG = "XDebug";
+ public int Max;
+ public int Progress;
+ private boolean enabled;
+ Handler handler;
+ private final String mBrightnessKey = "xfile_brightness_value";
+ Context mContext;
+ TextView mTextView;
+ ViewGroup mViewGroup;
+
+ public void initialise(Context context, ViewGroup viewGroup) {
+ this.enabled = false;
+ this.mViewGroup = viewGroup;
+ this.mContext = context;
+ float systemBrightness = Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
+ int _systemBrightness = (int) ((systemBrightness / 255.0f) * 100.0f);
+ this.Progress = SharedPrefs.getInt(this.mContext, "xfile_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
+ this.Max = 100;
+ this.mTextView = new TextView(context);
+ this.mTextView.setTextSize(24.0f);
+ this.mTextView.setBackgroundColor(Integer.MIN_VALUE);
+ this.mTextView.setTextColor(-1);
+ this.mViewGroup.addView(this.mTextView);
+ }
+
+ public void refreshViewGroup(ViewGroup viewGroup) {
+ if (this.mTextView.getParent() != null) {
+ ((ViewGroup) this.mTextView.getParent()).removeView(this.mTextView);
+ }
+ this.mContext = YouTubePlayerOverlaysLayout.overlayContext;
+ this.mViewGroup = viewGroup;
+ this.mViewGroup.addView(this.mTextView);
+ }
+
+ private void updateBrightnessProgress() {
+ this.Progress = BrightnessHelper.getBrightness(this.mContext);
+ if (this.mTextView != null) {
+ this.mTextView.setText("Brightness: " + this.Progress);
+ if (!isVisible()) {
+ this.mTextView.setVisibility(View.VISIBLE);
+ }
+ }
+ if (XGlobals.debug) {
+ Log.d("XDebug", "updateBrightnessProgress: " + this.Progress);
+ }
+ }
+
+ private void disableBrightness() {
+ BrightnessHelper.setBrightness(this.mContext, -1);
+ }
+
+ public void setBrightness(int brightness) {
+ if (this.enabled) {
+ if (brightness < 0) {
+ brightness = 0;
+ } else if (brightness > 100) {
+ brightness = 100;
+ }
+ BrightnessHelper.setBrightness(this.mContext, brightness);
+ updateBrightnessProgress();
+ }
+ }
+
+ public void manuallyUpdate(int update) {
+ if (this.enabled) {
+ setBrightness(update);
+ }
+ }
+
+ public void hide() {
+ if (isVisible()) {
+ this.mTextView.setVisibility(View.INVISIBLE);
+ }
+ }
+
+ public void hideDelayed() {
+ if (this.handler == null) {
+ this.handler = new Handler();
+ }
+ this.handler.postDelayed(new Runnable() { // from class: fi.razerman.youtube.Fenster.Seekbar.BrightnessSeekBar.1
+ @Override // java.lang.Runnable
+ public void run() {
+ BrightnessSeekBar.this.hide();
+ }
+ }, 2000L);
+ }
+
+ public boolean isVisible() {
+ if (this.mTextView != null && this.mTextView.getVisibility() == View.VISIBLE) {
+ return true;
+ }
+ return false;
+ }
+
+ public void disable() {
+ this.enabled = false;
+ SharedPrefs.saveInt(this.mContext, "xfile_brightness_value", Integer.valueOf(this.Progress));
+ disableBrightness();
+ Log.d("XDebug", "Brightness swipe disabled");
+ }
+
+ public void enable() {
+ this.enabled = true;
+ float systemBrightness = Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
+ int _systemBrightness = (int) ((systemBrightness / 255.0f) * 100.0f);
+ int brightness = SharedPrefs.getInt(this.mContext, "xfile_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
+ if (brightness < 0) {
+ brightness = 0;
+ } else if (brightness > 100) {
+ brightness = 100;
+ }
+ BrightnessHelper.setBrightness(this.mContext, brightness);
+ Log.d("XDebug", "Brightness swipe enabled");
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Fenster/Seekbar/VolumeSeekBar.java b/integrations/java/fi/razerman/youtube/Fenster/Seekbar/VolumeSeekBar.java
new file mode 100644
index 000000000..2a9acb049
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Fenster/Seekbar/VolumeSeekBar.java
@@ -0,0 +1,124 @@
+package fi.razerman.youtube.Fenster.Seekbar;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.media.AudioManager;
+import android.os.Handler;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import fi.razerman.youtube.XGlobals;
+
+/* loaded from: classes6.dex */
+public class VolumeSeekBar {
+ public int Max;
+ public int Progress;
+ private AudioManager audioManager;
+ private boolean enabled;
+ Handler handler;
+ private boolean isRegistered;
+ private Context mContext;
+ TextView mTextView;
+ ViewGroup mViewGroup;
+ private final BroadcastReceiver volumeReceiver = new BroadcastReceiver() { // from class: fi.razerman.youtube.Fenster.Seekbar.VolumeSeekBar.1
+ @Override // android.content.BroadcastReceiver
+ public void onReceive(Context context, Intent intent) {
+ VolumeSeekBar.this.updateVolumeProgress();
+ VolumeSeekBar.this.hideDelayed();
+ }
+ };
+
+ public void initialise(Context context, ViewGroup viewGroup) {
+ this.enabled = false;
+ this.mViewGroup = viewGroup;
+ this.mContext = context;
+ this.audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+ this.Max = this.audioManager.getStreamMaxVolume(3);
+ this.Progress = this.audioManager.getStreamVolume(3);
+ this.mTextView = new TextView(context);
+ this.mTextView.setTextSize(24.0f);
+ this.mTextView.setBackgroundColor(Integer.MIN_VALUE);
+ this.mTextView.setTextColor(-1);
+ this.mViewGroup.addView(this.mTextView);
+ }
+
+ public void refreshViewGroup(ViewGroup viewGroup) {
+ if (this.mTextView.getParent() != null) {
+ ((ViewGroup) this.mTextView.getParent()).removeView(this.mTextView);
+ }
+ this.mViewGroup = viewGroup;
+ this.mViewGroup.addView(this.mTextView);
+ }
+
+ /* JADX INFO: Access modifiers changed from: private */
+ public void updateVolumeProgress() {
+ this.Progress = this.audioManager.getStreamVolume(3);
+ if (this.mTextView != null) {
+ this.mTextView.setText("Volume: " + this.Progress);
+ if (!isVisible()) {
+ this.mTextView.setVisibility(View.VISIBLE);
+ }
+ }
+ if (XGlobals.debug) {
+ Log.d("XDebug", "updateVolumeProgress: " + this.Progress);
+ }
+ }
+
+ private void setVolume(int volume) {
+ this.audioManager.setStreamVolume(3, volume, 0);
+ updateVolumeProgress();
+ }
+
+ private void registerVolumeReceiver() {
+ this.mContext.registerReceiver(this.volumeReceiver, new IntentFilter("android.media.VOLUME_CHANGED_ACTION"));
+ this.isRegistered = true;
+ }
+
+ public void unregisterVolumeReceiver() {
+ this.mContext.unregisterReceiver(this.volumeReceiver);
+ this.isRegistered = false;
+ }
+
+ public void manuallyUpdate(int update) {
+ if (this.enabled) {
+ setVolume(update);
+ }
+ }
+
+ public void hide() {
+ if (isVisible()) {
+ this.mTextView.setVisibility(View.INVISIBLE);
+ }
+ }
+
+ public void hideDelayed() {
+ if (this.handler == null) {
+ this.handler = new Handler();
+ }
+ // from class: fi.razerman.youtube.Fenster.Seekbar.VolumeSeekBar.2
+// java.lang.Runnable
+ this.handler.postDelayed(VolumeSeekBar.this::hide, 2000L);
+ }
+
+ public boolean isVisible() {
+ return this.mTextView != null && this.mTextView.getVisibility() == View.VISIBLE;
+ }
+
+ public void disable() {
+ this.enabled = false;
+ if (this.isRegistered) {
+ unregisterVolumeReceiver();
+ }
+ }
+
+ public void enable() {
+ this.enabled = true;
+ this.Progress = this.audioManager.getStreamVolume(3);
+ if (!this.isRegistered) {
+ registerVolumeReceiver();
+ }
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Fenster/XFenster.java b/integrations/java/fi/razerman/youtube/Fenster/XFenster.java
new file mode 100644
index 000000000..5f61c78c7
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Fenster/XFenster.java
@@ -0,0 +1,307 @@
+package fi.razerman.youtube.Fenster;
+
+import android.content.Context;
+import android.os.Handler;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.Fenster.Seekbar.BrightnessSeekBar;
+import fi.razerman.youtube.Fenster.Seekbar.VolumeSeekBar;
+import fi.razerman.youtube.Helpers.XSwipeHelper;
+import fi.razerman.youtube.XGlobals;
+
+/* loaded from: classes6.dex */
+public class XFenster implements FensterEventsListener {
+ public static final int ONE_FINGER = 1;
+ public static final String TAG = "XDebug";
+ Handler handler;
+ float mBrightnessDownPos;
+ int mBrightnessDownProgress;
+ ViewGroup mViewGroup;
+ float mVolumeDownPos;
+ int mVolumeDownProgress;
+ float mTouchProgressOffset = 0.0f;
+ protected int mPaddingTop = 0;
+ protected int mPaddingBottom = 0;
+ protected int mPaddingLeft = 0;
+ protected int mPaddingRight = 0;
+ Orientation brightnessOrientation = Orientation.VERTICAL;
+ Orientation volumeOrientation = Orientation.VERTICAL;
+ Coverage brightnessCoverage = Coverage.LEFT;
+ Coverage volumeCoverage = Coverage.RIGHT;
+ BrightnessSeekBar mBrightness = new BrightnessSeekBar();
+ VolumeSeekBar mVolume = new VolumeSeekBar();
+
+ public XFenster(Context context, ViewGroup viewGroup) {
+ this.mViewGroup = viewGroup;
+ this.mBrightness.initialise(context, viewGroup);
+ this.mVolume.initialise(context, viewGroup);
+ }
+
+ @Override // fi.razerman.youtube.Fenster.FensterEventsListener
+ public void onTap() {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "onTap");
+ }
+ }
+
+ @Override // fi.razerman.youtube.Fenster.FensterEventsListener
+ public void onHorizontalScroll(MotionEvent event, float delta) {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "onHorizontalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
+ }
+ if (event.getPointerCount() == 1) {
+ if (this.brightnessOrientation == Orientation.HORIZONTAL && (this.brightnessCoverage == Coverage.FULL || getCoverageHorizontal(event) == this.brightnessCoverage)) {
+ updateBrightnessProgressBarHorizontal(event);
+ }
+ if (this.volumeOrientation != Orientation.HORIZONTAL) {
+ return;
+ }
+ if (this.volumeCoverage == Coverage.FULL || getCoverageHorizontal(event) == this.volumeCoverage) {
+ updateVolumeProgressBarHorizontal(event);
+ }
+ }
+ }
+
+ @Override // fi.razerman.youtube.Fenster.FensterEventsListener
+ public void onVerticalScroll(MotionEvent event, float delta) {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "onVerticalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
+ }
+ if (event.getPointerCount() == 1) {
+ if (this.brightnessOrientation == Orientation.VERTICAL && (this.brightnessCoverage == Coverage.FULL || getCoverageVertical(event) == this.brightnessCoverage)) {
+ updateBrightnessProgressBarVertical(event);
+ }
+ if (this.volumeOrientation != Orientation.VERTICAL) {
+ return;
+ }
+ if (this.volumeCoverage == Coverage.FULL || getCoverageVertical(event) == this.volumeCoverage) {
+ updateVolumeProgressBarVertical(event);
+ }
+ }
+ }
+
+ @Override // fi.razerman.youtube.Fenster.FensterEventsListener
+ public void onSwipeRight() {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "onSwipeRight");
+ }
+ }
+
+ @Override // fi.razerman.youtube.Fenster.FensterEventsListener
+ public void onSwipeLeft() {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "onSwipeLeft");
+ }
+ }
+
+ @Override // fi.razerman.youtube.Fenster.FensterEventsListener
+ public void onSwipeBottom() {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "onSwipeBottom");
+ }
+ }
+
+ @Override // fi.razerman.youtube.Fenster.FensterEventsListener
+ public void onSwipeTop() {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "onSwipeTop");
+ }
+ }
+
+ @Override // fi.razerman.youtube.Fenster.FensterEventsListener
+ public void onDown(MotionEvent event) {
+ if (XGlobals.debug) {
+ Log.d("XDebug", "onDown");
+ }
+ if (event.getPointerCount() == 1) {
+ if (this.brightnessOrientation == Orientation.VERTICAL && (this.brightnessCoverage == Coverage.FULL || getCoverageVertical(event) == this.brightnessCoverage)) {
+ this.mBrightnessDownPos = getProgressVertical(event, this.mBrightness.Max);
+ }
+ if (this.volumeOrientation == Orientation.VERTICAL && (this.volumeCoverage == Coverage.FULL || getCoverageVertical(event) == this.volumeCoverage)) {
+ this.mVolumeDownPos = getProgressVertical(event, this.mVolume.Max);
+ }
+ if (this.brightnessOrientation == Orientation.HORIZONTAL && (this.brightnessCoverage == Coverage.FULL || getCoverageHorizontal(event) == this.brightnessCoverage)) {
+ this.mBrightnessDownPos = getProgressHorizontal(event, this.mBrightness.Max);
+ }
+ if (this.volumeOrientation == Orientation.HORIZONTAL && (this.volumeCoverage == Coverage.FULL || getCoverageHorizontal(event) == this.volumeCoverage)) {
+ this.mVolumeDownPos = getProgressHorizontal(event, this.mVolume.Max);
+ }
+ this.mVolumeDownProgress = this.mVolume.Progress;
+ this.mBrightnessDownProgress = this.mBrightness.Progress;
+ }
+ }
+
+ @Override // fi.razerman.youtube.Fenster.FensterEventsListener
+ public void onUp() {
+ Log.d("XDebug", "onUp");
+ hideNotifications();
+ }
+
+ public void disable() {
+ if (this.mBrightness != null) {
+ this.mBrightness.disable();
+ }
+ if (this.mVolume != null) {
+ this.mVolume.disable();
+ }
+ hideNotifications();
+ }
+
+ public void enable(boolean brightness, boolean volume) {
+ checkPlayerOverlaysView();
+ if (brightness && this.mBrightness != null) {
+ this.mBrightness.enable();
+ }
+ if (volume && this.mVolume != null) {
+ this.mVolume.enable();
+ }
+ }
+
+ public void hideNotifications() {
+ if (this.handler == null) {
+ this.handler = new Handler();
+ }
+ // from class: fi.razerman.youtube.Fenster.XFenster.1
+// java.lang.Runnable
+ this.handler.postDelayed(() -> {
+ XFenster.this.mVolume.hide();
+ XFenster.this.mBrightness.hide();
+ }, 2000L);
+ }
+
+ private void updateVolumeProgressBarVertical(MotionEvent event) {
+ float difference = getDifferenceVertical(this.mVolumeDownPos, getProgressVertical(event, this.mVolume.Max));
+ if (this.mBrightness.isVisible()) {
+ this.mBrightness.hide();
+ }
+ this.mVolume.manuallyUpdate((int) (this.mVolumeDownProgress + difference));
+ }
+
+ private void updateBrightnessProgressBarVertical(MotionEvent event) {
+ float difference = getDifferenceVertical(this.mBrightnessDownPos, getProgressVertical(event, this.mBrightness.Max));
+ if (this.mVolume.isVisible()) {
+ this.mVolume.hide();
+ }
+ this.mBrightness.manuallyUpdate((int) (this.mBrightnessDownProgress + difference));
+ }
+
+ private void updateVolumeProgressBarHorizontal(MotionEvent event) {
+ float difference = getDifferenceHorizontal(this.mVolumeDownPos, getProgressHorizontal(event, this.mVolume.Max));
+ if (this.mBrightness.isVisible()) {
+ this.mBrightness.hide();
+ }
+ this.mVolume.manuallyUpdate((int) (this.mVolumeDownProgress + difference));
+ }
+
+ private void updateBrightnessProgressBarHorizontal(MotionEvent event) {
+ float difference = getDifferenceHorizontal(this.mBrightnessDownPos, getProgressHorizontal(event, this.mBrightness.Max));
+ if (this.mVolume.isVisible()) {
+ this.mVolume.hide();
+ }
+ this.mBrightness.manuallyUpdate((int) (this.mBrightnessDownProgress + difference));
+ }
+
+ private float getDifferenceVertical(float downProgress, float newProgress) {
+ float diff = downProgress - newProgress;
+ return diff * (-1.0f);
+ }
+
+ private float getDifferenceHorizontal(float downProgress, float newProgress) {
+ float diff = downProgress - newProgress;
+ return diff;
+ }
+
+ private float getProgressVertical(MotionEvent event, int maxSteps) {
+ float progress = calculateProgressVertical(event, maxSteps);
+ if (XGlobals.debug) {
+ Log.d("XDebug", "Progress vertical: " + progress);
+ }
+ return progress;
+ }
+
+ private float getProgressHorizontal(MotionEvent event, int maxSteps) {
+ float progress = calculateProgressHorizontal(event, maxSteps);
+ if (XGlobals.debug) {
+ Log.d("XDebug", "Progress horizontal: " + progress);
+ }
+ return progress;
+ }
+
+ private float calculateProgressVertical(MotionEvent event, int maxSteps) {
+ float scale;
+ int height = this.mViewGroup.getHeight();
+ if (XGlobals.debug) {
+ Log.d("XDebug", "calculateProgressVertical - height: " + height);
+ }
+ int available = (height - this.mPaddingTop) - this.mPaddingBottom;
+ int y = height - ((int) event.getY());
+ float progress = 0.0f;
+ if (y < this.mPaddingBottom) {
+ scale = 0.0f;
+ } else if (y > height - this.mPaddingTop) {
+ scale = 1.0f;
+ } else {
+ scale = (y - this.mPaddingBottom) / available;
+ progress = this.mTouchProgressOffset;
+ }
+ return progress + (maxSteps * scale);
+ }
+
+ private float calculateProgressHorizontal(MotionEvent event, int maxSteps) {
+ float scale;
+ int width = this.mViewGroup.getWidth();
+ int available = (width - this.mPaddingLeft) - this.mPaddingRight;
+ int x = width - ((int) event.getX());
+ float progress = 0.0f;
+ if (x < this.mPaddingRight) {
+ scale = 0.0f;
+ } else if (x > width - this.mPaddingLeft) {
+ scale = 1.0f;
+ } else {
+ scale = (x - this.mPaddingRight) / available;
+ progress = this.mTouchProgressOffset;
+ }
+ return progress + (maxSteps * scale);
+ }
+
+ private Coverage getCoverageHorizontal(MotionEvent event) {
+ int halfScreen = this.mViewGroup.getHeight() / 2;
+ int y = (int) event.getY();
+ return y <= halfScreen ? Coverage.LEFT : Coverage.RIGHT;
+ }
+
+ private Coverage getCoverageVertical(MotionEvent event) {
+ int halfScreen = this.mViewGroup.getWidth() / 2;
+ int x = (int) event.getX();
+ return x <= halfScreen ? Coverage.LEFT : Coverage.RIGHT;
+ }
+
+ private void checkPlayerOverlaysView() {
+ try {
+ if ((this.mViewGroup.getHeight() == 0 || this.mViewGroup.getWidth() == 0) && XSwipeHelper.nextGenWatchLayout != null) {
+ View layout = XSwipeHelper.nextGenWatchLayout.findViewById(getIdentifier());
+ if (layout != null) {
+ this.mViewGroup = (ViewGroup) layout;
+ this.mBrightness.refreshViewGroup(this.mViewGroup);
+ this.mVolume.refreshViewGroup(this.mViewGroup);
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "player_overlays refreshed");
+ }
+ } else if (XGlobals.debug) {
+ Log.d("XGlobals", "player_overlays was not found");
+ }
+ }
+ } catch (Exception ex) {
+ Log.e("XError", "Unable to refresh player_overlays layout", ex);
+ }
+ }
+
+ private static int getIdentifier() {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ assert context != null;
+ return context.getResources().getIdentifier("player_overlays", "id", context.getPackageName());
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Helpers/ColorRef.java b/integrations/java/fi/razerman/youtube/Helpers/ColorRef.java
new file mode 100644
index 000000000..317ad5cb5
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Helpers/ColorRef.java
@@ -0,0 +1,67 @@
+package fi.razerman.youtube.Helpers;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import java.util.HashMap;
+
+/* loaded from: classes6.dex */
+public class ColorRef {
+ public static final String CREDITS = "Converted from jakubweg's StringRef https://github.com/YTVanced/SponsorBlock/blob/master/app/src/main/java/pl/jakubweg/StringRef.java";
+ public static final String TAG = "ColorRef";
+ private static final HashMap colors = new HashMap<>();
+ private static String packageName;
+ private static Resources resources;
+ @NonNull
+ private final String colorName;
+ private boolean resolved;
+ private Integer value;
+
+ public static void setContext(Context context) {
+ if (context != null) {
+ resources = context.getApplicationContext().getResources();
+ packageName = context.getPackageName();
+ }
+ }
+
+ @NonNull
+ /* renamed from: cf */
+ public static ColorRef m32591cf(@NonNull String resName, @NonNull Integer defaultValue) {
+ ColorRef ref = colors.get(resName);
+ if (ref != null) {
+ return ref;
+ }
+ ColorRef ref2 = new ColorRef(resName, defaultValue);
+ colors.put(resName, ref2);
+ return ref2;
+ }
+
+ @NonNull
+ public static Integer color(@NonNull String resName, @NonNull Integer defaultValue) {
+ return m32591cf(resName, defaultValue).resolve();
+ }
+
+ public ColorRef(@NonNull String resName, @NonNull Integer defaultValue) {
+ this.colorName = resName;
+ this.value = defaultValue;
+ }
+
+ @NonNull
+ public Integer resolve() {
+ if (!this.resolved) {
+ this.resolved = true;
+ Resources resources2 = resources;
+ if (resources2 != null) {
+ try {
+ this.value = resources2.getColor(resources2.getIdentifier(this.colorName, "color", packageName));
+ } catch (Resources.NotFoundException e) {
+ Log.e(TAG, "Resource not found: " + this.value);
+ }
+ }
+ }
+ return this.value;
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Helpers/NullCheck.java b/integrations/java/fi/razerman/youtube/Helpers/NullCheck.java
new file mode 100644
index 000000000..aacfe8047
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Helpers/NullCheck.java
@@ -0,0 +1,10 @@
+package fi.razerman.youtube.Helpers;
+
+import android.text.TextUtils;
+
+/* loaded from: classes6.dex */
+public class NullCheck {
+ public static String ensureHasFragment(String fragmentName) {
+ return TextUtils.isEmpty(fragmentName) ? "placeholder" : fragmentName;
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Helpers/SharedPrefs.java b/integrations/java/fi/razerman/youtube/Helpers/SharedPrefs.java
new file mode 100644
index 000000000..f8ddb8558
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Helpers/SharedPrefs.java
@@ -0,0 +1,49 @@
+package fi.razerman.youtube.Helpers;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+/* loaded from: classes6.dex */
+public class SharedPrefs {
+ public static void saveString(Context context, String key, String value) {
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ sharedPreferences.edit().putString(key, value).apply();
+ }
+
+ public static void saveBoolean(Context context, String key, Boolean value) {
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ sharedPreferences.edit().putBoolean(key, value).apply();
+ }
+
+ public static void saveInt(Context context, String key, Integer value) {
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ sharedPreferences.edit().putInt(key, value).apply();
+ }
+
+ public static String getString(Context context, String key) {
+ return getString(context, key, null);
+ }
+
+ public static String getString(Context context, String key, String _default) {
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ return sharedPreferences.getString(key, _default);
+ }
+
+ public static Boolean getBoolean(Context context, String key) {
+ return getBoolean(context, key, false);
+ }
+
+ public static Boolean getBoolean(Context context, String key, Boolean _default) {
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ return sharedPreferences.getBoolean(key, _default);
+ }
+
+ public static Integer getInt(Context context, String key) {
+ return getInt(context, key, -1);
+ }
+
+ public static Integer getInt(Context context, String key, Integer _default) {
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ return sharedPreferences.getInt(key, _default);
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Helpers/XScreenSizeHelpers.java b/integrations/java/fi/razerman/youtube/Helpers/XScreenSizeHelpers.java
new file mode 100644
index 000000000..e4778a143
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Helpers/XScreenSizeHelpers.java
@@ -0,0 +1,14 @@
+package fi.razerman.youtube.Helpers;
+
+import android.content.Context;
+
+/* loaded from: classes6.dex */
+public class XScreenSizeHelpers {
+ public static boolean isTablet(Context context) {
+ return smallestWidthDp(context) >= 600;
+ }
+
+ private static int smallestWidthDp(Context context) {
+ return context.getResources().getConfiguration().smallestScreenWidthDp;
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Helpers/XSharedPrefs.java b/integrations/java/fi/razerman/youtube/Helpers/XSharedPrefs.java
new file mode 100644
index 000000000..b4ffb76b2
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Helpers/XSharedPrefs.java
@@ -0,0 +1,22 @@
+package fi.razerman.youtube.Helpers;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.util.Log;
+
+/* loaded from: classes6.dex */
+public class XSharedPrefs {
+ public static boolean getBoolean(Context context, String key, boolean defValue) {
+ try {
+ if (context == null) {
+ Log.e("XSharedPrefs", "context is null");
+ return false;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ return sharedPreferences.getBoolean(key, defValue);
+ } catch (Exception ex) {
+ Log.e("XSharedPrefs", "Error getting boolean", ex);
+ return defValue;
+ }
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Helpers/XSwipeHelper.java b/integrations/java/fi/razerman/youtube/Helpers/XSwipeHelper.java
index 7817e2b52..46e82486e 100644
--- a/integrations/java/fi/razerman/youtube/Helpers/XSwipeHelper.java
+++ b/integrations/java/fi/razerman/youtube/Helpers/XSwipeHelper.java
@@ -1,8 +1,82 @@
package fi.razerman.youtube.Helpers;
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.Log;
+import android.view.View;
import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.XGlobals;
+/* loaded from: classes6.dex */
public class XSwipeHelper {
- // Implementation in another repo
+ static FrameLayout _frameLayout;
+ public static boolean isTabletMode;
public static ViewGroup nextGenWatchLayout;
-}
\ No newline at end of file
+
+ public static void SetFrameLayout(Object obj) {
+ try {
+ _frameLayout = (FrameLayout) obj;
+ Context appContext = YouTubeTikTokRoot_Application.getAppContext();
+ if (XScreenSizeHelpers.isTablet(appContext) || XSharedPrefs.getBoolean(appContext, "pref_xfenster_tablet", false)) {
+ isTabletMode = true;
+ }
+ } catch (Exception e) {
+ Log.e("XError", "Unable to set FrameLayout", e);
+ }
+ }
+
+ public static void setNextGenWatchLayout(Object obj) {
+ try {
+ nextGenWatchLayout = (ViewGroup) obj;
+ } catch (Exception e) {
+ Log.e("XError", "Unable to set _nextGenWatchLayout", e);
+ }
+ }
+
+ public static boolean IsControlsShown() {
+ FrameLayout frameLayout;
+ if (isTabletMode || (frameLayout = _frameLayout) == null || frameLayout.getVisibility() != View.VISIBLE) {
+ return false;
+ }
+ try {
+ } catch (Exception e) {
+ Log.e("XError", "Unable to get related_endscreen_results visibility", e);
+ }
+ if (_frameLayout.getChildCount() > 0) {
+ return _frameLayout.getChildAt(0).getVisibility() == View.VISIBLE;
+ }
+ refreshLayout();
+ return false;
+ }
+
+ private static void refreshLayout() {
+ View findViewById;
+ try {
+ if (XGlobals.isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) {
+ _frameLayout = (FrameLayout) findViewById.getParent();
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "related_endscreen_results refreshed");
+ }
+ }
+ } catch (Exception e) {
+ Log.e("XError", "Unable to refresh related_endscreen_results layout", e);
+ }
+ }
+
+ private static String getViewMessage(View view) {
+ try {
+ String resourceName = view.getResources() != null ? view.getId() != 0 ? view.getResources().getResourceName(view.getId()) : "no_id" : "no_resources";
+ return "[" + view.getClass().getSimpleName() + "] " + resourceName + "\n";
+ } catch (Resources.NotFoundException unused) {
+ return "[" + view.getClass().getSimpleName() + "] name_not_found\n";
+ }
+ }
+
+ private static int getIdentifier() {
+ Context appContext = YouTubeTikTokRoot_Application.getAppContext();
+ assert appContext != null;
+ return appContext.getResources().getIdentifier("related_endscreen_results", "id", appContext.getPackageName());
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/Helpers/XThemeHelpers.java b/integrations/java/fi/razerman/youtube/Helpers/XThemeHelpers.java
new file mode 100644
index 000000000..aa0fd5949
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/Helpers/XThemeHelpers.java
@@ -0,0 +1,43 @@
+package fi.razerman.youtube.Helpers;
+
+import android.os.Build;
+import android.util.Log;
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+
+import java.util.Objects;
+
+import fi.razerman.youtube.XGlobals;
+
+/* loaded from: classes6.dex */
+public class XThemeHelpers {
+ static String TAG = "XTheme";
+ static int themeValue;
+
+ public static void setTheme(int value) {
+ themeValue = value;
+ if (XGlobals.debug) {
+ String str = TAG;
+ Log.d(str, "Theme value: " + themeValue);
+ }
+ }
+
+ public static void setTheme(Object value) {
+ themeValue = ((Enum) value).ordinal();
+ if (XGlobals.debug) {
+ String str = TAG;
+ Log.d(str, "Theme value: " + themeValue);
+ }
+ }
+
+ 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/integrations/java/fi/razerman/youtube/VideoUrl/Copy.java b/integrations/java/fi/razerman/youtube/VideoUrl/Copy.java
new file mode 100644
index 000000000..1c5a68d30
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/VideoUrl/Copy.java
@@ -0,0 +1,117 @@
+package fi.razerman.youtube.VideoUrl;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+
+import androidx.constraintlayout.widget.ConstraintLayout;
+
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.XGlobals;
+import fi.vanced.libraries.youtube.player.VideoHelpers;
+import java.lang.ref.WeakReference;
+
+/* loaded from: classes6.dex */
+public class Copy {
+ static String TAG = "CopyButton";
+ static WeakReference _button = new WeakReference<>(null);
+ static ConstraintLayout _constraintLayout;
+ static int fadeDurationFast;
+ static int fadeDurationScheduled;
+ static Animation fadeIn;
+ static Animation fadeOut;
+ public static boolean isCopyButtonEnabled;
+ static boolean isShowing;
+
+ public static void initializeCopyButton(Object obj) {
+ try {
+ if (XGlobals.debug) {
+ Log.d(TAG, "initializing");
+ }
+ _constraintLayout = (ConstraintLayout) obj;
+ isCopyButtonEnabled = shouldBeShown();
+ ImageView imageView = _constraintLayout.findViewById(getIdentifier("copy_button", "id"));
+ if (XGlobals.debug && imageView == null) {
+ Log.d(TAG, "Couldn't find imageView with id \"copy_button\"");
+ }
+ if (imageView != null) {
+ // from class: fi.razerman.youtube.VideoUrl.Copy.1
+// android.view.View.OnClickListener
+ imageView.setOnClickListener(view -> {
+ if (XGlobals.debug) {
+ Log.d(Copy.TAG, "Button clicked");
+ }
+ VideoHelpers.copyVideoUrlToClipboard();
+ });
+ _button = new WeakReference<>(imageView);
+ fadeDurationFast = getInteger("fade_duration_fast");
+ fadeDurationScheduled = getInteger("fade_duration_scheduled");
+ Animation animation = getAnimation("fade_in");
+ fadeIn = animation;
+ animation.setDuration(fadeDurationFast);
+ Animation animation2 = getAnimation("fade_out");
+ fadeOut = animation2;
+ animation2.setDuration(fadeDurationScheduled);
+ isShowing = true;
+ changeVisibility(false);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to set FrameLayout", e);
+ }
+ }
+
+ public static void changeVisibility(boolean z) {
+ if (isShowing != z) {
+ isShowing = z;
+ ImageView imageView = _button.get();
+ if (_constraintLayout != null && imageView != null) {
+ if (z && isCopyButtonEnabled) {
+ if (XGlobals.debug) {
+ Log.d(TAG, "Fading in");
+ }
+ imageView.setVisibility(View.VISIBLE);
+ imageView.startAnimation(fadeIn);
+ } else if (imageView.getVisibility() == View.VISIBLE) {
+ if (XGlobals.debug) {
+ Log.d(TAG, "Fading out");
+ }
+ imageView.startAnimation(fadeOut);
+ imageView.setVisibility(View.GONE);
+ }
+ }
+ }
+ }
+
+ public static void refreshShouldBeShown() {
+ isCopyButtonEnabled = shouldBeShown();
+ }
+
+ private static boolean shouldBeShown() {
+ Context appContext = YouTubeTikTokRoot_Application.getAppContext();
+ if (appContext == null) {
+ Log.e(TAG, "shouldBeShown - context is null!");
+ return false;
+ }
+ String string = appContext.getSharedPreferences("youtube", 0).getString("pref_copy_video_url_button_list", null);
+ if (string == null || string.isEmpty()) {
+ return false;
+ }
+ return string.equalsIgnoreCase("PLAYER") || string.equalsIgnoreCase("BOTH");
+ }
+
+ private static int getIdentifier(String str, String str2) {
+ Context appContext = YouTubeTikTokRoot_Application.getAppContext();
+ return appContext.getResources().getIdentifier(str, str2, appContext.getPackageName());
+ }
+
+ private static int getInteger(String str) {
+ return YouTubeTikTokRoot_Application.getAppContext().getResources().getInteger(getIdentifier(str, "integer"));
+ }
+
+ private static Animation getAnimation(String str) {
+ return AnimationUtils.loadAnimation(YouTubeTikTokRoot_Application.getAppContext(), getIdentifier(str, "anim"));
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/VideoUrl/CopyWithTimeStamp.java b/integrations/java/fi/razerman/youtube/VideoUrl/CopyWithTimeStamp.java
new file mode 100644
index 000000000..105189d29
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/VideoUrl/CopyWithTimeStamp.java
@@ -0,0 +1,118 @@
+package fi.razerman.youtube.VideoUrl;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+
+import androidx.constraintlayout.widget.ConstraintLayout;
+
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.XGlobals;
+import fi.vanced.libraries.youtube.player.VideoHelpers;
+import java.lang.ref.WeakReference;
+
+/* loaded from: classes6.dex */
+public class CopyWithTimeStamp {
+ static String TAG = "CopyButtonWithTimeStamp";
+ static WeakReference _button = new WeakReference<>(null);
+ static ConstraintLayout _constraintLayout;
+ static int fadeDurationFast;
+ static int fadeDurationScheduled;
+ static Animation fadeIn;
+ static Animation fadeOut;
+ public static boolean isCopyButtonWithTimeStampEnabled;
+ static boolean isShowing;
+
+ public static void initializeCopyButtonWithTimeStamp(Object obj) {
+ try {
+ if (XGlobals.debug) {
+ Log.d(TAG, "initializing");
+ }
+ _constraintLayout = (ConstraintLayout) obj;
+ isCopyButtonWithTimeStampEnabled = shouldBeShown();
+ ImageView imageView = (ImageView) _constraintLayout.findViewById(getIdentifier("copy_with_timestamp_button", "id"));
+ if (XGlobals.debug && imageView == null) {
+ Log.d(TAG, "Couldn't find imageView with id \"copy_with_timestamp_button\"");
+ }
+ if (imageView != null) {
+ imageView.setOnClickListener(new View.OnClickListener() { // from class: fi.razerman.youtube.VideoUrl.CopyWithTimeStamp.1
+ @Override // android.view.View.OnClickListener
+ public void onClick(View view) {
+ if (XGlobals.debug) {
+ Log.d(CopyWithTimeStamp.TAG, "Button clicked");
+ }
+ VideoHelpers.copyVideoUrlWithTimeStampToClipboard();
+ }
+ });
+ _button = new WeakReference<>(imageView);
+ fadeDurationFast = getInteger("fade_duration_fast");
+ fadeDurationScheduled = getInteger("fade_duration_scheduled");
+ Animation animation = getAnimation("fade_in");
+ fadeIn = animation;
+ animation.setDuration(fadeDurationFast);
+ Animation animation2 = getAnimation("fade_out");
+ fadeOut = animation2;
+ animation2.setDuration(fadeDurationScheduled);
+ isShowing = true;
+ changeVisibility(false);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to set FrameLayout", e);
+ }
+ }
+
+ public static void changeVisibility(boolean z) {
+ if (isShowing != z) {
+ isShowing = z;
+ ImageView imageView = _button.get();
+ if (_constraintLayout != null && imageView != null) {
+ if (z && isCopyButtonWithTimeStampEnabled) {
+ if (XGlobals.debug) {
+ Log.d(TAG, "Fading in");
+ }
+ imageView.setVisibility(View.VISIBLE);
+ imageView.startAnimation(fadeIn);
+ } else if (imageView.getVisibility() == View.VISIBLE) {
+ if (XGlobals.debug) {
+ Log.d(TAG, "Fading out");
+ }
+ imageView.startAnimation(fadeOut);
+ imageView.setVisibility(View.GONE);
+ }
+ }
+ }
+ }
+
+ public static void refreshShouldBeShown() {
+ isCopyButtonWithTimeStampEnabled = shouldBeShown();
+ }
+
+ private static boolean shouldBeShown() {
+ Context appContext = YouTubeTikTokRoot_Application.getAppContext();
+ if (appContext == null) {
+ Log.e(TAG, "shouldBeShown - context is null!");
+ return false;
+ }
+ String string = appContext.getSharedPreferences("youtube", 0).getString("pref_copy_video_url_timestamp_button_list", null);
+ if (string == null || string.isEmpty()) {
+ return false;
+ }
+ return string.equalsIgnoreCase("PLAYER") || string.equalsIgnoreCase("BOTH");
+ }
+
+ private static int getIdentifier(String str, String str2) {
+ Context appContext = YouTubeTikTokRoot_Application.getAppContext();
+ return appContext.getResources().getIdentifier(str, str2, appContext.getPackageName());
+ }
+
+ private static int getInteger(String str) {
+ return YouTubeTikTokRoot_Application.getAppContext().getResources().getInteger(getIdentifier(str, "integer"));
+ }
+
+ private static Animation getAnimation(String str) {
+ return AnimationUtils.loadAnimation(YouTubeTikTokRoot_Application.getAppContext(), getIdentifier(str, "anim"));
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/XAdRemover.java b/integrations/java/fi/razerman/youtube/XAdRemover.java
new file mode 100644
index 000000000..9a27474b3
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/XAdRemover.java
@@ -0,0 +1,234 @@
+package fi.razerman.youtube;
+
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.Toolbar;
+import fi.razerman.youtube.preferences.BooleanPreferences;
+
+/* loaded from: classes6.dex */
+public class XAdRemover {
+ public static Object RemoveInfoCardSuggestions(Object InfoCardOverlayPresenter) {
+ XGlobals.ReadSettings();
+ if (!XGlobals.suggestionsShown) {
+ InfoCardOverlayPresenter = null;
+ }
+ if (XGlobals.debug) {
+ if (InfoCardOverlayPresenter == null) {
+ Log.d("XAdRemover", "RemoveInfoCardSuggestions: true");
+ } else {
+ Log.d("XAdRemover", "RemoveInfoCardSuggestions: false");
+ }
+ }
+ return InfoCardOverlayPresenter;
+ }
+
+ public static Boolean RemoveSuggestions(Boolean showSuggestions) {
+ XGlobals.ReadSettings();
+ if (showSuggestions && !XGlobals.suggestionsShown) {
+ if (XGlobals.debug) {
+ Log.d("XAdRemover", "RemoveSuggestions: Removed");
+ }
+ return false;
+ } else if (XGlobals.debug && showSuggestions) {
+ Log.d("XAdRemover", "RemoveSuggestions: Not removed");
+ return true;
+ } else if (!XGlobals.debug) {
+ return showSuggestions;
+ } else {
+ Log.d("XAdRemover", "RemoveSuggestions: Already not shown");
+ return false;
+ }
+ }
+
+ public static FrameLayout CheckInfoCardsStatus(FrameLayout frameLayout) {
+ XGlobals.ReadSettings();
+ frameLayout.setVisibility(XGlobals.infoCardsShown ? View.VISIBLE : View.GONE);
+ if (XGlobals.debug) {
+ Log.d("XAdRemover", "CheckInfoCardsStatus - Set visibility to: " + XGlobals.infoCardsShown);
+ }
+ return frameLayout;
+ }
+
+ public static boolean isBrandingWatermarkShown(boolean defaultValue) {
+ XGlobals.ReadSettings();
+ if (defaultValue && !XGlobals.brandingShown) {
+ if (XGlobals.debug) {
+ Log.d("XAdRemover", "BrandingWatermark: Removed");
+ }
+ return false;
+ } else if (XGlobals.debug && defaultValue) {
+ Log.d("XAdRemover", "BrandingWatermark: Not removed");
+ return true;
+ } else if (!XGlobals.debug) {
+ return defaultValue;
+ } else {
+ Log.d("XAdRemover", "BrandingWatermark: Already not shown");
+ return false;
+ }
+ }
+
+ public static int BrandingWatermark(int defaultValue) {
+ XGlobals.ReadSettings();
+ if (defaultValue == 0 && !XGlobals.brandingShown) {
+ if (XGlobals.debug) {
+ Log.d("XAdRemover", "BrandingWatermark: Removed");
+ }
+ return 8;
+ } else if (XGlobals.debug && defaultValue == 0) {
+ Log.d("XAdRemover", "BrandingWatermark: Not removed");
+ return defaultValue;
+ } else if (!XGlobals.debug) {
+ return defaultValue;
+ } else {
+ Log.d("XAdRemover", "BrandingWatermark: Already not shown");
+ return defaultValue;
+ }
+ }
+
+ private static void recursiveLoopChildren(ViewGroup parent) {
+ for (int i = 0; i < parent.getChildCount(); i++) {
+ View child = parent.getChildAt(i);
+ if (child instanceof ViewGroup) {
+ recursiveLoopChildren((ViewGroup) child);
+ child.setVisibility(View.GONE);
+ } else if (child != null) {
+ child.setVisibility(View.GONE);
+ }
+ }
+ }
+
+ public static void HideViewV2(View view) {
+ XGlobals.ReadSettings();
+ if (!XGlobals.homeAdsShown) {
+ recursiveLoopChildren((ViewGroup) view);
+ RelativeLayout relativeLayout = new RelativeLayout(XGlobals.getContext());
+ RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(1, 1);
+ ((ViewGroup) view).addView(relativeLayout, rlp);
+ }
+ }
+
+ public static void HideReel(View view) {
+ XGlobals.ReadSettings();
+ if (!XGlobals.reelShown) {
+ if (XGlobals.debug) {
+ Log.d("XAdRemover", "HideReel: " + view.getId());
+ }
+ HideViewWithLayout1dp(view);
+ }
+ }
+
+ public static void HideView(View view) {
+ XGlobals.ReadSettings();
+ if (!XGlobals.homeAdsShown) {
+ if (XGlobals.debug) {
+ Log.d("XAdRemover", "HideView: " + view.getId());
+ }
+ HideViewWithLayout1dp(view);
+ }
+ }
+
+ private static void HideViewWithLayout1dp(View view) {
+ if (view instanceof LinearLayout) {
+ LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(1, 1);
+ view.setLayoutParams(layoutParams);
+ } else if (view instanceof FrameLayout) {
+ FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(1, 1);
+ view.setLayoutParams(layoutParams2);
+ } else if (view instanceof RelativeLayout) {
+ RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(1, 1);
+ view.setLayoutParams(layoutParams3);
+ } else if (view instanceof Toolbar) {
+ Toolbar.LayoutParams layoutParams4 = new Toolbar.LayoutParams(1, 1);
+ view.setLayoutParams(layoutParams4);
+ } else if (view instanceof ViewGroup) {
+ ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1);
+ view.setLayoutParams(layoutParams5);
+ } else if (XGlobals.debug) {
+ Log.d("XAdRemover", "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
+ }
+ }
+
+ public static boolean VideoAdsEnabled(boolean input) {
+ XGlobals.ReadSettings();
+ if (XGlobals.videoAdsShown) {
+ if (XGlobals.debug) {
+ Log.d("XAdRemover", "Videoads: shown - " + input);
+ }
+ return input;
+ } else if (!XGlobals.debug) {
+ return false;
+ } else {
+ Log.d("XAdRemover", "Videoads: hidden");
+ return false;
+ }
+ }
+
+ public static void hideCreateButton(View view) {
+ if (BooleanPreferences.isCreateButtonHidden()) {
+ if (XGlobals.debug) {
+ Log.d("XAdRemover", "Create button: shown");
+ }
+ view.setVisibility(View.GONE);
+ } else if (XGlobals.debug) {
+ Log.d("XAdRemover", "Create button: hidden");
+ }
+ }
+
+ public static void inspectComponentHost(Object item) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("Litho", "Couldn't locate the method called from.");
+ } else {
+ String sb = "Called from method: " +
+ stackTraceElements[3].toString() + "\n";
+ Log.d("Litho", sb);
+ }
+ if (item == null) {
+ Log.d("Litho", "Item is null.");
+ } else if (item.getClass().getSimpleName().contains("cwl")) {
+ Log.d("Litho", "Item is a cwl item.");
+ Log.i("Litho", getViewHierarcy((ViewGroup) item));
+ } else {
+ Log.d("Litho", "Item is not a cwl item.");
+ }
+ }
+
+ public static String getViewHierarcy(ViewGroup v) {
+ StringBuffer buf = new StringBuffer();
+ printViews(v, buf, 0);
+ return buf.toString();
+ }
+
+ private static String printViews(ViewGroup v, StringBuffer buf, int level) {
+ int childCount = v.getChildCount();
+ v.getId();
+ indent(buf, level);
+ buf.append(v.getClass().getName());
+ buf.append(" children:");
+ buf.append(childCount);
+ buf.append(" id:").append(v.getId());
+ buf.append("\n");
+ for (int i = 0; i < childCount; i++) {
+ View child = v.getChildAt(i);
+ if (child instanceof ViewGroup) {
+ printViews((ViewGroup) child, buf, level + 1);
+ } else {
+ indent(buf, level + 1);
+ buf.append(child.getClass().getName());
+ buf.append(" id:").append(child.getId());
+ buf.append("\n");
+ }
+ }
+ return buf.toString();
+ }
+
+ private static void indent(StringBuffer buf, int level) {
+ for (int i = 0; i < level; i++) {
+ buf.append(" ");
+ }
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/XDebug.java b/integrations/java/fi/razerman/youtube/XDebug.java
new file mode 100644
index 000000000..6a005a973
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/XDebug.java
@@ -0,0 +1,431 @@
+package fi.razerman.youtube;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.res.ColorStateList;
+import android.content.res.Resources;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.media.MediaCodec;
+import android.os.Build;
+import android.util.Base64;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import androidx.annotation.NonNull;
+
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+
+/* loaded from: classes6.dex */
+public class XDebug {
+ private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
+
+ public static void printBooleanWithMethod(boolean bool) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XBoolean", "Couldn't locate the method called from.");
+ Log.d("XBoolean", "" + bool);
+ return;
+ }
+ Log.d("XBoolean", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ Log.d("XBoolean", "" + bool);
+ }
+
+ public static void printColorStateListWithMethod(ColorStateList colorStateList) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XColorStateList", "Couldn't locate the method called from.");
+ } else {
+ Log.d("XColorStateList", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ }
+ if (colorStateList == null) {
+ Log.d("XColorStateList", "");
+ } else {
+ Log.d("XColorStateList", "" + colorStateList);
+ }
+ }
+
+ public static void printIntIntWithMethod(int integer, int integer2) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XIntInt", "Couldn't locate the method called from.");
+ Log.d("XIntInt", "" + integer + " | " + integer2);
+ return;
+ }
+ Log.d("XIntInt", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ Log.d("XIntInt", "" + integer + " | " + integer2);
+ }
+
+ public static void printIntWithMethod(int integer) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XInt", "Couldn't locate the method called from.");
+ Log.d("XInt", "" + integer);
+ return;
+ }
+ Log.d("XInt", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ Log.d("XInt", "" + integer);
+ }
+
+ public static void printStringWithMethod(String string) {
+ if (string == null || string.isEmpty()) {
+ string = "-- null --";
+ }
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XString", "Couldn't locate the method called from.");
+ Log.d("XString", string);
+ return;
+ }
+ Log.d("XString", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ Log.d("XString", string);
+ }
+
+ public static void printCharSequenceBooleanWithMethod(CharSequence charSequence, boolean bool) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XCharSequenceB", "Couldn't locate the method called from.");
+ } else {
+ Log.d("XCharSequenceB", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ }
+ if (charSequence == null) {
+ Log.d("XCharSequenceB", "");
+ } else {
+ Log.d("XCharSequenceB", charSequence + " | " + (bool ? "true" : "false"));
+ }
+ }
+
+ public static void printCharSequenceWithMethod(CharSequence charSequence) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XCharSequence", "Couldn't locate the method called from.");
+ } else {
+ Log.d("XCharSequence", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ }
+ if (charSequence == null) {
+ Log.d("XCharSequence", "");
+ } else {
+ Log.d("XCharSequence", charSequence.toString());
+ }
+ }
+
+ public static void printCharSequenceAndBufferTypeWithMethod(CharSequence charSequence, TextView.BufferType bufferType) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XCharSequenceBT", "Couldn't locate the method called from.");
+ if (charSequence == null) {
+ if (bufferType == null) {
+ Log.d("XCharSequenceBT", "");
+ } else {
+ Log.d("XCharSequenceBT", " | " + bufferType);
+ }
+ } else if (bufferType == null) {
+ Log.d("XCharSequenceBT", charSequence.toString());
+ } else {
+ Log.d("XCharSequenceBT", charSequence.toString() + " | " + bufferType);
+ }
+ } else {
+ Log.d("XCharSequenceBT", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ if (charSequence == null) {
+ Log.d("XCharSequenceBT", "");
+ } else {
+ Log.d("XCharSequenceBT", charSequence.toString());
+ }
+ }
+ }
+
+ public static void printStringBuilder(StringBuilder stringBuilder) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XStringBuilder", "Couldn't locate the method called from.");
+ Log.d("XStringBuilder", stringBuilder.toString());
+ return;
+ }
+ Log.d("XStringBuilder", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ Log.d("XStringBuilder", stringBuilder.toString());
+ Log.d("StackWithMethod", stringBuilder.toString());
+ printStackTrace("StackWithMethod");
+ }
+
+ public static void printMethod() {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length > 3) {
+ Log.d("XStack", stackTraceElements[3].toString() + "\n");
+ }
+ }
+
+ public static void printStackTraces() {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ for (StackTraceElement element : stackTraceElements) {
+ System.out.println("Class name :: " + element.getClassName() + " || method name :: " + element.getMethodName());
+ }
+ }
+
+ public static void printStackTrace() {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ StringBuilder stringBuilder = new StringBuilder();
+ for (StackTraceElement element : stackTraceElements) {
+ stringBuilder.append(element.toString()).append("\n");
+ }
+ Log.d("xfileSTACK", stringBuilder.toString());
+ }
+
+ public static void printStackTrace(String tag) {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ StringBuilder stringBuilder = new StringBuilder();
+ for (StackTraceElement element : stackTraceElements) {
+ stringBuilder.append(element.toString()).append("\n");
+ }
+ Log.d(tag, stringBuilder.toString());
+ }
+
+ public static void printDebugBoolean(boolean val) {
+ Log.d("XDebug", "" + val);
+ }
+
+ public static void printDebugInteger(int value) {
+ Log.d("XDebug", "" + value);
+ }
+
+ public static void printDebugFloat(float value) {
+ Log.d("XDebug", "" + value);
+ }
+
+ public static void printDebugLong(long value) {
+ Log.d("XDebug", "" + value);
+ }
+
+ public static void printDebugString(String value) {
+ if (value != null) {
+ Log.d("XDebug", value);
+ }
+ }
+
+ public static void printDebugStringWithMethodName(String value) {
+ StackTraceElement[] stackTraceElements;
+ if (value != null && (stackTraceElements = Thread.currentThread().getStackTrace()) != null && stackTraceElements.length > 3) {
+ Log.d("XDebug", value + " | " + stackTraceElements[3].toString() + "\n");
+ }
+ }
+
+ public static void printDebugStringWithStack(String value) {
+ StackTraceElement[] stackTraceElements;
+ if (!(value == null || (stackTraceElements = Thread.currentThread().getStackTrace()) == null)) {
+ StringBuilder stringBuilder = new StringBuilder();
+ for (StackTraceElement element : stackTraceElements) {
+ stringBuilder.append(element.toString()).append("\n");
+ }
+ Log.d("XDebug", value + " | " + stringBuilder.toString());
+ }
+ }
+
+ public static void printDebugByteArray(byte[] value) {
+ Log.d("XDebug", bytesToHex(value));
+ }
+
+ public static void printByteBufferWithMethod(ByteBuffer buf) {
+ String string;
+ if (buf == null) {
+ string = "-- null --";
+ } else {
+ string = new String(buf.array(), StandardCharsets.UTF_8);
+ if (string.isEmpty()) {
+ string = "-- null --";
+ }
+ }
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ if (stackTraceElements.length <= 3) {
+ Log.d("XByteBuffer", "Couldn't locate the method called from.");
+ Log.d("XByteBuffer", string);
+ return;
+ }
+ Log.d("XByteBuffer", "Called from method: " + stackTraceElements[3].toString() + "\n");
+ Log.d("XByteBuffer", string);
+ }
+
+ public static void printDebugByteBuffer(ByteBuffer buf) {
+ byte[] bytes = new byte[buf.remaining()];
+ buf.get(bytes, 0, bytes.length);
+ buf.clear();
+ byte[] bytes2 = new byte[buf.capacity()];
+ buf.get(bytes2, 0, bytes2.length);
+ Log.d("XDebug", bytesToHex(bytes2));
+ }
+
+ public static void printDebugByteBuffer(ByteBuffer[] buffers) {
+ int length = buffers.length;
+ int i = 0;
+ int index = 0;
+ while (i < length) {
+ ByteBuffer buf = buffers[i];
+ byte[] bytes = new byte[buf.remaining()];
+ buf.get(bytes, 0, bytes.length);
+ buf.clear();
+ byte[] bytes2 = new byte[buf.capacity()];
+ buf.get(bytes2, 0, bytes2.length);
+ Log.d("XDebug - Index: " + index, bytesToHex(bytes2));
+ i++;
+ index++;
+ }
+ }
+
+ public static void printDebugMediaCodec(MediaCodec mediaCodec) {
+ Exception e;
+ int i = 0;
+ try {
+ ByteBuffer[] outputBuffers = mediaCodec.getOutputBuffers();
+ int length = outputBuffers.length;
+ int index = 0;
+ while (i < length) {
+ try {
+ ByteBuffer buf = outputBuffers[i];
+ byte[] bytes = new byte[buf.remaining()];
+ buf.get(bytes, 0, bytes.length);
+ buf.clear();
+ byte[] bytes2 = new byte[buf.capacity()];
+ buf.get(bytes2, 0, bytes2.length);
+ int index2 = index + 1;
+ Log.d("XDebug - Index: " + index, bytesToHex(bytes2));
+ i++;
+ index = index2;
+ } catch (Exception e2) {
+ e = e2;
+ Log.d("XDebug abc", "Error: " + e.getMessage());
+ return;
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ public static void printDebugMediaCodec(MediaCodec mediaCodec, int i) {
+ try {
+ ByteBuffer buf = mediaCodec.getOutputBuffer(i);
+ byte[] bytes = getByteArrayFromByteBuffer(buf);
+ Log.d("XDebug - decrypt: " + i, bytesToHex(bytes));
+ } catch (Exception e) {
+ Log.d("XDebug - buffer: " + i, "Error: " + i + " | " + e.getMessage());
+ }
+ }
+
+ private static byte[] getByteArrayFromByteBuffer(ByteBuffer byteBuffer) {
+ byte[] bytesArray = new byte[byteBuffer.capacity()];
+ byteBuffer.get(bytesArray, 0, bytesArray.length);
+ return bytesArray;
+ }
+
+ public static void printDebugRect(Rect value) {
+ Log.d("XDebug", "Rectangle| Left:" + value.left + " - Top: " + value.top + " - Right: " + value.right + " - Bottom: " + value.bottom);
+ }
+
+ public static DisplayMetrics getMetrics() {
+ return new DisplayMetrics();
+ }
+
+ public static Point getRealSize() {
+ return new Point(3840, 2160);
+ }
+
+ public static Point getSize() {
+ return new Point(3840, 2160);
+ }
+
+ public static Point getPhysicalSize() {
+ return new Point(3840, 2160);
+ }
+
+ public static int getDisplayWidth() {
+ return 2160;
+ }
+
+ public static int getDisplayHeight() {
+ return 3840;
+ }
+
+ public static String CheckYTRed(String input, String original) {
+ if (input.equals("has_unlimited_entitlement") || input.equals("has_unlimited_ncc_free_trial")) {
+ return "True";
+ }
+ if (input.equals("e")) {
+ return "11202604,23700636,23701019,9415293,9422596,9431754,9435797,9444109,9444635,9449243,9456940,9461315,9463829,9464088,9466234,9467503,9474594,9476327,9477602,9478523,9479785,9480475,9480495,9482942,9484378,9484706,9488038,9489706";
+ }
+ return original;
+ }
+
+ public static String DecodeColdConfig() {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (XGlobals.XFILEDEBUG && context == null) {
+ context = XSettingActivity.getAppContext();
+ }
+ if (context == null) {
+ Log.e("XDebug", "Context is null, ignoring to decode");
+ return Build.MANUFACTURER;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ String config_group = sharedPreferences.getString("com.google.android.libraries.youtube.innertube.cold_config_group", null);
+ String decoded = "";
+ if (config_group == null) {
+ return decoded;
+ }
+ try {
+ if (config_group.isEmpty()) {
+ return decoded;
+ }
+ decoded = bytesToHex(Base64.decode(config_group, 8));
+ sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group.decoded", decoded).apply();
+ return decoded;
+ } catch (Exception e) {
+ return decoded;
+ }
+ }
+
+ public static String bytesToHex(byte[] bytes) {
+ char[] hexChars = new char[bytes.length * 2];
+ for (int j = 0; j < bytes.length; j++) {
+ int v = bytes[j] & 255;
+ hexChars[j * 2] = hexArray[v >>> 4];
+ hexChars[(j * 2) + 1] = hexArray[v & 15];
+ }
+ return new String(hexChars);
+ }
+
+ public static long ConvertDoubleToLong(double value) {
+ return (long) value;
+ }
+
+ public static void getViewHierarchy(@NonNull View v) {
+ StringBuilder desc = new StringBuilder();
+ getViewHierarchy(v, desc, 0);
+ Log.d("XDebug", desc.toString());
+ }
+
+ private static void getViewHierarchy(View v, StringBuilder desc, int margin) {
+ desc.append(getViewMessage(v, margin));
+ if (v instanceof ViewGroup) {
+ int margin2 = margin + 1;
+ ViewGroup vg = (ViewGroup) v;
+ for (int i = 0; i < vg.getChildCount(); i++) {
+ getViewHierarchy(vg.getChildAt(i), desc, margin2);
+ }
+ }
+ }
+
+ private static String getViewMessage(View v, int marginOffset) {
+ String resourceId;
+ String repeated = new String(new char[marginOffset]).replace("\u0000", " ");
+ try {
+ if (v.getResources() != null) {
+ resourceId = v.getId() != 0 ? v.getResources().getResourceName(v.getId()) : "no_id";
+ } else {
+ resourceId = "no_resources";
+ }
+ return repeated + "[" + v.getClass().getSimpleName() + "] " + resourceId + "\n";
+ } catch (Resources.NotFoundException e) {
+ return repeated + "[" + v.getClass().getSimpleName() + "] name_not_found\n";
+ }
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/XGlobals.java b/integrations/java/fi/razerman/youtube/XGlobals.java
index 7bc8ec22e..d4c33fb49 100644
--- a/integrations/java/fi/razerman/youtube/XGlobals.java
+++ b/integrations/java/fi/razerman/youtube/XGlobals.java
@@ -1,6 +1,1381 @@
package fi.razerman.youtube;
-// Ignore this file, the implementation is in another repository
-public class XGlobals {
- public static Boolean debug = false;
+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.ColorStateList;
+import android.content.res.Resources;
+import android.os.Build;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.MotionEvent;
+import android.view.ViewConfiguration;
+import android.view.ViewGroup;
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.Fenster.FensterGestureController;
+import fi.razerman.youtube.Fenster.FensterGestureListener;
+import fi.razerman.youtube.Fenster.Helpers.BrightnessHelper;
+import fi.razerman.youtube.Fenster.XFenster;
+import fi.razerman.youtube.Helpers.ColorRef;
+import fi.razerman.youtube.Helpers.XSwipeHelper;
+import fi.vanced.libraries.youtube.player.PlayerType;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+
+import pl.jakubweg.NewSegmentHelperLayout;
+
+/* compiled from: PG */
+/* renamed from: env */
+/* loaded from: classes3.dex */
+enum env {
+ NONE,
+ HIDDEN,
+ WATCH_WHILE_MINIMIZED,
+ WATCH_WHILE_MAXIMIZED,
+ WATCH_WHILE_FULLSCREEN,
+ WATCH_WHILE_SLIDING_MAXIMIZED_FULLSCREEN,
+ WATCH_WHILE_SLIDING_MINIMIZED_MAXIMIZED,
+ WATCH_WHILE_SLIDING_MINIMIZED_DISMISSED,
+ WATCH_WHILE_SLIDING_FULLSCREEN_DISMISSED,
+ INLINE_MINIMAL,
+ VIRTUAL_REALITY_FULLSCREEN,
+ WATCH_WHILE_PICTURE_IN_PICTURE;
+
+ /* renamed from: a */
+ public final boolean m33524a() {
+ return !m33520e() && m33523b() && m33517h();
+ }
+
+ /* renamed from: b */
+ public final boolean m33523b() {
+ return this == WATCH_WHILE_FULLSCREEN || this == VIRTUAL_REALITY_FULLSCREEN || this == WATCH_WHILE_PICTURE_IN_PICTURE;
+ }
+
+ /* renamed from: c */
+ public final boolean m33522c() {
+ return this == NONE || m33521d();
+ }
+
+ /* renamed from: d */
+ public final boolean m33521d() {
+ return this == INLINE_MINIMAL;
+ }
+
+ /* renamed from: e */
+ public final boolean m33520e() {
+ return this == WATCH_WHILE_PICTURE_IN_PICTURE;
+ }
+
+ /* renamed from: f */
+ public final boolean m33519f() {
+ return (this == NONE || this == HIDDEN) ? false : true;
+ }
+
+ /* renamed from: g */
+ public final boolean m33518g() {
+ return this == VIRTUAL_REALITY_FULLSCREEN;
+ }
+
+ /* renamed from: h */
+ public final boolean m33517h() {
+ return this == WATCH_WHILE_MINIMIZED || this == WATCH_WHILE_MAXIMIZED || this == WATCH_WHILE_FULLSCREEN || this == WATCH_WHILE_SLIDING_MAXIMIZED_FULLSCREEN || this == WATCH_WHILE_SLIDING_MINIMIZED_MAXIMIZED || this == WATCH_WHILE_SLIDING_MINIMIZED_DISMISSED || this == WATCH_WHILE_SLIDING_FULLSCREEN_DISMISSED || this == WATCH_WHILE_PICTURE_IN_PICTURE;
+ }
+
+ /* renamed from: i */
+ public final boolean m33516i() {
+ return this == WATCH_WHILE_MAXIMIZED || this == WATCH_WHILE_FULLSCREEN;
+ }
+
+ /* renamed from: j */
+ public final boolean m33515j() {
+ return m33516i() || this == WATCH_WHILE_SLIDING_MAXIMIZED_FULLSCREEN;
+ }
+
+ /* renamed from: k */
+ public final boolean m33514k() {
+ return this == WATCH_WHILE_MINIMIZED || this == WATCH_WHILE_SLIDING_MINIMIZED_DISMISSED;
+ }
+
+ /* renamed from: l */
+ public final boolean m33513l() {
+ return m33514k() || m33512m();
+ }
+
+ /* renamed from: m */
+ public final boolean m33512m() {
+ return this == WATCH_WHILE_SLIDING_MINIMIZED_MAXIMIZED || this == WATCH_WHILE_SLIDING_MINIMIZED_DISMISSED || this == WATCH_WHILE_SLIDING_MAXIMIZED_FULLSCREEN || this == WATCH_WHILE_SLIDING_FULLSCREEN_DISMISSED;
+ }
+}
+
+/* loaded from: classes6.dex */
+public class XGlobals {
+ private static Object AutoRepeatClass;
+ private static env PlayerType;
+ public static FensterGestureController fensterGestureController;
+ public static Boolean XFILEDEBUG = false;
+ public static Boolean newVideo = false;
+ public static Boolean newVideoSpeed = false;
+ public static Boolean debug = false;
+ private static Boolean settingsInitialized = false;
+ public static String manufacturerOverride = null;
+ public static String modelOverride = null;
+ public static Boolean overrideCodec = false;
+ public static Boolean userChangedQuality = false;
+ public static Boolean userChangedSpeed = false;
+ public static Integer prefResolutionWIFI = -2;
+ public static Integer prefResolutionMobile = -2;
+ public static Float prefVideoSpeed = -2.0f;
+ public static Boolean prefAutoCaptions = false;
+ public static Boolean homeAdsShown = false;
+ public static Boolean videoAdsShown = false;
+ public static Boolean reelShown = true;
+ public static Boolean suggestionsShown = true;
+ public static Boolean infoCardsShown = true;
+ public static Boolean brandingShown = true;
+ public static Boolean castButtonShown = true;
+ public static Boolean tabletMiniplayer = false;
+ public static Boolean commentsLocation = false;
+ public static Boolean newActionBar = false;
+ public static Boolean verticalZoomToFit = false;
+ public static Boolean isDarkApp = false;
+ public static Boolean accessibilitySeek = false;
+ public static Boolean HDRBrightness = true;
+ public static Boolean EnableXFensterBrightness = false;
+ public static Boolean EnableXFensterVolume = false;
+ public static Integer maxBuffer = 120000;
+ public static Integer playbackMS = 2500;
+ public static Integer reBuffer = 5000;
+
+ public static void ReadSettings() {
+ Context context;
+ if (!settingsInitialized.booleanValue() && (context = YouTubeTikTokRoot_Application.getAppContext()) != null) {
+ ColorRef.setContext(context);
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ debug = Boolean.valueOf(sharedPreferences.getBoolean("debug_xfile_enabled", false));
+ manufacturerOverride = sharedPreferences.getString("override_manufacturer", null);
+ modelOverride = sharedPreferences.getString("override_model", null);
+ overrideCodec = Boolean.valueOf(sharedPreferences.getBoolean("override_resolution_xfile_enabled", false));
+ prefResolutionWIFI = Integer.valueOf(Integer.parseInt(sharedPreferences.getString("pref_preferred_video_quality_wifi", "-2")));
+ prefResolutionMobile = Integer.valueOf(Integer.parseInt(sharedPreferences.getString("pref_preferred_video_quality_mobile", "-2")));
+ prefVideoSpeed = Float.valueOf(Float.parseFloat(sharedPreferences.getString("pref_preferred_video_speed", "-2")));
+ prefAutoCaptions = Boolean.valueOf(sharedPreferences.getBoolean("pref_auto_captions", false));
+ homeAdsShown = Boolean.valueOf(sharedPreferences.getBoolean("home_ads_enabled", false));
+ videoAdsShown = Boolean.valueOf(sharedPreferences.getBoolean("video_ads_enabled", false));
+ reelShown = Boolean.valueOf(sharedPreferences.getBoolean("reel_enabled", true));
+ suggestionsShown = Boolean.valueOf(sharedPreferences.getBoolean("info_card_suggestions_enabled", true));
+ infoCardsShown = Boolean.valueOf(sharedPreferences.getBoolean("info_cards_enabled", true));
+ brandingShown = Boolean.valueOf(sharedPreferences.getBoolean("branding_watermark_enabled", true));
+ castButtonShown = Boolean.valueOf(sharedPreferences.getBoolean("cast_button_enabled", true));
+ tabletMiniplayer = Boolean.valueOf(sharedPreferences.getBoolean("tablet_miniplayer", false));
+ commentsLocation = Boolean.valueOf(sharedPreferences.getBoolean("comments_location", false));
+ newActionBar = Boolean.valueOf(sharedPreferences.getBoolean("xfile_new_actionbar", false));
+ verticalZoomToFit = Boolean.valueOf(sharedPreferences.getBoolean("xfile_zoom_to_fit_vertical", false));
+ isDarkApp = Boolean.valueOf(sharedPreferences.getBoolean("app_theme_dark", false));
+ accessibilitySeek = Boolean.valueOf(sharedPreferences.getBoolean("xfile_accessibility_seek_buttons", false));
+ HDRBrightness = Boolean.valueOf(sharedPreferences.getBoolean("pref_hdr_autobrightness", true));
+ if (sharedPreferences.getBoolean("pref_xfenster", false)) {
+ sharedPreferences.edit().remove("pref_xfenster").putBoolean("pref_xfenster_brightness", true).putBoolean("pref_xfenster_volume", true).apply();
+ }
+ EnableXFensterBrightness = Boolean.valueOf(sharedPreferences.getBoolean("pref_xfenster_brightness", false));
+ EnableXFensterVolume = Boolean.valueOf(sharedPreferences.getBoolean("pref_xfenster_volume", false));
+ try {
+ FensterGestureListener.SWIPE_THRESHOLD = Integer.parseInt(sharedPreferences.getString("pref_xfenster_swipe_threshold", "0"));
+ } catch (NumberFormatException e) {
+ sharedPreferences.edit().putString("pref_xfenster_swipe_threshold", "0").apply();
+ FensterGestureListener.SWIPE_THRESHOLD = 0;
+ }
+ try {
+ FensterGestureListener.TOP_PADDING = Integer.parseInt(sharedPreferences.getString("pref_xfenster_swipe_padding_top", "20"));
+ } catch (NumberFormatException e2) {
+ sharedPreferences.edit().putString("pref_xfenster_swipe_padding_top", "20").apply();
+ FensterGestureListener.TOP_PADDING = 20;
+ }
+ String string = sharedPreferences.getString("pref_max_buffer_ms", "120000");
+ if (string.isEmpty()) {
+ string = "1";
+ }
+ maxBuffer = Integer.valueOf(Integer.parseInt(string));
+ String string2 = sharedPreferences.getString("pref_buffer_for_playback_ms", "2500");
+ if (string2.isEmpty()) {
+ string2 = "1";
+ }
+ playbackMS = Integer.valueOf(Integer.parseInt(string2));
+ String string3 = sharedPreferences.getString("pref_buffer_for_playback_after_rebuffer_ms", "5000");
+ if (string3.isEmpty()) {
+ string3 = "1";
+ }
+ reBuffer = Integer.valueOf(Integer.parseInt(string3));
+ settingsInitialized = true;
+ }
+ }
+
+ public static String getManufacturer() {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning Build.MANUFACTURER!");
+ return Build.MANUFACTURER;
+ }
+ String manufacturer = manufacturerOverride;
+ if (manufacturer == null || manufacturer.isEmpty()) {
+ manufacturer = Build.MANUFACTURER;
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getManufacturer: " + manufacturer);
+ }
+ return manufacturer;
+ }
+
+ public static String getModel() {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning Build.MODEL!");
+ return Build.MODEL;
+ }
+ String model = modelOverride;
+ if (model == null || model.isEmpty()) {
+ model = Build.MODEL;
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getModel: " + model);
+ }
+ return model;
+ }
+
+ public static boolean autoCaptions(boolean original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ }
+ Boolean captions = Boolean.valueOf(original);
+ if (prefAutoCaptions.booleanValue()) {
+ captions = true;
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "autoCaptions: " + captions);
+ }
+ return captions.booleanValue();
+ }
+
+ public static boolean getOverride(boolean original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ }
+ Boolean compatibility = Boolean.valueOf(original);
+ if (overrideCodec.booleanValue()) {
+ compatibility = true;
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getOverride: " + compatibility);
+ }
+ return compatibility.booleanValue();
+ }
+
+ public static int getCommentsLocation(int original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ } else if (!commentsLocation.booleanValue()) {
+ return original;
+ } else {
+ if (!debug.booleanValue()) {
+ return 3;
+ }
+ Log.d("XGlobals", "getCommentsLocation: Moving comments back down");
+ return 3;
+ }
+ }
+
+ public static boolean getTabletMiniplayerOverride(boolean original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ } else if (!tabletMiniplayer.booleanValue()) {
+ return original;
+ } else {
+ if (!debug.booleanValue()) {
+ return true;
+ }
+ Log.d("XGlobals", "getTabletMiniplayerOverride: Using tablet miniplayer");
+ return true;
+ }
+ }
+
+ public static boolean getCastButtonOverride(boolean original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ } else if (castButtonShown.booleanValue()) {
+ return original;
+ } else {
+ if (!debug.booleanValue()) {
+ return true;
+ }
+ Log.d("XGlobals", "getCastButtonOverride: Hidden by override");
+ return true;
+ }
+ }
+
+ public static boolean getNewActionBar(boolean original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ } else if (!newActionBar.booleanValue()) {
+ return original;
+ } else {
+ if (!debug.booleanValue()) {
+ return true;
+ }
+ Log.d("XGlobals", "getNewActionBar: Enabled");
+ return true;
+ }
+ }
+
+ public static int getCastButtonOverrideV2(int original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ } else if (castButtonShown.booleanValue()) {
+ return original;
+ } else {
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getCastButtonOverrideV2: Hidden by override");
+ }
+ return 8;
+ }
+ }
+
+ public static boolean getNewActionBarNegated(boolean original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ } else if (!newActionBar.booleanValue()) {
+ return original;
+ } else {
+ if (!debug.booleanValue()) {
+ return false;
+ }
+ Log.d("XGlobals", "getNewActionBar: Enabled");
+ return false;
+ }
+ }
+
+ public static boolean getVerticalZoomToFit(boolean original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ } else if (!verticalZoomToFit.booleanValue()) {
+ return original;
+ } else {
+ if (!debug.booleanValue()) {
+ return true;
+ }
+ Log.d("XGlobals", "getVerticalZoomToFit: Enabled");
+ return true;
+ }
+ }
+
+ public static int getMinimizedVideo(int original) {
+ ReadSettings();
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ int preferredType = Integer.parseInt(sharedPreferences.getString("pref_minimized_video_preview", "-2"));
+ if (preferredType == -2) {
+ return original;
+ }
+ if (preferredType == 0 || preferredType == 1) {
+ return preferredType;
+ }
+ return original;
+ }
+
+ public static boolean getThemeStatus() {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning false!");
+ return false;
+ } else if (!isDarkApp.booleanValue()) {
+ return false;
+ } else {
+ if (!debug.booleanValue()) {
+ return true;
+ }
+ Log.d("XGlobals", "getThemeStatus: Is themed");
+ return true;
+ }
+ }
+
+ public static boolean accessibilitySeek(boolean original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ }
+ Boolean seek = Boolean.valueOf(original);
+ if (accessibilitySeek.booleanValue()) {
+ seek = true;
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "accessibilitySeek: " + seek);
+ }
+ return seek.booleanValue();
+ }
+
+ public static boolean useOldStyleQualitySettings() {
+ boolean value;
+ try {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XGlobals", "useOldStyleQualitySettings - Context is null, returning false!");
+ value = true;
+ } else {
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ value = sharedPreferences.getBoolean("old_style_quality_settings", true);
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "old_style_quality_settings set to: " + value);
+ }
+ }
+ return value;
+ } catch (Exception ex) {
+ Log.e("XGlobals", "Unable to get old style quality settings", ex);
+ return true;
+ }
+ }
+
+ public static boolean shouldAutoRepeat() {
+ ReadSettings();
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XGlobals", "shouldAutoRepeat - Context is null, returning false!");
+ return false;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ boolean repeat = sharedPreferences.getBoolean("pref_auto_repeat", false);
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "shouldAutoRepeat: " + repeat);
+ }
+ return repeat;
+ }
+
+ @Deprecated
+ public static void trySetAutonav(boolean autoNav) {
+ try {
+ ReadSettings();
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XGlobals", "shouldAutoRepeat - Context is null, returning false!");
+ return;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ sharedPreferences.edit().putBoolean("autonav_settings_activity_key", autoNav).apply();
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "autonav_settings_activity_key set to: " + autoNav);
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ public static float getHDRBrightness(float original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, getHDRBrightness returning " + original + "!");
+ return original;
+ }
+ float finalValue = original;
+ if (!HDRBrightness.booleanValue()) {
+ if (isFensterBrightnessEnabled()) {
+ finalValue = BrightnessHelper.getBrightness();
+ } else {
+ finalValue = -1.0f;
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getHDRBrightness switched to: " + finalValue);
+ }
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getHDRBrightness: " + finalValue);
+ }
+ return finalValue;
+ }
+
+ public static int getMaxBuffer(int original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, getMaxBuffer returning " + original + "!");
+ return original;
+ }
+ int retrievedValue = maxBuffer.intValue();
+ return retrievedValue;
+ }
+
+ public static int getPlaybackBuffer(int original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, getMaxBuffer returning " + original + "!");
+ return original;
+ }
+ int retrievedValue = playbackMS.intValue();
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getPlaybackBuffer switched to: " + retrievedValue);
+ }
+ return retrievedValue;
+ }
+
+ public static int getReBuffer(int original) {
+ ReadSettings();
+ if (!settingsInitialized.booleanValue()) {
+ Log.e("XGlobals", "Context is null, getMaxBuffer returning " + original + "!");
+ return original;
+ }
+ int retrievedValue = reBuffer.intValue();
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getReBuffer switched to: " + retrievedValue);
+ }
+ return retrievedValue;
+ }
+
+ public static void InitializeFensterController(Context context, ViewGroup viewGroup, ViewConfiguration viewConfiguration) {
+ fensterGestureController = new FensterGestureController();
+ fensterGestureController.setFensterEventsListener(new XFenster(context, viewGroup), context, viewConfiguration);
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "XFenster initialized");
+ }
+ }
+
+ public static boolean FensterTouchEvent(MotionEvent motionEvent) {
+ if (fensterGestureController == null) {
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "fensterGestureController is null");
+ }
+ return false;
+ } else if (motionEvent == null) {
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "motionEvent is null");
+ }
+ return false;
+ } else if (!XSwipeHelper.IsControlsShown()) {
+ return fensterGestureController.onTouchEvent(motionEvent);
+ } else {
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "skipping onTouchEvent dispatching because controls are shown.");
+ }
+ return false;
+ }
+ }
+
+ public static void PlayerTypeChanged(env playerType) {
+ if (debug.booleanValue()) {
+ Log.d("XDebug", playerType.toString());
+ }
+ if (PlayerType != playerType) {
+ String playerTypeString = playerType.toString();
+ if (playerTypeString.equals("WATCH_WHILE_FULLSCREEN")) {
+ EnableXFenster();
+ } else {
+ DisableXFenster();
+ }
+ if (playerTypeString.equals("WATCH_WHILE_SLIDING_MINIMIZED_MAXIMIZED") || playerTypeString.equals("WATCH_WHILE_MINIMIZED") || playerTypeString.equals("WATCH_WHILE_PICTURE_IN_PICTURE")) {
+ NewSegmentHelperLayout.hide();
+ }
+ fi.vanced.libraries.youtube.player.PlayerType.playerTypeChanged(playerTypeString);
+ }
+ PlayerType = playerType;
+ }
+
+ public static void EnableXFenster() {
+ if (EnableXFensterBrightness.booleanValue() || EnableXFensterVolume.booleanValue()) {
+ FensterGestureController fensterGestureController2 = fensterGestureController;
+ fensterGestureController2.TouchesEnabled = true;
+ ((XFenster) fensterGestureController2.listener).enable(EnableXFensterBrightness.booleanValue(), EnableXFensterVolume.booleanValue());
+ }
+ }
+
+ public static void DisableXFenster() {
+ FensterGestureController fensterGestureController2 = fensterGestureController;
+ fensterGestureController2.TouchesEnabled = false;
+ ((XFenster) fensterGestureController2.listener).disable();
+ }
+
+ public static boolean isFensterBrightnessEnabled() {
+ return EnableXFensterBrightness.booleanValue();
+ }
+
+ public static void CheckForMicroG(Activity activity) {
+ AlertDialog.Builder builder;
+ if (!appInstalledOrNot("com.mgoogle.android.gms")) {
+ if (debug.booleanValue()) {
+ Log.d("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: fi.razerman.youtube.XGlobals.1
+ @Override // android.content.DialogInterface.OnClickListener
+ public void onClick(DialogInterface dialog, int id) {
+ }
+ }).show();
+ } else if (debug.booleanValue()) {
+ Log.i("XDebug", "Custom MicroG installation detected");
+ }
+ }
+
+ public static boolean isFensterEnabled() {
+ if (PlayerType != null && PlayerType.toString().equals("WATCH_WHILE_FULLSCREEN") && !XSwipeHelper.IsControlsShown()) {
+ return EnableXFensterBrightness.booleanValue() || EnableXFensterVolume.booleanValue();
+ }
+ return false;
+ }
+
+ public static boolean isWatchWhileFullScreen() {
+ if (PlayerType == null) {
+ return false;
+ }
+ return PlayerType.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;
+ }
+ }
+
+ private static String getVersionName() {
+ try {
+ PackageInfo pInfo = getContext().getPackageManager().getPackageInfo(getPackageName(), 0);
+ String version = pInfo.versionName;
+ return version;
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ return "Unknown";
+ }
+ }
+
+ private static int appGetFirstTimeRun() {
+ SharedPreferences appPreferences = getContext().getSharedPreferences("youtube_vanced", 0);
+ String appCurrentBuildVersion = getVersionName();
+ String appLastBuildVersion = appPreferences.getString("app_first_time", null);
+ if (appLastBuildVersion == null || !appLastBuildVersion.equalsIgnoreCase(appCurrentBuildVersion)) {
+ return appLastBuildVersion == null ? 0 : 2;
+ }
+ return 1;
+ }
+
+ public static void ChangeLogAndOfficialChecker(Activity activity) {
+ AlertDialog.Builder builder;
+ if (appGetFirstTimeRun() != 1) {
+ final String versionName = getVersionName();
+ String[] results = XJson.getVersion(versionName);
+ String title = "Vanced Team";
+ String message = "\n - xfileFIN\n - Laura Almeida \n - ZaneZam\n - KevinX8";
+ String buttonPositive = "Close";
+ String buttonNegative = "Remind later";
+ if (results != null && results.length >= 3 && results[0] != null && !results[0].isEmpty() && results[1] != null && !results[1].isEmpty() && results[2] != null && !results[2].isEmpty()) {
+ title = results[0];
+ message = results[1];
+ buttonPositive = results[2];
+ buttonNegative = (results.length < 4 || results[3] == null || results[3].isEmpty()) ? null : results[3];
+ }
+ if (Build.VERSION.SDK_INT >= 21) {
+ builder = new AlertDialog.Builder(activity, 16974374);
+ } else {
+ builder = new AlertDialog.Builder(activity);
+ }
+ builder.setTitle(title).setMessage(message).setPositiveButton(buttonPositive, new DialogInterface.OnClickListener() { // from class: fi.razerman.youtube.XGlobals.3
+ @Override // android.content.DialogInterface.OnClickListener
+ public void onClick(DialogInterface dialog, int id) {
+ SharedPreferences appPreferences = XGlobals.getContext().getSharedPreferences("youtube_vanced", 0);
+ appPreferences.edit().putString("app_first_time", versionName).apply();
+ }
+ }).setNegativeButton(buttonNegative, new DialogInterface.OnClickListener() { // from class: fi.razerman.youtube.XGlobals.2
+ @Override // android.content.DialogInterface.OnClickListener
+ public void onClick(DialogInterface dialog, int id) {
+ }
+ }).show();
+ }
+ }
+
+ private static void UnofficialChecker(Activity activity) {
+ AlertDialog.Builder builder;
+ if (ExecuteShellCommand("grep -r m0yP /magisk/iYTBPforMagisk")) {
+ if (Build.VERSION.SDK_INT >= 21) {
+ builder = new AlertDialog.Builder(activity, 16974374);
+ } else {
+ builder = new AlertDialog.Builder(activity);
+ }
+ builder.setTitle("Unofficial Version").setMessage("This is an unofficial Magisk module.\nNo support is provided for this and it's adviced to download the official one from the following url.\nUrl: goo.gl/xW9u4U").setPositiveButton("Close", new DialogInterface.OnClickListener() { // from class: fi.razerman.youtube.XGlobals.4
+ @Override // android.content.DialogInterface.OnClickListener
+ public void onClick(DialogInterface dialog, int id) {
+ }
+ }).show();
+ }
+ }
+
+ public static String getPackageName() {
+ ReadSettings();
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (XFILEDEBUG.booleanValue() && context == null) {
+ context = XSettingActivity.getAppContext();
+ }
+ if (context == null) {
+ Log.e("XGlobals", "Context is null, returning com.google.android.youtube!");
+ return "com.google.android.youtube";
+ }
+ String PACKAGE_NAME = context.getPackageName();
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getPackageName: " + PACKAGE_NAME);
+ }
+ return PACKAGE_NAME;
+ }
+
+ 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) {
+ Log.e("XGlobals", "Resource not found.", exception);
+ return "";
+ }
+ }
+
+ public static int getOverrideWidth(int original) {
+ ReadSettings();
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ int compatibility = original;
+ if (sharedPreferences.getBoolean("override_resolution_xfile_enabled", false)) {
+ compatibility = 2160;
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getOverrideWidth: " + compatibility);
+ }
+ return compatibility;
+ }
+
+ public static int getOverrideHeight(int original) {
+ ReadSettings();
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XGlobals", "Context is null, returning " + original + "!");
+ return original;
+ }
+ SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
+ int compatibility = original;
+ if (sharedPreferences.getBoolean("override_resolution_xfile_enabled", false)) {
+ compatibility = 3840;
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getOverrideHeight: " + compatibility);
+ }
+ return compatibility;
+ }
+
+ public static Context getContext() {
+ ReadSettings();
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context != null) {
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "getContext");
+ }
+ return context;
+ } else if (XFILEDEBUG.booleanValue()) {
+ return XSettingActivity.getAppContext();
+ } else {
+ Log.e("XGlobals", "Context is null, returning null!");
+ return null;
+ }
+ }
+
+ public static void setOldLayout(SharedPreferences sharedPreferences, String config, long timeStamp) {
+ ReadSettings();
+ if (!sharedPreferences.getBoolean("old_layout_xfile_enabled", false)) {
+ 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();
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "setOldLayout: true");
+ return;
+ }
+ 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();
+ }
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "setOldLayout: false");
+ }
+ }
+
+ public static void NewVideoStarted() {
+ ReadSettings();
+ newVideo = true;
+ newVideoSpeed = true;
+ if (debug.booleanValue()) {
+ Log.d("XGlobals", "New video started!");
+ }
+ }
+
+ public static boolean ExecuteShellCommand(String command) {
+ Process process = null;
+ try {
+ process = Runtime.getRuntime().exec(command);
+ BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ String line = in.readLine();
+ in.close();
+ if (debug.booleanValue()) {
+ Log.d("XDebug", "Command Output: " + line);
+ }
+ if (line.contains("m0yP")) {
+ if (process != null) {
+ try {
+ process.destroy();
+ } catch (Exception e) {
+ }
+ }
+ return true;
+ }
+ if (process != null) {
+ try {
+ process.destroy();
+ } catch (Exception e2) {
+ }
+ }
+ return false;
+ } catch (Exception e3) {
+ if (process != null) {
+ try {
+ process.destroy();
+ } catch (Exception e4) {
+ }
+ }
+ return false;
+ } catch (Throwable th) {
+ if (process != null) {
+ try {
+ process.destroy();
+ } catch (Exception e5) {
+ }
+ }
+ throw th;
+ }
+ }
+
+ public static Object PrintSettings(Object[] settings) {
+ Exception e;
+ Exception e2;
+ Class> stringType;
+ ReadSettings();
+ Class> stringType2 = String.class;
+ if (debug.booleanValue()) {
+ Log.d("Protobuf", "new settings array");
+ }
+ Object[] newArray = new Object[settings.length + 1];
+ boolean found = false;
+ int index = 0;
+ try {
+ if (debug.booleanValue()) {
+ try {
+ Log.d("Protobuf", "Printing array");
+ } catch (Exception e3) {
+ e = e3;
+ Log.e("Protobuf", "Error: " + e.getMessage());
+ return settings;
+ }
+ }
+ try {
+ try {
+ int i = 0;
+ String className = null;
+ for (Object settingObject : settings) {
+ try {
+ Field[] fields = settingObject.getClass().getFields();
+ int length = fields.length;
+ int i2 = 0;
+ while (true) {
+ if (i2 >= length) {
+ break;
+ }
+ Field field = fields[i2];
+ if (field.getType().isAssignableFrom(stringType2) && field.getName().equals("a")) {
+ String value = field.get(settingObject).toString();
+ if (value.equals("e")) {
+ className = settingObject.getClass().getName();
+ found = true;
+ break;
+ }
+ }
+ i2++;
+ }
+ index++;
+ if (found) {
+ break;
+ }
+ } catch (Exception e4) {
+ e2 = e4;
+ Log.e("Protobuf", "Error: " + e2.getMessage());
+ return settings;
+ }
+ }
+ if (found) {
+ if (debug.booleanValue()) {
+ Log.d("Protobuf", "Modifying array");
+ }
+ System.arraycopy(settings, 0, newArray, 0, index - 1);
+ Class> clazz = Class.forName(className);
+ Object object = clazz.newInstance();
+ newArray[index - 1] = object;
+ System.arraycopy(settings, index - 1, newArray, index, (settings.length - index) + 1);
+ } else {
+ newArray = settings;
+ }
+ int length2 = newArray.length;
+ boolean hitE = false;
+ int loop = 0;
+ int loop2 = 0;
+ while (loop2 < length2) {
+ Object settingObject2 = newArray[loop2];
+ Field[] fields2 = settingObject2.getClass().getFields();
+ int length3 = fields2.length;
+ boolean hitE2 = hitE;
+ while (i < length3) {
+ Field field2 = fields2[i];
+ if (!field2.getType().isAssignableFrom(stringType2)) {
+ stringType = stringType2;
+ length2 = length2;
+ } else if (field2.getName().equals("a")) {
+ if (loop != index - 1 || !found) {
+ stringType = stringType2;
+ } else {
+ if (debug.booleanValue()) {
+ StringBuilder sb = new StringBuilder();
+ stringType = stringType2;
+ sb.append("String a field: ");
+ sb.append(field2.get(settingObject2).toString());
+ sb.append(" set: country-type");
+ Log.d("Protobuf", sb.toString());
+ } else {
+ stringType = stringType2;
+ }
+ field2.set(settingObject2, "country-type");
+ }
+ String value2 = field2.get(settingObject2).toString();
+ if (value2.equals("e")) {
+ hitE2 = true;
+ }
+ if (debug.booleanValue()) {
+ StringBuilder sb2 = new StringBuilder();
+ length2 = length2;
+ sb2.append("String a field: ");
+ sb2.append(value2);
+ Log.d("Protobuf", sb2.toString());
+ } else {
+ length2 = length2;
+ }
+ } else {
+ stringType = stringType2;
+ length2 = length2;
+ if (field2.getName().equals("b")) {
+ if (loop == index - 1 && found) {
+ if (debug.booleanValue()) {
+ Log.d("Protobuf", "String b field: " + field2.get(settingObject2).toString() + " set: B");
+ }
+ field2.set(settingObject2, "B");
+ }
+ String value3 = field2.get(settingObject2).toString();
+ if (hitE2) {
+ field2.set(settingObject2, "11202606,9415293,9422596,9429003,9431755,9435797,9442923,9444108,9444635,9449243,9453077,9456940,9463829,9464088,9467503,9476327,9477614,9478523,9480475,9480495,9482942,9483422,9483531,9484706,9485998,9487653,9487664,9488038,9488230,9489113");
+ hitE2 = false;
+ }
+ if (debug.booleanValue()) {
+ Log.d("Protobuf", "String b field: " + value3);
+ }
+ } else {
+ String value4 = field2.get(settingObject2).toString();
+ if (debug.booleanValue()) {
+ Log.d("Protobuf", "String field: " + field2.getName() + " = " + value4);
+ }
+ }
+ }
+ i++;
+ stringType2 = stringType;
+ }
+ loop++;
+ loop2++;
+ hitE = hitE2;
+ i = 0;
+ }
+ return newArray;
+ } catch (Exception e5) {
+ e = e5;
+ Log.e("Protobuf", "Error: " + e.getMessage());
+ return settings;
+ }
+ } catch (Exception e6) {
+ e2 = e6;
+ }
+ } catch (Exception e7) {
+ e = e7;
+ }
+ return null;
+ }
+
+ public static Object PrintSettings(Object[] settings, int type) {
+ Exception e;
+ int i = 0;
+ boolean found;
+ Class> stringType;
+ ReadSettings();
+ boolean modifyArray = type == 2;
+ Class> stringType2 = String.class;
+ if (debug.booleanValue()) {
+ Log.d("Protobuf", "new settings array");
+ }
+ Object[] newArray = new Object[settings.length + 1];
+ if (!modifyArray) {
+ newArray = settings;
+ }
+ boolean found2 = false;
+ int index = 0;
+ if (modifyArray) {
+ try {
+ if (debug.booleanValue()) {
+ Log.d("Protobuf", "Modifying array");
+ }
+ try {
+ int length = settings.length;
+ int index2 = 0;
+ boolean found3 = false;
+ int i2 = 0;
+ while (true) {
+ if (i2 >= length) {
+ found2 = found3;
+ index = index2;
+ break;
+ }
+ try {
+ Object settingObject = settings[i2];
+ Field[] fields = settingObject.getClass().getFields();
+ int length2 = fields.length;
+ int i3 = 0;
+ while (true) {
+ if (i3 >= length2) {
+ break;
+ }
+ Field field = fields[i3];
+ if (field.getType().isAssignableFrom(stringType2) && field.getName().equals("a")) {
+ String value = field.get(settingObject).toString();
+ if (value.equals("e")) {
+ found3 = true;
+ break;
+ }
+ }
+ i3++;
+ }
+ index2++;
+ if (found3) {
+ found2 = found3;
+ index = index2;
+ break;
+ }
+ i2++;
+ } catch (Exception e2) {
+ e = e2;
+ Log.e("Protobuf", "Error: " + e.getMessage());
+ return settings;
+ }
+ }
+ i = 0;
+ System.arraycopy(settings, 0, newArray, 0, index);
+ System.arraycopy(settings, index - 1, newArray, index, (settings.length - index) + 1);
+ } catch (Exception e3) {
+ e = e3;
+ }
+ } catch (Exception e4) {
+ e = e4;
+ Log.e("Protobuf", "Error: " + e.getMessage());
+ return settings;
+ }
+ } else {
+ i = 0;
+ newArray = settings;
+ }
+ try {
+ int length3 = newArray.length;
+ int loop = 0;
+ int loop2 = i;
+ while (loop2 < length3) {
+ Object settingObject2 = newArray[loop2];
+ Field[] fields2 = settingObject2.getClass().getFields();
+ int length4 = fields2.length;
+ while (i < length4) {
+ Field field2 = fields2[i];
+ if (!field2.getType().isAssignableFrom(stringType2)) {
+ stringType = stringType2;
+ found = found2;
+ } else if (field2.getName().equals("a")) {
+ if (loop == index - 1 && modifyArray) {
+ field2.set(settingObject2, "country-type");
+ }
+ String value2 = field2.get(settingObject2).toString();
+ if (debug.booleanValue()) {
+ stringType = stringType2;
+ try {
+ StringBuilder sb = new StringBuilder();
+ found = found2;
+ sb.append("String a field: ");
+ sb.append(value2);
+ Log.d("Protobuf", sb.toString());
+ } catch (Exception e5) {
+ e = e5;
+ Log.e("Protobuf", "Error: " + e.getMessage());
+ return settings;
+ }
+ } else {
+ stringType = stringType2;
+ found = found2;
+ }
+ } else {
+ stringType = stringType2;
+ found = found2;
+ if (field2.getName().equals("b")) {
+ if (loop == index - 1 && modifyArray) {
+ field2.set(settingObject2, "B");
+ }
+ String value3 = field2.get(settingObject2).toString();
+ if (debug.booleanValue()) {
+ Log.d("Protobuf", "String b field: " + value3);
+ }
+ } else {
+ String value4 = field2.get(settingObject2).toString();
+ if (debug.booleanValue()) {
+ Log.d("Protobuf", "String field: " + field2.getName() + " = " + value4);
+ }
+ }
+ }
+ i++;
+ stringType2 = stringType;
+ found2 = found;
+ }
+ loop++;
+ loop2++;
+ i = 0;
+ }
+ return newArray;
+ } catch (Exception e6) {
+ e = e6;
+ }
+ return null;
+ }
+
+ public static void PrintVideoQualities(Object quality, int mode) {
+ Class> intType;
+ Class> stringType;
+ Field fieldArray;
+ ReadSettings();
+ if (debug.booleanValue()) {
+ Log.d("VideoQualities", "Quality parameter: " + mode);
+ }
+ if (mode == 0) {
+ Class> intType2 = Integer.TYPE;
+ Class> stringType2 = String.class;
+ Class> boolType = Boolean.TYPE;
+ try {
+ Class> clazz = quality.getClass();
+ Field fieldArray2 = clazz.getField("e");
+ Object[] fieldValue = (Object[]) fieldArray2.get(quality);
+ ArrayList iStreamQualities = new ArrayList<>();
+ ArrayList sStreamQualities = new ArrayList<>();
+ ArrayList bStreamQualities = new ArrayList<>();
+ int length = fieldValue.length;
+ int i = 0;
+ while (i < length) {
+ Object streamQuality = fieldValue[i];
+ Field[] fields = streamQuality.getClass().getFields();
+ int length2 = fields.length;
+ int i2 = 0;
+ while (i2 < length2) {
+ Field field = fields[i2];
+ if (field.getType().isAssignableFrom(intType2)) {
+ try {
+ int value = field.getInt(streamQuality);
+ intType = intType2;
+ try {
+ int length3 = field.getName().length();
+ fieldArray = fieldArray2;
+ if (length3 <= 2) {
+ iStreamQualities.add(Integer.valueOf(value));
+ }
+ if (debug.booleanValue()) {
+ Log.d("VideoQualities", "Integer field: " + field.getName() + " = " + value);
+ }
+ stringType = stringType2;
+ } catch (Exception e) {
+ return;
+ }
+ } catch (Exception e2) {
+ return;
+ }
+ } else {
+ intType = intType2;
+ fieldArray = fieldArray2;
+ try {
+ if (field.getType().isAssignableFrom(stringType2)) {
+ String value2 = field.get(streamQuality).toString();
+ sStreamQualities.add(value2);
+ if (debug.booleanValue()) {
+ StringBuilder sb = new StringBuilder();
+ stringType = stringType2;
+ try {
+ sb.append("String field: ");
+ sb.append(field.getName());
+ sb.append(" = ");
+ sb.append(value2);
+ Log.d("VideoQualities", sb.toString());
+ } catch (Exception e3) {
+ return;
+ }
+ } else {
+ stringType = stringType2;
+ }
+ } else {
+ stringType = stringType2;
+ if (field.getType().isAssignableFrom(boolType)) {
+ boolean value3 = field.getBoolean(streamQuality);
+ bStreamQualities.add(Boolean.valueOf(value3));
+ if (debug.booleanValue()) {
+ Log.d("VideoQualities", "Boolean field: " + field.getName() + " = " + value3);
+ }
+ }
+ }
+ } catch (Exception e4) {
+ return;
+ }
+ }
+ i2++;
+ fieldArray2 = fieldArray;
+ stringType2 = stringType;
+ intType2 = intType;
+ }
+ i++;
+ clazz = clazz;
+ }
+ } catch (Exception e5) {
+ }
+ }
+ }
+
+ public static void PrintQualities(Object[] qualities, int quality) {
+ ArrayList iStreamQualities;
+ Class> intType;
+ Object[] objArr = qualities;
+ ReadSettings();
+ Class> intType2 = Integer.TYPE;
+ Class> boolType = Boolean.TYPE;
+ if (debug.booleanValue()) {
+ Log.d("QUALITY", "Quality parameter: " + quality);
+ }
+ try {
+ ArrayList iStreamQualities2 = new ArrayList<>();
+ ArrayList sStreamQualities = new ArrayList<>();
+ ArrayList bStreamQualities = new ArrayList<>();
+ int length = objArr.length;
+ int i = 0;
+ while (i < length) {
+ Object streamQuality = objArr[i];
+ Field[] fields = streamQuality.getClass().getFields();
+ int length2 = fields.length;
+ int i2 = 0;
+ while (i2 < length2) {
+ Field field = fields[i2];
+ if (field.getType().isAssignableFrom(intType2)) {
+ int value = field.getInt(streamQuality);
+ intType = intType2;
+ if (field.getName().length() <= 2) {
+ try {
+ iStreamQualities2.add(Integer.valueOf(value));
+ } catch (Exception e) {
+ return;
+ }
+ }
+ if (debug.booleanValue()) {
+ StringBuilder sb = new StringBuilder();
+ iStreamQualities = iStreamQualities2;
+ sb.append("Integer field: ");
+ sb.append(field.getName());
+ sb.append(" = ");
+ sb.append(value);
+ Log.d("QUALITY", sb.toString());
+ } else {
+ iStreamQualities = iStreamQualities2;
+ }
+ } else {
+ iStreamQualities = iStreamQualities2;
+ intType = intType2;
+ if (field.getType().isAssignableFrom(String.class)) {
+ String value2 = field.get(streamQuality).toString();
+ sStreamQualities.add(value2);
+ if (debug.booleanValue()) {
+ Log.d("QUALITY", "String field: " + field.getName() + " = " + value2);
+ }
+ } else if (field.getType().isAssignableFrom(boolType)) {
+ boolean value3 = field.getBoolean(streamQuality);
+ bStreamQualities.add(Boolean.valueOf(value3));
+ if (debug.booleanValue()) {
+ Log.d("QUALITY", "Boolean field: " + field.getName() + " = " + value3);
+ }
+ }
+ }
+ i2++;
+ intType2 = intType;
+ iStreamQualities2 = iStreamQualities;
+ }
+ i++;
+ objArr = qualities;
+ }
+ } catch (Exception e2) {
+ }
+ }
+
+ public static ColorStateList getAttributeColor(Context context, int attributeId) {
+ TypedValue typedValue = new TypedValue();
+ context.getTheme().resolveAttribute(attributeId, typedValue, true);
+ int colorRes = typedValue.resourceId;
+ int color = -1;
+ try {
+ color = context.getResources().getColor(colorRes);
+ } catch (Resources.NotFoundException e) {
+ Log.w("XGlobals", "Not found color resource by id: " + colorRes);
+ }
+ int[][] states = {new int[]{16842910}, new int[]{-16842910}, new int[]{-16842912}, new int[]{16842919}};
+ int[] colors = {color, color, color, color};
+ ColorStateList myList = new ColorStateList(states, colors);
+ return myList;
+ }
}
diff --git a/integrations/java/fi/razerman/youtube/XJson.java b/integrations/java/fi/razerman/youtube/XJson.java
new file mode 100644
index 000000000..307914920
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/XJson.java
@@ -0,0 +1,65 @@
+package fi.razerman.youtube;
+
+import android.text.format.Time;
+import android.util.Log;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import org.json.JSONObject;
+
+/* loaded from: classes6.dex */
+public class XJson {
+ public static String[] getVersion(String versionName) {
+ try {
+ final String[] results = new String[4];
+ final String vName = versionName.replace('.', '_');
+ Thread t = new Thread() { // from class: fi.razerman.youtube.XJson.1
+ @Override // java.lang.Thread, java.lang.Runnable
+ public void run() {
+ try {
+ Time now = new Time();
+ now.setToNow();
+ String time = "" + now.hour + now.minute + now.second;
+ int time_int = Integer.parseInt(time);
+ URL url = new URL("https://github.com/YTVanced/VancedBackend/releases/download/changelogs/" + vName + "?searchTime=" + time_int); // TODO change to ReVanced changelog URL.
+ url.openConnection().setReadTimeout(2000);
+ url.openConnection().setConnectTimeout(2000);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
+ StringBuilder sb = new StringBuilder();
+ while (true) {
+ String line = reader.readLine();
+ if (line != null) {
+ sb.append(line).append("\n");
+ } else {
+ String json = sb.toString();
+ reader.close();
+ JSONObject jsonObject = new JSONObject(json);
+ String title = jsonObject.getString("title");
+ String message = jsonObject.getString("message");
+ String buttonpositive = jsonObject.getString("buttonpositive");
+ results[0] = title;
+ results[1] = message;
+ results[2] = buttonpositive;
+ try {
+ String buttonnegative = jsonObject.getString("buttonnegative");
+ results[3] = buttonnegative;
+ return;
+ } catch (Exception e) {
+ return;
+ }
+ }
+ }
+ } catch (Exception e2) {
+ Log.e("XError", "exception", e2);
+ }
+ }
+ };
+ t.start();
+ t.join();
+ return results;
+ } catch (Exception e) {
+ Log.e("XError", "exception", e);
+ return null;
+ }
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/XReboot.java b/integrations/java/fi/razerman/youtube/XReboot.java
new file mode 100644
index 000000000..e19dcc16a
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/XReboot.java
@@ -0,0 +1,29 @@
+package fi.razerman.youtube;
+
+import android.app.Activity;
+import android.app.AlarmManager;
+import android.app.AlertDialog;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Process;
+import com.google.android.apps.youtube.app.application.Shell_HomeActivity;
+
+/* loaded from: classes6.dex */
+public class XReboot {
+ static void Reboot(Activity activity) {
+ 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, Shell_HomeActivity.class), intent));
+ Process.killProcess(Process.myPid());
+ }
+
+ /* JADX INFO: Access modifiers changed from: package-private */
+ public static void RebootDialog(final Activity activity) {
+ // from class: fi.razerman.youtube.XReboot.1
+// android.content.DialogInterface.OnClickListener
+ new AlertDialog.Builder(activity).setMessage(XGlobals.getStringByName(activity, "pref_refresh_config")).setPositiveButton(XGlobals.getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> XReboot.Reboot(activity)).setNegativeButton(XGlobals.getStringByName(activity, "sign_in_cancel"), null).show();
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/XRecreate.java b/integrations/java/fi/razerman/youtube/XRecreate.java
new file mode 100644
index 000000000..0b08d9291
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/XRecreate.java
@@ -0,0 +1,18 @@
+package fi.razerman.youtube;
+
+import android.app.Activity;
+
+/* loaded from: classes6.dex */
+final class XRecreate implements Runnable {
+ private final Activity activity;
+
+ /* JADX INFO: Access modifiers changed from: package-private */
+ public XRecreate(Activity activity) {
+ this.activity = activity;
+ }
+
+ @Override // java.lang.Runnable
+ public final void run() {
+ this.activity.recreate();
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/XRefresher.java b/integrations/java/fi/razerman/youtube/XRefresher.java
new file mode 100644
index 000000000..ca54cdce9
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/XRefresher.java
@@ -0,0 +1,25 @@
+package fi.razerman.youtube;
+
+import android.app.Activity;
+import android.os.Handler;
+import android.os.Looper;
+import android.preference.Preference;
+
+/* loaded from: classes6.dex */
+public final class XRefresher implements Preference.OnPreferenceClickListener {
+ private final XSettingsFragment fragment;
+
+ public XRefresher(XSettingsFragment xSettingsFragment) {
+ this.fragment = xSettingsFragment;
+ }
+
+ @Override // android.preference.Preference.OnPreferenceClickListener
+ public final boolean onPreferenceClick(Preference preference) {
+ XSettingsFragment fragment = this.fragment;
+ Handler handler = new Handler(Looper.getMainLooper());
+ Activity activity = fragment.getActivity();
+ activity.getClass();
+ handler.postAtFrontOfQueue(new XRecreate(activity));
+ return true;
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/XSettingActivity.java b/integrations/java/fi/razerman/youtube/XSettingActivity.java
new file mode 100644
index 000000000..1c05d7225
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/XSettingActivity.java
@@ -0,0 +1,122 @@
+package fi.razerman.youtube;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageButton;
+import android.widget.TextView;
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.Helpers.XThemeHelpers;
+import fi.vanced.libraries.youtube.ryd.RYDFragment;
+import pl.jakubweg.SponsorBlockPreferenceFragment;
+
+/* loaded from: classes6.dex */
+public class XSettingActivity extends Activity {
+ static String TAG = "XSettingsActivity";
+ private static Context context;
+ boolean currentTheme;
+
+ @Override // android.app.Activity
+ protected void onCreate(Bundle bundle) {
+ boolean isDarkTheme = XThemeHelpers.isDarkTheme();
+ this.currentTheme = isDarkTheme;
+ if (isDarkTheme) {
+ Log.d("XSettingsActivity", "set Theme.YouTube.Settings.Dark");
+ setTheme(getIdentifier("Theme.YouTube.Settings.Dark", "style"));
+ } else {
+ Log.d("XSettingsActivity", "set Theme.YouTube.Settings");
+ setTheme(getIdentifier("Theme.YouTube.Settings", "style"));
+ }
+ super.onCreate(bundle);
+ setContentView(getIdentifier("xsettings_with_toolbar", "layout"));
+ initImageButton(this.currentTheme);
+ String dataString = getIntent().getDataString();
+ if (dataString.equalsIgnoreCase("sponsorblock_settings")) {
+ trySetTitle(getIdentifier("sb_settings", "string"));
+ getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new SponsorBlockPreferenceFragment()).commit();
+ } else if (dataString.equalsIgnoreCase("ryd_settings")) {
+ trySetTitle(getIdentifier("vanced_ryd_settings_title", "string"));
+ getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new RYDFragment()).commit();
+ } else {
+ trySetTitle(getIdentifier("xfile_settings", "string"));
+ getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), new XSettingsFragment()).commit();
+ }
+ context = getApplicationContext();
+ }
+
+ private void trySetTitle(int i) {
+ try {
+ getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(i);
+ } catch (Exception e) {
+ Log.e(TAG, "Couldn't set Toolbar title", e);
+ }
+ }
+
+ private void trySetTitle(String str) {
+ try {
+ getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(str);
+ } catch (Exception e) {
+ Log.e(TAG, "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: fi.razerman.youtube.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) {
+ Log.e(TAG, "Couldn't set Toolbar click handler", e);
+ }
+ }
+
+ public static ImageButton getImageButton(ViewGroup viewGroup) {
+ if (viewGroup == null) {
+ return null;
+ }
+ int childCount = viewGroup.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View childAt = viewGroup.getChildAt(i);
+ if (childAt instanceof ImageButton) {
+ return (ImageButton) childAt;
+ }
+ }
+ return null;
+ }
+
+ public static TextView getTextView(ViewGroup viewGroup) {
+ if (viewGroup == null) {
+ return null;
+ }
+ int childCount = viewGroup.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View childAt = viewGroup.getChildAt(i);
+ if (childAt instanceof TextView) {
+ return (TextView) childAt;
+ }
+ }
+ return null;
+ }
+
+ private static int getIdentifier(String str, String str2) {
+ Context appContext = YouTubeTikTokRoot_Application.getAppContext();
+ return appContext.getResources().getIdentifier(str, str2, appContext.getPackageName());
+ }
+
+ public static Context getAppContext() {
+ Context context2 = context;
+ if (context2 != null) {
+ return context2;
+ }
+ Log.e("WatchWhileActivity", "Context is null!");
+ return null;
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/XSettingsFragment.java b/integrations/java/fi/razerman/youtube/XSettingsFragment.java
new file mode 100644
index 000000000..89911f87a
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/XSettingsFragment.java
@@ -0,0 +1,607 @@
+package fi.razerman.youtube;
+
+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.util.Log;
+import android.widget.Toast;
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.Autorepeat.AutoRepeat;
+import fi.razerman.youtube.Fenster.FensterGestureListener;
+import fi.razerman.youtube.Helpers.XScreenSizeHelpers;
+import fi.razerman.youtube.Helpers.XSwipeHelper;
+import fi.razerman.youtube.VideoUrl.Copy;
+import fi.razerman.youtube.VideoUrl.CopyWithTimeStamp;
+import vanced.integrations.BuildConfig;
+
+/* loaded from: classes6.dex */
+public class XSettingsFragment extends PreferenceFragment {
+
+ 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: fi.razerman.youtube.XSettingsFragment.9
+// android.content.SharedPreferences.OnSharedPreferenceChangeListener
+ SharedPreferences.OnSharedPreferenceChangeListener listener = (sharedPreferences, str) -> {
+ if ("debug_xfile_enabled".equals(str)) {
+ XGlobals.debug = ((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();
+ XGlobals.manufacturerOverride = "samsung";
+ XGlobals.modelOverride = "SM-G920F";
+ return;
+ }
+ sharedPreferences.edit().remove("override_manufacturer").apply();
+ sharedPreferences.edit().remove("override_model").apply();
+ XGlobals.manufacturerOverride = null;
+ XGlobals.modelOverride = null;
+ } else if ("override_manufacturer".equals(str)) {
+ EditTextPreference editTextPreference = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_manufacturer");
+ if (editTextPreference != null) {
+ editTextPreference.setSummary(editTextPreference.getText());
+ XGlobals.manufacturerOverride = editTextPreference.getText();
+ }
+ } else if ("override_model".equals(str)) {
+ EditTextPreference editTextPreference2 = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_model");
+ if (editTextPreference2 != null) {
+ editTextPreference2.setSummary(editTextPreference2.getText());
+ XGlobals.modelOverride = editTextPreference2.getText();
+ }
+ } else if ("home_ads_enabled".equals(str)) {
+ XGlobals.homeAdsShown = ((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("home_ads_enabled")).isChecked();
+ if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
+ XReboot.RebootDialog(XSettingsFragment.this.getActivity());
+ }
+ } else if ("video_ads_enabled".equals(str)) {
+ XGlobals.videoAdsShown = ((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("video_ads_enabled")).isChecked();
+ if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
+ XReboot.RebootDialog(XSettingsFragment.this.getActivity());
+ }
+ } else if ("reel_enabled".equals(str)) {
+ XGlobals.reelShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("reel_enabled")).isChecked();
+ if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
+ XReboot.RebootDialog(XSettingsFragment.this.getActivity());
+ }
+ } else if ("info_card_suggestions_enabled".equals(str)) {
+ XGlobals.suggestionsShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("info_card_suggestions_enabled")).isChecked();
+ } else if ("info_cards_enabled".equals(str)) {
+ XGlobals.infoCardsShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("info_cards_enabled")).isChecked();
+ } else if ("branding_watermark_enabled".equals(str)) {
+ XGlobals.brandingShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("branding_watermark_enabled")).isChecked();
+ } else if ("cast_button_enabled".equals(str)) {
+ XGlobals.castButtonShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("cast_button_enabled")).isChecked();
+ } else if ("tablet_miniplayer".equals(str)) {
+ XGlobals.tabletMiniplayer = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer")).isChecked();
+ if (XGlobals.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");
+ XGlobals.commentsLocation = switchPreference.isChecked();
+ XSwipeHelper.isTabletMode = switchPreference.isChecked();
+ if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
+ XReboot.RebootDialog(XSettingsFragment.this.getActivity());
+ }
+ } else if ("xfile_create_button_hidden".equals(str)) {
+ if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
+ XReboot.RebootDialog(XSettingsFragment.this.getActivity());
+ }
+ } else if ("xfile_new_actionbar".equals(str)) {
+ XGlobals.newActionBar = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_new_actionbar")).isChecked();
+ if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
+ XReboot.RebootDialog(XSettingsFragment.this.getActivity());
+ }
+ } else if ("xfile_zoom_to_fit_vertical".equals(str)) {
+ XGlobals.verticalZoomToFit = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_zoom_to_fit_vertical")).isChecked();
+ if (XGlobals.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 (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
+ XReboot.RebootDialog(XSettingsFragment.this.getActivity());
+ }
+ } else if ("xfile_accessibility_seek_buttons".equals(str)) {
+ XGlobals.accessibilitySeek = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_accessibility_seek_buttons")).isChecked();
+ } else if ("override_resolution_xfile_enabled".equals(str)) {
+ XGlobals.overrideCodec = ((SwitchPreference) XSettingsFragment.this.findPreference("override_resolution_xfile_enabled")).isChecked();
+ if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
+ XReboot.RebootDialog(XSettingsFragment.this.getActivity());
+ }
+ } else if ("pref_auto_captions".equals(str)) {
+ XGlobals.prefAutoCaptions = ((SwitchPreference) XSettingsFragment.this.findPreference("pref_auto_captions")).isChecked();
+ if (XGlobals.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)]);
+ XGlobals.prefResolutionWIFI = 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)]);
+ XGlobals.prefResolutionMobile = 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)]);
+ XGlobals.prefVideoSpeed = 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());
+ XGlobals.maxBuffer = 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());
+ XGlobals.playbackMS = 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());
+ XGlobals.reBuffer = 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)) {
+ XGlobals.HDRBrightness = ((SwitchPreference) XSettingsFragment.this.miscsPreferenceScreen.findPreference("pref_hdr_autobrightness")).isChecked();
+ } else if ("pref_xfenster_brightness".equals(str)) {
+ XGlobals.EnableXFensterBrightness = ((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_brightness")).isChecked();
+ } else if ("pref_xfenster_volume".equals(str)) {
+ XGlobals.EnableXFensterVolume = ((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_volume")).isChecked();
+ } else if ("pref_xfenster_tablet".equals(str)) {
+ XSwipeHelper.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) && XGlobals.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", XGlobals.getPackageName());
+ if (XGlobals.XFILEDEBUG) {
+ addPreferencesFromResource(2131689473);
+ } else {
+ addPreferencesFromResource(identifier);
+ }
+ if (!XGlobals.XFILEDEBUG) {
+ String stringByName = XGlobals.getStringByName(getActivity(), "quality_auto");
+ this.videoQualityEntries[0] = stringByName;
+ this.minimizedVideoEntries[0] = stringByName;
+ this.videoSpeedEntries[0] = stringByName;
+ String stringByName2 = XGlobals.getStringByName(getActivity(), "pref_subtitles_scale_normal");
+ if (stringByName2.equals("")) {
+ this.videoSpeedEntries[4] = "Normal";
+ } else {
+ this.videoSpeedEntries[4] = stringByName2;
+ }
+ this.minimizedVideoEntries[1] = XGlobals.getStringByName(getActivity(), "xfile_miniplayer_style_video");
+ this.minimizedVideoEntries[2] = XGlobals.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: fi.razerman.youtube.XSettingsFragment.1
+// android.preference.Preference.OnPreferenceClickListener
+ listPreference.setOnPreferenceClickListener(preference -> {
+ XSettingsFragment.this.setListPreferenceData(listPreference, true);
+ return false;
+ });
+ // from class: fi.razerman.youtube.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: fi.razerman.youtube.XSettingsFragment.3
+// android.preference.Preference.OnPreferenceClickListener
+ listPreference3.setOnPreferenceClickListener(preference -> {
+ XSettingsFragment.this.setSpeedListPreferenceData(listPreference3);
+ return false;
+ });
+ Preference findPreference = findPreference("pref_about_field");
+ final String stringByName3 = XGlobals.getStringByName(getActivity(), "xfile_hiddenmenu_open");
+ final String stringByName4 = XGlobals.getStringByName(getActivity(), "xfile_hiddenmenu_opened");
+ final String str = " " + XGlobals.getStringByName(getActivity(), "xfile_hiddenmenu_needed");
+ // from class: fi.razerman.youtube.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(XGlobals.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(XGlobals.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 = XGlobals.getContext();
+ xSettingsFragment.toast = Toast.makeText(context, i + str, Toast.LENGTH_SHORT);
+ }
+ XSettingsFragment.this.toast.show();
+ } else {
+ XSettingsFragment.this.clicks = 0;
+ }
+ return false;
+ });
+ // from class: fi.razerman.youtube.XSettingsFragment.5
+// android.preference.Preference.OnPreferenceClickListener
+ this.codecDefault.setOnPreferenceClickListener(preference -> {
+ XSettingsFragment.this.ChangeCodec(preference);
+ return false;
+ });
+ // from class: fi.razerman.youtube.XSettingsFragment.6
+// android.preference.Preference.OnPreferenceClickListener
+ this.codecVP9.setOnPreferenceClickListener(preference -> {
+ XSettingsFragment.this.ChangeCodec(preference);
+ return false;
+ });
+ // from class: fi.razerman.youtube.XSettingsFragment.7
+// android.preference.Preference.OnPreferenceClickListener
+ this.codecHDRH.setOnPreferenceClickListener(preference -> {
+ XSettingsFragment.this.ChangeCodec(preference);
+ return false;
+ });
+ // from class: fi.razerman.youtube.XSettingsFragment.8
+// android.preference.Preference.OnPreferenceClickListener
+ this.codecHDRS.setOnPreferenceClickListener(preference -> {
+ XSettingsFragment.this.ChangeCodec(preference);
+ return false;
+ });
+ if (XScreenSizeHelpers.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) {
+ Log.e("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: fi.razerman.youtube.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: fi.razerman.youtube.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: fi.razerman.youtube.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: fi.razerman.youtube.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/integrations/java/fi/razerman/youtube/XTheme.java b/integrations/java/fi/razerman/youtube/XTheme.java
new file mode 100644
index 000000000..e4903087b
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/XTheme.java
@@ -0,0 +1,165 @@
+package fi.razerman.youtube;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.res.Resources;
+import android.util.Log;
+import android.util.TypedValue;
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.Helpers.ColorRef;
+
+/* loaded from: classes6.dex */
+public class XTheme {
+ static boolean ENABLE_COLOR_OVERRIDE = false;
+
+ public static int SearchIconColor(int original) {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XTheme", "Context is null, returning " + original);
+ return original;
+ }
+ try {
+ return context.getResources().getColor(context.getResources().getIdentifier("custom_search_color", "color", XGlobals.getPackageName()));
+ } catch (Resources.NotFoundException e) {
+ return original;
+ }
+ }
+
+ public static int RefreshIconColor(int original) {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XTheme", "Context is null, returning " + original);
+ return original;
+ }
+ try {
+ return context.getResources().getColor(context.getResources().getIdentifier("custom_refresh_color", "color", XGlobals.getPackageName()));
+ } catch (Resources.NotFoundException e) {
+ return original;
+ }
+ }
+
+ public static int RefreshIconColor(Context context, int attributeId) {
+ return getColorAttrContext(context, attributeId);
+ }
+
+ public static int getColorAttrContext(Context context, int attributeId) {
+ TypedValue typedValue = new TypedValue();
+ context.getTheme().resolveAttribute(attributeId, typedValue, true);
+ int colorRes = typedValue.resourceId;
+ try {
+ int color = context.getResources().getColor(colorRes);
+ return color;
+ } catch (Resources.NotFoundException e) {
+ Log.w("XGlobals", "Not found color resource by id: " + colorRes);
+ return -328966;
+ }
+ }
+
+ public static int getColorAttrActivity(Activity context, int attributeId) {
+ TypedValue typedValue = new TypedValue();
+ context.getTheme().resolveAttribute(attributeId, typedValue, true);
+ int colorRes = typedValue.resourceId;
+ try {
+ return context.getResources().getColor(colorRes);
+ } catch (Resources.NotFoundException e) {
+ Log.w("XGlobals", "Not found color resource by id: " + colorRes);
+ return -328966;
+ }
+ }
+
+ public static int PinnedMessageColor(int original) {
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XTheme", "Context is null, returning " + original);
+ return original;
+ }
+ try {
+ return context.getResources().getColor(context.getResources().getIdentifier("custom_pinned_color", "color", XGlobals.getPackageName()));
+ } catch (Resources.NotFoundException e) {
+ return original;
+ }
+ }
+
+ public static int getTheme(SharedPreferences sharedPreferences) {
+ if (sharedPreferences.getBoolean("app_theme_dark", false)) {
+ return 2;
+ }
+ if (sharedPreferences.getBoolean("app_theme_dark", false)) {
+ return 3;
+ }
+ return 1;
+ }
+
+ private static boolean isDarkTheme() {
+ return XGlobals.getThemeStatus();
+ }
+
+ public static int foregroundColorOverride(int original) {
+ int returnValue;
+ int returnValue2;
+ if (!ENABLE_COLOR_OVERRIDE) {
+ return original;
+ }
+ if (XGlobals.debug) {
+ Log.d("XTheme", "foregroundColorOverride: " + original);
+ }
+ switch (original) {
+ case -16359468:
+ int returnValue3 = ColorRef.color("vanced_link_text_light", -16359468);
+ if (!XGlobals.debug) {
+ return returnValue3;
+ }
+ Log.d("XTheme", "foregroundColorOverride - returning blue: " + returnValue3);
+ return returnValue3;
+ case -15527149:
+ if (isDarkTheme()) {
+ returnValue2 = ColorRef.color("vanced_text_secondary_dark", -15527149);
+ } else {
+ returnValue2 = ColorRef.color("vanced_text_primary_light", -15527149);
+ }
+ if (!XGlobals.debug) {
+ return returnValue2;
+ }
+ Log.d("XTheme", "foregroundColorOverride - returning black: " + returnValue2);
+ return returnValue2;
+ case -12671233:
+ int returnValue4 = ColorRef.color("vanced_link_text_dark", -12671233);
+ if (!XGlobals.debug) {
+ return returnValue4;
+ }
+ Log.d("XTheme", "foregroundColorOverride - returning blue: " + returnValue4);
+ return returnValue4;
+ case -10461088:
+ int returnValue5 = ColorRef.color("vanced_text_accent_light", -10461088);
+ if (!XGlobals.debug) {
+ return returnValue5;
+ }
+ Log.d("XTheme", "foregroundColorOverride - returning grey: " + returnValue5);
+ return returnValue5;
+ case -5592406:
+ int returnValue6 = ColorRef.color("vanced_text_accent_dark", -5592406);
+ if (!XGlobals.debug) {
+ return returnValue6;
+ }
+ Log.d("XTheme", "foregroundColorOverride - returning grey: " + returnValue6);
+ return returnValue6;
+ case -1:
+ if (isDarkTheme()) {
+ returnValue = ColorRef.color("vanced_text_primary_dark", -1);
+ } else {
+ returnValue = ColorRef.color("vanced_text_secondary_light", -1);
+ }
+ if (!XGlobals.debug) {
+ return returnValue;
+ }
+ Log.d("XTheme", "foregroundColorOverride - returning white: " + returnValue);
+ return returnValue;
+ default:
+ if (XGlobals.debug) {
+ Log.d("XTheme", "foregroundColorOverride - returning original: " + original);
+ }
+ return original;
+ }
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/litho/LithoAdRemoval.java b/integrations/java/fi/razerman/youtube/litho/LithoAdRemoval.java
new file mode 100644
index 000000000..a625fa386
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/litho/LithoAdRemoval.java
@@ -0,0 +1,212 @@
+package fi.razerman.youtube.litho;
+
+import android.util.Log;
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.Helpers.SharedPrefs;
+import fi.razerman.youtube.XGlobals;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/* loaded from: classes6.dex */
+public class LithoAdRemoval {
+ private static final byte[] endRelatedPageAd = {112, 97, 103, 101, 97, 100};
+ private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
+
+ public static boolean isExperimentalAdRemoval() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_ad_removal", true);
+ }
+
+ public static boolean isExperimentalMerchandiseRemoval() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_merchandise", false);
+ }
+
+ public static boolean isExperimentalCommunityPostRemoval() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_community_posts", false);
+ }
+
+ public static boolean isExperimentalMovieUpsellRemoval() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_movie_upsell", false);
+ }
+
+ public static boolean isExperimentalCompactBannerRemoval() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_compact_banner", false);
+ }
+
+ public static boolean isExperimentalCommentsRemoval() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_comments", false);
+ }
+
+ public static boolean isExperimentalCompactMovieRemoval() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_compact_movie", false);
+ }
+
+ public static boolean isExperimentalHorizontalMovieShelfRemoval() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_horizontal_movie_shelf", false);
+ }
+
+ public static boolean isInFeedSurvey() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_in_feed_survey", false);
+ }
+
+ public static boolean isShortsShelf() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_shorts_shelf", false);
+ }
+
+ public static boolean isCommunityGuidelines() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_community_guidelines", false);
+ }
+
+ public static boolean containsAd(String value) {
+ if (!(isExperimentalAdRemoval() || isExperimentalMerchandiseRemoval() || isExperimentalCommunityPostRemoval() || isExperimentalMovieUpsellRemoval() || isExperimentalCompactBannerRemoval() || isExperimentalCommentsRemoval() || isExperimentalCompactMovieRemoval() || isExperimentalHorizontalMovieShelfRemoval() || isInFeedSurvey() || isShortsShelf() || isCommunityGuidelines()) || value == null || value.isEmpty()) {
+ return false;
+ }
+ List blockList = new ArrayList<>();
+ if (isExperimentalAdRemoval()) {
+ blockList.add("_ad");
+ blockList.add("ad_badge");
+ }
+ if (isExperimentalMerchandiseRemoval()) {
+ blockList.add("product_carousel");
+ }
+ if (isExperimentalCommunityPostRemoval()) {
+ blockList.add("post_base_wrapper");
+ }
+ if (isExperimentalMovieUpsellRemoval()) {
+ blockList.add("movie_and_show_upsell_card");
+ }
+ if (isExperimentalCompactBannerRemoval()) {
+ blockList.add("compact_banner");
+ }
+ if (isExperimentalCommentsRemoval()) {
+ blockList.add("comments_composite_entry_point");
+ }
+ if (isExperimentalCompactMovieRemoval()) {
+ blockList.add("compact_movie");
+ }
+ if (isExperimentalHorizontalMovieShelfRemoval()) {
+ blockList.add("horizontal_movie_shelf");
+ }
+ if (isInFeedSurvey()) {
+ blockList.add("in_feed_survey");
+ }
+ if (isShortsShelf()) {
+ blockList.add("shorts_shelf");
+ }
+ if (isCommunityGuidelines()) {
+ blockList.add("community_guidelines");
+ }
+ for (String s : blockList) {
+ if (value.contains(s)) {
+ if (XGlobals.debug) {
+ Log.d("TemplateBlocked", value);
+ }
+ return true;
+ }
+ }
+ if (!XGlobals.debug) {
+ return false;
+ }
+ Log.d("Template", value);
+ return false;
+ }
+
+ public static boolean containsAd(String value, ByteBuffer buffer) {
+ try {
+ if (!(isExperimentalAdRemoval() || isExperimentalMerchandiseRemoval() || isExperimentalCommunityPostRemoval() || isExperimentalMovieUpsellRemoval() || isExperimentalCompactBannerRemoval() || isExperimentalCommentsRemoval() || isExperimentalCompactMovieRemoval() || isExperimentalHorizontalMovieShelfRemoval() || isInFeedSurvey() || isShortsShelf() || isCommunityGuidelines()) || value == null || value.isEmpty()) {
+ return false;
+ }
+ List blockList = new ArrayList<>();
+ if (isExperimentalAdRemoval()) {
+ blockList.add("_ad");
+ blockList.add("ad_badge");
+ blockList.add("ads_video_with_context");
+ }
+ if (isExperimentalMerchandiseRemoval()) {
+ blockList.add("product_carousel");
+ }
+ if (isExperimentalCommunityPostRemoval()) {
+ blockList.add("post_base_wrapper");
+ }
+ if (isExperimentalMovieUpsellRemoval()) {
+ blockList.add("movie_and_show_upsell_card");
+ }
+ if (isExperimentalCompactBannerRemoval()) {
+ blockList.add("compact_banner");
+ }
+ if (isExperimentalCommentsRemoval()) {
+ blockList.add("comments_composite_entry_point");
+ }
+ if (isExperimentalCompactMovieRemoval()) {
+ blockList.add("compact_movie");
+ }
+ if (isExperimentalHorizontalMovieShelfRemoval()) {
+ blockList.add("horizontal_movie_shelf");
+ }
+ if (isInFeedSurvey()) {
+ blockList.add("in_feed_survey");
+ }
+ if (isShortsShelf()) {
+ blockList.add("shorts_shelf");
+ }
+ if (isCommunityGuidelines()) {
+ blockList.add("community_guidelines");
+ }
+ if (!value.contains("related_video_with_context") || indexOf(buffer.array(), endRelatedPageAd) <= 0) {
+ for (String s : blockList) {
+ if (value.contains(s)) {
+ if (XGlobals.debug) {
+ Log.d("TemplateBlocked", value);
+ }
+ return true;
+ }
+ }
+ if (!XGlobals.debug) {
+ return false;
+ }
+ if (value.contains("related_video_with_context")) {
+ Log.d("Template", value + " | " + bytesToHex(buffer.array()));
+ return false;
+ }
+ Log.d("Template", value);
+ return false;
+ }
+ if (XGlobals.debug) {
+ Log.d("TemplateBlocked", value);
+ }
+ return true;
+ } catch (Exception ex) {
+ Log.e("Template", ex.getMessage(), ex);
+ return false;
+ }
+ }
+
+
+ public static int indexOf(byte[] array, byte[] target) {
+ if (target.length == 0) {
+ return 0;
+ }
+
+ int i = 0;
+ while (i < array.length - target.length + 1 ){
+ for (int j = 0; j < target.length; j++) {
+ if (array[i+j] != target[j]) {
+ break;
+ }
+ }
+ return i;
+ }
+ return -1;
+ }
+
+ private static String bytesToHex(byte[] bytes) {
+ char[] hexChars = new char[bytes.length * 2];
+ for (int j = 0; j < bytes.length; j++) {
+ int v = bytes[j] & 255;
+ hexChars[j * 2] = hexArray[v >>> 4];
+ hexChars[(j * 2) + 1] = hexArray[v & 15];
+ }
+ return new String(hexChars);
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/preferences/BooleanPreferences.java b/integrations/java/fi/razerman/youtube/preferences/BooleanPreferences.java
new file mode 100644
index 000000000..4e0f5a1e2
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/preferences/BooleanPreferences.java
@@ -0,0 +1,22 @@
+package fi.razerman.youtube.preferences;
+
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+
+import java.util.Objects;
+
+import fi.razerman.youtube.Helpers.SharedPrefs;
+
+/* loaded from: classes6.dex */
+public class BooleanPreferences {
+ public static boolean isTapSeekingEnabled() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "xfile_enable_tap_seeking", true);
+ }
+
+ public static boolean isExoplayerV2Enabled() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "xfile_exoplayer_v2", true);
+ }
+
+ public static boolean isCreateButtonHidden() {
+ return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "xfile_create_button_hidden", false);
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/videosettings/VideoQuality.java b/integrations/java/fi/razerman/youtube/videosettings/VideoQuality.java
new file mode 100644
index 000000000..24d504437
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/videosettings/VideoQuality.java
@@ -0,0 +1,108 @@
+package fi.razerman.youtube.videosettings;
+
+import android.content.Context;
+import android.util.Log;
+import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
+import fi.razerman.youtube.Connectivity;
+import fi.razerman.youtube.XGlobals;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+
+/* loaded from: classes6.dex */
+public class VideoQuality {
+ static final int[] videoResolutions = {0, 144, 240, 360, 480, 720, 1080, 1440, 2160};
+
+ public static void userChangedQuality() {
+ XGlobals.userChangedQuality = true;
+ XGlobals.newVideo = false;
+ }
+
+ public static int setVideoQuality(Object[] qualities, int quality, Object qInterface) {
+ int preferredQuality;
+ Field[] fields;
+ if (!XGlobals.newVideo || XGlobals.userChangedQuality || qInterface == null) {
+ if (XGlobals.debug && XGlobals.userChangedQuality) {
+ Log.d("XGlobals - quality", "Skipping quality change because user changed it: " + quality);
+ }
+ XGlobals.userChangedQuality = false;
+ return quality;
+ }
+ XGlobals.newVideo = false;
+ if (XGlobals.debug) {
+ Log.d("XGlobals - quality", "Quality: " + quality);
+ }
+ Context context = YouTubeTikTokRoot_Application.getAppContext();
+ if (context == null) {
+ Log.e("XGlobals", "Context is null or settings not initialized, returning quality: " + quality);
+ return quality;
+ }
+ if (Connectivity.isConnectedWifi(context)) {
+ preferredQuality = XGlobals.prefResolutionWIFI;
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "Wi-Fi connection detected, preferred quality: " + preferredQuality);
+ }
+ } else if (Connectivity.isConnectedMobile(context)) {
+ preferredQuality = XGlobals.prefResolutionMobile;
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "Mobile data connection detected, preferred quality: " + preferredQuality);
+ }
+ } else {
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "No Internet connection!");
+ }
+ return quality;
+ }
+ if (preferredQuality == -2) {
+ return quality;
+ }
+ Class> intType = Integer.TYPE;
+ ArrayList iStreamQualities = new ArrayList<>();
+ try {
+ for (Object streamQuality : qualities) {
+ for (Field field : streamQuality.getClass().getFields()) {
+ if (field.getType().isAssignableFrom(intType)) {
+ int value = field.getInt(streamQuality);
+ if (field.getName().length() <= 2) {
+ iStreamQualities.add(value);
+ }
+ }
+ }
+ }
+ } catch (Exception ignored) {}
+ Collections.sort(iStreamQualities);
+ int index = 0;
+ for (int streamQuality2 : iStreamQualities) {
+ if (XGlobals.debug) {
+ Log.d("XGlobals - qualities", "Quality at index " + index + ": " + streamQuality2);
+ }
+ index++;
+ }
+ for (Integer iStreamQuality : iStreamQualities) {
+ int streamQuality3 = iStreamQuality;
+ if (streamQuality3 <= preferredQuality) {
+ quality = streamQuality3;
+ }
+ }
+ if (quality == -2) {
+ return quality;
+ }
+ int qualityIndex = iStreamQualities.indexOf(quality);
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "Index of quality " + quality + " is " + qualityIndex);
+ }
+ try {
+ Class> cl = qInterface.getClass();
+ Method m = cl.getMethod("x", Integer.TYPE);
+ m.invoke(qInterface, iStreamQualities.get(qualityIndex));
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "Quality changed to: " + qualityIndex);
+ }
+ return qualityIndex;
+ } catch (Exception ex) {
+ Log.e("XGlobals", "Failed to set quality", ex);
+ return qualityIndex;
+ }
+ }
+}
diff --git a/integrations/java/fi/razerman/youtube/videosettings/VideoSpeed.java b/integrations/java/fi/razerman/youtube/videosettings/VideoSpeed.java
new file mode 100644
index 000000000..9ec1ead75
--- /dev/null
+++ b/integrations/java/fi/razerman/youtube/videosettings/VideoSpeed.java
@@ -0,0 +1,198 @@
+package fi.razerman.youtube.videosettings;
+
+import android.util.Log;
+import fi.razerman.youtube.XGlobals;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/* loaded from: classes6.dex */
+public class VideoSpeed {
+ static final float[] videoSpeeds = {0.25f, 0.5f, 0.75f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f};
+
+ public static int DefaultSpeed(Object[] speeds, int speed, Object qInterface) {
+ int speed2;
+ Exception e;
+ if (!XGlobals.newVideoSpeed) {
+ return speed;
+ }
+ XGlobals.newVideoSpeed = false;
+ if (XGlobals.debug) {
+ Log.d("XGlobals - speeds", "Speed: " + speed);
+ }
+ float preferredSpeed = XGlobals.prefVideoSpeed;
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "Preferred speed: " + preferredSpeed);
+ }
+ if (preferredSpeed == -2.0f) {
+ return speed;
+ }
+ Class> floatType = Float.TYPE;
+ ArrayList iStreamSpeeds = new ArrayList<>();
+ try {
+ for (Object streamSpeed : speeds) {
+ Field[] fields = streamSpeed.getClass().getFields();
+ for (Field field : fields) {
+ if (field.getType().isAssignableFrom(floatType)) {
+ float value = field.getFloat(streamSpeed);
+ if (field.getName().length() <= 2) {
+ iStreamSpeeds.add(value);
+ }
+ }
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ Iterator it = iStreamSpeeds.iterator();
+ int index = 0;
+ while (it.hasNext()) {
+ float streamSpeed2 = it.next();
+ if (XGlobals.debug) {
+ Log.d("XGlobals - speeds", "Speed at index " + index + ": " + streamSpeed2);
+ }
+ index++;
+ }
+ int speed3 = -1;
+ for (float streamSpeed3 : iStreamSpeeds) {
+ if (streamSpeed3 <= preferredSpeed) {
+ speed3++;
+ if (XGlobals.debug) {
+ Log.d("XGlobals - speeds", "Speed loop at index " + speed3 + ": " + streamSpeed3);
+ }
+ }
+ }
+ if (speed3 == -1) {
+ if (XGlobals.debug) {
+ Log.d("XGlobals - speeds", "Speed was not found");
+ }
+ speed2 = 3;
+ } else {
+ speed2 = speed3;
+ }
+ try {
+ Method[] declaredMethods = qInterface.getClass().getDeclaredMethods();
+ for (Method method : declaredMethods) {
+ if (method.getName().length() <= 2) {
+ if (XGlobals.debug) {
+ Log.d("SPEED - Method", "Method name: " + method.getName());
+ }
+ try {
+ try {
+ method.invoke(qInterface, videoSpeeds[speed2]);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
+ } catch (Exception e6) {
+ e = e6;
+ Log.e("XDebug", e.getMessage());
+ return speed2;
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ } catch (Exception e10) {
+ e = e10;
+ }
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "Speed changed to: " + speed2);
+ }
+ return speed2;
+ }
+
+ public static void userChangedSpeed() {
+ XGlobals.userChangedSpeed = true;
+ XGlobals.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 float getSpeedValue(Object[] speeds, int speed) {
+ int i = 0;
+ if (!XGlobals.newVideoSpeed || XGlobals.userChangedSpeed) {
+ if (XGlobals.debug && XGlobals.userChangedSpeed) {
+ Log.d("XGlobals - speeds", "Skipping speed change because user changed it: " + speed);
+ }
+ XGlobals.userChangedSpeed = false;
+ return -1.0f;
+ }
+ XGlobals.newVideoSpeed = false;
+ if (XGlobals.debug) {
+ Log.d("XGlobals - speeds", "Speed: " + speed);
+ }
+ float preferredSpeed = XGlobals.prefVideoSpeed;
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "Preferred speed: " + preferredSpeed);
+ }
+ if (preferredSpeed == -2.0f) {
+ return -1.0f;
+ }
+ Class> floatType = Float.TYPE;
+ ArrayList iStreamSpeeds = new ArrayList<>();
+ try {
+ int length = speeds.length;
+ int i2 = 0;
+ while (i2 < length) {
+ Object streamSpeed = speeds[i2];
+ Field[] fields = streamSpeed.getClass().getFields();
+ int length2 = fields.length;
+ while (i < length2) {
+ Field field = fields[i];
+ if (field.getType().isAssignableFrom(floatType)) {
+ float value = field.getFloat(streamSpeed);
+ if (field.getName().length() <= 2) {
+ iStreamSpeeds.add(value);
+ }
+ }
+ i++;
+ }
+ i2++;
+ i = 0;
+ }
+ } catch (Exception ignored) {
+ }
+ int index = 0;
+ for (Float iStreamSpeed : iStreamSpeeds) {
+ float streamSpeed2 = iStreamSpeed;
+ if (XGlobals.debug) {
+ Log.d("XGlobals - speeds", "Speed at index " + index + ": " + streamSpeed2);
+ }
+ index++;
+ }
+ int newSpeedIndex = -1;
+ for (Float iStreamSpeed : iStreamSpeeds) {
+ float streamSpeed3 = iStreamSpeed;
+ if (streamSpeed3 <= preferredSpeed) {
+ newSpeedIndex++;
+ if (XGlobals.debug) {
+ Log.d("XGlobals - speeds", "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
+ }
+ }
+ }
+ if (newSpeedIndex == -1) {
+ if (XGlobals.debug) {
+ Log.d("XGlobals - speeds", "Speed was not found");
+ }
+ newSpeedIndex = 3;
+ }
+ if (newSpeedIndex == speed) {
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "Trying to set speed to what it already is, skipping...: " + newSpeedIndex);
+ }
+ return -1.0f;
+ }
+ if (XGlobals.debug) {
+ Log.d("XGlobals", "Speed changed to: " + newSpeedIndex);
+ }
+ return getSpeedByIndex(newSpeedIndex);
+ }
+}
diff --git a/integrations/java/pl/jakubweg/SponsorBlockSettings.java b/integrations/java/pl/jakubweg/SponsorBlockSettings.java
index 3a8cd93d8..9e52ef510 100644
--- a/integrations/java/pl/jakubweg/SponsorBlockSettings.java
+++ b/integrations/java/pl/jakubweg/SponsorBlockSettings.java
@@ -37,7 +37,7 @@ public class SponsorBlockSettings {
public static final String PREFERENCES_KEY_LAST_VIP_CHECK = "sb-last-vip-check";
public static final String PREFERENCES_KEY_API_URL = "sb-api-url";
- public static final SegmentBehaviour DefaultBehaviour = SegmentBehaviour.SKIP_AUTOMATICALLY;
+ public static final SegmentBehaviour DefaultBehaviour = SegmentBehaviour.IGNORE;
public static final String DEFAULT_SERVER_URL = "https://sponsor.ajay.app";
public static final String DEFAULT_API_URL = DEFAULT_SERVER_URL + "/api/";
@@ -203,7 +203,7 @@ public class SponsorBlockSettings {
}
public enum SegmentInfo {
- SPONSOR("sponsor", sf("segments_sponsor"), sf("skipped_sponsor"), sf("segments_sponsor_sum"), DefaultBehaviour, 0xFF00d400),
+ SPONSOR("sponsor", sf("segments_sponsor"), sf("skipped_sponsor"), sf("segments_sponsor_sum"), SegmentBehaviour.SKIP_AUTOMATICALLY, 0xFF00d400),
INTRO("intro", sf("segments_intermission"), sf("skipped_intermission"), sf("segments_intermission_sum"), DefaultBehaviour, 0xFF00ffff),
OUTRO("outro", sf("segments_endcards"), sf("skipped_endcard"), sf("segments_endcards_sum"), DefaultBehaviour, 0xFF0202ed),
INTERACTION("interaction", sf("segments_subscribe"), sf("skipped_subscribe"), sf("segments_subscribe_sum"), DefaultBehaviour, 0xFFcc00ff),