refactor: integrations (#17)

This commit is contained in:
Joey Peter 2022-06-24 00:16:32 +02:00 committed by GitHub
parent 61ed39722e
commit d26b9339fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
117 changed files with 2442 additions and 4190 deletions

View File

@ -2,10 +2,10 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 32
namespace 'vanced.integrations'
namespace 'app.revanced.integrations'
defaultConfig {
applicationId "revanced.integrationsapp"
applicationId "app.revanced.integrations"
minSdkVersion 23
targetSdkVersion 32
versionCode 1

View File

@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
</manifest>

View File

@ -0,0 +1,179 @@
package app.revanced.integrations.adremover;
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 app.revanced.integrations.patches.HideShortsButtonPatch;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
/**
* API Class that provides the logic to the Patch classes. All methods in here should be protected/private and only be accessed from a Patch class.
*/
public class AdRemoverAPI {
/**
* Removes Reels and Home ads
*
* @param view
*/
public 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 {
LogHelper.debug("XAdRemover", "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
}
}
/**
* Removes the Create button
*
* @param view
*/
public static void hideCreateButton(View view) {
String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: shown" : "Create button: hidden";
LogHelper.debug("HideCreateButton", message);
if (!SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
view.setVisibility(View.GONE);
} else {
view.setVisibility(View.VISIBLE);
}
}
/**
* Removes the shorts button
*
* @param view
*/
public static void hideShortsButton(View view) {
if (HideShortsButtonPatch.lastPivotTab != null && HideShortsButtonPatch.lastPivotTab.name() == "TAB_SHORTS") {
String message = SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Shorts button: shown" : "Shorts button: hidden";
LogHelper.debug("HideShortsButton", message);
if (!SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
view.setVisibility(View.GONE);
}
}
}
/**
* Removes the InfoCardSuggestions
*
* @param InfoCardOverlayPresenter
* @return
*/
public static Object removeInfoCardSuggestions(Object InfoCardOverlayPresenter) {
if (!SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.getBoolean()) InfoCardOverlayPresenter = null;
String message = InfoCardOverlayPresenter == null ? "RemoveInfoCardSuggestions: true" : "RemoveInfoCardSuggestions: false";
LogHelper.debug("AdRemoverAPI", message);
return InfoCardOverlayPresenter;
}
/**
* Removes the Suggestions
*
* @param showSuggestions
* @return
*/
public static Boolean removeSuggestions(Boolean showSuggestions) {
if (!SettingsEnum.SUGGESTIONS_SHOWN_BOOLEAN.getBoolean()) showSuggestions = false;
String message = showSuggestions ? "RemoveSuggestions: true" : "RemoveSuggestions: false";
LogHelper.debug("AdRemoverAPI", message);
return showSuggestions;
}
public static int BrandingWatermark(int defaultValue) {
if (defaultValue == 0 && !SettingsEnum.BRANDING_SHOWN_BOOLEAN.getBoolean()) {
defaultValue = 8;
}
String message = defaultValue == 8 ? "BrandingWatermark: Removed" : "BrandingWatermark: Shown";
LogHelper.debug("AdRemoverAPI", message);
return defaultValue;
}
/*
private static void inspectComponentHost(Object item) {
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
if (stackTraceElements.length <= 3) {
LogHelper.debug("Litho", "Couldn't locate the method called from.");
} else {
String sb = "Called from method: " +
stackTraceElements[3].toString() + "\n";
LogHelper.debug("Litho", sb);
}
if (item == null) {
LogHelper.debug("Litho", "Item is null.");
} else if (item.getClass().getSimpleName().contains("cwl")) {
LogHelper.debug("Litho", "Item is a cwl item.");
LogHelper.debug("Litho", getViewHierarchy((ViewGroup) item));
} else {
LogHelper.debug("Litho", "Item is not a cwl item.");
}
}
private static String getViewHierarchy(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(" ");
}
}
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);
}
}
}*/
}

View File

@ -1,7 +1,7 @@
package fi.razerman.youtube.litho;
package app.revanced.integrations.adremover;
import android.os.Build;
import android.util.Log;
import androidx.annotation.RequiresApi;
@ -13,12 +13,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import fi.razerman.youtube.Helpers.SharedPrefs;
import fi.razerman.youtube.XGlobals;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.settings.Settings;
public class LithoAdRemoval {
private static boolean getBoolean(String key, boolean _default) {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), key, _default);
return SharedPrefHelper.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), SharedPrefHelper.SharedPrefNames.YOUTUBE, key, _default);
}
private static boolean isExperimentalInfoPanelRemoval() {
@ -33,43 +35,43 @@ public class LithoAdRemoval {
return getBoolean("experimental_emergency_box", true);
}
public static boolean isExperimentalAdRemoval() {
private static boolean isExperimentalAdRemoval() {
return getBoolean("experimental_ad_removal", true);
}
public static boolean isExperimentalMerchandiseRemoval() {
private static boolean isExperimentalMerchandiseRemoval() {
return getBoolean("experimental_merchandise", true);
}
public static boolean isExperimentalCommunityPostRemoval() {
private static boolean isExperimentalCommunityPostRemoval() {
return getBoolean("experimental_community_posts", false);
}
public static boolean isExperimentalMovieRemoval() {
private static boolean isExperimentalMovieRemoval() {
return getBoolean("experimental_movie", true);
}
public static boolean isExperimentalCompactBannerRemoval() {
private static boolean isExperimentalCompactBannerRemoval() {
return getBoolean("experimental_compact_banner", false);
}
public static boolean isExperimentalPaidContentRemoval() {
private static boolean isExperimentalPaidContentRemoval() {
return getBoolean("experimental_paid_content", true);
}
public static boolean isExperimentalCommentsRemoval() {
private static boolean isExperimentalCommentsRemoval() {
return getBoolean("experimental_comments", false);
}
public static boolean isInFeedSurvey() {
private static boolean isInFeedSurvey() {
return getBoolean("experimental_in_feed_survey", false);
}
public static boolean isShortsShelf() {
private static boolean isShortsShelf() {
return getBoolean("experimental_shorts_shelf", true);
}
public static boolean isCommunityGuidelines() {
private static boolean isCommunityGuidelines() {
return getBoolean("experimental_community_guidelines", true);
}
@ -168,20 +170,20 @@ public class LithoAdRemoval {
)) return false;
if (blockList.stream().anyMatch(value::contains)) {
if (XGlobals.debug) Log.d("TemplateBlocked", value);
LogHelper.debug("TemplateBlocked", value);
return true;
}
if (!XGlobals.debug) return false;
if (!SettingsEnum.DEBUG_BOOLEAN.getBoolean()) return false;
if (value.contains("related_video_with_context")) {
Log.d("Template", value + " | " + bytesToHex(buffer.array()));
LogHelper.debug("Template", value + " | " + bytesToHex(buffer.array()));
return false;
}
Log.d("Template", value);
LogHelper.debug("Template", value);
return false;
} catch (
Exception ex) {
Log.e("Template", ex.getMessage(), ex);
LogHelper.printException("Template", ex.getMessage(), ex);
return false;
}

View File

@ -1,15 +1,13 @@
package fi.vanced.libraries.youtube.whitelisting;
package app.revanced.integrations.adremover.whitelist;
import static fi.razerman.youtube.XGlobals.debug;
import static fi.vanced.libraries.youtube.player.VideoInformation.channelName;
import static fi.vanced.libraries.youtube.ui.SlimButtonContainer.adBlockButton;
import static fi.vanced.libraries.youtube.ui.SlimButtonContainer.sbWhitelistButton;
import static fi.vanced.utils.VancedUtils.getPreferences;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.channelName;
import static app.revanced.integrations.sponsorblock.player.ui.SlimButtonContainer.adBlockButton;
import static app.revanced.integrations.sponsorblock.player.ui.SlimButtonContainer.sbWhitelistButton;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.Toast;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
@ -22,18 +20,21 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import fi.vanced.libraries.youtube.player.ChannelModel;
import fi.vanced.libraries.youtube.player.VideoInformation;
import fi.vanced.utils.ObjectSerializer;
import fi.vanced.utils.SharedPrefUtils;
import fi.vanced.utils.VancedUtils;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.sponsorblock.player.ChannelModel;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.utils.ObjectSerializer;
import app.revanced.integrations.utils.SharedPrefHelper;
public class Whitelist {
private static final String TAG = "VI - Whitelisting";
private static final Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = parseWhitelist(YouTubeTikTokRoot_Application.getAppContext());
private static final Map<WhitelistType, Boolean> enabledMap = parseEnabledMap(YouTubeTikTokRoot_Application.getAppContext());
private Whitelist() {}
private Whitelist() {
}
// injected calls
@ -42,9 +43,7 @@ public class Whitelist {
}
public static void setChannelName(String channelName) {
if (debug) {
Log.d(TAG, "channel name set to " + channelName);
}
LogHelper.debug(TAG, "channel name set to " + channelName);
VideoInformation.channelName = channelName;
if (enabledMap.get(WhitelistType.ADS) && adBlockButton != null) {
@ -69,26 +68,23 @@ public class Whitelist {
Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = new EnumMap<>(WhitelistType.class);
for (WhitelistType whitelistType : whitelistTypes) {
SharedPreferences preferences = VancedUtils.getPreferences(context, whitelistType.getPreferencesName());
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, whitelistType.getPreferencesName());
String serializedChannels = preferences.getString("channels", null);
if (serializedChannels == null) {
if (debug) {
Log.d(TAG, String.format("channels string was null for %s whitelisting", whitelistType));
}
LogHelper.debug(TAG, String.format("channels string was null for %s whitelisting", whitelistType));
whitelistMap.put(whitelistType, new ArrayList<>());
continue;
}
try {
ArrayList<ChannelModel> deserializedChannels = (ArrayList<ChannelModel>) ObjectSerializer.deserialize(serializedChannels);
if (debug) {
Log.d(TAG, serializedChannels);
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
LogHelper.debug(TAG, serializedChannels);
for (ChannelModel channel : deserializedChannels) {
Log.d(TAG, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
LogHelper.debug(TAG, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
}
}
whitelistMap.put(whitelistType, deserializedChannels);
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}
@ -101,7 +97,7 @@ public class Whitelist {
}
Map<WhitelistType, Boolean> enabledMap = new EnumMap<>(WhitelistType.class);
for (WhitelistType whitelistType : WhitelistType.values()) {
enabledMap.put(whitelistType, SharedPrefUtils.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName()));
enabledMap.put(whitelistType, SharedPrefHelper.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName()));
}
return enabledMap;
}
@ -112,17 +108,14 @@ public class Whitelist {
return false;
}
if (channelName == null || channelName.trim().isEmpty()) {
if (debug) {
Log.d(TAG, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
}
LogHelper.debug(TAG, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
return false;
}
List<ChannelModel> whitelistedChannels = whitelistMap.get(whitelistType);
for (ChannelModel channel : whitelistedChannels) {
if (channel.getAuthor().equals(channelName)) {
if (debug) {
Log.d(TAG, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
}
LogHelper.debug(TAG, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
return true;
}
}
@ -134,10 +127,8 @@ public class Whitelist {
for (ChannelModel whitelistedChannel : whitelisted) {
String channelId = channel.getChannelId();
if (whitelistedChannel.getChannelId().equals(channelId)) {
if (debug) {
Log.d(TAG, String.format("Tried whitelisting an existing channel again. Old info (%1$s | %2$s) - New info (%3$s | %4$s)",
whitelistedChannel.getAuthor(), channelId, channelName, channelId));
}
LogHelper.debug(TAG, String.format("Tried whitelisting an existing channel again. Old info (%1$s | %2$s) - New info (%3$s | %4$s)",
whitelistedChannel.getAuthor(), channelId, channelName, channelId));
return true;
}
}
@ -159,8 +150,7 @@ public class Whitelist {
String friendlyName = whitelistType.getFriendlyName();
if (success) {
Toast.makeText(context, str("vanced_whitelisting_removed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
}
else {
} else {
Toast.makeText(context, str("vanced_whitelisting_remove_failed", channelName, friendlyName), Toast.LENGTH_SHORT).show();
}
}
@ -169,7 +159,7 @@ public class Whitelist {
if (context == null) {
return false;
}
SharedPreferences preferences = getPreferences(context, whitelistType.getPreferencesName());
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, whitelistType.getPreferencesName());
SharedPreferences.Editor editor = preferences.edit();
try {

View File

@ -0,0 +1,38 @@
package app.revanced.integrations.adremover.whitelist;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import app.revanced.integrations.utils.SharedPrefHelper;
public enum WhitelistType {
ADS(SharedPrefHelper.SharedPrefNames.YOUTUBE, "vanced_whitelist_ads_enabled"),
SPONSORBLOCK(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, "vanced_whitelist_sb_enabled");
private final String friendlyName;
private final String preferencesName;
private final String preferenceEnabledName;
private final SharedPrefHelper.SharedPrefNames name;
WhitelistType(SharedPrefHelper.SharedPrefNames name, String preferenceEnabledName) {
this.friendlyName = str("vanced_whitelisting_" + name().toLowerCase());
this.name = name;
this.preferencesName = "whitelist_" + name();
this.preferenceEnabledName = preferenceEnabledName;
}
public String getFriendlyName() {
return friendlyName;
}
public SharedPrefHelper.SharedPrefNames getSharedPreferencesName() {
return name;
}
public String getPreferencesName() {
return preferencesName;
}
public String getPreferenceEnabledName() {
return preferenceEnabledName;
}
}

View File

@ -1,4 +1,4 @@
package fi.vanced.utils.requests;
package app.revanced.integrations.adremover.whitelist.requests;
import org.json.JSONArray;
import org.json.JSONObject;
@ -10,10 +10,9 @@ import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import fi.vanced.libraries.youtube.whitelisting.requests.WhitelistRoutes;
public class Requester {
private Requester() {}
private Requester() {
}
public static HttpURLConnection getConnectionFromRoute(String apiUrl, Route route, String... params) throws IOException {
String url = apiUrl + route.compile(params).getCompiledRoute();

View File

@ -1,6 +1,4 @@
package fi.vanced.utils.requests;
import fi.vanced.utils.VancedUtils;
package app.revanced.integrations.adremover.whitelist.requests;
public class Route {
private final String route;
@ -10,9 +8,9 @@ public class Route {
public Route(Route.Method method, String route) {
this.method = method;
this.route = route;
this.paramCount = VancedUtils.countMatches(route, '{');
this.paramCount = countMatches(route, '{');
if (paramCount != VancedUtils.countMatches(route, '}'))
if (paramCount != countMatches(route, '}'))
throw new IllegalArgumentException("Not enough parameters");
}
@ -52,6 +50,15 @@ public class Route {
}
}
private int countMatches(CharSequence seq, char c) {
int count = 0;
for (int i = 0; i < seq.length(); i++) {
if (seq.charAt(i) == c)
count++;
}
return count;
}
public enum Method {
GET,
POST

View File

@ -1,13 +1,11 @@
package fi.vanced.libraries.youtube.whitelisting.requests;
package app.revanced.integrations.adremover.whitelist.requests;
import static fi.razerman.youtube.XGlobals.debug;
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
import static fi.vanced.libraries.youtube.ui.AdButton.TAG;
import static fi.vanced.utils.VancedUtils.runOnMainThread;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
import static app.revanced.integrations.utils.ReVancedUtils.runOnMainThread;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
@ -19,18 +17,18 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import fi.vanced.libraries.youtube.player.ChannelModel;
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
import fi.vanced.utils.VancedUtils;
import fi.vanced.utils.requests.Requester;
import fi.vanced.utils.requests.Route;
import vanced.integrations.BuildConfig;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.ChannelModel;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.BuildConfig;
public class WhitelistRequester {
private static final String YT_API_URL = "https://www.youtube.com/youtubei/v1/";
private WhitelistRequester() {}
private WhitelistRequester() {
}
public static void addChannelToWhitelist(WhitelistType whitelistType, View view, ImageView buttonIcon, Context context) {
try {
@ -40,9 +38,9 @@ public class WhitelistRequester {
connection.setDoOutput(true);
connection.setConnectTimeout(2 * 1000);
String versionName = VancedUtils.getVersionName(context);
String versionName = Settings.getVersionName(context);
String jsonInputString = "{\"context\": {\"client\": { \"clientName\": \"Android\", \"clientVersion\": \"" + versionName + "\" } }, \"videoId\": \"" + currentVideoId + "\"}";
try(OutputStream os = connection.getOutputStream()) {
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
@ -52,9 +50,7 @@ public class WhitelistRequester {
JSONObject videoInfo = json.getJSONObject("videoDetails");
ChannelModel channelModel = new ChannelModel(videoInfo.getString("author"), videoInfo.getString("channelId"));
String author = channelModel.getAuthor();
if (debug) {
Log.d(TAG, "channelId " + channelModel.getChannelId() + " fetched for author " + author);
}
LogHelper.debug("WhitelistRequester", "channelId " + channelModel.getChannelId() + " fetched for author " + author);
boolean success = Whitelist.addToWhitelist(whitelistType, context, channelModel);
String whitelistTypeName = whitelistType.getFriendlyName();
@ -62,18 +58,14 @@ public class WhitelistRequester {
if (success) {
buttonIcon.setEnabled(whitelistType != WhitelistType.SPONSORBLOCK);
Toast.makeText(context, str("vanced_whitelisting_added", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
}
else {
} else {
buttonIcon.setEnabled(whitelistType == WhitelistType.SPONSORBLOCK);
Toast.makeText(context, str("vanced_whitelisting_add_failed", author, whitelistTypeName), Toast.LENGTH_SHORT).show();
}
view.setEnabled(true);
});
}
else {
if (debug) {
Log.d(TAG, "player fetch response was " + responseCode);
}
} else {
LogHelper.debug("WhitelistRequester", "player fetch response was " + responseCode);
runOnMainThread(() -> {
Toast.makeText(context, str("vanced_whitelisting_fetch_failed", responseCode), Toast.LENGTH_SHORT).show();
buttonIcon.setEnabled(true);
@ -81,9 +73,8 @@ public class WhitelistRequester {
});
}
connection.disconnect();
}
catch (Exception ex) {
Log.e(TAG, "Failed to fetch channelId", ex);
} catch (Exception ex) {
LogHelper.printException("WhitelistRequester", "Failed to fetch channelId", ex);
runOnMainThread(() -> view.setEnabled(true));
}
}

View File

@ -0,0 +1,10 @@
package app.revanced.integrations.adremover.whitelist.requests;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
public class WhitelistRoutes {
public static final Route GET_CHANNEL_DETAILS = new Route(POST, "player?key={api_key}");
private WhitelistRoutes() {
}
}

View File

@ -0,0 +1,19 @@
package app.revanced.integrations.patches;
import android.os.Build;
import androidx.annotation.RequiresApi;
import java.nio.ByteBuffer;
import app.revanced.integrations.adremover.LithoAdRemoval;
public class GeneralBytecodeAdsPatch {
//Used by app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
@RequiresApi(api = Build.VERSION_CODES.N)
public static boolean containsAd(String value, ByteBuffer buffer) {
return LithoAdRemoval.containsAd(value, buffer);
}
}

View File

@ -0,0 +1,11 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class HideCastButtonPatch {
//Used by app.revanced.patches.youtube.layout.castbutton.patch.HideCastButonPatch
public static int getCastButtonOverrideV2(int original) {
return SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.getBoolean() ? original : 8;
}
}

View File

@ -0,0 +1,14 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
public class HideCreateButtonPatch {
//Todo: Switch BooleanPreferences to Settings class
//Used by app.revanced.patches.youtube.layout.createbutton.patch.CreateButtonRemoverPatch
public static void hideCreateButton(View view) {
AdRemoverAPI.hideCreateButton(view);
}
}

View File

@ -0,0 +1,21 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
public class HideHomeAdsPatch {
/**
* Used by package app.revanced.extensions.Extensions
* @param view
*/
public static void HideHomeAds(View view) {
if (!SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.getBoolean()) {
AdRemoverAPI.HideViewWithLayout1dp(view);
}
}
}

View File

@ -0,0 +1,12 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.adremover.AdRemoverAPI;
public class HideInfoCardSuggestionsPatch {
//TODO: Create Patch
//Not used yet
public static void HideInfoCardSuggestions(Object InfoCardOverlayPresenter) {
AdRemoverAPI.removeInfoCardSuggestions(InfoCardOverlayPresenter);
}
}

View File

@ -0,0 +1,21 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
public class HideReelsPatch {
/**
* Used by app.revanced.patches.youtube.layout.reels.patch.HideReelsPatch
*
* @param view
*/
public static void HideReel(View view) {
if (!SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
AdRemoverAPI.HideViewWithLayout1dp(view);
}
}
}

View File

@ -0,0 +1,18 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
public class HideShortsButtonPatch {
//Todo: Switch BooleanPreferences to Settings class
//Used by app.revanced.patches.youtube.layout.shorts.button.patch.ShortsButtonRemoverPatch
public static void hideShortsButton(View view) {
AdRemoverAPI.hideShortsButton(view);
}
//Needed for the ShortsButtonRemoverPatch
public static Enum lastPivotTab;
}

View File

@ -0,0 +1,13 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.adremover.AdRemoverAPI;
public class HideSuggestionsPatch {
//TODO: Create Patch
//Not used yet
public static void HideSuggestions(boolean showSuggestions) {
AdRemoverAPI.removeSuggestions(showSuggestions);
}
}

View File

@ -0,0 +1,11 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class OldStyleQualityPatch {
//Used by app.revanced.patches.youtube.layout.oldqualitylayout.patch.OldQualityLayoutPatch
public static boolean useOldStyleQualitySettings() {
return SettingsEnum.OLD_STYLE_QUALITY_SETTINGS_BOOLEAN.getBoolean();
}
}

View File

@ -0,0 +1,12 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class SeekbarTappingPatch {
//Used by app.revanced.patches.youtube.interaction.seekbar.patch.EnableSeekbarTappingPatch
public static boolean isTapSeekingEnabled() {
return SettingsEnum.TAP_SEEKING_ENABLED_BOOLEAN.getBoolean();
}
}

View File

@ -0,0 +1,12 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.adremover.whitelist.Whitelist;
public class VideoAdsPatch {
//Used by app.revanced.patches.youtube.ad.general.video.patch.VideoAdsPatch
public static boolean shouldShowAds() {
return Whitelist.shouldShowAds();
}
}

View File

@ -1,10 +1,8 @@
package fi.vanced.libraries.youtube.ryd;
package app.revanced.integrations.ryd;
import static fi.razerman.youtube.XGlobals.debug;
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_NAME;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.app.Activity;
import android.content.Context;
@ -17,13 +15,15 @@ import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import fi.vanced.utils.SharedPrefUtils;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.SharedPrefHelper;
public class RYDFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesName(PREFERENCES_NAME);
getPreferenceManager().setSharedPreferencesName(SharedPrefHelper.SharedPrefNames.RYD.getName());
final Activity context = this.getActivity();
@ -36,7 +36,7 @@ public class RYDFragment extends PreferenceFragment {
preferenceScreen.addPreference(preference);
preference.setKey(PREFERENCES_KEY_RYD_ENABLED);
preference.setDefaultValue(false);
preference.setChecked(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED));
preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED));
preference.setTitle(str("vanced_ryd_title"));
preference.setSummary(str("vanced_ryd_summary"));
preference.setOnPreferenceChangeListener((pref, newValue) -> {
@ -47,12 +47,12 @@ public class RYDFragment extends PreferenceFragment {
}
// Clear hint
if (debug) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
SwitchPreference preference = new SwitchPreference(context);
preferenceScreen.addPreference(preference);
preference.setKey(PREFERENCES_KEY_RYD_HINT_SHOWN);
preference.setDefaultValue(false);
preference.setChecked(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN));
preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN));
preference.setTitle("Hint debug");
preference.setSummary("Debug toggle for clearing the hint shown preference");
preference.setOnPreferenceChangeListener((pref, newValue) -> true);

View File

@ -1,7 +1,6 @@
package fi.vanced.libraries.youtube.ryd;
package app.revanced.integrations.ryd;
public class RYDSettings {
public static final String PREFERENCES_NAME = "ryd";
public static final String PREFERENCES_KEY_USERID = "userId";
public static final String PREFERENCES_KEY_RYD_ENABLED = "ryd-enabled";
public static final String PREFERENCES_KEY_RYD_HINT_SHOWN = "ryd_hint_shown";

View File

@ -0,0 +1,56 @@
package app.revanced.integrations.ryd;
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_USERID;
import static app.revanced.integrations.ryd.Utils.randomString;
import android.content.Context;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.ryd.requests.RYDRequester;
import app.revanced.integrations.utils.SharedPrefHelper;
public class Registration {
private String userId;
private Context context;
public Registration(Context context) {
this.context = context;
}
public String getUserId() {
return userId != null ? userId : fetchUserId();
}
private String fetchUserId() {
try {
if (this.context == null)
throw new Exception("Unable to fetch userId because context was null");
this.userId = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_USERID, null);
if (this.userId == null) {
this.userId = register();
}
} catch (Exception ex) {
LogHelper.printException("Registration", "Unable to fetch the userId from shared preferences", ex);
}
return this.userId;
}
public void saveUserId(String userId) {
try {
if (this.context == null)
throw new Exception("Unable to save userId because context was null");
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_USERID, userId);
} catch (Exception ex) {
LogHelper.printException("Registration", "Unable to save the userId in shared preferences", ex);
}
}
private String register() {
String userId = randomString(36);
LogHelper.debug("Registration", "Trying to register the following userId: " + userId);
return RYDRequester.register(userId, this);
}
}

View File

@ -1,16 +1,14 @@
package fi.vanced.libraries.youtube.ryd;
package app.revanced.integrations.ryd;
import static fi.razerman.youtube.XGlobals.debug;
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
import static fi.vanced.libraries.youtube.player.VideoInformation.dislikeCount;
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_NAME;
import static fi.vanced.utils.VancedUtils.getIdentifier;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.dislikeCount;
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
import static app.revanced.integrations.utils.ReVancedUtils.getIdentifier;
import android.content.Context;
import android.icu.text.CompactDecimalFormat;
import android.os.Build;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
@ -19,12 +17,12 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.util.Locale;
import java.util.Objects;
import fi.vanced.libraries.youtube.ryd.requests.RYDRequester;
import fi.vanced.utils.SharedPrefUtils;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.ryd.requests.RYDRequester;
import app.revanced.integrations.utils.SharedPrefHelper;
public class ReturnYouTubeDislikes {
public static boolean isEnabled;
public static final String TAG = "VI - RYD";
private static View _dislikeView = null;
private static Thread _dislikeFetchThread = null;
private static Thread _votingThread = null;
@ -37,16 +35,14 @@ public class ReturnYouTubeDislikes {
static {
Context context = YouTubeTikTokRoot_Application.getAppContext();
isEnabled = SharedPrefUtils.getBoolean(Objects.requireNonNull(context), PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false);
isEnabled = SharedPrefHelper.getBoolean(Objects.requireNonNull(context), SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false);
if (isEnabled) {
registration = new Registration(context);
voting = new Voting(context, registration);
}
Locale locale = context.getResources().getConfiguration().locale;
if (debug) {
Log.d(TAG, "locale - " + locale);
}
LogHelper.debug("ReturnYoutubeDislikes", "locale - " + locale);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
compactNumberFormatter = CompactDecimalFormat.getInstance(
locale,
@ -66,23 +62,18 @@ public class ReturnYouTubeDislikes {
}
public static void newVideoLoaded(String videoId) {
if (debug) {
Log.d(TAG, "newVideoLoaded - " + videoId);
}
LogHelper.debug("ReturnYoutubeDislikes", "newVideoLoaded - " + videoId);
dislikeCount = null;
if (!isEnabled) return;
try {
if (_dislikeFetchThread != null && _dislikeFetchThread.getState() != Thread.State.TERMINATED) {
if (debug) {
Log.d(TAG, "Interrupting the thread. Current state " + _dislikeFetchThread.getState());
}
LogHelper.debug("ReturnYoutubeDislikes", "Interrupting the thread. Current state " + _dislikeFetchThread.getState());
_dislikeFetchThread.interrupt();
}
}
catch (Exception ex) {
Log.e(TAG, "Error in the dislike fetch thread", ex);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error in the dislike fetch thread", ex);
}
_dislikeFetchThread = new Thread(() -> RYDRequester.fetchDislikes(videoId));
@ -103,9 +94,8 @@ public class ReturnYouTubeDislikes {
if (likeActive) {
votingValue = 1;
}
if (debug) {
Log.d(TAG, "Like tag active " + likeActive);
}
LogHelper.debug("ReturnYoutubeDislikes", "Like tag active " + likeActive);
setTag(view, "like");
}
@ -125,9 +115,7 @@ public class ReturnYouTubeDislikes {
votingValue = -1;
}
_dislikeView = view;
if (debug) {
Log.d(TAG, "Dislike tag active " + dislikeActive);
}
LogHelper.debug("ReturnYoutubeDislikes", "Dislike tag active " + dislikeActive);
setTag(view, "dislike");
}
@ -149,20 +137,16 @@ public class ReturnYouTubeDislikes {
try {
CharSequence tag = (CharSequence) view.getTag();
if (debug) {
Log.d(TAG, "handleOnSetText - " + tag + " - original text - " + originalText);
}
LogHelper.debug("ReturnYoutubeDislikes", "handleOnSetText - " + tag + " - original text - " + originalText);
if (tag == null) return originalText;
if (tag == "like") {
return originalText;
}
else if (tag == "dislike") {
} else if (tag == "dislike") {
return dislikeCount != null ? formatDislikes(dislikeCount) : originalText;
}
}
catch (Exception ex) {
Log.e(TAG, "Error while handling the setText", ex);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error while handling the setText", ex);
}
return originalText;
@ -174,105 +158,100 @@ public class ReturnYouTubeDislikes {
try {
// Try to set normal video dislike count
if (_dislikeView == null) {
if (debug) { Log.d(TAG, "_dislikeView was null"); }
LogHelper.debug("ReturnYoutubeDislikes", "_dislikeView was null");
return;
}
View buttonView = _dislikeView.findViewById(getIdentifier("button_text", "id"));
if (buttonView == null) {
if (debug) { Log.d(TAG, "buttonView was null"); }
LogHelper.debug("ReturnYoutubeDislikes", "buttonView was null");
return;
}
TextView button = (TextView) buttonView;
button.setText(dislikeCount);
if (debug) {
Log.d(TAG, "trySetDislikes - " + dislikeCount);
}
}
catch (Exception ex) {
if (debug) {
Log.e(TAG, "Error while trying to set dislikes text", ex);
}
LogHelper.debug("ReturnYoutubeDislikes", "trySetDislikes - " + dislikeCount);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error while trying to set dislikes text", ex);
}
}
private static void handleOnClick(View view, boolean previousState) {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (!isEnabled || SharedPrefUtils.getBoolean(Objects.requireNonNull(context),"youtube","user_signed_out",true)) return;
if (!isEnabled || SharedPrefHelper.getBoolean(Objects.requireNonNull(context), SharedPrefHelper.SharedPrefNames.YOUTUBE, "user_signed_out", true))
return;
try {
String tag = (String) view.getTag();
if (debug) {
Log.d(TAG, "handleOnClick - " + tag + " - previousState - " + previousState);
}
LogHelper.debug("ReturnYoutubeDislikes", "handleOnClick - " + tag + " - previousState - " + previousState);
if (tag == null) return;
// If active status was removed, vote should be none
if (previousState) { votingValue = 0; }
if (previousState) {
votingValue = 0;
}
if (tag.equals("like")) {
// Like was activated
if (!previousState) { votingValue = 1; likeActive = true; }
else { likeActive = false; }
if (!previousState) {
votingValue = 1;
likeActive = true;
} else {
likeActive = false;
}
// Like was activated and dislike was previously activated
if (!previousState && dislikeActive) { dislikeCount--; trySetDislikes(formatDislikes(dislikeCount)); }
if (!previousState && dislikeActive) {
dislikeCount--;
trySetDislikes(formatDislikes(dislikeCount));
}
dislikeActive = false;
}
else if (tag.equals("dislike")) {
} else if (tag.equals("dislike")) {
likeActive = false;
// Dislike was activated
if (!previousState) { votingValue = -1; dislikeActive = true; dislikeCount++; }
if (!previousState) {
votingValue = -1;
dislikeActive = true;
dislikeCount++;
}
// Dislike was removed
else { dislikeActive = false; dislikeCount--; }
else {
dislikeActive = false;
dislikeCount--;
}
trySetDislikes(formatDislikes(dislikeCount));
}
else {
} else {
// Unknown tag
return;
}
if (debug) {
Log.d(TAG, "New vote status - " + votingValue);
Log.d(TAG, "Like button " + likeActive + " | Dislike button " + dislikeActive);
}
LogHelper.debug("ReturnYoutubeDislikes", "New vote status - " + votingValue);
LogHelper.debug("ReturnYoutubeDislikes", "Like button " + likeActive + " | Dislike button " + dislikeActive);
sendVote(votingValue);
}
catch (Exception ex) {
Log.e(TAG, "Error while handling the onClick", ex);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error while handling the onClick", ex);
}
}
private static void sendVote(int vote) {
if (!isEnabled) return;
if (debug) {
Log.d(TAG, "sending vote - " + vote + " for video " + currentVideoId);
}
LogHelper.debug("ReturnYoutubeDislikes", "sending vote - " + vote + " for video " + currentVideoId);
try {
if (_votingThread != null && _votingThread.getState() != Thread.State.TERMINATED) {
if (debug) {
Log.d(TAG, "Interrupting the thread. Current state " + _votingThread.getState());
}
LogHelper.debug("ReturnYoutubeDislikes", "Interrupting the thread. Current state " + _votingThread.getState());
_votingThread.interrupt();
}
}
catch (Exception ex) {
Log.e(TAG, "Error in the voting thread", ex);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error in the voting thread", ex);
}
_votingThread = new Thread(() -> {
try {
boolean result = voting.sendVote(currentVideoId, vote);
if (debug) {
Log.d(TAG, "sendVote status " + result);
}
}
catch (Exception ex) {
Log.e(TAG, "Failed to send vote", ex);
LogHelper.debug("ReturnYoutubeDislikes", "sendVote status " + result);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Failed to send vote", ex);
}
});
_votingThread.start();
@ -283,36 +262,23 @@ public class ReturnYouTubeDislikes {
try {
if (view == null) {
if (debug) {
Log.d(TAG, "View was empty");
}
LogHelper.debug("ReturnYoutubeDislikes", "View was empty");
return;
}
if (debug) {
Log.d(TAG, "setTag - " + tag);
}
LogHelper.debug("ReturnYoutubeDislikes", "setTag - " + tag);
view.setTag(tag);
}
catch (Exception ex) {
Log.e(TAG, "Error while trying to set tag to view", ex);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error while trying to set tag to view", ex);
}
}
public static String formatDislikes(int dislikes) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && compactNumberFormatter != null) {
final String formatted = compactNumberFormatter.format(dislikes);
if (debug) {
Log.d(TAG, "Formatting dislikes - " + dislikes + " - " + formatted);
}
LogHelper.debug("ReturnYoutubeDislikes", "Formatting dislikes - " + dislikes + " - " + formatted);
return formatted;
}
if (debug) {
Log.d(TAG, "Couldn't format dislikes, using the unformatted count - " + dislikes);
}
LogHelper.debug("ReturnYoutubeDislikes", "Couldn't format dislikes, using the unformatted count - " + dislikes);
return String.valueOf(dislikes);
}
}

View File

@ -1,12 +1,18 @@
package fi.vanced.libraries.youtube.ryd;
package app.revanced.integrations.ryd;
import android.util.Base64;
import android.util.Log;
import java.security.MessageDigest;
import java.security.SecureRandom;
import app.revanced.integrations.utils.LogHelper;
public class Utils {
private static final String TAG = "VI - RYD - Utils";
// https://stackoverflow.com/a/157202
private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private static SecureRandom rnd = new SecureRandom();
public static String solvePuzzle(String challenge, int difficulty) {
byte[] decodedChallenge = Base64.decode(challenge, Base64.NO_WRAP);
@ -20,10 +26,10 @@ public class Utils {
int maxCount = (int) (Math.pow(2, difficulty + 1) * 5);
MessageDigest md = MessageDigest.getInstance("SHA-512");
for (int i = 0; i < maxCount; i++) {
buffer[0] = (byte)i;
buffer[1] = (byte)(i >> 8);
buffer[2] = (byte)(i >> 16);
buffer[3] = (byte)(i >> 24);
buffer[0] = (byte) i;
buffer[1] = (byte) (i >> 8);
buffer[2] = (byte) (i >> 16);
buffer[3] = (byte) (i >> 24);
byte[] messageDigest = md.digest(buffer);
if (countLeadingZeroes(messageDigest) >= difficulty) {
@ -31,9 +37,8 @@ public class Utils {
return encode;
}
}
}
catch (Exception ex) {
Log.e(TAG, "Failed to solve puzzle", ex);
} catch (Exception ex) {
LogHelper.printException("RYD Utils", "Failed to solve puzzle", ex);
}
return null;
@ -62,4 +67,11 @@ public class Utils {
}
return zeroes;
}
public static String randomString(int len) {
StringBuilder sb = new StringBuilder(len);
for (int i = 0; i < len; i++)
sb.append(AB.charAt(rnd.nextInt(AB.length())));
return sb.toString();
}
}

View File

@ -1,15 +1,12 @@
package fi.vanced.libraries.youtube.ryd;
import static fi.razerman.youtube.XGlobals.debug;
package app.revanced.integrations.ryd;
import android.content.Context;
import android.util.Log;
import fi.vanced.libraries.youtube.ryd.requests.RYDRequester;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.ryd.requests.RYDRequester;
public class Voting {
private static final String TAG = "VI - RYD - Voting";
private Registration registration;
private Context context;
@ -20,9 +17,7 @@ public class Voting {
public boolean sendVote(String videoId, int vote) {
String userId = registration.getUserId();
if (debug) {
Log.d(TAG, "Trying to vote the following video: " + videoId + " with vote " + vote + " and userId: " + userId);
}
LogHelper.debug("Voting", "Trying to vote the following video: " + videoId + " with vote " + vote + " and userId: " + userId);
return RYDRequester.sendVote(videoId, userId, vote);
}
}

View File

@ -1,11 +1,10 @@
package fi.vanced.libraries.youtube.dialog;
package app.revanced.integrations.ryd.dialog;
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
import static fi.vanced.libraries.youtube.ryd.RYDSettings.PREFERENCES_NAME;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_ENABLED;
import static app.revanced.integrations.ryd.RYDSettings.PREFERENCES_KEY_RYD_HINT_SHOWN;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.app.Activity;
import android.app.AlertDialog;
@ -18,9 +17,8 @@ import android.os.Build;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import fi.vanced.utils.SharedPrefUtils;
import fi.vanced.utils.VancedUtils;
import pl.jakubweg.SponsorBlockSettings;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.utils.ReVancedUtils;
public class Dialogs {
// Inject call from YT to this
@ -31,14 +29,14 @@ public class Dialogs {
private static void rydFirstRun(Activity activity) {
Context context = YouTubeTikTokRoot_Application.getAppContext();
boolean enabled = SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false);
boolean hintShown = SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, false);
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false);
boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, false);
// If RYD is enabled or hint has been shown, exit
if (enabled || hintShown) {
// If RYD is enabled but hint hasn't been shown, mark it as shown
if (enabled && !hintShown) {
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
}
return;
}
@ -50,20 +48,20 @@ public class Dialogs {
builder = new AlertDialog.Builder(activity);
}
builder.setTitle(str("vanced_ryd"));
builder.setIcon(VancedUtils.getIdentifier("reel_dislike_icon", "drawable"));
builder.setIcon(ReVancedUtils.getIdentifier("reel_dislike_icon", "drawable"));
builder.setCancelable(false);
builder.setMessage(str("vanced_ryd_firstrun"));
builder.setPositiveButton(str("vanced_enable"),
(dialog, id) -> {
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, true);
dialog.dismiss();
});
builder.setNegativeButton(str("vanced_disable"),
(dialog, id) -> {
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
SharedPrefUtils.saveBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_RYD_ENABLED, false);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_HINT_SHOWN, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_RYD_ENABLED, false);
dialog.dismiss();
});
@ -73,7 +71,7 @@ public class Dialogs {
dialog.show();
// Set black background
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, VancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, ReVancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {
@ -85,14 +83,14 @@ public class Dialogs {
private static void sbFirstRun(Activity activity) {
Context context = YouTubeTikTokRoot_Application.getAppContext();
boolean enabled = SharedPrefUtils.getBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
boolean hintShown = SharedPrefUtils.getBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, false);
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
boolean hintShown = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, false);
// If SB is enabled or hint has been shown, exit
if (enabled || hintShown) {
// If SB is enabled but hint hasn't been shown, mark it as shown
if (enabled && !hintShown) {
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
}
return;
}
@ -104,20 +102,20 @@ public class Dialogs {
builder = new AlertDialog.Builder(activity);
}
builder.setTitle(str("vanced_sb"));
builder.setIcon(VancedUtils.getIdentifier("ic_sb_logo", "drawable"));
builder.setIcon(ReVancedUtils.getIdentifier("ic_sb_logo", "drawable"));
builder.setCancelable(false);
builder.setMessage(str("vanced_sb_firstrun"));
builder.setPositiveButton(str("vanced_enable"),
(dialog, id) -> {
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, true);
dialog.dismiss();
});
builder.setNegativeButton(str("vanced_disable"),
(dialog, id) -> {
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
SharedPrefUtils.saveBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN, true);
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.RYD, PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, false);
dialog.dismiss();
});
@ -127,7 +125,7 @@ public class Dialogs {
dialog.show();
// Set black background
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, VancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
dialog.getWindow().getDecorView().getBackground().setColorFilter(new LightingColorFilter(0xFF000000, ReVancedUtils.getIdentifier("ytBrandBackgroundSolid", "color")));
// Set learn more action (set here so clicking it doesn't dismiss the dialog)
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(v -> {

View File

@ -1,13 +1,11 @@
package fi.vanced.libraries.youtube.ryd.requests;
package app.revanced.integrations.ryd.requests;
import static fi.razerman.youtube.XGlobals.debug;
import static fi.vanced.libraries.youtube.player.VideoInformation.dislikeCount;
import static fi.vanced.libraries.youtube.ryd.ReturnYouTubeDislikes.TAG;
import static fi.vanced.utils.requests.Requester.parseJson;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.dislikeCount;
import static app.revanced.integrations.adremover.whitelist.requests.Requester.parseJson;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import org.json.JSONObject;
@ -16,43 +14,40 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import fi.vanced.libraries.youtube.ryd.Registration;
import fi.vanced.libraries.youtube.ryd.ReturnYouTubeDislikes;
import fi.vanced.libraries.youtube.ryd.Utils;
import fi.vanced.utils.requests.Requester;
import fi.vanced.utils.requests.Route;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.ryd.Registration;
import app.revanced.integrations.ryd.ReturnYouTubeDislikes;
import app.revanced.integrations.ryd.Utils;
import app.revanced.integrations.adremover.whitelist.requests.Requester;
import app.revanced.integrations.adremover.whitelist.requests.Route;
public class RYDRequester {
private static final String RYD_API_URL = "https://returnyoutubedislikeapi.com/";
private RYDRequester() {}
private RYDRequester() {
}
public static void fetchDislikes(String videoId) {
try {
if (debug) {
Log.d(TAG, "Fetching dislikes for " + videoId);
}
LogHelper.debug("RYDRequester", "Fetching dislikes for " + videoId);
HttpURLConnection connection = getConnectionFromRoute(RYDRoutes.GET_DISLIKES, videoId);
connection.setConnectTimeout(5 * 1000);
if (connection.getResponseCode() == 200) {
JSONObject json = getJSONObject(connection);
int dislikes = json.getInt("dislikes");
dislikeCount = dislikes;
if (debug) {
Log.d(TAG, "dislikes fetched - " + dislikeCount);
}
LogHelper.debug("RYDRequester", "dislikes fetched - " + dislikeCount);
// Set the dislikes
new Handler(Looper.getMainLooper()).post(() -> ReturnYouTubeDislikes.trySetDislikes(ReturnYouTubeDislikes.formatDislikes(dislikes)));
}
else if (debug) {
Log.d(TAG, "dislikes fetch response was " + connection.getResponseCode());
} else {
LogHelper.debug("RYDRequester", "dislikes fetch response was " + connection.getResponseCode());
}
connection.disconnect();
}
catch (Exception ex) {
} catch (Exception ex) {
dislikeCount = null;
Log.e(TAG, "Failed to fetch dislikes", ex);
LogHelper.printException("RYDRequester", "Failed to fetch dislikes", ex);
}
}
@ -64,65 +59,51 @@ public class RYDRequester {
JSONObject json = getJSONObject(connection);
String challenge = json.getString("challenge");
int difficulty = json.getInt("difficulty");
if (debug) {
Log.d(TAG, "Registration challenge - " + challenge + " with difficulty of " + difficulty);
}
LogHelper.debug("RYDRequester", "Registration challenge - " + challenge + " with difficulty of " + difficulty);
// Solve the puzzle
String solution = Utils.solvePuzzle(challenge, difficulty);
if (debug) {
Log.d(TAG, "Registration confirmation solution is " + solution);
}
LogHelper.debug("RYDRequester", "Registration confirmation solution is " + solution);
return confirmRegistration(userId, solution, registration);
}
else if (debug) {
Log.d(TAG, "Registration response was " + connection.getResponseCode());
} else {
LogHelper.debug("RYDRequester", "Registration response was " + connection.getResponseCode());
}
connection.disconnect();
}
catch (Exception ex){
Log.e(TAG, "Failed to register userId", ex);
} catch (Exception ex) {
LogHelper.printException("RYDRequester", "Failed to register userId", ex);
}
return null;
}
private static String confirmRegistration(String userId, String solution, Registration registration) {
try {
if (debug) {
Log.d(TAG, "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
}
LogHelper.debug("RYDRequester", "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
HttpURLConnection connection = getConnectionFromRoute(RYDRoutes.CONFIRM_REGISTRATION, userId);
applyCommonRequestSettings(connection);
String jsonInputString = "{\"solution\": \"" + solution + "\"}";
try(OutputStream os = connection.getOutputStream()) {
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
if (connection.getResponseCode() == 200) {
String result = parseJson(connection);
if (debug) {
Log.d(TAG, "Registration confirmation result was " + result);
}
LogHelper.debug("RYDRequester", "Registration confirmation result was " + result);
if (result.equalsIgnoreCase("true")) {
registration.saveUserId(userId);
if (debug) {
Log.d(TAG, "Registration was successful for user " + userId);
}
LogHelper.debug("RYDRequester", "Registration was successful for user " + userId);
return userId;
}
}
else if (debug) {
Log.d(TAG, "Registration confirmation response was " + connection.getResponseCode());
} else {
LogHelper.debug("RYDRequester", "Registration confirmation response was " + connection.getResponseCode());
}
connection.disconnect();
}
catch (Exception ex) {
Log.e(TAG, "Failed to confirm registration", ex);
} catch (Exception ex) {
LogHelper.printException("RYDRequester", "Failed to confirm registration", ex);
}
return null;
@ -134,7 +115,7 @@ public class RYDRequester {
applyCommonRequestSettings(connection);
String voteJsonString = "{\"userId\": \"" + userId + "\", \"videoId\": \"" + videoId + "\", \"value\": \"" + vote + "\"}";
try(OutputStream os = connection.getOutputStream()) {
try (OutputStream os = connection.getOutputStream()) {
byte[] input = voteJsonString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
@ -143,26 +124,20 @@ public class RYDRequester {
JSONObject json = getJSONObject(connection);
String challenge = json.getString("challenge");
int difficulty = json.getInt("difficulty");
if (debug) {
Log.d(TAG, "Vote challenge - " + challenge + " with difficulty of " + difficulty);
}
LogHelper.debug("RYDRequester", "Vote challenge - " + challenge + " with difficulty of " + difficulty);
// Solve the puzzle
String solution = Utils.solvePuzzle(challenge, difficulty);
if (debug) {
Log.d(TAG, "Vote confirmation solution is " + solution);
}
LogHelper.debug("RYDRequester", "Vote confirmation solution is " + solution);
// Confirm vote
return confirmVote(videoId, userId, solution);
}
else if (debug) {
Log.d(TAG, "Vote response was " + connection.getResponseCode());
} else {
LogHelper.debug("RYDRequester", "Vote response was " + connection.getResponseCode());
}
connection.disconnect();
}
catch (Exception ex) {
Log.e(TAG, "Failed to send vote", ex);
} catch (Exception ex) {
LogHelper.printException("RYDRequester", "Failed to send vote", ex);
}
return false;
}
@ -173,31 +148,26 @@ public class RYDRequester {
applyCommonRequestSettings(connection);
String jsonInputString = "{\"userId\": \"" + userId + "\", \"videoId\": \"" + videoId + "\", \"solution\": \"" + solution + "\"}";
try(OutputStream os = connection.getOutputStream()) {
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
if (connection.getResponseCode() == 200) {
String result = parseJson(connection);
if (debug) {
Log.d(TAG, "Vote confirmation result was " + result);
}
LogHelper.debug("RYDRequester", "Vote confirmation result was " + result);
if (result.equalsIgnoreCase("true")) {
if (debug) {
Log.d(TAG, "Vote was successful for user " + userId);
}
LogHelper.debug("RYDRequester", "Vote was successful for user " + userId);
return true;
}
}
else if (debug) {
Log.d(TAG, "Vote confirmation response was " + connection.getResponseCode());
} else {
LogHelper.debug("RYDRequester", "Vote confirmation response was " + connection.getResponseCode());
}
connection.disconnect();
}
catch (Exception ex) {
Log.e(TAG, "Failed to confirm vote", ex);
} catch (Exception ex) {
LogHelper.printException("RYDRequester", "Failed to confirm vote", ex);
}
return false;
}

View File

@ -0,0 +1,17 @@
package app.revanced.integrations.ryd.requests;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.GET;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
import app.revanced.integrations.adremover.whitelist.requests.Route;
public class RYDRoutes {
public static final Route SEND_VOTE = new Route(POST, "interact/vote");
public static final Route CONFIRM_VOTE = new Route(POST, "interact/confirmVote");
public static final Route GET_DISLIKES = new Route(GET, "votes?videoId={video_id}");
public static final Route GET_REGISTRATION = new Route(GET, "puzzle/registration?userId={user_id}");
public static final Route CONFIRM_REGISTRATION = new Route(POST, "puzzle/registration?userId={user_id}");
private RYDRoutes() {
}
}

View File

@ -0,0 +1,393 @@
package app.revanced.integrations.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Build;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.util.Objects;
import app.revanced.integrations.sponsorblock.player.PlayerType;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
import app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.videoswipecontrols.FensterGestureController;
import app.revanced.integrations.videoswipecontrols.XFenster;
import app.revanced.integrations.utils.SwipeHelper;
import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout;
public class Settings {
private static Object AutoRepeatClass;
private static PlayerType env;
private static FensterGestureController fensterGestureController;
public static Boolean userChangedQuality = false;
public static Boolean userChangedSpeed = false;
public static Boolean newVideo = false;
public static Boolean newVideoSpeed = false;
public static float[] videoSpeeds = { 0.25f, 0.5f, 0.75f, 1.0f, 1.25f, 1.5f, 2f, 3f, 4f, 5f };
public static String getManufacturer() {
String manufacturer = SettingsEnum.MANUFACTURER_OVERRIDE_STRING.getString();
if (manufacturer == null || manufacturer.isEmpty()) {
manufacturer = Build.MANUFACTURER;
}
LogHelper.debug("Settings", "getManufacturer: " + manufacturer);
return manufacturer;
}
public static String getModel() {
String model = SettingsEnum.MODEL_OVERRIDE_STRING.getString();
if (model == null || model.isEmpty()) {
model = Build.MODEL;
}
LogHelper.debug("Settings", "getModel: " + model);
return model;
}
public static String getStringByName(Context context, String name) {
try {
Resources res = context.getResources();
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
} catch (Throwable exception) {
LogHelper.printException("Settings", "Resource not found.", exception);
return "";
}
}
public static void CheckForMicroG(Activity activity) {
AlertDialog.Builder builder;
if (!appInstalledOrNot("com.mgoogle.android.gms")) {
LogHelper.debug("XDebug", "Custom MicroG installation undetected");
if (Build.VERSION.SDK_INT >= 21) {
builder = new AlertDialog.Builder(activity, 16974374);
} else {
builder = new AlertDialog.Builder(activity);
}
builder.setTitle("Someone is not reading...").setMessage("You didn't install the MicroG as instructed, you can't login without it.\n\nInstall it and try again.").setPositiveButton("Close", new DialogInterface.OnClickListener() { // from class: app.revanced.integrations.settings.Settings.1
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialog, int id) {
}
}).show();
} else {
LogHelper.debug("XDebug", "Custom MicroG installation detected");
}
}
public static boolean isFensterEnabled() {
if (env != null && env == PlayerType.WATCH_WHILE_FULLSCREEN && !SwipeHelper.IsControlsShown()) {
return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() || SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean();
}
return false;
}
public static boolean isWatchWhileFullScreen() {
if (env == null) {
return false;
}
return env.toString().equals("WATCH_WHILE_FULLSCREEN");
}
private static boolean appInstalledOrNot(String uri) {
try {
PackageManager pm = getContext().getPackageManager();
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
public static String getVersionName(Context context) {
try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
String version = pInfo.versionName;
return (version);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return ("17.23.35");
}
public static String getPackageName() {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (context == null) {
LogHelper.printException("Settings", "Context is null, returning com.google.android.youtube!");
return "com.google.android.youtube";
}
String PACKAGE_NAME = context.getPackageName();
LogHelper.debug("Settings", "getPackageName: " + PACKAGE_NAME);
return PACKAGE_NAME;
}
public static int getOverrideWidth(int original) {
int compatibility = SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? 2160 : original;
return compatibility;
}
public static int getOverrideHeight(int original) {
int compatibility = SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? 3840 : original;
return compatibility;
}
public static Context getContext() {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (context != null) {
LogHelper.debug("Settings", "getContext");
return context;
} else {
LogHelper.printException("Settings", "Context is null, returning null!");
return null;
}
}
public static void setOldLayout(SharedPreferences sharedPreferences, String config, long timeStamp) {
if (!SettingsEnum.OLD_LAYOUT_XFILE_ENABLED_BOOLEAN.getBoolean()) {
sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group", config).putLong("com.google.android.libraries.youtube.innertube.cold_stored_timestamp", timeStamp).apply();
LogHelper.debug("Settings", "setOldLayout: true");
return;
}
if (sharedPreferences.contains("com.google.android.libraries.youtube.innertube.cold_config_group")) {
sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group_backup", sharedPreferences.getString("com.google.android.libraries.youtube.innertube.cold_config_group", null)).remove("com.google.android.libraries.youtube.innertube.cold_config_group").apply();
}
LogHelper.debug("Settings", "setOldLayout: false");
}
public static void NewVideoStarted() {
newVideo = true;
newVideoSpeed = true;
LogHelper.debug("Settings", "New video started!");
}
public static void InitializeFensterController(Context context, ViewGroup viewGroup, ViewConfiguration viewConfiguration) {
fensterGestureController = new FensterGestureController();
fensterGestureController.setFensterEventsListener(new XFenster(context, viewGroup), context, viewConfiguration);
LogHelper.debug("Settings", "XFenster initialized");
}
public static boolean FensterTouchEvent(MotionEvent motionEvent) {
if (fensterGestureController == null) {
LogHelper.debug("Settings", "fensterGestureController is null");
return false;
} else if (motionEvent == null) {
LogHelper.debug("Settings", "motionEvent is null");
return false;
} else if (!SwipeHelper.IsControlsShown()) {
return fensterGestureController.onTouchEvent(motionEvent);
} else {
LogHelper.debug("Settings", "skipping onTouchEvent dispatching because controls are shown.");
return false;
}
}
public static void PlayerTypeChanged(PlayerType playerType) {
LogHelper.debug("XDebug", playerType.toString());
if (env != playerType) {
if (playerType == PlayerType.WATCH_WHILE_FULLSCREEN) {
EnableXFenster();
} else {
DisableXFenster();
}
if (playerType == PlayerType.WATCH_WHILE_SLIDING_MINIMIZED_MAXIMIZED || playerType == PlayerType.WATCH_WHILE_MINIMIZED || playerType == PlayerType.WATCH_WHILE_PICTURE_IN_PICTURE) {
NewSegmentHelperLayout.hide();
}
SponsorBlockView.playerTypeChanged(playerType);
SponsorBlockUtils.playerTypeChanged(playerType);
}
env = playerType;
}
public static void EnableXFenster() {
if (SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() || SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean()) {
FensterGestureController fensterGestureController2 = fensterGestureController;
fensterGestureController2.TouchesEnabled = true;
((XFenster) fensterGestureController2.listener).enable(SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean(), SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean());
}
}
public static void DisableXFenster() {
FensterGestureController fensterGestureController2 = fensterGestureController;
fensterGestureController2.TouchesEnabled = false;
((XFenster) fensterGestureController2.listener).disable();
}
/*public static boolean autoCaptions(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
}
Boolean captions = Boolean.valueOf(original);
if (prefAutoCaptions.booleanValue()) {
captions = true;
}
LogHelper.debug("Settings", "autoCaptions: " + captions);
return captions.booleanValue();
}
public static boolean getOverride(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
}
Boolean compatibility = Boolean.valueOf(original);
if (overrideCodec.booleanValue()) {
compatibility = true;
}
LogHelper.debug("Settings", "getOverride: " + compatibility);
return compatibility.booleanValue();
}
public static int getCommentsLocation(int original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
} else if (!commentsLocation.booleanValue()) {
return original;
} else {
LogHelper.debug("Settings", "getCommentsLocation: Moving comments back down");
return 3;
}
}
public static boolean getTabletMiniplayerOverride(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
} else if (!tabletMiniplayer.booleanValue()) {
return original;
} else {
LogHelper.debug("Settings", "getTabletMiniplayerOverride: Using tablet miniplayer");
return true;
}
}
public static boolean getNewActionBar(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
} else if (!newActionBar.booleanValue()) {
return original;
} else {
LogHelper.debug("Settings", "getNewActionBar: Enabled");
return true;
}
}*/
/*
public static boolean getNewActionBarNegated(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
} else if (!newActionBar.booleanValue()) {
return original;
} else {
LogHelper.debug("Settings", "getNewActionBar: Enabled");
return false;
}
}
public static boolean getVerticalZoomToFit(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
} else if (!verticalZoomToFit.booleanValue()) {
return original;
} else {
LogHelper.debug("Settings", "getVerticalZoomToFit: Enabled");
return true;
}
}
public static int getMinimizedVideo(int original) {
int preferredType = SettingsEnum.PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER.getInt();
if (preferredType == -2) {
return original;
}
if (preferredType == 0 || preferredType == 1) {
return preferredType;
}
return original;
}
public static boolean getThemeStatus() {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning false!");
return false;
} else if (!isDarkApp.booleanValue()) {
return false;
} else {
LogHelper.debug("Settings", "getThemeStatus: Is themed");
return true;
}
}
public static boolean accessibilitySeek(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
}
Boolean seek = Boolean.valueOf(original);
if (accessibilitySeek.booleanValue()) {
seek = true;
}
LogHelper.debug("Settings", "accessibilitySeek: " + seek);
return seek.booleanValue();
}
public static boolean shouldAutoRepeat() {
return SettingsEnum.PREFERRED_AUTO_REPEAT_BOOLEAN.getBoolean();
}
public static float getHDRBrightness(float original) {
if (!SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.getBoolean()) return original;
return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() ? BrightnessHelper.getBrightness() : -1.0f;
}
public static int getMaxBuffer(int original) {
return SettingsEnum.MAX_BUFFER_INTEGER.getInt();
}
public static int getPlaybackBuffer(int original) {
return SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.getInt();
}
*/
/*
public static int getReBuffer(int original) {
return SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.getInt();
}
public static boolean isFensterBrightnessEnabled() {
return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean();
}
*/
}

View File

@ -0,0 +1,162 @@
package app.revanced.integrations.settings;
import android.content.Context;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SharedPrefHelper;
public enum SettingsEnum {
DEBUG_BOOLEAN("debug_xfile_enabled", false),
MANUFACTURER_OVERRIDE_STRING("override_manufacturer", null),
MODEL_OVERRIDE_STRING("override_model", null),
CODEC_OVERRIDE_BOOLEAN("override_resolution_xfile_enabled", false),
PREFERRED_RESOLUTION_WIFI_INTEGER("pref_video_quality_wifi", -2),
PREFERRED_RESOLUTION_MOBILE_INTEGER("pref_video_quality_mobile", -2),
PREFERRED_VIDEO_SPEED_FLOAT("pref_video_speed", -2.0f),
PREFERRED_AUTO_CAPTIONS_BOOLEAN("pref_auto_captions", false),
PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER("pref_minimized_video_preview", -2),
PREFERRED_AUTO_REPEAT_BOOLEAN("pref_auto_repeat", false),
HOME_ADS_SHOWN_BOOLEAN("home_ads_enabled", false),
VIDEO_ADS_SHOWN_BOOLEAN("video_ads_enabled", false),
REEL_BUTTON_SHOWN_BOOLEAN("reel_button_enabled", false),
SHORTS_BUTTON_SHOWN_BOOLEAN("shorts_button_enabled", false),
CAST_BUTTON_SHOWN_BOOLEAN("cast_button_enabled", false),
CREATE_BUTTON_SHOWN_BOOLEAN("xfile_create_button_hidden", true),
SUGGESTIONS_SHOWN_BOOLEAN("info_card_suggestions_enabled", true),
INFO_CARDS_SHOWN_BOOLEAN("info_cards_enabled", true),
BRANDING_SHOWN_BOOLEAN("branding_watermark_enabled", true),
USE_TABLET_MINIPLAYER_BOOLEAN("tablet_miniplayer", false),
CHANGE_COMMENT_LOCATION_BOOLEAN("comments_location", false),
USE_NEW_ACTIONBAR_BOOLEAN("xfile_new_actionbar", false),
USE_VERTICAL_ZOOM_TO_FIT_BOOLEAN("xfile_zoom_to_fit_vertical", false),
USE_DARK_THEME_BOOLEAN("app_theme_dark", false),
ACCESSIBILITY_SEEK_BOOLEAN("xfile_accessibility_seek_buttons", false),
USE_HDR_BRIGHTNESS_BOOLEAN("pref_hdr_autobrightness", false),
ENABLE_SWIPE_BRIGHTNESS_BOOLEAN("pref_xfenster_brightness", false),
ENABLE_SWIPE_VOLUME_BOOLEAN("pref_xfenster_volume", false),
SWIPE_THRESHOLD_INTEGER("pref_xfenster_swipe_threshold", 30),
SWIPE_PADDING_TOP_INTEGER("pref_xfenster_swipe_padding_top", 50),
MAX_BUFFER_INTEGER("pref_max_buffer_ms", 120000),
PLAYBACK_MAX_BUFFER_INTEGER("pref_buffer_for_playback_ms", 2500),
MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER("pref_buffer_for_playback_after_rebuffer_ms", 5000),
OLD_STYLE_QUALITY_SETTINGS_BOOLEAN("old_style_quality_settings", true),
OLD_LAYOUT_XFILE_ENABLED_BOOLEAN("old_layout_xfile_enabled", false),
TAP_SEEKING_ENABLED_BOOLEAN("xfile_enable_tap_seeking", true),
;
private final String path;
private final Object defaultValue;
private Object value = null;
private static boolean loaded = false;
SettingsEnum(String path, Object defaultValue) {
this.path = path;
this.defaultValue = defaultValue;
}
public static void loadSettings() {
if (loaded) return;
Context context;
if ((context = YouTubeTikTokRoot_Application.getAppContext()) != null) {
for (SettingsEnum setting : values()) {
Object value = null;
if (setting.name().endsWith("BOOLEAN")) {
value = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
} else if (setting.name().endsWith("INTEGER")) {
value = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
} else if (setting.name().endsWith("STRING")) {
value = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
} else if (setting.name().endsWith("LONG")) {
value = SharedPrefHelper.getLong(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
} else if (setting.name().endsWith(("FLOAT"))) {
value = SharedPrefHelper.getFloat(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath());
} else {
LogHelper.printException("SettingsEnum", "Setting does not end with a valid Type. Name is: " + setting.name());
continue;
}
if (value == null) value = setting.getDefaultValue();
setting.setValue(value);
}
loaded = true;
}
}
public static boolean isLoaded() {
return loaded;
}
public void setValue(Object newValue) {
this.value = newValue;
}
public void saveValue(Object newValue) {
loadSettings();
Context context;
if ((context = YouTubeTikTokRoot_Application.getAppContext()) != null) {
if (name().endsWith("BOOLEAN")) {
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Boolean) newValue);
} else if (name().endsWith("INTEGER")) {
SharedPrefHelper.saveInt(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (int) newValue);
} else if (name().endsWith("STRING")) {
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (String) newValue);
} else if (name().endsWith("LONG")) {
SharedPrefHelper.saveLong(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Long) newValue);
} else if (name().endsWith(("FLOAT"))) {
SharedPrefHelper.saveFloat(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, getPath(), (Float) newValue);
} else {
LogHelper.printException("SettingsEnum", "Setting does not end with a valid Type. Name is: " + name());
}
} else {
LogHelper.printException("SettingsEnum", "Context on SaveValue is null!");
}
}
public int getInt() {
SettingsEnum.loadSettings();
if (value == null) value = -1;
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
return (int) value;
}
public String getString() {
SettingsEnum.loadSettings();
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
return (String) value;
}
public boolean getBoolean() {
SettingsEnum.loadSettings();
//LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
return (Boolean) value;
}
public Long getLong() {
SettingsEnum.loadSettings();
if (value == null) value = -1L;
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
return (Long) value;
}
public Float getFloat() {
SettingsEnum.loadSettings();
if (value == null) value = -1.0f;
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
return (Float) value;
}
private Object getDefaultValue() {
return defaultValue;
}
private String getPath() {
return path;
}
}

View File

@ -1,4 +1,4 @@
package fi.razerman.youtube;
package app.revanced.integrations.settings;
import android.annotation.SuppressLint;
import android.content.Context;
@ -11,16 +11,19 @@ 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;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.videoplayer.autorepeat.AutoRepeat;
import app.revanced.integrations.videoswipecontrols.FensterGestureListener;
import app.revanced.integrations.videoplayer.settings.XReboot;
import app.revanced.integrations.utils.ScreenSizeHelper;
import app.revanced.integrations.utils.SwipeHelper;
import app.revanced.integrations.videoplayer.videourl.Copy;
import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp;
import app.revanced.integrations.BuildConfig;
/* loaded from: classes6.dex */
public class XSettingsFragment extends PreferenceFragment {
@ -62,82 +65,84 @@ public class XSettingsFragment extends PreferenceFragment {
private final int neededClicks = 5;
private boolean hiddenMenuOpened = false;
private boolean settingsInitialized = false;
// from class: fi.razerman.youtube.XSettingsFragment.9
// from class: app.revanced.integrations.settings.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();
SettingsEnum.DEBUG_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.findPreference("debug_xfile_enabled")).isChecked());
} else if ("vp9_xfile_enabled".equals(str)) {
if (((SwitchPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("vp9_xfile_enabled")).isChecked()) {
sharedPreferences.edit().putString("override_manufacturer", "samsung").apply();
sharedPreferences.edit().putString("override_model", "SM-G920F").apply();
XGlobals.manufacturerOverride = "samsung";
XGlobals.modelOverride = "SM-G920F";
SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue("samsung");
SettingsEnum.MODEL_OVERRIDE_STRING.setValue("SM-G920F");
return;
}
sharedPreferences.edit().remove("override_manufacturer").apply();
sharedPreferences.edit().remove("override_model").apply();
XGlobals.manufacturerOverride = null;
XGlobals.modelOverride = null;
SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue(null);
SettingsEnum.MODEL_OVERRIDE_STRING.setValue(null);
} else if ("override_manufacturer".equals(str)) {
EditTextPreference editTextPreference = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_manufacturer");
if (editTextPreference != null) {
editTextPreference.setSummary(editTextPreference.getText());
XGlobals.manufacturerOverride = editTextPreference.getText();
SettingsEnum.MANUFACTURER_OVERRIDE_STRING.setValue(editTextPreference.getText());
}
} else if ("override_model".equals(str)) {
EditTextPreference editTextPreference2 = (EditTextPreference) XSettingsFragment.this.codecPreferenceScreen.findPreference("override_model");
if (editTextPreference2 != null) {
editTextPreference2.setSummary(editTextPreference2.getText());
XGlobals.modelOverride = editTextPreference2.getText();
SettingsEnum.MODEL_OVERRIDE_STRING.setValue(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) {
SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("home_ads_enabled")).isChecked());
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("video_ads_enabled".equals(str)) {
XGlobals.videoAdsShown = ((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("video_ads_enabled")).isChecked();
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
SettingsEnum.VIDEO_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.adsSettingsPreferenceScreen.findPreference("video_ads_enabled")).isChecked());
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("reel_enabled".equals(str)) {
XGlobals.reelShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("reel_enabled")).isChecked();
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("reel_enabled")).isChecked());
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("info_card_suggestions_enabled".equals(str)) {
XGlobals.suggestionsShown = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("info_card_suggestions_enabled")).isChecked();
SettingsEnum.SUGGESTIONS_SHOWN_BOOLEAN.setValue(((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();
SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.setValue(((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();
SettingsEnum.BRANDING_SHOWN_BOOLEAN.setValue(((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();
SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.setValue(((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) {
SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer")).isChecked());
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("comments_location".equals(str)) {
SwitchPreference switchPreference = (SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("comments_location");
XGlobals.commentsLocation = switchPreference.isChecked();
XSwipeHelper.isTabletMode = switchPreference.isChecked();
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
SettingsEnum.CHANGE_COMMENT_LOCATION_BOOLEAN.setValue(switchPreference.isChecked());
SwipeHelper.isTabletMode = switchPreference.isChecked();
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("xfile_create_button_hidden".equals(str)) {
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
SwitchPreference switchPreference = (SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_create_button_hidden");
SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.setValue(switchPreference.isChecked());
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("xfile_new_actionbar".equals(str)) {
XGlobals.newActionBar = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_new_actionbar")).isChecked();
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_new_actionbar")).isChecked());
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("xfile_zoom_to_fit_vertical".equals(str)) {
XGlobals.verticalZoomToFit = ((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_zoom_to_fit_vertical")).isChecked();
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
SettingsEnum.USE_VERTICAL_ZOOM_TO_FIT_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.layoutSettingsPreferenceScreen.findPreference("xfile_zoom_to_fit_vertical")).isChecked());
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("pref_minimized_video_preview".equals(str)) {
@ -145,19 +150,19 @@ public class XSettingsFragment extends PreferenceFragment {
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) {
if (Settings.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();
SettingsEnum.ACCESSIBILITY_SEEK_BOOLEAN.setValue(((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) {
SettingsEnum.CODEC_OVERRIDE_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.findPreference("override_resolution_xfile_enabled")).isChecked());
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("pref_auto_captions".equals(str)) {
XGlobals.prefAutoCaptions = ((SwitchPreference) XSettingsFragment.this.findPreference("pref_auto_captions")).isChecked();
if (XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
SettingsEnum.PREFERRED_AUTO_CAPTIONS_BOOLEAN.setValue(((SwitchPreference) XSettingsFragment.this.findPreference("pref_auto_captions")).isChecked());
if (Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
} else if ("pref_preferred_video_quality_wifi".equals(str)) {
@ -165,36 +170,36 @@ public class XSettingsFragment extends PreferenceFragment {
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);
SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.setValue(Integer.parseInt(string2));
} else if ("pref_preferred_video_quality_mobile".equals(str)) {
ListPreference listPreference3 = (ListPreference) XSettingsFragment.this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_quality_mobile");
String string3 = sharedPreferences.getString("pref_preferred_video_quality_mobile", "-2");
listPreference3.setDefaultValue(string3);
listPreference3.setSummary(XSettingsFragment.this.videoQualityEntries[listPreference3.findIndexOfValue(string3)]);
XGlobals.prefResolutionMobile = Integer.parseInt(string3);
SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.setValue(Integer.parseInt(string3));
} else if ("pref_preferred_video_speed".equals(str)) {
ListPreference listPreference4 = (ListPreference) XSettingsFragment.this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_speed");
String string4 = sharedPreferences.getString("pref_preferred_video_speed", "-2");
listPreference4.setDefaultValue(string4);
listPreference4.setSummary(XSettingsFragment.this.videoSpeedEntries[listPreference4.findIndexOfValue(string4)]);
XGlobals.prefVideoSpeed = Float.parseFloat(string4);
SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.setValue(Float.parseFloat(string4));
} else if ("pref_max_buffer_ms".equals(str)) {
EditTextPreference editTextPreference3 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_max_buffer_ms");
if (editTextPreference3 != null) {
editTextPreference3.setSummary(editTextPreference3.getText());
XGlobals.maxBuffer = Integer.parseInt(editTextPreference3.getText());
SettingsEnum.MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference3.getText()));
}
} else if ("pref_buffer_for_playback_ms".equals(str)) {
EditTextPreference editTextPreference4 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_buffer_for_playback_ms");
if (editTextPreference4 != null) {
editTextPreference4.setSummary(editTextPreference4.getText());
XGlobals.playbackMS = Integer.parseInt(editTextPreference4.getText());
SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference4.getText()));
}
} else if ("pref_buffer_for_playback_after_rebuffer_ms".equals(str)) {
EditTextPreference editTextPreference5 = (EditTextPreference) XSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference("pref_buffer_for_playback_after_rebuffer_ms");
if (editTextPreference5 != null) {
editTextPreference5.setSummary(editTextPreference5.getText());
XGlobals.reBuffer = Integer.parseInt(editTextPreference5.getText());
SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference5.getText()));
}
} else if ("pref_auto_repeat_button".equals(str)) {
XSettingsFragment.this.AutoRepeatLinks();
@ -205,13 +210,13 @@ public class XSettingsFragment extends PreferenceFragment {
} 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();
SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.setValue(((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();
SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.setValue(((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();
SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.setValue(((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();
SwipeHelper.isTabletMode = ((SwitchPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_tablet")).isChecked();
} else if ("pref_xfenster_swipe_threshold".equals(str)) {
EditTextPreference editTextPreference6 = (EditTextPreference) XSettingsFragment.this.xFensterPreferenceScreen.findPreference("pref_xfenster_swipe_threshold");
if (editTextPreference6 != null) {
@ -232,7 +237,7 @@ public class XSettingsFragment extends PreferenceFragment {
FensterGestureListener.TOP_PADDING = 20;
}
}
} else if ("vanced_ryd_enabled".equals(str) && XGlobals.getContext() != null && XSettingsFragment.this.settingsInitialized) {
} else if ("vanced_ryd_enabled".equals(str) && Settings.getContext() != null && XSettingsFragment.this.settingsInitialized) {
XReboot.RebootDialog(XSettingsFragment.this.getActivity());
}
};
@ -249,26 +254,21 @@ public class XSettingsFragment extends PreferenceFragment {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName("youtube");
try {
int identifier = getResources().getIdentifier("xfile_prefs", "xml", XGlobals.getPackageName());
if (XGlobals.XFILEDEBUG) {
addPreferencesFromResource(2131689473);
int identifier = getResources().getIdentifier("xfile_prefs", "xml", Settings.getPackageName());
addPreferencesFromResource(identifier);
String stringByName = Settings.getStringByName(getActivity(), "quality_auto");
this.videoQualityEntries[0] = stringByName;
this.minimizedVideoEntries[0] = stringByName;
this.videoSpeedEntries[0] = stringByName;
String stringByName2 = Settings.getStringByName(getActivity(), "pref_subtitles_scale_normal");
if (stringByName2.equals("")) {
this.videoSpeedEntries[4] = "Normal";
} else {
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");
this.videoSpeedEntries[4] = stringByName2;
}
this.minimizedVideoEntries[1] = Settings.getStringByName(getActivity(), "xfile_miniplayer_style_video");
this.minimizedVideoEntries[2] = Settings.getStringByName(getActivity(), "xfile_miniplayer_style_video_controls");
SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences();
this.sharedPreferences = sharedPreferences;
this.settingsInitialized = sharedPreferences.getBoolean("xfile_initialized", false);
@ -302,13 +302,13 @@ public class XSettingsFragment extends PreferenceFragment {
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
// from class: app.revanced.integrations.settings.XSettingsFragment.1
// android.preference.Preference.OnPreferenceClickListener
listPreference.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.setListPreferenceData(listPreference, true);
return false;
});
// from class: fi.razerman.youtube.XSettingsFragment.2
// from class: app.revanced.integrations.settings.XSettingsFragment.2
// android.preference.Preference.OnPreferenceClickListener
listPreference2.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.setListPreferenceData(listPreference2, false);
@ -316,24 +316,24 @@ public class XSettingsFragment extends PreferenceFragment {
});
final ListPreference listPreference3 = (ListPreference) this.videoSettingsPreferenceScreen.findPreference("pref_preferred_video_speed");
setSpeedListPreferenceData(listPreference3);
// from class: fi.razerman.youtube.XSettingsFragment.3
// from class: app.revanced.integrations.settings.XSettingsFragment.3
// android.preference.Preference.OnPreferenceClickListener
listPreference3.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.setSpeedListPreferenceData(listPreference3);
return false;
});
Preference findPreference = findPreference("pref_about_field");
final String stringByName3 = 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
final String stringByName3 = Settings.getStringByName(getActivity(), "xfile_hiddenmenu_open");
final String stringByName4 = Settings.getStringByName(getActivity(), "xfile_hiddenmenu_opened");
final String str = " " + Settings.getStringByName(getActivity(), "xfile_hiddenmenu_needed");
// from class: app.revanced.integrations.settings.XSettingsFragment.4
// android.preference.Preference.OnPreferenceClickListener
findPreference.setOnPreferenceClickListener(preference -> {
if (XSettingsFragment.this.hiddenMenuOpened) {
if (XSettingsFragment.this.toast != null) {
XSettingsFragment.this.toast.cancel();
}
XSettingsFragment.this.toast = Toast.makeText(XGlobals.getContext(), stringByName3, Toast.LENGTH_SHORT);
XSettingsFragment.this.toast = Toast.makeText(Settings.getContext(), stringByName3, Toast.LENGTH_SHORT);
XSettingsFragment.this.toast.show();
return false;
}
@ -346,13 +346,13 @@ public class XSettingsFragment extends PreferenceFragment {
XSettingsFragment.this.toast.cancel();
}
if (i <= 0) {
XSettingsFragment.this.toast = Toast.makeText(XGlobals.getContext(), stringByName4, Toast.LENGTH_SHORT);
XSettingsFragment.this.toast = Toast.makeText(Settings.getContext(), stringByName4, Toast.LENGTH_SHORT);
XSettingsFragment.this.hiddenMenuOpened = true;
XSettingsFragment.this.sharedPreferences.edit().putBoolean("xfile_hiddenMenu_enabled", true).apply();
XSettingsFragment.this.CheckHiddenMenuStatus();
} else {
XSettingsFragment xSettingsFragment = XSettingsFragment.this;
Context context = XGlobals.getContext();
Context context = Settings.getContext();
xSettingsFragment.toast = Toast.makeText(context, i + str, Toast.LENGTH_SHORT);
}
XSettingsFragment.this.toast.show();
@ -361,31 +361,31 @@ public class XSettingsFragment extends PreferenceFragment {
}
return false;
});
// from class: fi.razerman.youtube.XSettingsFragment.5
// from class: app.revanced.integrations.settings.XSettingsFragment.5
// android.preference.Preference.OnPreferenceClickListener
this.codecDefault.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.ChangeCodec(preference);
return false;
});
// from class: fi.razerman.youtube.XSettingsFragment.6
// from class: app.revanced.integrations.settings.XSettingsFragment.6
// android.preference.Preference.OnPreferenceClickListener
this.codecVP9.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.ChangeCodec(preference);
return false;
});
// from class: fi.razerman.youtube.XSettingsFragment.7
// from class: app.revanced.integrations.settings.XSettingsFragment.7
// android.preference.Preference.OnPreferenceClickListener
this.codecHDRH.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.ChangeCodec(preference);
return false;
});
// from class: fi.razerman.youtube.XSettingsFragment.8
// from class: app.revanced.integrations.settings.XSettingsFragment.8
// android.preference.Preference.OnPreferenceClickListener
this.codecHDRS.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.ChangeCodec(preference);
return false;
});
if (XScreenSizeHelpers.isTablet(YouTubeTikTokRoot_Application.getAppContext())) {
if (ScreenSizeHelper.isTablet(YouTubeTikTokRoot_Application.getAppContext())) {
if (this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer") != null) {
this.layoutSettingsPreferenceScreen.removePreference(this.tabletMiniplayer);
}
@ -396,7 +396,7 @@ public class XSettingsFragment extends PreferenceFragment {
this.sharedPreferences.edit().putBoolean("xfile_initialized", true);
this.settingsInitialized = true;
} catch (Throwable th) {
Log.e("XSettingsFragment", "Unable to retrieve resourceId for xfile_prefs", th);
LogHelper.printException("XSettingsFragment", "Unable to retrieve resourceId for xfile_prefs", th);
}
}
@ -477,7 +477,7 @@ public class XSettingsFragment extends PreferenceFragment {
}
if (this.codecPreferenceScreen.findPreference("pref_default_override") == null) {
this.codecPreferenceScreen.addPreference(this.codecDefault);
// from class: fi.razerman.youtube.XSettingsFragment.10
// from class: app.revanced.integrations.settings.XSettingsFragment.10
// android.preference.Preference.OnPreferenceClickListener
this.codecDefault.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.ChangeCodec(preference);
@ -486,7 +486,7 @@ public class XSettingsFragment extends PreferenceFragment {
}
if (this.codecPreferenceScreen.findPreference("pref_vp9_override") == null) {
this.codecPreferenceScreen.addPreference(this.codecVP9);
// from class: fi.razerman.youtube.XSettingsFragment.11
// from class: app.revanced.integrations.settings.XSettingsFragment.11
// android.preference.Preference.OnPreferenceClickListener
this.codecVP9.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.ChangeCodec(preference);
@ -495,7 +495,7 @@ public class XSettingsFragment extends PreferenceFragment {
}
if (this.codecPreferenceScreen.findPreference("pref_hdrhardware_override") == null) {
this.codecPreferenceScreen.addPreference(this.codecHDRH);
// from class: fi.razerman.youtube.XSettingsFragment.12
// from class: app.revanced.integrations.settings.XSettingsFragment.12
// android.preference.Preference.OnPreferenceClickListener
this.codecHDRH.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.ChangeCodec(preference);
@ -504,7 +504,7 @@ public class XSettingsFragment extends PreferenceFragment {
}
if (this.codecPreferenceScreen.findPreference("pref_hdrsoftware_override") == null) {
this.codecPreferenceScreen.addPreference(this.codecHDRS);
// from class: fi.razerman.youtube.XSettingsFragment.13
// from class: app.revanced.integrations.settings.XSettingsFragment.13
// android.preference.Preference.OnPreferenceClickListener
this.codecHDRS.setOnPreferenceClickListener(preference -> {
XSettingsFragment.this.ChangeCodec(preference);

View File

@ -1,27 +1,27 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import java.lang.reflect.Field;
import app.revanced.integrations.utils.LogHelper;
// invoke-static {p0}, Lpl/jakubweg/InjectedPlugin;->inject(Landroid/content/Context;)V
// invoke-static {}, Lpl/jakubweg/InjectedPlugin;->printSomething()V
// InlineTimeBar
public class InjectedPlugin {
private static final String TAG = "jakubweg.InjectedPlugin";
public static void printSomething() {
Log.d(TAG, "printSomething called");
LogHelper.debug("InjectedPlugin", "printSomething called");
}
public static void printObject(Object o, int recursive) {
if (o == null)
Log.d(TAG, "Printed object is null");
LogHelper.debug("InjectedPlugin", "Printed object is null");
else {
Log.d(TAG, "Printed object ("
LogHelper.debug("InjectedPlugin", "Printed object ("
+ o.getClass().getName()
+ ") = " + o.toString());
for (Field field : o.getClass().getDeclaredFields()) {
@ -32,9 +32,9 @@ public class InjectedPlugin {
Object value = field.get(o);
try {
// if ("java.lang.String".equals(field.getType().getName()))
Log.d(TAG, "Field: " + field.toString() + " has value " + value);
LogHelper.debug("InjectedPlugin", "Field: " + field.toString() + " has value " + value);
} catch (Exception e) {
Log.d(TAG, "Field: " + field.toString() + " has value that thrown an exception in toString method");
LogHelper.debug("InjectedPlugin", "Field: " + field.toString() + " has value that thrown an exception in toString method");
}
if (recursive > 0 && value != null && !value.getClass().isPrimitive())
printObject(value, recursive - 1);
@ -63,9 +63,9 @@ public class InjectedPlugin {
public static void printStackTrace() {
StackTraceElement[] stackTrace = (new Throwable()).getStackTrace();
Log.d(TAG, "Printing stack trace:");
LogHelper.debug("InjectedPlugin", "Printing stack trace:");
for (StackTraceElement element : stackTrace) {
Log.d(TAG, element.toString());
LogHelper.debug("InjectedPlugin", element.toString());
}
}
@ -77,19 +77,19 @@ public class InjectedPlugin {
String spacesStr = builder.toString();
if (view == null) {
Log.i(TAG, spacesStr + "Null view");
LogHelper.debug("InjectedPlugin", spacesStr + "Null view");
return;
}
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
Log.i(TAG, spacesStr + "View group: " + view);
LogHelper.debug("InjectedPlugin", spacesStr + "View group: " + view);
int childCount = group.getChildCount();
Log.i(TAG, spacesStr + "Children count: " + childCount);
LogHelper.debug("InjectedPlugin", spacesStr + "Children count: " + childCount);
for (int i = 0; i < childCount; i++) {
printViewStack(group.getChildAt(i), spaces + 1);
}
} else {
Log.i(TAG, spacesStr + "Normal view: " + view);
LogHelper.debug("InjectedPlugin", spacesStr + "Normal view: " + view);
}
}
}

View File

@ -1,9 +1,9 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import android.content.Context;
import static fi.vanced.libraries.youtube.sponsors.player.ui.SponsorBlockView.hideNewSegmentLayout;
import static fi.vanced.libraries.youtube.sponsors.player.ui.SponsorBlockView.showNewSegmentLayout;
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.hideNewSegmentLayout;
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.showNewSegmentLayout;
public class NewSegmentHelperLayout {
public static Context context;

View File

@ -1,19 +1,18 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import static pl.jakubweg.SponsorBlockSettings.skippedSegments;
import static pl.jakubweg.SponsorBlockSettings.skippedTime;
import static pl.jakubweg.SponsorBlockUtils.timeWithoutSegments;
import static pl.jakubweg.SponsorBlockUtils.videoHasSegments;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedSegments;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedTime;
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.timeWithoutSegments;
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.videoHasSegments;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@ -26,14 +25,15 @@ import java.util.Arrays;
import java.util.Timer;
import java.util.TimerTask;
import fi.vanced.libraries.youtube.player.VideoInformation;
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
import pl.jakubweg.objects.SponsorSegment;
import pl.jakubweg.requests.SBRequester;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
import app.revanced.integrations.sponsorblock.requests.SBRequester;
import app.revanced.integrations.utils.SharedPrefHelper;
@SuppressLint({"LongLogTag"})
public class PlayerController {
public static final String TAG = "jakubweg.PlayerController";
public static final boolean VERBOSE = false;
@SuppressWarnings("PointlessBooleanExpression")
public static final boolean VERBOSE_DRAW_OPTIONS = false && VERBOSE;
@ -48,7 +48,6 @@ public class PlayerController {
private static long currentVideoLength = 1L;
private static long lastKnownVideoTime = -1L;
private static final Runnable findAndSkipSegmentRunnable = () -> {
// Log.d(TAG, "findAndSkipSegmentRunnable");
findAndSkipSegment(false);
};
private static float sponsorBarLeft = 1f;
@ -68,8 +67,8 @@ public class PlayerController {
}
Context context = YouTubeTikTokRoot_Application.getAppContext();
if(context == null){
Log.e(TAG, "context is null");
if (context == null) {
LogHelper.printException("PlayerController", "context is null");
return;
}
SponsorBlockSettings.update(context);
@ -85,7 +84,7 @@ public class PlayerController {
currentVideoId = videoId;
sponsorSegmentsOfCurrentVideo = null;
if (VERBOSE)
Log.d(TAG, "setCurrentVideoId: videoId=" + videoId);
LogHelper.debug("PlayerController", "setCurrentVideoId: videoId=" + videoId);
sponsorTimer.schedule(new TimerTask() {
@Override
@ -102,12 +101,12 @@ public class PlayerController {
// "Plugin.printStackTrace();
if (o == null) {
Log.e(TAG, "onCreate called with null object");
LogHelper.printException("PlayerController", "onCreate called with null object");
return;
}
if (VERBOSE)
Log.i(TAG, String.format("onCreate called with object %s on thread %s", o.toString(), Thread.currentThread().toString()));
LogHelper.debug("PlayerController", String.format("onCreate called with object %s on thread %s", o.toString(), Thread.currentThread().toString()));
try {
setMillisecondMethod = o.getClass().getMethod("replaceMeWithsetMillisecondMethod", Long.TYPE);
@ -121,7 +120,7 @@ public class PlayerController {
SkipSegmentView.hide();
NewSegmentHelperLayout.hide();
} catch (Exception e) {
Log.e(TAG, "Exception while initializing skip method", e);
LogHelper.printException("PlayerController", "Exception while initializing skip method", e);
}
}
@ -135,7 +134,7 @@ public class PlayerController {
if (VERBOSE)
for (SponsorSegment segment : segments) {
Log.v(TAG, "Detected segment: " + segment.toString());
LogHelper.debug("PlayerController", "Detected segment: " + segment.toString());
}
sponsorSegmentsOfCurrentVideo = segments;
@ -152,7 +151,7 @@ public class PlayerController {
// if (currentVideoLink != null) {
// if (VERBOSE)
// Log.w(TAG, "asyncGetVideoLinkFromObject: currentVideoLink != null probably share button was clicked");
// Log.w("PlayerController", "asyncGetVideoLinkFromObject: currentVideoLink != null probably share button was clicked");
// return;
// }
//
@ -169,7 +168,7 @@ public class PlayerController {
// Object objLink = b.get(o);
// if (objLink == null) {
// if (VERBOSE)
// Log.e(TAG, "asyncGetVideoLinkFromObject: objLink is null");
// LogHelper.printException("PlayerController", "asyncGetVideoLinkFromObject: objLink is null");
// } else {
// videoUrl = objLink.toString();
// if (videoUrl.isEmpty())
@ -180,7 +179,7 @@ public class PlayerController {
// break;
//
// if (attempts++ > 5) {
// Log.w(TAG, "asyncGetVideoLinkFromObject: attempts++ > 5");
// Log.w("PlayerController", "asyncGetVideoLinkFromObject: attempts++ > 5");
// return;
// }
// Thread.sleep(50);
@ -189,13 +188,13 @@ public class PlayerController {
// if (currentVideoLink == null) {
// currentVideoLink = videoUrl;
// if (VERBOSE)
// Log.d(TAG, "asyncGetVideoLinkFromObject: link set to " + videoUrl);
// LogH("PlayerController", "asyncGetVideoLinkFromObject: link set to " + videoUrl);
//
// executeDownloadSegments(substringVideoIdFromLink(videoUrl), false);
// }
//
// } catch (Exception e) {
// Log.e(TAG, "Cannot get link from object", e);
// LogHelper.printException("PlayerController", "Cannot get link from object", e);
// }
// }
// }).start();
@ -210,7 +209,7 @@ public class PlayerController {
*/
public static void setCurrentVideoTime(long millis) {
if (VERBOSE)
Log.v(TAG, "setCurrentVideoTime: current video time: " + millis);
LogHelper.debug("PlayerController", "setCurrentVideoTime: current video time: " + millis);
VideoInformation.lastKnownVideoTime = millis;
if (!SponsorBlockSettings.isSponsorBlockEnabled) return;
lastKnownVideoTime = millis;
@ -238,7 +237,7 @@ public class PlayerController {
if (skipSponsorTask == null) {
if (VERBOSE)
Log.d(TAG, "Scheduling skipSponsorTask");
LogHelper.debug("PlayerController", "Scheduling skipSponsorTask");
skipSponsorTask = new TimerTask() {
@Override
public void run() {
@ -251,7 +250,7 @@ public class PlayerController {
sponsorTimer.schedule(skipSponsorTask, segment.start - millis);
} else {
if (VERBOSE)
Log.d(TAG, "skipSponsorTask is already scheduled...");
LogHelper.debug("PlayerController", "skipSponsorTask is already scheduled...");
}
break;
@ -277,10 +276,9 @@ public class PlayerController {
if (segment.category != SponsorBlockSettings.SegmentInfo.UNSUBMITTED) {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (context != null) {
SharedPreferences preferences = SponsorBlockSettings.getPreferences(context);
long newSkippedTime = skippedTime + (segment.end - segment.start);
preferences.edit().putInt(SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS, skippedSegments + 1).apply();
preferences.edit().putLong(SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS_TIME, newSkippedTime).apply();
SharedPrefHelper.saveInt(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS, skippedSegments + 1);
SharedPrefHelper.saveLong(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, SponsorBlockSettings.PREFERENCES_KEY_SKIPPED_SEGMENTS_TIME, newSkippedTime);
}
}
new Thread(() -> {
@ -304,8 +302,7 @@ public class PlayerController {
if (lastKnownVideoTime > 0) {
lastKnownVideoTime = millis;
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
}
else
} else
setCurrentVideoTime(millis);
}
@ -322,7 +319,7 @@ public class PlayerController {
*/
public static void setVideoLength(final long length) {
if (VERBOSE_DRAW_OPTIONS)
Log.d(TAG, "setVideoLength: length=" + length);
LogHelper.debug("PlayerController", "setVideoLength: length=" + length);
currentVideoLength = length;
}
@ -333,7 +330,7 @@ public class PlayerController {
public static void setSponsorBarAbsoluteLeft(final float left) {
if (VERBOSE_DRAW_OPTIONS)
Log.d(TAG, String.format("setSponsorBarLeft: left=%.2f", left));
LogHelper.debug("PlayerController", String.format("setSponsorBarLeft: left=%.2f", left));
sponsorBarLeft = left;
}
@ -358,7 +355,7 @@ public class PlayerController {
public static void setSponsorBarAbsoluteRight(final float right) {
if (VERBOSE_DRAW_OPTIONS)
Log.d(TAG, String.format("setSponsorBarRight: right=%.2f", right));
LogHelper.debug("PlayerController", String.format("setSponsorBarRight: right=%.2f", right));
sponsorBarRight = right;
}
@ -369,14 +366,14 @@ public class PlayerController {
public static void setSponsorBarThickness(final float thickness) {
// if (VERBOSE_DRAW_OPTIONS)
// Log.d(TAG, String.format("setSponsorBarThickness: thickness=%.2f", thickness));
// LogH("PlayerController", String.format("setSponsorBarThickness: thickness=%.2f", thickness));
sponsorBarThickness = thickness;
}
public static void onSkipSponsorClicked() {
if (VERBOSE)
Log.d(TAG, "Skip segment clicked");
LogHelper.debug("PlayerController", "Skip segment clicked");
findAndSkipSegment(true);
}
@ -384,7 +381,7 @@ public class PlayerController {
public static void addSkipSponsorView15(final View view) {
playerActivity = new WeakReference<>((Activity) view.getContext());
if (VERBOSE)
Log.d(TAG, "addSkipSponsorView15: view=" + view.toString());
LogHelper.debug("PlayerController", "addSkipSponsorView15: view=" + view.toString());
new Handler(Looper.getMainLooper()).postDelayed(() -> {
final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) view).getChildAt(2);
@ -396,7 +393,7 @@ public class PlayerController {
public static void addSkipSponsorView14(final View view) {
playerActivity = new WeakReference<>((Activity) view.getContext());
if (VERBOSE)
Log.d(TAG, "addSkipSponsorView14: view=" + view.toString());
LogHelper.debug("PlayerController", "addSkipSponsorView14: view=" + view.toString());
new Handler(Looper.getMainLooper()).postDelayed(() -> {
final ViewGroup viewGroup = (ViewGroup) view.getParent();
Activity activity = (Activity) viewGroup.getContext();
@ -442,37 +439,37 @@ public class PlayerController {
long now = System.currentTimeMillis();
if (now < allowNextSkipRequestTime) {
if (VERBOSE)
Log.w(TAG, "skipToMillisecond: to fast, slow down, because you'll fail");
LogHelper.debug("PlayerController", "skipToMillisecond: to fast, slow down, because you'll fail");
return;
}
allowNextSkipRequestTime = now + 100;
if (setMillisecondMethod == null) {
Log.e(TAG, "setMillisecondMethod is null");
LogHelper.printException("PlayerController", "setMillisecondMethod is null");
return;
}
final Object currentObj = currentPlayerController.get();
if (currentObj == null) {
Log.e(TAG, "currentObj is null (might have been collected by GC)");
LogHelper.printException("PlayerController", "currentObj is null (might have been collected by GC)");
return;
}
if (VERBOSE)
Log.d(TAG, String.format("Requesting skip to millis=%d on thread %s", millisecond, Thread.currentThread().toString()));
LogHelper.debug("PlayerController", String.format("Requesting skip to millis=%d on thread %s", millisecond, Thread.currentThread().toString()));
final long finalMillisecond = millisecond;
new Handler(Looper.getMainLooper()).post(() -> {
try {
if (VERBOSE)
Log.i(TAG, "Skipping to millis=" + finalMillisecond);
LogHelper.debug("PlayerController", "Skipping to millis=" + finalMillisecond);
lastKnownVideoTime = finalMillisecond;
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
setMillisecondMethod.invoke(currentObj, finalMillisecond);
} catch (Exception e) {
Log.e(TAG, "Cannot skip to millisecond", e);
LogHelper.printException("PlayerController", "Cannot skip to millisecond", e);
}
});
}
@ -507,7 +504,7 @@ public class PlayerController {
// if (lastSkippedSegment == segment) return;
// lastSkippedSegment = segment;
if (VERBOSE)
Log.d(TAG, "Skipping segment: " + segment.toString());
LogHelper.debug("PlayerController", "Skipping segment: " + segment.toString());
if (SponsorBlockSettings.showToastWhenSkippedAutomatically && !wasClicked)
SkipSegmentView.notifySkipped(segment);

View File

@ -1,7 +1,7 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
@ -12,12 +12,12 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.lang.ref.WeakReference;
import static fi.razerman.youtube.XGlobals.debug;
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength;
import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime;
import app.revanced.integrations.utils.LogHelper;
public class ShieldButton {
static String TAG = "SHIELD";
static RelativeLayout _youtubeControlsLayout;
static WeakReference<ImageView> _shieldBtn = new WeakReference<>(null);
static int fadeDurationFast;
@ -28,17 +28,15 @@ public class ShieldButton {
public static void initialize(Object viewStub) {
try {
if(debug){
Log.d(TAG, "initializing shield button");
}
LogHelper.debug("ShieldButton", "initializing shield button");
_youtubeControlsLayout = (RelativeLayout) viewStub;
ImageView imageView = (ImageView)_youtubeControlsLayout
ImageView imageView = (ImageView) _youtubeControlsLayout
.findViewById(getIdentifier("sponsorblock_button", "id"));
if (debug && imageView == null){
Log.d(TAG, "Couldn't find imageView with tag \"sponsorblock_button\"");
if (imageView == null) {
LogHelper.debug("ShieldButton", "Couldn't find imageView with \"sponsorblock_button\"");
}
if (imageView == null) return;
imageView.setOnClickListener(SponsorBlockUtils.sponsorBlockBtnListener);
@ -53,9 +51,8 @@ public class ShieldButton {
fadeOut.setDuration(fadeDurationScheduled);
isShowing = true;
changeVisibilityImmediate(false);
}
catch (Exception ex) {
Log.e(TAG, "Unable to set RelativeLayout", ex);
} catch (Exception ex) {
LogHelper.printException("ShieldButton", "Unable to set RelativeLayout", ex);
}
}
@ -82,9 +79,8 @@ public class ShieldButton {
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
return;
}
if (debug) {
Log.d(TAG, "Fading in");
}
LogHelper.debug("ShieldButton", "Fading in");
iView.setVisibility(View.VISIBLE);
if (!immediate)
iView.startAnimation(fadeIn);
@ -92,9 +88,7 @@ public class ShieldButton {
}
if (iView.getVisibility() == View.VISIBLE) {
if (debug) {
Log.d(TAG, "Fading out");
}
LogHelper.debug("ShieldButton", "Fading out");
if (!immediate)
iView.startAnimation(fadeOut);
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);

View File

@ -1,22 +1,23 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.Toast;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import pl.jakubweg.objects.SponsorSegment;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
import static fi.vanced.libraries.youtube.sponsors.player.ui.SponsorBlockView.hideSkipButton;
import static fi.vanced.libraries.youtube.sponsors.player.ui.SponsorBlockView.showSkipButton;
import static pl.jakubweg.PlayerController.VERBOSE;
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.hideSkipButton;
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.showSkipButton;
import static app.revanced.integrations.sponsorblock.PlayerController.VERBOSE;
@SuppressLint({"RtlHardcoded", "SetTextI18n", "LongLogTag", "AppCompatCustomView"})
public class SkipSegmentView {
public static final String TAG = "jakubweg.SkipSegmentView";
private static SponsorSegment lastNotifiedSegment;
public static void show() {
@ -30,14 +31,14 @@ public class SkipSegmentView {
public static void notifySkipped(SponsorSegment segment) {
if (segment == lastNotifiedSegment) {
if (VERBOSE)
Log.d(TAG, "notifySkipped; segment == lastNotifiedSegment");
LogHelper.debug("SkipSegmentView", "notifySkipped; segment == lastNotifiedSegment");
return;
}
lastNotifiedSegment = segment;
String skipMessage = segment.category.skipMessage.toString();
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (VERBOSE)
Log.d(TAG, String.format("notifySkipped; message=%s", skipMessage));
LogHelper.debug("SkipSegmentView", String.format("notifySkipped; message=%s", skipMessage));
if (context != null)
Toast.makeText(context, skipMessage, Toast.LENGTH_SHORT).show();

View File

@ -1,28 +1,26 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import static fi.razerman.youtube.XGlobals.debug;
import static pl.jakubweg.SponsorBlockSettings.DEFAULT_API_URL;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_API_URL;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_VOTING_ENABLED;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME;
import static pl.jakubweg.SponsorBlockSettings.adjustNewSegmentMillis;
import static pl.jakubweg.SponsorBlockSettings.countSkips;
import static pl.jakubweg.SponsorBlockSettings.minDuration;
import static pl.jakubweg.SponsorBlockSettings.setSeenGuidelines;
import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments;
import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically;
import static pl.jakubweg.SponsorBlockSettings.uuid;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_API_URL;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_ADJUST_NEW_SEGMENT_STEP;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_API_URL;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_NEW_SEGMENT_ENABLED;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_UUID;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_VOTING_ENABLED;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.adjustNewSegmentMillis;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.countSkips;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.minDuration;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.setSeenGuidelines;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showTimeWithoutSegments;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showToastWhenSkippedAutomatically;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.uuid;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.app.Activity;
import android.app.AlertDialog;
@ -49,10 +47,12 @@ import java.lang.ref.WeakReference;
import java.text.DecimalFormat;
import java.util.ArrayList;
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
import fi.vanced.utils.SharedPrefUtils;
import pl.jakubweg.objects.EditTextListPreference;
import pl.jakubweg.requests.SBRequester;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.sponsorblock.objects.EditTextListPreference;
import app.revanced.integrations.sponsorblock.requests.SBRequester;
@SuppressWarnings({"unused", "deprecation"}) // injected
public class SponsorBlockPreferenceFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -64,7 +64,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesName(PREFERENCES_NAME);
getPreferenceManager().setSharedPreferencesName(SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK.getName());
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
@ -91,12 +91,12 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
}
// Clear hint
if (debug) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
SwitchPreference preference = new SwitchPreference(context);
preferenceScreen.addPreference(preference);
preference.setKey(PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN);
preference.setDefaultValue(false);
preference.setChecked(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN));
preference.setChecked(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, PREFERENCES_KEY_SPONSOR_BLOCK_HINT_SHOWN));
preference.setTitle("Hint debug");
preference.setSummary("Debug toggle for clearing the hint shown preference");
preference.setOnPreferenceChangeListener((pref, newValue) -> true);
@ -393,7 +393,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
return;
Context context = ((AlertDialog) dialog).getContext();
Context applicationContext = context.getApplicationContext();
SharedPreferences preferences = SponsorBlockSettings.getPreferences(context);
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK);
switch (which) {
case DialogInterface.BUTTON_NEUTRAL:
@ -405,13 +405,11 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
Toast invalidToast = Toast.makeText(applicationContext, str("api_url_invalid"), Toast.LENGTH_SHORT);
if (text == null) {
invalidToast.show();
}
else {
} else {
String textAsString = text.toString();
if (textAsString.isEmpty() || !Patterns.WEB_URL.matcher(textAsString).matches()) {
invalidToast.show();
}
else {
} else {
preferences.edit().putString(PREFERENCES_KEY_API_URL, textAsString).apply();
Toast.makeText(applicationContext, str("api_url_changed"), Toast.LENGTH_SHORT).show();
}

View File

@ -1,6 +1,6 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import static pl.jakubweg.StringRef.sf;
import static app.revanced.integrations.sponsorblock.StringRef.sf;
import android.content.Context;
import android.content.SharedPreferences;
@ -8,16 +8,18 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SharedPrefHelper;
public class SponsorBlockSettings {
public static final String PREFERENCES_NAME = "sponsor-block";
public static final String PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP = "show-toast";
public static final String PREFERENCES_KEY_COUNT_SKIPS = "count-skips";
public static final String PREFERENCES_KEY_UUID = "uuid";
@ -61,22 +63,19 @@ public class SponsorBlockSettings {
@SuppressWarnings("unused")
@Deprecated
public SponsorBlockSettings(Context ignored) {
Log.e("jakubweg.Settings", "Do not call SponsorBlockSettings constructor!");
}
public static SharedPreferences getPreferences(Context context) {
return context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
LogHelper.printException("revanced.Settings", "Do not call SponsorBlockSettings constructor!");
}
public static void setSeenGuidelines(Context context) {
SponsorBlockSettings.seenGuidelinesPopup = true;
getPreferences(context).edit().putBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, true).apply();
SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit().putBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, true).apply();
}
public static void update(Context context) {
if (context == null) return;
SharedPreferences preferences = getPreferences(context);
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK);
isSponsorBlockEnabled = preferences.getBoolean(PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED, isSponsorBlockEnabled);
seenGuidelinesPopup = preferences.getBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, seenGuidelinesPopup);
@ -122,8 +121,7 @@ public class SponsorBlockSettings {
}
if (behaviour != null) {
segment.behaviour = behaviour;
}
else {
} else {
behaviour = segment.behaviour;
}

View File

@ -1,41 +1,38 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import static android.text.Html.fromHtml;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static fi.razerman.youtube.XGlobals.debug;
import static pl.jakubweg.PlayerController.getCurrentVideoId;
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
import static pl.jakubweg.PlayerController.sponsorSegmentsOfCurrentVideo;
import static pl.jakubweg.SponsorBlockPreferenceFragment.FORMATTER;
import static pl.jakubweg.SponsorBlockPreferenceFragment.SAVED_TEMPLATE;
import static pl.jakubweg.SponsorBlockSettings.DEFAULT_API_URL;
import static pl.jakubweg.SponsorBlockSettings.DEFAULT_SERVER_URL;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_API_URL;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_IS_VIP;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_UUID;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_NAME;
import static pl.jakubweg.SponsorBlockSettings.apiUrl;
import static pl.jakubweg.SponsorBlockSettings.countSkips;
import static pl.jakubweg.SponsorBlockSettings.getPreferences;
import static pl.jakubweg.SponsorBlockSettings.isSponsorBlockEnabled;
import static pl.jakubweg.SponsorBlockSettings.lastVipCheck;
import static pl.jakubweg.SponsorBlockSettings.minDuration;
import static pl.jakubweg.SponsorBlockSettings.showTimeWithoutSegments;
import static pl.jakubweg.SponsorBlockSettings.showToastWhenSkippedAutomatically;
import static pl.jakubweg.SponsorBlockSettings.skippedSegments;
import static pl.jakubweg.SponsorBlockSettings.skippedTime;
import static pl.jakubweg.SponsorBlockSettings.uuid;
import static pl.jakubweg.SponsorBlockSettings.vip;
import static pl.jakubweg.StringRef.str;
import static pl.jakubweg.requests.SBRequester.voteForSegment;
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoId;
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength;
import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime;
import static app.revanced.integrations.sponsorblock.PlayerController.sponsorSegmentsOfCurrentVideo;
import static app.revanced.integrations.sponsorblock.SponsorBlockPreferenceFragment.FORMATTER;
import static app.revanced.integrations.sponsorblock.SponsorBlockPreferenceFragment.SAVED_TEMPLATE;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_API_URL;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.DEFAULT_SERVER_URL;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_API_URL;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_CATEGORY_COLOR_SUFFIX;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_COUNT_SKIPS;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_IS_VIP;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_MIN_DURATION;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TIME_WITHOUT_SEGMENTS;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SHOW_TOAST_WHEN_SKIP;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_UUID;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.apiUrl;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.countSkips;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.isSponsorBlockEnabled;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.lastVipCheck;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.minDuration;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showTimeWithoutSegments;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.showToastWhenSkippedAutomatically;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedSegments;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.skippedTime;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.uuid;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.vip;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import static app.revanced.integrations.sponsorblock.requests.SBRequester.voteForSegment;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
@ -49,7 +46,7 @@ import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
@ -68,14 +65,16 @@ import java.util.List;
import java.util.Objects;
import java.util.TimeZone;
import fi.vanced.utils.SharedPrefUtils;
import pl.jakubweg.objects.SponsorSegment;
import pl.jakubweg.objects.UserStats;
import pl.jakubweg.requests.SBRequester;
import app.revanced.integrations.sponsorblock.player.PlayerType;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
import app.revanced.integrations.sponsorblock.objects.UserStats;
import app.revanced.integrations.sponsorblock.requests.SBRequester;
@SuppressWarnings({"LongLogTag"})
public abstract class SponsorBlockUtils {
public static final String TAG = "jakubweg.SponsorBlockUtils";
public static final String TAG = "revanced.SponsorBlockUtils";
public static final String DATE_FORMAT = "HH:mm:ss.SSS";
@SuppressLint("SimpleDateFormat")
public static final SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT);
@ -84,15 +83,11 @@ public abstract class SponsorBlockUtils {
private static final int sponsorBtnId = 1234;
private static final String LOCKED_COLOR = "#FFC83D";
public static final View.OnClickListener sponsorBlockBtnListener = v -> {
if (debug) {
Log.d(TAG, "Shield button clicked");
}
LogHelper.debug(TAG, "Shield button clicked");
NewSegmentHelperLayout.toggle();
};
public static final View.OnClickListener voteButtonListener = v -> {
if (debug) {
Log.d(TAG, "Vote button clicked");
}
LogHelper.debug(TAG, "Vote button clicked");
SponsorBlockUtils.onVotingClicked(v.getContext());
};
private static int shareBtnId = -1;
@ -230,8 +225,7 @@ public abstract class SponsorBlockUtils {
String title = voteOption.title;
if (vip && segment.isLocked && voteOption.shouldHighlight) {
items[i] = Html.fromHtml(String.format("<font color=\"%s\">%s</font>", LOCKED_COLOR, title));
}
else {
} else {
items[i] = title;
}
}
@ -261,13 +255,13 @@ public abstract class SponsorBlockUtils {
final SponsorBlockSettings.SegmentInfo segmentType = SponsorBlockUtils.newSponsorBlockSegmentType;
try {
if (start < 0 || end < 0 || start >= end || segmentType == null || videoId == null || uuid == null) {
Log.e(TAG, "Unable to submit times, invalid parameters");
LogHelper.printException(TAG, "Unable to submit times, invalid parameters");
return;
}
SBRequester.submitSegments(videoId, uuid, ((float) start) / 1000f, ((float) end) / 1000f, segmentType.key, toastRunnable);
newSponsorSegmentEndMillis = newSponsorSegmentStartMillis = -1;
} catch (Exception e) {
Log.e(TAG, "Unable to submit segment", e);
LogHelper.printException(TAG, "Unable to submit segment", e);
}
if (videoId != null)
@ -420,9 +414,10 @@ public abstract class SponsorBlockUtils {
}
public static void notifyShareBtnVisibilityChanged(View v) {
if (v.getId() != shareBtnId || !/*SponsorBlockSettings.isAddNewSegmentEnabled*/false) return;
if (v.getId() != shareBtnId || !/*SponsorBlockSettings.isAddNewSegmentEnabled*/false)
return;
// if (VERBOSE)
// Log.d(TAG, "VISIBILITY CHANGED of view " + v);
// LogH(TAG, "VISIBILITY CHANGED of view " + v);
ImageView sponsorBtn = ShieldButton._shieldBtn.get();
if (sponsorBtn != null) {
sponsorBtn.setVisibility(v.getVisibility());
@ -457,14 +452,13 @@ public abstract class SponsorBlockUtils {
return String.format(" (%s)", formatted);
}
public static void playerTypeChanged(String playerType) {
public static void playerTypeChanged(PlayerType playerType) {
try {
if (videoHasSegments && (playerType.equalsIgnoreCase("NONE"))) {
if (videoHasSegments && (playerType == PlayerType.NONE)) {
PlayerController.setCurrentVideoId(null);
}
}
catch (Exception ex) {
Log.e(TAG, "Player type changed caused a crash.", ex);
} catch (Exception ex) {
LogHelper.printException(TAG, "Player type changed caused a crash.", ex);
}
}
@ -541,7 +535,8 @@ public abstract class SponsorBlockUtils {
JSONObject barTypesObject = settingsJson.getJSONObject("barTypes");
JSONArray categorySelectionsArray = settingsJson.getJSONArray("categorySelections");
SharedPreferences.Editor editor = getPreferences(context).edit();
SharedPreferences.Editor editor = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit();
SponsorBlockSettings.SegmentInfo[] categories = SponsorBlockSettings.SegmentInfo.valuesWithoutUnsubmitted();
for (SponsorBlockSettings.SegmentInfo category : categories) {
@ -585,8 +580,7 @@ public abstract class SponsorBlockUtils {
editor.apply();
Toast.makeText(context, str("settings_import_successful"), Toast.LENGTH_SHORT).show();
}
catch (Exception ex) {
} catch (Exception ex) {
Toast.makeText(context, str("settings_import_failed"), Toast.LENGTH_SHORT).show();
ex.printStackTrace();
}
@ -631,8 +625,7 @@ public abstract class SponsorBlockUtils {
json.put("serverAddress", apiAddress);
return json.toString();
}
catch (Exception ex) {
} catch (Exception ex) {
Toast.makeText(context, str("settings_export_failed"), Toast.LENGTH_SHORT).show();
ex.printStackTrace();
return "";
@ -644,7 +637,7 @@ public abstract class SponsorBlockUtils {
}
public static boolean isSBButtonEnabled(Context context, String key) {
return isSettingEnabled(SharedPrefUtils.getBoolean(context, PREFERENCES_NAME, key, false));
return isSettingEnabled(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, key, false));
}
public enum VoteOption {

View File

@ -1,21 +1,22 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import androidx.annotation.NonNull;
import java.util.HashMap;
public class StringRef {
public static final String TAG = "jakubweg.StringRef";
import app.revanced.integrations.utils.LogHelper;
public class StringRef {
private static Resources resources;
private static String packageName;
/**
* Called in Application onCreate, should be called as soon as possible when after application startup
*
* @param context Any context, it will be used to obtain string resources
*/
public static void setContext(Context context) {
@ -28,7 +29,8 @@ public class StringRef {
/**
* Gets strings reference from shared collection or creates if not exists yet,
* this method should be called if you want to get StringRef
* this method should be called if you want to get StringRef
*
* @param id string resource name/id
* @return String reference that'll resolve to excepted string, may be from cache
*/
@ -44,6 +46,7 @@ public class StringRef {
/**
* Gets string value by string id, shorthand for <code>sf(id).toString()</code>
*
* @param id string resource name/id
* @return String value from string.xml
*/
@ -55,6 +58,7 @@ public class StringRef {
/**
* Gets string value by string id, shorthand for <code>sf(id).toString()</code> and formats the string
* with given args.
*
* @param id string resource name/id
* @param args the args to format the string with
* @return String value from string.xml formatted with given args
@ -67,6 +71,7 @@ public class StringRef {
/**
* Creates a StringRef object that'll not change it's value
*
* @param value value which toString() method returns when invoked on returned object
* @return Unique StringRef instance, its value will never change
*/
@ -100,7 +105,7 @@ public class StringRef {
if (resources != null) {
final int identifier = resources.getIdentifier(value, "string", packageName);
if (identifier == 0)
Log.e(TAG, "Resource not found: " + value);
LogHelper.printException("StringRef", "Resource not found: " + value);
else
value = resources.getString(identifier);
}

View File

@ -1,7 +1,7 @@
package pl.jakubweg;
package app.revanced.integrations.sponsorblock;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
@ -12,12 +12,12 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.lang.ref.WeakReference;
import static fi.razerman.youtube.XGlobals.debug;
import static pl.jakubweg.PlayerController.getCurrentVideoLength;
import static pl.jakubweg.PlayerController.getLastKnownVideoTime;
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength;
import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime;
import app.revanced.integrations.utils.LogHelper;
public class VotingButton {
static String TAG = "VOTING";
static RelativeLayout _youtubeControlsLayout;
static WeakReference<ImageView> _votingButton = new WeakReference<>(null);
static int fadeDurationFast;
@ -28,17 +28,14 @@ public class VotingButton {
public static void initialize(Object viewStub) {
try {
if(debug){
Log.d(TAG, "initializing voting button");
}
LogHelper.debug("VotingButton", "initializing voting button");
_youtubeControlsLayout = (RelativeLayout) viewStub;
ImageView imageView = (ImageView)_youtubeControlsLayout
ImageView imageView = (ImageView) _youtubeControlsLayout
.findViewById(getIdentifier("voting_button", "id"));
if (debug && imageView == null){
Log.d(TAG, "Couldn't find imageView with tag \"voting_button\"");
if (imageView == null) {
LogHelper.debug("VotingButton", "Couldn't find imageView with \"voting_button\"");
}
if (imageView == null) return;
imageView.setOnClickListener(SponsorBlockUtils.voteButtonListener);
@ -53,9 +50,8 @@ public class VotingButton {
fadeOut.setDuration(fadeDurationScheduled);
isShowing = true;
changeVisibilityImmediate(false);
}
catch (Exception ex) {
Log.e(TAG, "Unable to set RelativeLayout", ex);
} catch (Exception ex) {
LogHelper.printException("VotingButton", "Unable to set RelativeLayout", ex);
}
}
@ -82,9 +78,7 @@ public class VotingButton {
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
return;
}
if (debug) {
Log.d(TAG, "Fading in");
}
LogHelper.debug("VotingButton", "Fading in");
iView.setVisibility(View.VISIBLE);
if (!immediate)
iView.startAnimation(fadeIn);
@ -92,9 +86,7 @@ public class VotingButton {
}
if (iView.getVisibility() == View.VISIBLE) {
if (debug) {
Log.d(TAG, "Fading out");
}
LogHelper.debug("VotingButton", "Fading out");
if (!immediate)
iView.startAnimation(fadeOut);
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);

View File

@ -1,7 +1,7 @@
package pl.jakubweg.objects;
package app.revanced.integrations.sponsorblock.objects;
import static pl.jakubweg.SponsorBlockUtils.formatColorString;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.formatColorString;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.app.AlertDialog;
import android.content.Context;
@ -16,7 +16,7 @@ import android.util.AttributeSet;
import android.widget.EditText;
import android.widget.Toast;
import pl.jakubweg.SponsorBlockSettings;
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
@SuppressWarnings("deprecation")
public class EditTextListPreference extends ListPreference {
@ -49,18 +49,20 @@ public class EditTextListPreference extends ListPreference {
mEditText.setText(formatColorString(category.color));
mEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
try {
Color.parseColor(s.toString()); // validation
getDialog().setTitle(Html.fromHtml(String.format("<font color=\"%s\">⬤</font> %s", s, category.title)));
} catch (Exception ex) {
}
catch (Exception ex) {}
}
});
builder.setView(mEditText);
@ -102,8 +104,7 @@ public class EditTextListPreference extends ListPreference {
Toast.makeText(applicationContext, str("color_changed"), Toast.LENGTH_SHORT).show();
getSharedPreferences().edit().putString(getColorPreferenceKey(), formatColorString(color)).apply();
reformatTitle();
}
catch (Exception ex) {
} catch (Exception ex) {
Toast.makeText(applicationContext, str("color_invalid"), Toast.LENGTH_SHORT).show();
}
}

View File

@ -1,6 +1,6 @@
package pl.jakubweg.objects;
package app.revanced.integrations.sponsorblock.objects;
import pl.jakubweg.SponsorBlockSettings;
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
public class SponsorSegment implements Comparable<SponsorSegment> {
public final long start;

View File

@ -1,4 +1,4 @@
package pl.jakubweg.objects;
package app.revanced.integrations.sponsorblock.objects;
public class UserStats {
private final String userName;

View File

@ -1,4 +1,4 @@
package fi.vanced.libraries.youtube.player;
package app.revanced.integrations.sponsorblock.player;
import java.io.Serializable;

View File

@ -0,0 +1,18 @@
package app.revanced.integrations.sponsorblock.player;
public enum PlayerType {
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;
}

View File

@ -1,16 +1,15 @@
package fi.vanced.libraries.youtube.player;
package app.revanced.integrations.sponsorblock.player;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import static fi.razerman.youtube.XGlobals.debug;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import app.revanced.integrations.utils.LogHelper;
public class VideoHelpers {
public static final String TAG = "VideoHelpers";
public static void copyVideoUrlToClipboard() {
generateVideoUrl(false);
@ -24,9 +23,7 @@ public class VideoHelpers {
try {
String videoId = VideoInformation.currentVideoId;
if (videoId == null || videoId.isEmpty()) {
if (debug) {
Log.d(TAG, "VideoId was empty");
}
LogHelper.debug("VideoHelpers", "VideoId was empty");
return;
}
@ -36,21 +33,18 @@ public class VideoHelpers {
videoUrl += String.format("?t=%s", (videoTime / 1000));
}
if (debug) {
Log.d(TAG, "Video URL: " + videoUrl);
}
LogHelper.debug("VideoHelpers", "Video URL: " + videoUrl);
setClipboard(YouTubeTikTokRoot_Application.getAppContext(), videoUrl);
Toast.makeText(YouTubeTikTokRoot_Application.getAppContext(), str("share_copy_url_success"), Toast.LENGTH_SHORT).show();
}
catch (Exception ex) {
Log.e(TAG, "Couldn't generate video url", ex);
} catch (Exception ex) {
LogHelper.printException("VideoHelpers", "Couldn't generate video url", ex);
}
}
private static void setClipboard(Context context, String text) {
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(text);
} else {

View File

@ -1,14 +1,9 @@
package fi.vanced.libraries.youtube.player;
package app.revanced.integrations.sponsorblock.player;
import static fi.razerman.youtube.XGlobals.debug;
import android.util.Log;
import fi.vanced.libraries.youtube.ryd.ReturnYouTubeDislikes;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.ryd.ReturnYouTubeDislikes;
public class VideoInformation {
private static final String TAG = "VI - VideoInfo";
public static String currentVideoId;
public static Integer dislikeCount;
public static String channelName;
@ -21,9 +16,7 @@ public class VideoInformation {
// Call hook in the YT code when the video changes
public static void setCurrentVideoId(final String videoId) {
if (videoId == null) {
if (debug) {
Log.d(TAG, "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
}
LogHelper.debug("VideoInformation", "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
clearInformation(true);
return;
}
@ -34,15 +27,11 @@ public class VideoInformation {
}
if (videoId.equals(currentVideoId)) {
if (debug) {
Log.d(TAG, "setCurrentVideoId - new and current video were equal - " + videoId);
}
LogHelper.debug("VideoInformation", "setCurrentVideoId - new and current video were equal - " + videoId);
return;
}
if (debug) {
Log.d(TAG, "setCurrentVideoId - video id updated from " + currentVideoId + " to " + videoId);
}
LogHelper.debug("VideoInformation", "setCurrentVideoId - video id updated from " + currentVideoId + " to " + videoId);
currentVideoId = videoId;

View File

@ -1,42 +1,38 @@
package fi.vanced.libraries.youtube.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import static fi.razerman.youtube.XGlobals.debug;
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import fi.vanced.libraries.youtube.player.VideoInformation;
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
import fi.vanced.libraries.youtube.whitelisting.requests.WhitelistRequester;
import fi.vanced.utils.SharedPrefUtils;
import fi.vanced.utils.VancedUtils;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.adremover.whitelist.requests.WhitelistRequester;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.utils.ReVancedUtils;
public class AdButton extends SlimButton {
public static final String TAG = "VI - AdButton - Button";
public AdButton(Context context, ViewGroup container) {
super(context, container, SlimButton.SLIM_METADATA_BUTTON_ID,
SharedPrefUtils.getBoolean(context, WhitelistType.ADS.getSharedPreferencesName(), WhitelistType.ADS.getPreferenceEnabledName(), false));
SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, WhitelistType.ADS.getPreferenceEnabledName(), false));
initialize();
}
private void initialize() {
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_yt_ad_button", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_ad_button", "drawable"));
this.button_text.setText(str("action_ads"));
changeEnabled(Whitelist.shouldShowAds());
}
public void changeEnabled(boolean enabled) {
if (debug) {
Log.d(TAG, "changeEnabled " + enabled);
}
LogHelper.debug("AdButton", "changeEnabled " + enabled);
this.button_icon.setEnabled(enabled);
}
@ -56,9 +52,8 @@ public class AdButton extends SlimButton {
try {
Whitelist.removeFromWhitelist(WhitelistType.ADS, this.context, VideoInformation.channelName);
changeEnabled(false);
}
catch (Exception ex) {
Log.e(TAG, "Failed to remove from whitelist", ex);
} catch (Exception ex) {
LogHelper.printException("AdButton", "Failed to remove from whitelist", ex);
return;
}
@ -67,9 +62,7 @@ public class AdButton extends SlimButton {
private void addToWhiteList(View view, ImageView buttonIcon) {
new Thread(() -> {
if (debug) {
Log.d(TAG, "Fetching channelId for " + currentVideoId);
}
LogHelper.debug("AdButton", "Fetching channelId for " + currentVideoId);
WhitelistRequester.addChannelToWhitelist(WhitelistType.ADS, view, buttonIcon, this.context);
}).start();
}

View File

@ -1,24 +1,28 @@
package fi.vanced.libraries.youtube.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import android.content.Context;
import fi.vanced.utils.SharedPrefUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
public class ButtonVisibility {
public static Visibility getButtonVisibility(Context context, String key) {
return getButtonVisibility(context, key, "youtube");
return getButtonVisibility(context, key, SharedPrefHelper.SharedPrefNames.YOUTUBE);
}
public static Visibility getButtonVisibility(Context context, String key, String preferenceName) {
String value = SharedPrefUtils.getString(context, preferenceName, key, null);
public static Visibility getButtonVisibility(Context context, String key, SharedPrefHelper.SharedPrefNames name) {
String value = SharedPrefHelper.getString(context, name, key, null);
if (value == null || value.isEmpty()) return Visibility.NONE;
switch (value.toUpperCase()) {
case "PLAYER": return Visibility.PLAYER;
case "BUTTON_CONTAINER": return Visibility.BUTTON_CONTAINER;
case "BOTH": return Visibility.BOTH;
default: return Visibility.NONE;
case "PLAYER":
return Visibility.PLAYER;
case "BUTTON_CONTAINER":
return Visibility.BUTTON_CONTAINER;
case "BOTH":
return Visibility.BOTH;
default:
return Visibility.NONE;
}
}
@ -26,8 +30,8 @@ public class ButtonVisibility {
return isVisibleInContainer(getButtonVisibility(context, key));
}
public static boolean isVisibleInContainer(Context context, String key, String preferenceName) {
return isVisibleInContainer(getButtonVisibility(context, key, preferenceName));
public static boolean isVisibleInContainer(Context context, String key, SharedPrefHelper.SharedPrefNames name) {
return isVisibleInContainer(getButtonVisibility(context, key, name));
}
public static boolean isVisibleInContainer(Visibility visibility) {

View File

@ -1,13 +1,13 @@
package fi.vanced.libraries.youtube.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import fi.vanced.libraries.youtube.player.VideoHelpers;
import fi.vanced.utils.VancedUtils;
import app.revanced.integrations.sponsorblock.player.VideoHelpers;
import app.revanced.integrations.utils.ReVancedUtils;
public class CopyButton extends SlimButton {
public CopyButton(Context context, ViewGroup container) {
@ -17,7 +17,7 @@ public class CopyButton extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_yt_copy_icon", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_copy_icon", "drawable"));
this.button_text.setText(str("action_copy"));
}

View File

@ -1,13 +1,13 @@
package fi.vanced.libraries.youtube.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import fi.vanced.libraries.youtube.player.VideoHelpers;
import fi.vanced.utils.VancedUtils;
import app.revanced.integrations.sponsorblock.player.VideoHelpers;
import app.revanced.integrations.utils.ReVancedUtils;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.StringRef.str;
public class CopyWithTimestamp extends SlimButton {
public CopyWithTimestamp(Context context, ViewGroup container) {
@ -17,7 +17,7 @@ public class CopyWithTimestamp extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_yt_copy_icon_with_time", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_copy_icon_with_time", "drawable"));
this.button_text.setText(str("action_tcopy"));
}

View File

@ -1,11 +1,11 @@
package fi.vanced.libraries.youtube.sponsors.player.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.RippleDrawable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
@ -13,15 +13,13 @@ import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import pl.jakubweg.NewSegmentHelperLayout;
import pl.jakubweg.PlayerController;
import pl.jakubweg.SponsorBlockSettings;
import pl.jakubweg.SponsorBlockUtils;
import static fi.razerman.youtube.XGlobals.debug;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout;
import app.revanced.integrations.sponsorblock.PlayerController;
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
public class NewSegmentLayout extends FrameLayout {
static String TAG = "NewSegmentLayout";
private LinearLayout newSegmentContainer;
public int defaultBottomMargin;
@ -62,70 +60,70 @@ public class NewSegmentLayout extends FrameLayout {
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, rippleEffect, true);
rippleEffectId = rippleEffect.resourceId;
this.newSegmentContainer = (LinearLayout)this.findViewById(getIdentifier(context, "new_segment_container", "id"));
this.newSegmentContainer = (LinearLayout) this.findViewById(getIdentifier(context, "new_segment_container", "id"));
this.rewindButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_rewind", "id"));
this.rewindButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_rewind", "id"));
if (this.rewindButton != null) {
setClickEffect(this.rewindButton);
this.rewindButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (debug) { Log.d(TAG, "Rewind button clicked"); }
LogHelper.debug("NewSegmentLayout", "Rewind button clicked");
PlayerController.skipRelativeMilliseconds(-SponsorBlockSettings.adjustNewSegmentMillis);
}
});
}
this.forwardButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_forward", "id"));
this.forwardButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_forward", "id"));
if (this.forwardButton != null) {
setClickEffect(this.forwardButton);
this.forwardButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (debug) { Log.d(TAG, "Forward button clicked"); }
LogHelper.debug("NewSegmentLayout", "Forward button clicked");
PlayerController.skipRelativeMilliseconds(SponsorBlockSettings.adjustNewSegmentMillis);
}
});
}
this.adjustButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_adjust", "id"));
this.adjustButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_adjust", "id"));
if (this.adjustButton != null) {
setClickEffect(this.adjustButton);
this.adjustButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (debug) { Log.d(TAG, "Adjust button clicked"); }
LogHelper.debug("NewSegmentLayout", "Adjust button clicked");
SponsorBlockUtils.onMarkLocationClicked(NewSegmentHelperLayout.context);
}
});
}
this.compareButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_compare", "id"));
this.compareButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_compare", "id"));
if (this.compareButton != null) {
setClickEffect(this.compareButton);
this.compareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (debug) { Log.d(TAG, "Compare button clicked"); }
LogHelper.debug("NewSegmentLayout", "Compare button clicked");
SponsorBlockUtils.onPreviewClicked(NewSegmentHelperLayout.context);
}
});
}
this.editButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_edit", "id"));
this.editButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_edit", "id"));
if (this.editButton != null) {
setClickEffect(this.editButton);
this.editButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (debug) { Log.d(TAG, "Edit button clicked"); }
LogHelper.debug("NewSegmentLayout", "Edit button clicked");
SponsorBlockUtils.onEditByHandClicked(NewSegmentHelperLayout.context);
}
});
}
this.publishButton = (ImageButton)this.findViewById(getIdentifier(context, "new_segment_publish", "id"));
this.publishButton = (ImageButton) this.findViewById(getIdentifier(context, "new_segment_publish", "id"));
if (this.publishButton != null) {
setClickEffect(this.publishButton);
this.publishButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (debug) { Log.d(TAG, "Publish button clicked"); }
LogHelper.debug("NewSegmentLayout", "Publish button clicked");
SponsorBlockUtils.onPublishClicked(NewSegmentHelperLayout.context);
}
});
@ -138,10 +136,10 @@ public class NewSegmentLayout extends FrameLayout {
private void setClickEffect(ImageButton btn) {
btn.setBackgroundResource(rippleEffectId);
RippleDrawable rippleDrawable = (RippleDrawable)btn.getBackground();
RippleDrawable rippleDrawable = (RippleDrawable) btn.getBackground();
int[][] states = new int[][] { new int[] { android.R.attr.state_enabled } };
int[] colors = new int[] { 0x33ffffff }; // sets the ripple color to white
int[][] states = new int[][]{new int[]{android.R.attr.state_enabled}};
int[] colors = new int[]{0x33ffffff}; // sets the ripple color to white
ColorStateList colorStateList = new ColorStateList(states, colors);
rippleDrawable.setColor(colorStateList);

View File

@ -1,6 +1,6 @@
package fi.vanced.libraries.youtube.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.content.Intent;
@ -8,10 +8,10 @@ import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import fi.vanced.libraries.youtube.player.VideoInformation;
import fi.vanced.utils.VancedUtils;
import pl.jakubweg.SponsorBlockSettings;
import pl.jakubweg.SponsorBlockUtils;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
public class SBBrowserButton extends SlimButton {
private static final String BROWSER_URL = "https://sb.ltn.fi/video/";
@ -24,7 +24,7 @@ public class SBBrowserButton extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_sb_browser", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_sb_browser", "drawable"));
this.button_text.setText(str("action_browser"));
}

View File

@ -1,25 +1,23 @@
package fi.vanced.libraries.youtube.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import static fi.razerman.youtube.XGlobals.debug;
import static fi.vanced.libraries.youtube.player.VideoInformation.currentVideoId;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import fi.vanced.libraries.youtube.player.VideoInformation;
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
import fi.vanced.libraries.youtube.whitelisting.requests.WhitelistRequester;
import fi.vanced.utils.VancedUtils;
import pl.jakubweg.SponsorBlockUtils;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.adremover.whitelist.requests.WhitelistRequester;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
public class SBWhitelistButton extends SlimButton {
public static final String TAG = "VI - SBWhitelistButton";
public SBWhitelistButton(Context context, ViewGroup container) {
super(context, container, SlimButton.SLIM_METADATA_BUTTON_ID,
SponsorBlockUtils.isSBButtonEnabled(context, WhitelistType.SPONSORBLOCK.getPreferenceEnabledName()));
@ -28,15 +26,13 @@ public class SBWhitelistButton extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_yt_sb_button", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_yt_sb_button", "drawable"));
this.button_text.setText(str("action_segments"));
changeEnabled(Whitelist.isChannelSBWhitelisted());
}
public void changeEnabled(boolean enabled) {
if (debug) {
Log.d(TAG, "changeEnabled " + enabled);
}
LogHelper.debug("SBWhiteListButton", "changeEnabled " + enabled);
this.button_icon.setEnabled(!enabled); // enabled == true -> strikethrough (no segments), enabled == false -> clear (segments)
}
@ -56,9 +52,8 @@ public class SBWhitelistButton extends SlimButton {
try {
Whitelist.removeFromWhitelist(WhitelistType.SPONSORBLOCK, this.context, VideoInformation.channelName);
changeEnabled(false);
}
catch (Exception ex) {
Log.e(TAG, "Failed to remove from whitelist", ex);
} catch (Exception ex) {
LogHelper.printException("SBWhiteListButton", "Failed to remove from whitelist", ex);
return;
}
@ -67,9 +62,7 @@ public class SBWhitelistButton extends SlimButton {
private void addToWhiteList(View view, ImageView buttonIcon) {
new Thread(() -> {
if (debug) {
Log.d(TAG, "Fetching channelId for " + currentVideoId);
}
LogHelper.debug("SBWhiteListButton", "Fetching channelId for " + currentVideoId);
WhitelistRequester.addChannelToWhitelist(WhitelistType.SPONSORBLOCK, view, buttonIcon, this.context);
}).start();
}

View File

@ -1,4 +1,4 @@
package fi.vanced.libraries.youtube.sponsors.player.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import android.content.Context;
import android.content.res.Resources;
@ -7,7 +7,6 @@ import android.graphics.Paint;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
@ -15,12 +14,10 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import pl.jakubweg.PlayerController;
import static fi.razerman.youtube.XGlobals.debug;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.PlayerController;
public class SkipSponsorButton extends FrameLayout {
String TAG = "SkipSponsorButton";
public CharSequence skipSponsorTextViewText;
public CharSequence skipSponsorText;
public ImageView skipSponsorButtonIcon;
@ -68,8 +65,8 @@ public class SkipSponsorButton extends FrameLayout {
private final void initialize(Context context) {
LayoutInflater.from(context).inflate(getIdentifier(context, "skip_sponsor_button", "layout"), this, true); // layout:skip_ad_button
this.setMinimumHeight(this.getResources().getDimensionPixelSize(getIdentifier(context, "ad_skip_ad_button_min_height", "dimen"))); // dimen:ad_skip_ad_button_min_height
this.skipSponsorBtnContainer = (LinearLayout)this.findViewById(getIdentifier(context, "skip_sponsor_button_container", "id")); // id:skip_ad_button_container
this.skipSponsorButtonIcon = (ImageView)this.findViewById(getIdentifier(context, "skip_sponsor_button_icon", "id")); // id:skip_ad_button_icon
this.skipSponsorBtnContainer = (LinearLayout) this.findViewById(getIdentifier(context, "skip_sponsor_button_container", "id")); // id:skip_ad_button_container
this.skipSponsorButtonIcon = (ImageView) this.findViewById(getIdentifier(context, "skip_sponsor_button_icon", "id")); // id:skip_ad_button_icon
this.backgroundColor = getColor(context, getIdentifier(context, "skip_ad_button_background_color", "color")); // color:skip_ad_button_background_color
this.invertedBackgroundColor = getColor(context, getIdentifier(context, "skip_ad_button_inverted_background_color", "color")); // color:skip_ad_button_inverted_background_color
this.background.setColor(this.backgroundColor);
@ -79,7 +76,7 @@ public class SkipSponsorButton extends FrameLayout {
float borderWidth = this.getResources().getDimension(getIdentifier(context, "ad_skip_ad_button_border_width", "dimen")); // dimen:ad_skip_ad_button_border_width
this.border.setStrokeWidth(borderWidth);
this.border.setStyle(Paint.Style.STROKE);
TextView skipSponsorText = (TextView)this.findViewById(getIdentifier(context, "skip_sponsor_button_text", "id")); // id:skip_ad_button_text
TextView skipSponsorText = (TextView) this.findViewById(getIdentifier(context, "skip_sponsor_button_text", "id")); // id:skip_ad_button_text
this.skipSponsorTextView = skipSponsorText;
this.skipSponsorTextViewText = skipSponsorText.getText();
this.currentTextColor = this.skipSponsorTextView.getCurrentTextColor();
@ -93,9 +90,7 @@ public class SkipSponsorButton extends FrameLayout {
this.skipSponsorBtnContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (debug) {
Log.d(TAG, "Skip button clicked");
}
LogHelper.debug("SkipSponsorButton", "Skip button clicked");
PlayerController.onSkipSponsorClicked();
}
});
@ -107,13 +102,13 @@ public class SkipSponsorButton extends FrameLayout {
int height = this.skipSponsorBtnContainer.getHeight();
int top = this.skipSponsorBtnContainer.getTop();
int left = this.skipSponsorBtnContainer.getLeft();
float floatLeft = (float)left;
float floatTop = (float)top;
float floatWidth = (float)(left + width);
float floatHeight = (float)(top + height);
float floatLeft = (float) left;
float floatTop = (float) top;
float floatWidth = (float) (left + width);
float floatHeight = (float) (top + height);
canvas.drawRect(floatLeft, floatTop, floatWidth, floatHeight, this.background);
if (!this.highContrast) {
canvas.drawLines(new float[] { floatWidth, floatTop, floatLeft, floatTop, floatLeft, floatTop, floatLeft, floatHeight, floatLeft, floatHeight, floatWidth, floatHeight }, this.border);
canvas.drawLines(new float[]{floatWidth, floatTop, floatLeft, floatTop, floatLeft, floatTop, floatLeft, floatHeight, floatLeft, floatHeight, floatWidth, floatHeight}, this.border);
}
super.dispatchDraw(canvas);

View File

@ -1,19 +1,17 @@
package fi.vanced.libraries.youtube.ui;
import static fi.razerman.youtube.XGlobals.debug;
package app.revanced.integrations.sponsorblock.player.ui;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import fi.vanced.utils.VancedUtils;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
public abstract class SlimButton implements View.OnClickListener {
private static final String TAG = "VI - Slim - Button";
public static int SLIM_METADATA_BUTTON_ID;
public final View view;
public final Context context;
@ -23,18 +21,16 @@ public abstract class SlimButton implements View.OnClickListener {
private boolean viewAdded = false;
static {
SLIM_METADATA_BUTTON_ID = VancedUtils.getIdentifier("slim_metadata_button", "layout");
SLIM_METADATA_BUTTON_ID = ReVancedUtils.getIdentifier("slim_metadata_button", "layout");
}
public SlimButton(Context context, ViewGroup container, int id, boolean visible) {
if (debug) {
Log.d(TAG, "Adding button with id " + id + " and visibility of " + visible);
}
LogHelper.debug("SlimButton", "Adding button with id " + id + " and visibility of " + visible);
this.context = context;
this.container = container;
view = LayoutInflater.from(context).inflate(id, container, false);
button_icon = (ImageView)view.findViewById(VancedUtils.getIdentifier("button_icon", "id"));
button_text = (TextView)view.findViewById(VancedUtils.getIdentifier("button_text", "id"));
button_icon = (ImageView) view.findViewById(ReVancedUtils.getIdentifier("button_icon", "id"));
button_text = (TextView) view.findViewById(ReVancedUtils.getIdentifier("button_text", "id"));
view.setOnClickListener(this);
@ -46,15 +42,13 @@ public abstract class SlimButton implements View.OnClickListener {
if (!viewAdded && visible) {
container.addView(view);
viewAdded = true;
}
else if (viewAdded && !visible) {
} else if (viewAdded && !visible) {
container.removeView(view);
viewAdded = false;
}
setContainerVisibility();
}
catch (Exception ex) {
Log.e(TAG, "Error while changing button visibility", ex);
} catch (Exception ex) {
LogHelper.printException("SlimButton", "Error while changing button visibility", ex);
}
}

View File

@ -1,25 +1,25 @@
package fi.vanced.libraries.youtube.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import static fi.razerman.youtube.XGlobals.debug;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON;
import static pl.jakubweg.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_BROWSER_BUTTON;
import static app.revanced.integrations.sponsorblock.SponsorBlockSettings.PREFERENCES_KEY_SPONSOR_BLOCK_ENABLED;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ViewGroup;
import com.google.android.apps.youtube.app.ui.SlimMetadataScrollableButtonContainerLayout;
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
import fi.vanced.utils.SharedPrefUtils;
import fi.vanced.utils.VancedUtils;
import pl.jakubweg.SponsorBlockSettings;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLayout {
private static final String TAG = "VI - Slim - Container";
private ViewGroup container;
private CopyButton copyButton;
private CopyWithTimestamp copyWithTimestampButton;
@ -49,8 +49,9 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
public void initialize(Context context) {
try {
container = this.findViewById(VancedUtils.getIdentifier("button_container_vanced", "id"));
if (container == null) throw new Exception("Unable to initialize the button container because the button_container_vanced couldn't be found");
container = this.findViewById(ReVancedUtils.getIdentifier("button_container_vanced", "id"));
if (container == null)
throw new Exception("Unable to initialize the button container because the button_container_vanced couldn't be found");
copyButton = new CopyButton(context, this);
copyWithTimestampButton = new CopyWithTimestamp(context, this);
@ -60,18 +61,15 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
new SponsorBlockVoting(context, this);
addSharedPrefsChangeListener();
}
catch (Exception ex) {
Log.e(TAG, "Unable to initialize the button container", ex);
} catch (Exception ex) {
LogHelper.printException("SlimButtonContainer", "Unable to initialize the button container", ex);
}
}
private void addSharedPrefsChangeListener() {
listener = (sharedPreferences, key) -> {
try {
if (debug) {
Log.d(TAG, String.format("SharedPreference changed with key %s", key));
}
LogHelper.debug("SlimButtonContainer", String.format("SharedPreference changed with key %s", key));
if ("pref_copy_video_url_button_list".equals(key) && copyButton != null) {
copyButton.setVisible(ButtonVisibility.isVisibleInContainer(context, "pref_copy_video_url_button_list"));
return;
@ -84,8 +82,7 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
if (sbWhitelistButton != null) {
if (SponsorBlockSettings.isSponsorBlockEnabled) {
toggleWhitelistButton();
}
else {
} else {
Whitelist.setEnabled(WhitelistType.SPONSORBLOCK, false);
sbWhitelistButton.setVisible(false);
}
@ -93,8 +90,7 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
if (sbBrowserButton != null) {
if (SponsorBlockSettings.isSponsorBlockEnabled) {
toggleBrowserButton();
}
else {
} else {
sbBrowserButton.setVisible(false);
}
}
@ -106,7 +102,7 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
WhitelistType whitelistAds = WhitelistType.ADS;
String adsEnabledPreferenceName = whitelistAds.getPreferenceEnabledName();
if (adsEnabledPreferenceName.equals(key) && adBlockButton != null) {
boolean enabled = SharedPrefUtils.getBoolean(context, whitelistAds.getSharedPreferencesName(), adsEnabledPreferenceName, false);
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, adsEnabledPreferenceName, false);
Whitelist.setEnabled(whitelistAds, enabled);
adBlockButton.setVisible(enabled);
return;
@ -115,27 +111,26 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
toggleWhitelistButton();
return;
}
}
catch (Exception ex) {
Log.e(TAG, "Error handling shared preference change", ex);
} catch (Exception ex) {
LogHelper.printException("SlimButtonContainer", "Error handling shared preference change", ex);
}
};
context.getSharedPreferences(WhitelistType.ADS.getSharedPreferencesName(), Context.MODE_PRIVATE)
context.getSharedPreferences(WhitelistType.ADS.getSharedPreferencesName().getName(), Context.MODE_PRIVATE)
.registerOnSharedPreferenceChangeListener(listener);
context.getSharedPreferences(WhitelistType.SPONSORBLOCK.getSharedPreferencesName(), Context.MODE_PRIVATE)
context.getSharedPreferences(WhitelistType.SPONSORBLOCK.getSharedPreferencesName().getName(), Context.MODE_PRIVATE)
.registerOnSharedPreferenceChangeListener(listener);
}
private void toggleWhitelistButton() {
WhitelistType whitelistSB = WhitelistType.SPONSORBLOCK;
String sbEnabledPreferenceName = whitelistSB.getPreferenceEnabledName();
boolean enabled = SharedPrefUtils.getBoolean(context, whitelistSB.getSharedPreferencesName(), sbEnabledPreferenceName, false);
boolean enabled = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, sbEnabledPreferenceName, false);
Whitelist.setEnabled(whitelistSB, enabled);
sbWhitelistButton.setVisible(enabled);
}
private void toggleBrowserButton() {
sbBrowserButton.setVisible(SharedPrefUtils.getBoolean(context, SponsorBlockSettings.PREFERENCES_NAME, PREFERENCES_KEY_BROWSER_BUTTON, false));
sbBrowserButton.setVisible(SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, PREFERENCES_KEY_BROWSER_BUTTON, false));
}
}

View File

@ -1,7 +1,6 @@
package fi.vanced.libraries.youtube.sponsors.player.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -11,12 +10,12 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.lang.ref.WeakReference;
import fi.razerman.youtube.Helpers.XSwipeHelper;
import static fi.razerman.youtube.XGlobals.debug;
import app.revanced.integrations.sponsorblock.player.PlayerType;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SwipeHelper;
public class SponsorBlockView {
static String TAG = "SponsorBlockView";
static RelativeLayout inlineSponsorOverlay;
static ViewGroup _youtubeOverlaysLayout;
static WeakReference<SkipSponsorButton> _skipSponsorButton = new WeakReference<>(null);
@ -25,22 +24,20 @@ public class SponsorBlockView {
public static void initialize(Object viewGroup) {
try {
if(debug){
Log.d(TAG, "initializing");
}
LogHelper.debug("SponsorblockView", "initializing");
_youtubeOverlaysLayout = (ViewGroup) viewGroup;
addView();
}
catch (Exception ex) {
Log.e(TAG, "Unable to set ViewGroup", ex);
} catch (Exception ex) {
LogHelper.printException("SponsorblockView", "Unable to set ViewGroup", ex);
}
}
public static void showSkipButton() {
skipSponsorButtonVisibility(true);
}
public static void hideSkipButton() {
skipSponsorButtonVisibility(false);
}
@ -48,15 +45,16 @@ public class SponsorBlockView {
public static void showNewSegmentLayout() {
newSegmentLayoutVisibility(true);
}
public static void hideNewSegmentLayout() {
newSegmentLayoutVisibility(false);
}
public static void playerTypeChanged(String playerType) {
public static void playerTypeChanged(PlayerType playerType) {
try {
shouldShowOnPlayerType = playerType.equalsIgnoreCase("WATCH_WHILE_FULLSCREEN") || playerType.equalsIgnoreCase("WATCH_WHILE_MAXIMIZED");
shouldShowOnPlayerType = (playerType == PlayerType.WATCH_WHILE_FULLSCREEN || playerType == PlayerType.WATCH_WHILE_MAXIMIZED);
if (playerType.equalsIgnoreCase("WATCH_WHILE_FULLSCREEN")) {
if (playerType == PlayerType.WATCH_WHILE_FULLSCREEN) {
setSkipBtnMargins(true);
setNewSegmentLayoutMargins(true);
return;
@ -64,9 +62,8 @@ public class SponsorBlockView {
setSkipBtnMargins(false);
setNewSegmentLayoutMargins(false);
}
catch (Exception ex) {
Log.e(TAG, "Player type changed caused a crash.", ex);
} catch (Exception ex) {
LogHelper.printException("SponsorblockView", "Player type changed caused a crash.", ex);
}
}
@ -91,13 +88,13 @@ public class SponsorBlockView {
private static void setSkipBtnMargins(boolean fullScreen) {
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
if (skipSponsorButton == null) {
Log.e(TAG, "Unable to setSkipBtnMargins");
LogHelper.printException("SponsorblockView", "Unable to setSkipBtnMargins");
return;
}
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) skipSponsorButton.getLayoutParams();
if (params == null) {
Log.e(TAG, "Unable to setSkipBtnMargins");
LogHelper.printException("SponsorblockView", "Unable to setSkipBtnMargins");
return;
}
params.bottomMargin = fullScreen ? skipSponsorButton.ctaBottomMargin : skipSponsorButton.defaultBottomMargin;
@ -107,7 +104,7 @@ public class SponsorBlockView {
private static void skipSponsorButtonVisibility(boolean visible) {
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
if (skipSponsorButton == null) {
Log.e(TAG, "Unable to skipSponsorButtonVisibility");
LogHelper.printException("SponsorblockView", "Unable to skipSponsorButtonVisibility");
return;
}
@ -120,13 +117,13 @@ public class SponsorBlockView {
private static void setNewSegmentLayoutMargins(boolean fullScreen) {
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
if (newSegmentLayout == null) {
Log.e(TAG, "Unable to setNewSegmentLayoutMargins");
LogHelper.printException("SponsorblockView", "Unable to setNewSegmentLayoutMargins");
return;
}
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) newSegmentLayout.getLayoutParams();
if (params == null) {
Log.e(TAG, "Unable to setNewSegmentLayoutMargins");
LogHelper.printException("SponsorblockView", "Unable to setNewSegmentLayoutMargins");
return;
}
params.bottomMargin = fullScreen ? newSegmentLayout.ctaBottomMargin : newSegmentLayout.defaultBottomMargin;
@ -136,7 +133,7 @@ public class SponsorBlockView {
private static void newSegmentLayoutVisibility(boolean visible) {
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
if (newSegmentLayout == null) {
Log.e(TAG, "Unable to newSegmentLayoutVisibility");
LogHelper.printException("SponsorblockView", "Unable to newSegmentLayoutVisibility");
return;
}
@ -155,18 +152,15 @@ public class SponsorBlockView {
private static void checkLayout() {
if (inlineSponsorOverlay.getHeight() == 0) {
View layout = XSwipeHelper.nextGenWatchLayout.findViewById(getIdentifier("player_overlays", "id"));
if (layout != null) {
View layout = SwipeHelper.nextGenWatchLayout.findViewById(getIdentifier("player_overlays", "id"));
initialize(layout);
if (layout == null) {
LogHelper.debug("Settings", "player_overlays was not found for SB");
return;
}
if (debug){
Log.d("XGlobals", "player_overlays refreshed for SB");
}
}
else if (debug){
Log.d("XGlobals", "player_overlays was not found for SB");
}
initialize(layout);
LogHelper.debug("Settings", "player_overlays refreshed for SB");
}
}

View File

@ -1,4 +1,4 @@
package fi.vanced.libraries.youtube.ui;
package app.revanced.integrations.sponsorblock.player.ui;
import android.content.Context;
import android.view.View;
@ -7,7 +7,7 @@ import android.widget.Toast;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import fi.vanced.utils.VancedUtils;
import app.revanced.integrations.utils.ReVancedUtils;
public class SponsorBlockVoting extends SlimButton {
public SponsorBlockVoting(Context context, ViewGroup container) {
@ -17,7 +17,7 @@ public class SponsorBlockVoting extends SlimButton {
}
private void initialize() {
this.button_icon.setImageResource(VancedUtils.getIdentifier("vanced_sb_voting", "drawable"));
this.button_icon.setImageResource(ReVancedUtils.getIdentifier("vanced_sb_voting", "drawable"));
this.button_text.setText("SB Voting");
}

View File

@ -1,4 +1,4 @@
package fi.vanced.libraries.youtube.ui;
package app.revanced.integrations.sponsorblock.player.ui;
public enum Visibility {
NONE,

View File

@ -1,10 +1,10 @@
package pl.jakubweg.requests;
package app.revanced.integrations.sponsorblock.requests;
import static android.text.Html.fromHtml;
import static fi.vanced.utils.VancedUtils.runOnMainThread;
import static pl.jakubweg.SponsorBlockUtils.timeWithoutSegments;
import static pl.jakubweg.SponsorBlockUtils.videoHasSegments;
import static pl.jakubweg.StringRef.str;
import static app.revanced.integrations.utils.ReVancedUtils.runOnMainThread;
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.timeWithoutSegments;
import static app.revanced.integrations.sponsorblock.SponsorBlockUtils.videoHasSegments;
import static app.revanced.integrations.sponsorblock.StringRef.str;
import android.content.Context;
import android.content.SharedPreferences;
@ -25,19 +25,21 @@ import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import fi.vanced.utils.requests.Requester;
import fi.vanced.utils.requests.Route;
import pl.jakubweg.PlayerController;
import pl.jakubweg.SponsorBlockSettings;
import pl.jakubweg.SponsorBlockUtils;
import pl.jakubweg.SponsorBlockUtils.VoteOption;
import pl.jakubweg.objects.SponsorSegment;
import pl.jakubweg.objects.UserStats;
import app.revanced.integrations.adremover.whitelist.requests.Requester;
import app.revanced.integrations.adremover.whitelist.requests.Route;
import app.revanced.integrations.sponsorblock.PlayerController;
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils.VoteOption;
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
import app.revanced.integrations.sponsorblock.objects.UserStats;
import app.revanced.integrations.utils.SharedPrefHelper;
public class SBRequester {
private static final String TIME_TEMPLATE = "%.3f";
private SBRequester() {}
private SBRequester() {
}
public static synchronized SponsorSegment[] getSegments(String videoId) {
List<SponsorSegment> segments = new ArrayList<>();
@ -75,8 +77,7 @@ public class SBRequester {
}
}
connection.disconnect();
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
return segments.toArray(new SponsorSegment[0]);
@ -109,8 +110,7 @@ public class SBRequester {
}
runOnMainThread(toastRunnable);
connection.disconnect();
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}
@ -119,8 +119,7 @@ public class SBRequester {
try {
HttpURLConnection connection = getConnectionFromRoute(SBRoutes.VIEWED_SEGMENT, segment.UUID);
connection.disconnect();
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}
@ -152,8 +151,7 @@ public class SBRequester {
}
runOnMainThread(() -> Toast.makeText(context, SponsorBlockUtils.messageToToast, Toast.LENGTH_LONG).show());
connection.disconnect();
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}).start();
@ -171,8 +169,7 @@ public class SBRequester {
UserStats stats = new UserStats(json.getString("userName"), json.getDouble("minutesSaved"), json.getInt("segmentCount"),
json.getInt("viewCount"));
SponsorBlockUtils.addUserStats(category, loadingPreference, stats);
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}).start();
@ -190,14 +187,12 @@ public class SBRequester {
preference.setTitle(fromHtml(str("stats_username", username)));
preference.setText(username);
});
}
else {
} else {
SponsorBlockUtils.messageToToast = str("stats_username_change_unknown_error", responseCode, connection.getResponseMessage());
}
runOnMainThread(toastRunnable);
connection.disconnect();
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}).start();
@ -214,12 +209,11 @@ public class SBRequester {
SponsorBlockSettings.vip = vip;
SponsorBlockSettings.lastVipCheck = now;
SharedPreferences.Editor edit = SponsorBlockSettings.getPreferences(YouTubeTikTokRoot_Application.getAppContext()).edit();
SharedPreferences.Editor edit = SharedPrefHelper.getPreferences(YouTubeTikTokRoot_Application.getAppContext(), SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit();
edit.putString(SponsorBlockSettings.PREFERENCES_KEY_LAST_VIP_CHECK, String.valueOf(now));
edit.putBoolean(SponsorBlockSettings.PREFERENCES_KEY_IS_VIP, vip);
edit.apply();
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}

View File

@ -0,0 +1,20 @@
package app.revanced.integrations.sponsorblock.requests;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.GET;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
import app.revanced.integrations.adremover.whitelist.requests.Route;
public class SBRoutes {
public static final Route IS_USER_VIP = new Route(GET, "isUserVIP?userID={user_id}");
public static final Route GET_SEGMENTS = new Route(GET, "skipSegments?videoID={video_id}&categories={categories}");
public static final Route VIEWED_SEGMENT = new Route(POST, "viewedVideoSponsorTime?UUID={segment_id}");
public static final Route GET_USER_STATS = new Route(GET, "userInfo?userID={user_id}&values=[\"userName\", \"minutesSaved\", \"segmentCount\", \"viewCount\"]");
public static final Route CHANGE_USERNAME = new Route(POST, "setUsername?userID={user_id}&username={username}");
public static final Route SUBMIT_SEGMENTS = new Route(POST, "skipSegments?videoID={video_id}&userID={user_id}&startTime={start_time}&endTime={end_time}&category={category}&videoDuration={duration}");
public static final Route VOTE_ON_SEGMENT_QUALITY = new Route(POST, "voteOnSponsorTime?UUID={segment_id}&userID={user_id}&type={type}");
public static final Route VOTE_ON_SEGMENT_CATEGORY = new Route(POST, "voteOnSponsorTime?UUID={segment_id}&userID={user_id}&category={category}");
private SBRoutes() {
}
}

View File

@ -1,33 +1,36 @@
package fi.razerman.youtube;
package app.revanced.integrations.theme;
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;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.settings.XSettingsFragment;
import app.revanced.integrations.ryd.RYDFragment;
import app.revanced.integrations.sponsorblock.SponsorBlockPreferenceFragment;
import app.revanced.integrations.utils.ThemeHelper;
/* 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();
boolean isDarkTheme = ThemeHelper.isDarkTheme();
this.currentTheme = isDarkTheme;
if (isDarkTheme) {
Log.d("XSettingsActivity", "set Theme.YouTube.Settings.Dark");
LogHelper.debug("XSettingsActivity", "set Theme.YouTube.Settings.Dark");
setTheme(getIdentifier("Theme.YouTube.Settings.Dark", "style"));
} else {
Log.d("XSettingsActivity", "set Theme.YouTube.Settings");
LogHelper.debug("XSettingsActivity", "set Theme.YouTube.Settings");
setTheme(getIdentifier("Theme.YouTube.Settings", "style"));
}
super.onCreate(bundle);
@ -51,7 +54,7 @@ public class XSettingActivity extends Activity {
try {
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(i);
} catch (Exception e) {
Log.e(TAG, "Couldn't set Toolbar title", e);
LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar title", e);
}
}
@ -59,14 +62,14 @@ public class XSettingActivity extends Activity {
try {
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(str);
} catch (Exception e) {
Log.e(TAG, "Couldn't set Toolbar title", e);
LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar title", e);
}
}
private void initImageButton(boolean z) {
try {
ImageButton imageButton = getImageButton((ViewGroup) findViewById(getIdentifier("toolbar", "id")));
imageButton.setOnClickListener(new View.OnClickListener() { // from class: fi.razerman.youtube.XSettingActivity.1
imageButton.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.theme.XSettingActivity.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
XSettingActivity.this.onBackPressed();
@ -74,7 +77,7 @@ public class XSettingActivity extends Activity {
});
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);
LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar click handler", e);
}
}
@ -116,7 +119,7 @@ public class XSettingActivity extends Activity {
if (context2 != null) {
return context2;
}
Log.e("WatchWhileActivity", "Context is null!");
LogHelper.printException("WatchWhileActivity", "Context is null!");
return null;
}
}

View File

@ -1,7 +1,9 @@
package app.revanced.integrations;
package app.revanced.integrations.utils;
import android.content.Context;
import android.util.Log;
import app.revanced.integrations.utils.LogHelper;
public class Globals {
public static Context context;
@ -10,7 +12,7 @@ public class Globals {
if (context != null) {
return context;
}
Log.e("Globals", "Context is null!");
LogHelper.printException("Globals", "Context is null!");
return null;
}
}

View File

@ -0,0 +1,31 @@
package app.revanced.integrations.utils;
import android.util.Log;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
public class LogHelper {
public static void debug(String tag, String message) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
Log.d(tag, message);
}
}
public static void printException(String tag, String message, Throwable ex) {
Log.e(tag, message, ex);
}
public static void printException(String tag, String message) {
Log.e(tag, message);
}
public static void info(String tag, String message) {
Log.i(tag, message);
}
public static void info(String message) {
info("ReVanced", message);
}
}

View File

@ -1,26 +1,4 @@
package fi.vanced.utils;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Modifications copyright (C) 2022 Vanced
*/
import android.util.Log;
package app.revanced.integrations.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -29,10 +7,10 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class ObjectSerializer {
private static final String TAG = "VI - ObjectSerializer";
import app.revanced.integrations.utils.LogHelper;
public static String serialize(Serializable obj) throws IOException {
public class ObjectSerializer {
public static String serialize(Serializable obj) throws IOException {
if (obj == null) return "";
try {
ByteArrayOutputStream serialObj = new ByteArrayOutputStream();
@ -41,7 +19,7 @@ public class ObjectSerializer {
objStream.close();
return encodeBytes(serialObj.toByteArray());
} catch (Exception e) {
Log.e(TAG, "Serialization error: " + e.getMessage(), e);
LogHelper.printException("ObjectSerializer", "Serialization error: " + e.getMessage(), e);
throw new IOException(e);
}
}
@ -53,12 +31,12 @@ public class ObjectSerializer {
ObjectInputStream objStream = new ObjectInputStream(serialObj);
return objStream.readObject();
} catch (Exception e) {
Log.e(TAG, "Deserialization error: " + e.getMessage(), e);
LogHelper.printException("ObjectSerializer", "Deserialization error: " + e.getMessage(), e);
throw new IOException(e);
}
}
public static String encodeBytes(byte[] bytes) {
private static String encodeBytes(byte[] bytes) {
StringBuffer strBuf = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
@ -69,13 +47,13 @@ public class ObjectSerializer {
return strBuf.toString();
}
public static byte[] decodeBytes(String str) {
private static byte[] decodeBytes(String str) {
byte[] bytes = new byte[str.length() / 2];
for (int i = 0; i < str.length(); i+=2) {
for (int i = 0; i < str.length(); i += 2) {
char c = str.charAt(i);
bytes[i/2] = (byte) ((c - 'a') << 4);
c = str.charAt(i+1);
bytes[i/2] += (c - 'a');
bytes[i / 2] = (byte) ((c - 'a') << 4);
c = str.charAt(i + 1);
bytes[i / 2] += (c - 'a');
}
return bytes;
}

View File

@ -0,0 +1,24 @@
package app.revanced.integrations.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Looper;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import java.security.SecureRandom;
public class ReVancedUtils {
public static int getIdentifier(String name, String defType) {
Context context = YouTubeTikTokRoot_Application.getAppContext();
return context.getResources().getIdentifier(name, defType, context.getPackageName());
}
public static void runOnMainThread(Runnable runnable) {
new Handler(Looper.getMainLooper()).post(runnable);
}
}

View File

@ -1,9 +1,9 @@
package fi.razerman.youtube.Helpers;
package app.revanced.integrations.utils;
import android.content.Context;
/* loaded from: classes6.dex */
public class XScreenSizeHelpers {
public class ScreenSizeHelper {
public static boolean isTablet(Context context) {
return smallestWidthDp(context) >= 600;
}

View File

@ -0,0 +1,108 @@
package app.revanced.integrations.utils;
import android.content.Context;
import android.content.SharedPreferences;
public class SharedPrefHelper {
public static void saveString(Context context, SharedPrefNames prefName, String key, String value) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
sharedPreferences.edit().putString(key, value).apply();
}
public static void saveBoolean(Context context, SharedPrefNames prefName, String key, Boolean value) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
sharedPreferences.edit().putBoolean(key, value).apply();
}
public static void saveInt(Context context, SharedPrefNames prefName, String key, Integer value) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
sharedPreferences.edit().putInt(key, value).apply();
}
public static void saveLong(Context context, SharedPrefNames prefName, String key, Long value) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
sharedPreferences.edit().putLong(key, value).apply();
}
public static void saveFloat(Context context, SharedPrefNames prefName, String key, Float value) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
sharedPreferences.edit().putFloat(key, value).apply();
}
public static String getString(Context context, SharedPrefNames prefName, String key) {
return getString(context, prefName, key, null);
}
public static String getString(Context context, SharedPrefNames prefName, String key, String _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return (sharedPreferences.getString(key, _default));
}
public static Boolean getBoolean(Context context, SharedPrefNames prefName, String key) {
return getBoolean(context, prefName, key, false);
}
public static Boolean getBoolean(Context context, SharedPrefNames prefName, String key, Boolean _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return (sharedPreferences.getBoolean(key, _default));
}
public static Long getLong(Context context, SharedPrefNames prefName, String key) {
return getLong(context, prefName, key, -1L);
}
public static Long getLong(Context context, SharedPrefNames prefName, String key, Long _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return sharedPreferences.getLong(key, _default);
}
public static Float getFloat(Context context, SharedPrefNames prefName, String key) {
return getFloat(context, prefName, key, -1.0F);
}
public static Float getFloat(Context context, SharedPrefNames prefName, String key, Float _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return sharedPreferences.getFloat(key, _default);
}
public static Integer getInt(Context context, SharedPrefNames prefName, String key) {
return getInt(context, prefName, key, -1);
}
public static Integer getInt(Context context, SharedPrefNames prefName, String key, Integer _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return sharedPreferences.getInt(key, _default);
}
public static SharedPreferences getPreferences(Context context, SharedPrefNames name) {
if (context == null) return null;
return context.getSharedPreferences(name.getName(), Context.MODE_PRIVATE);
}
public static SharedPreferences getPreferences(Context context, String name) {
if (context == null) return null;
return context.getSharedPreferences(name, Context.MODE_PRIVATE);
}
public enum SharedPrefNames {
YOUTUBE("youtube"),
RYD("ryd"),
SPONSOR_BLOCK("sponsor-block");
private final String name;
SharedPrefNames(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public String toString() {
return name;
}
}
}

View File

@ -1,16 +1,18 @@
package fi.razerman.youtube.Helpers;
package app.revanced.integrations.utils;
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;
import app.revanced.integrations.settings.Settings;
/* loaded from: classes6.dex */
public class XSwipeHelper {
public class SwipeHelper {
static FrameLayout _frameLayout;
public static boolean isTabletMode;
public static ViewGroup nextGenWatchLayout;
@ -19,11 +21,11 @@ public class XSwipeHelper {
try {
_frameLayout = (FrameLayout) obj;
Context appContext = YouTubeTikTokRoot_Application.getAppContext();
if (XScreenSizeHelpers.isTablet(appContext) || XSharedPrefs.getBoolean(appContext, "pref_xfenster_tablet", false)) {
if (ScreenSizeHelper.isTablet(appContext) || SharedPrefHelper.getBoolean(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"pref_xfenster_tablet", false)) {
isTabletMode = true;
}
} catch (Exception e) {
Log.e("XError", "Unable to set FrameLayout", e);
LogHelper.printException("XError", "Unable to set FrameLayout", e);
}
}
@ -31,7 +33,7 @@ public class XSwipeHelper {
try {
nextGenWatchLayout = (ViewGroup) obj;
} catch (Exception e) {
Log.e("XError", "Unable to set _nextGenWatchLayout", e);
LogHelper.printException("XError", "Unable to set _nextGenWatchLayout", e);
}
}
@ -42,7 +44,7 @@ public class XSwipeHelper {
}
try {
} catch (Exception e) {
Log.e("XError", "Unable to get related_endscreen_results visibility", e);
LogHelper.printException("XError", "Unable to get related_endscreen_results visibility", e);
}
if (_frameLayout.getChildCount() > 0) {
return _frameLayout.getChildAt(0).getVisibility() == View.VISIBLE;
@ -54,14 +56,12 @@ public class XSwipeHelper {
private static void refreshLayout() {
View findViewById;
try {
if (XGlobals.isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) {
if (Settings.isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) {
_frameLayout = (FrameLayout) findViewById.getParent();
if (XGlobals.debug) {
Log.d("XGlobals", "related_endscreen_results refreshed");
}
LogHelper.debug("Settings", "related_endscreen_results refreshed");
}
} catch (Exception e) {
Log.e("XError", "Unable to refresh related_endscreen_results layout", e);
LogHelper.printException("XError", "Unable to refresh related_endscreen_results layout", e);
}
}

View File

@ -1,32 +1,25 @@
package fi.razerman.youtube.Helpers;
package app.revanced.integrations.utils;
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;
import app.revanced.integrations.utils.LogHelper;
/* loaded from: classes6.dex */
public class XThemeHelpers {
static String TAG = "XTheme";
public class ThemeHelper {
static int themeValue;
public static void setTheme(int value) {
themeValue = value;
if (XGlobals.debug) {
String str = TAG;
Log.d(str, "Theme value: " + themeValue);
}
LogHelper.debug("XTheme", "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);
}
LogHelper.debug("XTheme", "Theme value: " + themeValue);
}
public static boolean isDarkTheme() {

View File

@ -1,8 +1,7 @@
package fi.razerman.youtube.Autorepeat;
package app.revanced.integrations.videoplayer.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;
@ -11,9 +10,13 @@ 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 app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.videoplayer.videourl.Copy;
import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp;
import java.lang.ref.WeakReference;
/* loaded from: classes6.dex */
@ -29,25 +32,21 @@ public class AutoRepeat {
public static void initializeAutoRepeat(Object constraintLayout) {
try {
if (XGlobals.debug) {
Log.d("AutoRepeat", "initializing auto repeat");
}
LogHelper.debug("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) {
LogHelper.debug("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
imageView.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.videoplayer.Autorepeat.AutoRepeat.1
@Override // android.view.View.OnClickListener
public void onClick(View v) {
if (XGlobals.debug) {
Log.d("AutoRepeat", "Auto repeat button clicked");
}
LogHelper.debug("AutoRepeat", "Auto repeat button clicked");
AutoRepeat.changeSelected(!v.isSelected());
}
});
@ -62,7 +61,7 @@ public class AutoRepeat {
changeVisibility(false);
}
} catch (Exception ex) {
Log.e("XError", "Unable to set FrameLayout", ex);
LogHelper.printException("XError", "Unable to set FrameLayout", ex);
}
}
@ -74,15 +73,11 @@ public class AutoRepeat {
ImageView iView = _autoRepeatBtn.get();
if (_constraintLayout != null && iView != null) {
if (visible && isAutoRepeatBtnEnabled) {
if (XGlobals.debug) {
Log.d("AutoRepeat", "Fading in");
}
LogHelper.debug("AutoRepeat", "Fading in");
iView.setVisibility(View.VISIBLE);
iView.startAnimation(fadeIn);
} else if (iView.getVisibility() == View.VISIBLE) {
if (XGlobals.debug) {
Log.d("AutoRepeat", "Fading out");
}
LogHelper.debug("AutoRepeat", "Fading out");
iView.startAnimation(fadeOut);
iView.setVisibility(View.GONE);
}
@ -97,11 +92,11 @@ public class AutoRepeat {
public static void changeSelected(boolean selected, boolean onlyView) {
ImageView iView = _autoRepeatBtn.get();
if (_constraintLayout != null && iView != null) {
if (XGlobals.debug) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
StringBuilder sb = new StringBuilder();
sb.append("Changing selected state to: ");
sb.append(selected ? "SELECTED" : "NONE");
Log.d("AutoRepeat", sb.toString());
LogHelper.debug("AutoRepeat", sb.toString());
}
iView.setSelected(selected);
if (!onlyView) {
@ -113,34 +108,24 @@ public class AutoRepeat {
private static boolean shouldBeSelected() {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (context == null) {
Log.e("AutoRepeat", "ChangeSelected - context is null!");
LogHelper.printException("AutoRepeat", "ChangeSelected - context is null!");
return false;
}
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
return sharedPreferences.getBoolean("pref_auto_repeat", false);
return SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, "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) {
}
Context context = YouTubeTikTokRoot_Application.getAppContext();
SharedPrefHelper.saveBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_auto_repeat", selected);
}
private static boolean shouldBeShown() {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (context == null) {
Log.e("AutoRepeat", "ChangeSelected - context is null!");
LogHelper.printException("AutoRepeat", "ChangeSelected - context is null!");
return false;
}
SharedPreferences sharedPreferences = context.getSharedPreferences("youtube", 0);
return sharedPreferences.getBoolean("pref_auto_repeat_button", false);
return SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_auto_repeat_button", false);
}
private static int getIdentifier(String name, String defType) {

View File

@ -1,4 +1,4 @@
package fi.razerman.youtube;
package app.revanced.integrations.videoplayer.settings;
import android.app.Activity;
import android.app.AlarmManager;
@ -8,6 +8,9 @@ import android.content.Context;
import android.content.Intent;
import android.os.Process;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.XSettingsFragment;
/* loaded from: classes6.dex */
public class XReboot {
@ -23,8 +26,8 @@ public class XReboot {
/* JADX INFO: Access modifiers changed from: package-private */
public static void RebootDialog(final Activity activity) {
// from class: fi.razerman.youtube.XReboot.1
// from class: app.revanced.integrations.videoplayer.settings.XReboot.1
// android.content.DialogInterface.OnClickListenerXSettingsFragment.homeActivityClass
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, XSettingsFragment.homeActivityClass)).setNegativeButton(XGlobals.getStringByName(activity, "sign_in_cancel"), null).show();
new AlertDialog.Builder(activity).setMessage(Settings.getStringByName(activity, "pref_refresh_config")).setPositiveButton(Settings.getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> XReboot.Reboot(activity, XSettingsFragment.homeActivityClass)).setNegativeButton(Settings.getStringByName(activity, "sign_in_cancel"), null).show();
}
}

View File

@ -1,4 +1,4 @@
package fi.razerman.youtube;
package app.revanced.integrations.videoplayer.videosettings;
import android.content.Context;
import android.net.ConnectivityManager;

View File

@ -1,10 +1,14 @@
package fi.razerman.youtube.videosettings;
package app.revanced.integrations.videoplayer.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 app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.settings.Settings;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -15,43 +19,35 @@ 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;
Settings.userChangedQuality = true;
Settings.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);
if (!Settings.newVideo || Settings.userChangedQuality || qInterface == null) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && Settings.userChangedQuality) {
LogHelper.debug("Settings - quality", "Skipping quality change because user changed it: " + quality);
}
XGlobals.userChangedQuality = false;
Settings.userChangedQuality = false;
return quality;
}
XGlobals.newVideo = false;
if (XGlobals.debug) {
Log.d("XGlobals - quality", "Quality: " + quality);
}
Settings.newVideo = false;
LogHelper.debug("Settings - quality", "Quality: " + quality);
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (context == null) {
Log.e("XGlobals", "Context is null or settings not initialized, returning quality: " + quality);
LogHelper.printException("Settings", "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);
}
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.getInt();
LogHelper.debug("Settings", "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);
}
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.getInt();
LogHelper.debug("Settings", "Mobile data connection detected, preferred quality: " + preferredQuality);
} else {
if (XGlobals.debug) {
Log.d("XGlobals", "No Internet connection!");
}
LogHelper.debug("Settings", "No Internet connection!");
return quality;
}
if (preferredQuality == -2) {
@ -70,13 +66,12 @@ public class VideoQuality {
}
}
}
} catch (Exception ignored) {}
} 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);
}
LogHelper.debug("Settings - qualities", "Quality at index " + index + ": " + streamQuality2);
index++;
}
for (Integer iStreamQuality : iStreamQualities) {
@ -89,19 +84,15 @@ public class VideoQuality {
return quality;
}
int qualityIndex = iStreamQualities.indexOf(quality);
if (XGlobals.debug) {
Log.d("XGlobals", "Index of quality " + quality + " is " + qualityIndex);
}
LogHelper.debug("Settings", "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);
}
LogHelper.debug("Settings", "Quality changed to: " + qualityIndex);
return qualityIndex;
} catch (Exception ex) {
Log.e("XGlobals", "Failed to set quality", ex);
LogHelper.printException("Settings", "Failed to set quality", ex);
return qualityIndex;
}
}

View File

@ -1,7 +1,10 @@
package fi.razerman.youtube.videosettings;
package app.revanced.integrations.videoplayer.videosettings;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.settings.Settings;
import android.util.Log;
import fi.razerman.youtube.XGlobals;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -15,17 +18,13 @@ public class VideoSpeed {
public static int DefaultSpeed(Object[] speeds, int speed, Object qInterface) {
int speed2;
Exception e;
if (!XGlobals.newVideoSpeed) {
if (!Settings.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);
}
Settings.newVideoSpeed = false;
LogHelper.debug("Settings - speeds", "Speed: " + speed);
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat();
LogHelper.debug("Settings", "Preferred speed: " + preferredSpeed);
if (preferredSpeed == -2.0f) {
return speed;
}
@ -49,24 +48,18 @@ public class VideoSpeed {
int index = 0;
while (it.hasNext()) {
float streamSpeed2 = it.next();
if (XGlobals.debug) {
Log.d("XGlobals - speeds", "Speed at index " + index + ": " + streamSpeed2);
}
LogHelper.debug("Settings - 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);
}
LogHelper.debug("Settings - speeds", "Speed loop at index " + speed3 + ": " + streamSpeed3);
}
}
if (speed3 == -1) {
if (XGlobals.debug) {
Log.d("XGlobals - speeds", "Speed was not found");
}
LogHelper.debug("Settings - speeds", "Speed was not found");
speed2 = 3;
} else {
speed2 = speed3;
@ -75,16 +68,14 @@ public class VideoSpeed {
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());
}
LogHelper.debug("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());
LogHelper.printException("XDebug", e.getMessage());
return speed2;
}
} catch (Exception ignored) {
@ -94,15 +85,13 @@ public class VideoSpeed {
} catch (Exception e10) {
e = e10;
}
if (XGlobals.debug) {
Log.d("XGlobals", "Speed changed to: " + speed2);
}
LogHelper.debug("Settings", "Speed changed to: " + speed2);
return speed2;
}
public static void userChangedSpeed() {
XGlobals.userChangedSpeed = true;
XGlobals.newVideoSpeed = false;
Settings.userChangedSpeed = true;
Settings.newVideoSpeed = false;
}
private static float getSpeedByIndex(int index) {
@ -118,21 +107,17 @@ public class VideoSpeed {
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);
if (!Settings.newVideoSpeed || Settings.userChangedSpeed) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && Settings.userChangedSpeed) {
LogHelper.debug("Settings - speeds", "Skipping speed change because user changed it: " + speed);
}
XGlobals.userChangedSpeed = false;
Settings.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);
}
Settings.newVideoSpeed = false;
LogHelper.debug("Settings - speeds", "Speed: " + speed);
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat();
LogHelper.debug("Settings", "Preferred speed: " + preferredSpeed);
if (preferredSpeed == -2.0f) {
return -1.0f;
}
@ -163,9 +148,7 @@ public class VideoSpeed {
int index = 0;
for (Float iStreamSpeed : iStreamSpeeds) {
float streamSpeed2 = iStreamSpeed;
if (XGlobals.debug) {
Log.d("XGlobals - speeds", "Speed at index " + index + ": " + streamSpeed2);
}
LogHelper.debug("Settings - speeds", "Speed at index " + index + ": " + streamSpeed2);
index++;
}
int newSpeedIndex = -1;
@ -173,26 +156,18 @@ public class VideoSpeed {
float streamSpeed3 = iStreamSpeed;
if (streamSpeed3 <= preferredSpeed) {
newSpeedIndex++;
if (XGlobals.debug) {
Log.d("XGlobals - speeds", "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
}
LogHelper.debug("Settings - speeds", "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
}
}
if (newSpeedIndex == -1) {
if (XGlobals.debug) {
Log.d("XGlobals - speeds", "Speed was not found");
}
LogHelper.debug("Settings - 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);
}
LogHelper.debug("Settings", "Trying to set speed to what it already is, skipping...: " + newSpeedIndex);
return -1.0f;
}
if (XGlobals.debug) {
Log.d("XGlobals", "Speed changed to: " + newSpeedIndex);
}
LogHelper.debug("Settings", "Speed changed to: " + newSpeedIndex);
return getSpeedByIndex(newSpeedIndex);
}
}

View File

@ -1,7 +1,6 @@
package fi.razerman.youtube.VideoUrl;
package app.revanced.integrations.videoplayer.videourl;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
@ -10,13 +9,15 @@ 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 app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.VideoHelpers;
import app.revanced.integrations.utils.SharedPrefHelper;
import java.lang.ref.WeakReference;
/* loaded from: classes6.dex */
public class Copy {
static String TAG = "CopyButton";
static WeakReference<ImageView> _button = new WeakReference<>(null);
static ConstraintLayout _constraintLayout;
static int fadeDurationFast;
@ -28,38 +29,33 @@ public class Copy {
public static void initializeCopyButton(Object obj) {
try {
if (XGlobals.debug) {
Log.d(TAG, "initializing");
}
LogHelper.debug("CopyButton", "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);
if (imageView == null) {
LogHelper.debug("CopyButton", "Couldn't find imageView with id \"copy_button\"");
return;
}
imageView.setOnClickListener(view -> {
LogHelper.debug("CopyButton", "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);
LogHelper.printException("CopyButton", "Unable to set FrameLayout", e);
}
}
@ -69,15 +65,11 @@ public class Copy {
ImageView imageView = _button.get();
if (_constraintLayout != null && imageView != null) {
if (z && isCopyButtonEnabled) {
if (XGlobals.debug) {
Log.d(TAG, "Fading in");
}
LogHelper.debug("CopyButton", "Fading in");
imageView.setVisibility(View.VISIBLE);
imageView.startAnimation(fadeIn);
} else if (imageView.getVisibility() == View.VISIBLE) {
if (XGlobals.debug) {
Log.d(TAG, "Fading out");
}
LogHelper.debug("CopyButton", "Fading out");
imageView.startAnimation(fadeOut);
imageView.setVisibility(View.GONE);
}
@ -92,10 +84,10 @@ public class Copy {
private static boolean shouldBeShown() {
Context appContext = YouTubeTikTokRoot_Application.getAppContext();
if (appContext == null) {
Log.e(TAG, "shouldBeShown - context is null!");
LogHelper.printException("CopyButton", "shouldBeShown - context is null!");
return false;
}
String string = appContext.getSharedPreferences("youtube", 0).getString("pref_copy_video_url_button_list", null);
String string = SharedPrefHelper.getString(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_copy_video_url_button_list", null);
if (string == null || string.isEmpty()) {
return false;
}

View File

@ -1,7 +1,7 @@
package fi.razerman.youtube.VideoUrl;
package app.revanced.integrations.videoplayer.videourl;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
@ -10,13 +10,15 @@ 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 app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.VideoHelpers;
import app.revanced.integrations.utils.SharedPrefHelper;
import java.lang.ref.WeakReference;
/* loaded from: classes6.dex */
public class CopyWithTimeStamp {
static String TAG = "CopyButtonWithTimeStamp";
static WeakReference<ImageView> _button = new WeakReference<>(null);
static ConstraintLayout _constraintLayout;
static int fadeDurationFast;
@ -28,22 +30,18 @@ public class CopyWithTimeStamp {
public static void initializeCopyButtonWithTimeStamp(Object obj) {
try {
if (XGlobals.debug) {
Log.d(TAG, "initializing");
}
LogHelper.debug("CopyButtonWithTimeStamp", "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) {
LogHelper.debug("CopyButtonWithTimeStamp", "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
imageView.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.videoplayer.VideoUrl.CopyWithTimeStamp.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
if (XGlobals.debug) {
Log.d(CopyWithTimeStamp.TAG, "Button clicked");
}
LogHelper.debug("CopyButtonWithTimeStamp", "Button clicked");
VideoHelpers.copyVideoUrlWithTimeStampToClipboard();
}
});
@ -60,7 +58,7 @@ public class CopyWithTimeStamp {
changeVisibility(false);
}
} catch (Exception e) {
Log.e(TAG, "Unable to set FrameLayout", e);
LogHelper.printException("CopyButtonWithTimeStamp", "Unable to set FrameLayout", e);
}
}
@ -70,15 +68,11 @@ public class CopyWithTimeStamp {
ImageView imageView = _button.get();
if (_constraintLayout != null && imageView != null) {
if (z && isCopyButtonWithTimeStampEnabled) {
if (XGlobals.debug) {
Log.d(TAG, "Fading in");
}
LogHelper.debug("CopyButtonWithTimeStamp", "Fading in");
imageView.setVisibility(View.VISIBLE);
imageView.startAnimation(fadeIn);
} else if (imageView.getVisibility() == View.VISIBLE) {
if (XGlobals.debug) {
Log.d(TAG, "Fading out");
}
LogHelper.debug("CopyButtonWithTimeStamp", "Fading out");
imageView.startAnimation(fadeOut);
imageView.setVisibility(View.GONE);
}
@ -93,10 +87,11 @@ public class CopyWithTimeStamp {
private static boolean shouldBeShown() {
Context appContext = YouTubeTikTokRoot_Application.getAppContext();
if (appContext == null) {
Log.e(TAG, "shouldBeShown - context is null!");
LogHelper.printException("CopyButtonWithTimeStamp", "shouldBeShown - context is null!");
return false;
}
String string = appContext.getSharedPreferences("youtube", 0).getString("pref_copy_video_url_timestamp_button_list", null);
String string = SharedPrefHelper.getString(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_copy_video_url_timestamp_button_list", null);
if (string == null || string.isEmpty()) {
return false;
}

View File

@ -1,4 +1,4 @@
package fi.razerman.youtube.Fenster;
package app.revanced.integrations.videoswipecontrols;
/* loaded from: classes6.dex */
public enum Coverage {

View File

@ -1,4 +1,4 @@
package fi.razerman.youtube.Fenster;
package app.revanced.integrations.videoswipecontrols;
import android.view.MotionEvent;

View File

@ -1,11 +1,11 @@
package fi.razerman.youtube.Fenster;
package app.revanced.integrations.videoswipecontrols;
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;
import app.revanced.integrations.utils.LogHelper;
/* loaded from: classes6.dex */
public class FensterGestureController {
@ -19,9 +19,7 @@ public class FensterGestureController {
}
if (event.getAction() == 1) {
this.listener.onUp();
if (XGlobals.debug) {
Log.i("TouchTest", "Touch up");
}
LogHelper.debug("TouchTest", "Touch up");
}
return this.gestureDetector.onTouchEvent(event);
}

View File

@ -1,14 +1,13 @@
package fi.razerman.youtube.Fenster;
package app.revanced.integrations.videoswipecontrols;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import fi.razerman.youtube.XGlobals;
import app.revanced.integrations.utils.LogHelper;
/* 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;
@ -28,28 +27,22 @@ public class FensterGestureListener implements GestureDetector.OnGestureListener
@Override // android.view.GestureDetector.OnGestureListener
public void onLongPress(MotionEvent e) {
if (XGlobals.debug) {
Log.i(TAG, "Long Press");
}
LogHelper.debug("FensterGestureListener", "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");
}
LogHelper.debug("FensterGestureListener", "Scroll");
if (e1 == null || e2 == null) {
if (e1 == null && XGlobals.debug) {
Log.d("XDebug", "e1 is null");
if (e1 == null) {
LogHelper.debug("XDebug", "e1 is null");
}
if (e2 == null && XGlobals.debug) {
Log.d("XDebug", "e2 is null");
if (e2 == null) {
LogHelper.debug("XDebug", "e2 is null");
}
return false;
} else if (this.ignoreScroll) {
if (XGlobals.debug) {
Log.i(TAG, "Scroll ignored");
}
LogHelper.debug("FensterGestureListener", "Scroll ignored");
return false;
} else {
float deltaY = e2.getY() - e1.getY();
@ -57,23 +50,13 @@ public class FensterGestureListener implements GestureDetector.OnGestureListener
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");
}
String message = deltaX > 0.0f ? "Slide right" : "Slide left";
LogHelper.debug("FensterGestureListener", message);
}
} 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");
}
String message = deltaY > 0.0f ? "Slide down" : "Slide up";
LogHelper.debug("FensterGestureListener", message);
}
return false;
}
@ -81,9 +64,7 @@ public class FensterGestureListener implements GestureDetector.OnGestureListener
@Override // android.view.GestureDetector.OnGestureListener
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (XGlobals.debug) {
Log.i(TAG, "Fling");
}
LogHelper.debug("FensterGestureListener", "Fling");
try {
float diffY = e2.getY() - e1.getY();
float diffX = e2.getX() - e1.getX();
@ -111,16 +92,12 @@ public class FensterGestureListener implements GestureDetector.OnGestureListener
@Override // android.view.GestureDetector.OnGestureListener
public void onShowPress(MotionEvent e) {
if (XGlobals.debug) {
Log.i(TAG, "Show Press");
}
LogHelper.debug("FensterGestureListener", "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());
}
LogHelper.debug("FensterGestureListener", "Down - x: " + e.getX() + " y: " + e.getY());
this.ignoreScroll = e.getY() <= TOP_PADDING;
this.listener.onDown(e);
return false;

View File

@ -1,4 +1,4 @@
package fi.razerman.youtube.Fenster;
package app.revanced.integrations.videoswipecontrols;
/* loaded from: classes6.dex */
public enum Orientation {

View File

@ -1,22 +1,23 @@
package fi.razerman.youtube.Fenster;
package app.revanced.integrations.videoswipecontrols;
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;
import fi.razerman.youtube.XSettingsFragment;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.videoswipecontrols.seekbar.BrightnessSeekBar;
import app.revanced.integrations.videoswipecontrols.seekbar.VolumeSeekBar;
import app.revanced.integrations.utils.SwipeHelper;
import app.revanced.integrations.settings.XSettingsFragment;
/* 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;
@ -41,18 +42,14 @@ public class XFenster implements FensterEventsListener {
this.mVolume.initialise(context, viewGroup);
}
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onTap() {
if (XGlobals.debug) {
Log.d("XDebug", "onTap");
}
LogHelper.debug("XDebug", "onTap");
}
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onHorizontalScroll(MotionEvent event, float delta) {
if (XGlobals.debug) {
Log.d("XDebug", "onHorizontalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
}
LogHelper.debug("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);
@ -66,11 +63,9 @@ public class XFenster implements FensterEventsListener {
}
}
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onVerticalScroll(MotionEvent event, float delta) {
if (XGlobals.debug) {
Log.d("XDebug", "onVerticalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
}
LogHelper.debug("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);
@ -84,39 +79,29 @@ public class XFenster implements FensterEventsListener {
}
}
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onSwipeRight() {
if (XGlobals.debug) {
Log.d("XDebug", "onSwipeRight");
}
LogHelper.debug("XDebug", "onSwipeRight");
}
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onSwipeLeft() {
if (XGlobals.debug) {
Log.d("XDebug", "onSwipeLeft");
}
LogHelper.debug("XDebug", "onSwipeLeft");
}
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onSwipeBottom() {
if (XGlobals.debug) {
Log.d("XDebug", "onSwipeBottom");
}
LogHelper.debug("XDebug", "onSwipeBottom");
}
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onSwipeTop() {
if (XGlobals.debug) {
Log.d("XDebug", "onSwipeTop");
}
LogHelper.debug("XDebug", "onSwipeTop");
}
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onDown(MotionEvent event) {
if (XGlobals.debug) {
Log.d("XDebug", "onDown");
}
LogHelper.debug("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);
@ -135,9 +120,9 @@ public class XFenster implements FensterEventsListener {
}
}
@Override // fi.razerman.youtube.Fenster.FensterEventsListener
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onUp() {
Log.d("XDebug", "onUp");
LogHelper.debug("XDebug", "onUp");
hideNotifications();
}
@ -165,7 +150,7 @@ public class XFenster implements FensterEventsListener {
if (this.handler == null) {
this.handler = new Handler();
}
// from class: fi.razerman.youtube.Fenster.XFenster.1
// from class: app.revanced.integrations.videoplayer.Fenster.XFenster.1
// java.lang.Runnable
this.handler.postDelayed(() -> {
XFenster.this.mVolume.hide();
@ -217,26 +202,20 @@ public class XFenster implements FensterEventsListener {
private float getProgressVertical(MotionEvent event, int maxSteps) {
float progress = calculateProgressVertical(event, maxSteps);
if (XGlobals.debug) {
Log.d("XDebug", "Progress vertical: " + progress);
}
LogHelper.debug("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);
}
LogHelper.debug("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);
}
LogHelper.debug("XDebug", "calculateProgressVertical - height: " + height);
int available = (height - this.mPaddingTop) - this.mPaddingBottom;
int y = height - ((int) event.getY());
float progress = 0.0f;
@ -282,21 +261,19 @@ public class XFenster implements FensterEventsListener {
private void checkPlayerOverlaysView() {
try {
if ((this.mViewGroup.getHeight() == 0 || this.mViewGroup.getWidth() == 0) && XSwipeHelper.nextGenWatchLayout != null) {
View layout = XSwipeHelper.nextGenWatchLayout.findViewById(getIdentifier());
if ((this.mViewGroup.getHeight() == 0 || this.mViewGroup.getWidth() == 0) && SwipeHelper.nextGenWatchLayout != null) {
View layout = SwipeHelper.nextGenWatchLayout.findViewById(getIdentifier());
if (layout != null) {
this.mViewGroup = (ViewGroup) layout;
this.mBrightness.refreshViewGroup(this.mViewGroup, XSettingsFragment.overlayContext);
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");
LogHelper.debug("Settings", "player_overlays refreshed");
} else {
LogHelper.debug("Settings", "player_overlays was not found");
}
}
} catch (Exception ex) {
Log.e("XError", "Unable to refresh player_overlays layout", ex);
LogHelper.printException("XError", "Unable to refresh player_overlays layout", ex);
}
}

View File

@ -1,12 +1,12 @@
package fi.razerman.youtube.Fenster.Helpers;
package app.revanced.integrations.videoswipecontrols.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;
import app.revanced.integrations.utils.LogHelper;
/* loaded from: classes6.dex */
public class BrightnessHelper {
@ -26,9 +26,7 @@ public class BrightnessHelper {
}
public static void setBrightness(Context context, int brightness) {
if (XGlobals.debug) {
Log.d("XDebug", "Setting brightness: " + brightness);
}
LogHelper.debug("XDebug", "Setting brightness: " + brightness);
float bright = brightness / 100.0f;
WindowManager.LayoutParams lp = ((Activity) context).getWindow().getAttributes();
lp.screenBrightness = bright;
@ -36,18 +34,16 @@ public class BrightnessHelper {
}
public static void setBrightness2(Context context, int brightness) {
if (XGlobals.debug) {
Log.d("XDebug", "Setting brightness: " + brightness);
}
LogHelper.debug("XDebug", "Setting brightness: " + brightness);
ContentResolver cResolver = context.getContentResolver();
Settings.System.putInt(cResolver, "screen_brightness", brightness);
android.provider.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 android.provider.Settings.System.getInt(cResolver, "screen_brightness");
} catch (android.provider.Settings.SettingNotFoundException e) {
return 0;
}
}

View File

@ -1,21 +1,20 @@
package fi.razerman.youtube.Fenster.Seekbar;
package app.revanced.integrations.videoswipecontrols.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 fi.razerman.youtube.Fenster.Helpers.BrightnessHelper;
import fi.razerman.youtube.Helpers.SharedPrefs;
import fi.razerman.youtube.XGlobals;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.videoswipecontrols.helpers.BrightnessHelper;
/* 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;
@ -29,9 +28,9 @@ public class BrightnessSeekBar {
this.enabled = false;
this.mViewGroup = viewGroup;
this.mContext = context;
float systemBrightness = Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
float systemBrightness = android.provider.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.Progress = SharedPrefHelper.getInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "xfile_brightness_value", Integer.valueOf(_systemBrightness)).intValue();
this.Max = 100;
this.mTextView = new TextView(context);
this.mTextView.setTextSize(24.0f);
@ -60,9 +59,7 @@ public class BrightnessSeekBar {
this.mTextView.setVisibility(View.VISIBLE);
}
}
if (XGlobals.debug) {
Log.d("XDebug", "updateBrightnessProgress: " + this.Progress);
}
LogHelper.debug("XDebug", "updateBrightnessProgress: " + this.Progress);
}
private void disableBrightness() {
@ -97,7 +94,7 @@ public class BrightnessSeekBar {
if (this.handler == null) {
this.handler = new Handler();
}
this.handler.postDelayed(new Runnable() { // from class: fi.razerman.youtube.Fenster.Seekbar.BrightnessSeekBar.1
this.handler.postDelayed(new Runnable() { // from class: app.revanced.integrations.videoplayer.Fenster.Seekbar.BrightnessSeekBar.1
@Override // java.lang.Runnable
public void run() {
BrightnessSeekBar.this.hide();
@ -114,22 +111,22 @@ public class BrightnessSeekBar {
public void disable() {
this.enabled = false;
SharedPrefs.saveInt(this.mContext, "xfile_brightness_value", Integer.valueOf(this.Progress));
SharedPrefHelper.saveInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"xfile_brightness_value", Integer.valueOf(this.Progress));
disableBrightness();
Log.d("XDebug", "Brightness swipe disabled");
LogHelper.debug("XDebug", "Brightness swipe disabled");
}
public void enable() {
this.enabled = true;
float systemBrightness = Settings.System.getFloat(this.mContext.getContentResolver(), "screen_brightness", -1.0f);
float systemBrightness = android.provider.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();
int brightness = SharedPrefHelper.getInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"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");
LogHelper.debug("XDebug", "Brightness swipe enabled");
}
}

View File

@ -1,4 +1,4 @@
package fi.razerman.youtube.Fenster.Seekbar;
package app.revanced.integrations.videoswipecontrols.seekbar;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -6,11 +6,12 @@ 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;
import app.revanced.integrations.utils.LogHelper;
/* loaded from: classes6.dex */
public class VolumeSeekBar {
@ -23,7 +24,7 @@ public class VolumeSeekBar {
private Context mContext;
TextView mTextView;
ViewGroup mViewGroup;
private final BroadcastReceiver volumeReceiver = new BroadcastReceiver() { // from class: fi.razerman.youtube.Fenster.Seekbar.VolumeSeekBar.1
private final BroadcastReceiver volumeReceiver = new BroadcastReceiver() { // from class: app.revanced.integrations.videoplayer.Fenster.Seekbar.VolumeSeekBar.1
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
VolumeSeekBar.this.updateVolumeProgress();
@ -62,9 +63,7 @@ public class VolumeSeekBar {
this.mTextView.setVisibility(View.VISIBLE);
}
}
if (XGlobals.debug) {
Log.d("XDebug", "updateVolumeProgress: " + this.Progress);
}
LogHelper.debug("XDebug", "updateVolumeProgress: " + this.Progress);
}
private void setVolume(int volume) {
@ -98,7 +97,7 @@ public class VolumeSeekBar {
if (this.handler == null) {
this.handler = new Handler();
}
// from class: fi.razerman.youtube.Fenster.Seekbar.VolumeSeekBar.2
// from class: app.revanced.integrations.videoplayer.Fenster.Seekbar.VolumeSeekBar.2
// java.lang.Runnable
this.handler.postDelayed(VolumeSeekBar.this::hide, 2000L);
}

View File

@ -1,67 +0,0 @@
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<String, ColorRef> 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;
}
}

View File

@ -1,10 +0,0 @@
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;
}
}

View File

@ -1,49 +0,0 @@
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);
}
}

View File

@ -1,22 +0,0 @@
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;
}
}
}

View File

@ -1,247 +0,0 @@
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 hideShortsButton(View view) {
if (XGlobals.lastPivotTab != null && XGlobals.lastPivotTab.name() == "TAB_SHORTS") {
if (BooleanPreferences.isShortsButtonHidden()) {
if (XGlobals.debug) {
Log.d("XAdRemover", "Shorts button: shown");
}
view.setVisibility(View.GONE);
} else if (XGlobals.debug) {
Log.d("XAdRemover", "Shorts 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", getViewHierarchy((ViewGroup) item));
} else {
Log.d("Litho", "Item is not a cwl item.");
}
}
public static String getViewHierarchy(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(" ");
}
}
}

View File

@ -1,431 +0,0 @@
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", "<Null>");
} 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", "<Null>");
} 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", "<Null>");
} 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", "<Null>");
} else {
Log.d("XCharSequenceBT", "<Null> | " + 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", "<Null>");
} 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";
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +0,0 @@
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;
}
}
}

View File

@ -1,18 +0,0 @@
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();
}
}

View File

@ -1,25 +0,0 @@
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;
}
}

Some files were not shown because too many files have changed in this diff Show More