refactor: rename XSwipe and XSettingsActivity (#33)

This commit is contained in:
Joey Peter 2022-06-30 13:54:00 +02:00 committed by GitHub
parent 7a9c61b71b
commit cfb4132ed1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 388 additions and 509 deletions

View File

@ -39,7 +39,7 @@ public class AdRemoverAPI {
ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1);
view.setLayoutParams(layoutParams5);
} else {
LogHelper.debug("XAdRemover", "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
LogHelper.debug(AdRemoverAPI.class, "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
}
}
@ -50,7 +50,7 @@ public class AdRemoverAPI {
*/
public static void hideCreateButton(View view) {
String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: Shown" : "Create button: Hidden";
LogHelper.debug("HideCreateButton", message);
LogHelper.debug(AdRemoverAPI.class, message);
if (SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
view.setVisibility(View.VISIBLE);
} else {
@ -66,7 +66,7 @@ public class AdRemoverAPI {
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);
LogHelper.debug(AdRemoverAPI.class, message);
if (!SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
view.setVisibility(View.GONE);
}
@ -82,7 +82,7 @@ public class AdRemoverAPI {
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);
LogHelper.debug(AdRemoverAPI.class, message);
return InfoCardOverlayPresenter;
}
@ -95,20 +95,10 @@ public class AdRemoverAPI {
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);
LogHelper.debug(AdRemoverAPI.class, 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();

View File

@ -163,20 +163,20 @@ public class LithoAdRemoval {
)) return false;
if (blockList.stream().anyMatch(value::contains)) {
LogHelper.debug("TemplateBlocked", value);
LogHelper.debug(LithoAdRemoval.class, value);
return true;
}
if (!SettingsEnum.DEBUG_BOOLEAN.getBoolean()) return false;
if (value.contains("related_video_with_context")) {
LogHelper.debug("Template", value + " | " + bytesToHex(buffer.array()));
LogHelper.debug(LithoAdRemoval.class, value + " | " + bytesToHex(buffer.array()));
return false;
}
LogHelper.debug("Template", value);
LogHelper.debug(LithoAdRemoval.class, value);
return false;
} catch (
Exception ex) {
LogHelper.printException("Template", ex.getMessage(), ex);
LogHelper.printException(LithoAdRemoval.class, ex.getMessage(), ex);
return false;
}

View File

@ -27,7 +27,7 @@ import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
public class Whitelist {
private static final String TAG = "VI - Whitelisting";
private static final Map<WhitelistType, ArrayList<ChannelModel>> whitelistMap = parseWhitelist(ReVancedUtils.getContext());
private static final Map<WhitelistType, Boolean> enabledMap = parseEnabledMap(ReVancedUtils.getContext());
@ -41,7 +41,7 @@ public class Whitelist {
}
public static void setChannelName(String channelName) {
LogHelper.debug(TAG, "channel name set to " + channelName);
LogHelper.debug(Whitelist.class, "channel name set to " + channelName);
VideoInformation.channelName = channelName;
if (enabledMap.get(WhitelistType.ADS) && adBlockButton != null) {
@ -69,16 +69,16 @@ public class Whitelist {
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, whitelistType.getPreferencesName());
String serializedChannels = preferences.getString("channels", null);
if (serializedChannels == null) {
LogHelper.debug(TAG, String.format("channels string was null for %s whitelisting", whitelistType));
LogHelper.debug(Whitelist.class, 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 (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
LogHelper.debug(TAG, serializedChannels);
LogHelper.debug(Whitelist.class, serializedChannels);
for (ChannelModel channel : deserializedChannels) {
LogHelper.debug(TAG, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
LogHelper.debug(Whitelist.class, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
}
}
whitelistMap.put(whitelistType, deserializedChannels);
@ -106,14 +106,14 @@ public class Whitelist {
return false;
}
if (channelName == null || channelName.trim().isEmpty()) {
LogHelper.debug(TAG, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
LogHelper.debug(Whitelist.class, 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)) {
LogHelper.debug(TAG, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
LogHelper.debug(Whitelist.class, String.format("Whitelist for channel %s for type %s", channelName, whitelistType));
return true;
}
}
@ -125,7 +125,7 @@ public class Whitelist {
for (ChannelModel whitelistedChannel : whitelisted) {
String channelId = channel.getChannelId();
if (whitelistedChannel.getChannelId().equals(channelId)) {
LogHelper.debug(TAG, String.format("Tried whitelisting an existing channel again. Old info (%1$s | %2$s) - New info (%3$s | %4$s)",
LogHelper.debug(Whitelist.class, 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;
}

View File

@ -51,7 +51,7 @@ public class WhitelistRequester {
JSONObject videoInfo = json.getJSONObject("videoDetails");
ChannelModel channelModel = new ChannelModel(videoInfo.getString("author"), videoInfo.getString("channelId"));
String author = channelModel.getAuthor();
LogHelper.debug("WhitelistRequester", "channelId " + channelModel.getChannelId() + " fetched for author " + author);
LogHelper.debug(WhitelistRequester.class, "channelId " + channelModel.getChannelId() + " fetched for author " + author);
boolean success = Whitelist.addToWhitelist(whitelistType, context, channelModel);
String whitelistTypeName = whitelistType.getFriendlyName();
@ -66,7 +66,7 @@ public class WhitelistRequester {
view.setEnabled(true);
});
} else {
LogHelper.debug("WhitelistRequester", "player fetch response was " + responseCode);
LogHelper.debug(WhitelistRequester.class, "player fetch response was " + responseCode);
runOnMainThread(() -> {
Toast.makeText(context, str("revanced_whitelisting_fetch_failed", responseCode), Toast.LENGTH_SHORT).show();
buttonIcon.setEnabled(true);
@ -75,7 +75,7 @@ public class WhitelistRequester {
}
connection.disconnect();
} catch (Exception ex) {
LogHelper.printException("WhitelistRequester", "Failed to fetch channelId", ex);
LogHelper.printException(WhitelistRequester.class, "Failed to fetch channelId", ex);
runOnMainThread(() -> view.setEnabled(true));
}
}

View File

@ -1,9 +1,11 @@
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 android.util.Base64;
import java.security.MessageDigest;
import java.security.SecureRandom;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.ryd.requests.RYDRequester;
@ -17,40 +19,105 @@ public class Registration {
this.context = context;
}
// https://stackoverflow.com/a/157202
private final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private SecureRandom rnd = new SecureRandom();
public String getUserId() {
return userId != null ? userId : fetchUserId();
}
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, RYDSettings.PREFERENCES_KEY_USERID, userId);
} catch (Exception ex) {
LogHelper.printException(Registration.class, "Unable to save the userId in shared preferences", ex);
}
}
public static String solvePuzzle(String challenge, int difficulty) {
byte[] decodedChallenge = Base64.decode(challenge, Base64.NO_WRAP);
byte[] buffer = new byte[20];
for (int i = 4; i < 20; i++) {
buffer[i] = decodedChallenge[i - 4];
}
try {
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);
byte[] messageDigest = md.digest(buffer);
if (countLeadingZeroes(messageDigest) >= difficulty) {
String encode = Base64.encodeToString(new byte[]{buffer[0], buffer[1], buffer[2], buffer[3]}, Base64.NO_WRAP);
return encode;
}
}
} catch (Exception ex) {
LogHelper.printException(Registration.class, "Failed to solve puzzle", ex);
}
return null;
}
private String register() {
String userId = randomString(36);
LogHelper.debug(Registration.class, "Trying to register the following userId: " + userId);
return RYDRequester.register(userId, this);
}
private 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();
}
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);
this.userId = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.RYD, RYDSettings.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);
LogHelper.printException(Registration.class, "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 static int countLeadingZeroes(byte[] uInt8View) {
int zeroes = 0;
int value = 0;
for (int i = 0; i < uInt8View.length; i++) {
value = uInt8View[i] & 0xFF;
if (value == 0) {
zeroes += 8;
} else {
int count = 1;
if (value >>> 4 == 0) {
count += 4;
value <<= 4;
}
if (value >>> 6 == 0) {
count += 2;
value <<= 2;
}
zeroes += count - (value >>> 7);
break;
}
}
}
private String register() {
String userId = randomString(36);
LogHelper.debug("Registration", "Trying to register the following userId: " + userId);
return RYDRequester.register(userId, this);
return zeroes;
}
}

View File

@ -41,7 +41,7 @@ public class ReturnYouTubeDislikes {
}
Locale locale = context.getResources().getConfiguration().locale;
LogHelper.debug("ReturnYoutubeDislikes", "locale - " + locale);
LogHelper.debug(ReturnYouTubeDislikes.class, "locale - " + locale);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
compactNumberFormatter = CompactDecimalFormat.getInstance(
locale,
@ -61,18 +61,18 @@ public class ReturnYouTubeDislikes {
}
public static void newVideoLoaded(String videoId) {
LogHelper.debug("ReturnYoutubeDislikes", "newVideoLoaded - " + videoId);
LogHelper.debug(ReturnYouTubeDislikes.class, "newVideoLoaded - " + videoId);
dislikeCount = null;
if (!isEnabled) return;
try {
if (_dislikeFetchThread != null && _dislikeFetchThread.getState() != Thread.State.TERMINATED) {
LogHelper.debug("ReturnYoutubeDislikes", "Interrupting the thread. Current state " + _dislikeFetchThread.getState());
LogHelper.debug(ReturnYouTubeDislikes.class, "Interrupting the thread. Current state " + _dislikeFetchThread.getState());
_dislikeFetchThread.interrupt();
}
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error in the dislike fetch thread", ex);
LogHelper.printException(ReturnYouTubeDislikes.class, "Error in the dislike fetch thread", ex);
}
_dislikeFetchThread = new Thread(() -> RYDRequester.fetchDislikes(videoId));
@ -94,7 +94,7 @@ public class ReturnYouTubeDislikes {
votingValue = 1;
}
LogHelper.debug("ReturnYoutubeDislikes", "Like tag active " + likeActive);
LogHelper.debug(ReturnYouTubeDislikes.class, "Like tag active " + likeActive);
setTag(view, "like");
}
@ -114,7 +114,7 @@ public class ReturnYouTubeDislikes {
votingValue = -1;
}
_dislikeView = view;
LogHelper.debug("ReturnYoutubeDislikes", "Dislike tag active " + dislikeActive);
LogHelper.debug(ReturnYouTubeDislikes.class, "Dislike tag active " + dislikeActive);
setTag(view, "dislike");
}
@ -136,7 +136,7 @@ public class ReturnYouTubeDislikes {
try {
CharSequence tag = (CharSequence) view.getTag();
LogHelper.debug("ReturnYoutubeDislikes", "handleOnSetText - " + tag + " - original text - " + originalText);
LogHelper.debug(ReturnYouTubeDislikes.class, "handleOnSetText - " + tag + " - original text - " + originalText);
if (tag == null) return originalText;
if (tag == "like") {
@ -145,7 +145,7 @@ public class ReturnYouTubeDislikes {
return dislikeCount != null ? formatDislikes(dislikeCount) : originalText;
}
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error while handling the setText", ex);
LogHelper.printException(ReturnYouTubeDislikes.class, "Error while handling the setText", ex);
}
return originalText;
@ -157,20 +157,20 @@ public class ReturnYouTubeDislikes {
try {
// Try to set normal video dislike count
if (_dislikeView == null) {
LogHelper.debug("ReturnYoutubeDislikes", "_dislikeView was null");
LogHelper.debug(ReturnYouTubeDislikes.class, "_dislikeView was null");
return;
}
View buttonView = _dislikeView.findViewById(getIdentifier("button_text", "id"));
if (buttonView == null) {
LogHelper.debug("ReturnYoutubeDislikes", "buttonView was null");
LogHelper.debug(ReturnYouTubeDislikes.class, "buttonView was null");
return;
}
TextView button = (TextView) buttonView;
button.setText(dislikeCount);
LogHelper.debug("ReturnYoutubeDislikes", "trySetDislikes - " + dislikeCount);
LogHelper.debug(ReturnYouTubeDislikes.class, "trySetDislikes - " + dislikeCount);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error while trying to set dislikes text", ex);
LogHelper.printException(ReturnYouTubeDislikes.class, "Error while trying to set dislikes text", ex);
}
}
@ -181,7 +181,7 @@ public class ReturnYouTubeDislikes {
try {
String tag = (String) view.getTag();
LogHelper.debug("ReturnYoutubeDislikes", "handleOnClick - " + tag + " - previousState - " + previousState);
LogHelper.debug(ReturnYouTubeDislikes.class, "handleOnClick - " + tag + " - previousState - " + previousState);
if (tag == null) return;
// If active status was removed, vote should be none
@ -224,33 +224,33 @@ public class ReturnYouTubeDislikes {
return;
}
LogHelper.debug("ReturnYoutubeDislikes", "New vote status - " + votingValue);
LogHelper.debug("ReturnYoutubeDislikes", "Like button " + likeActive + " | Dislike button " + dislikeActive);
LogHelper.debug(ReturnYouTubeDislikes.class, "New vote status - " + votingValue);
LogHelper.debug(ReturnYouTubeDislikes.class, "Like button " + likeActive + " | Dislike button " + dislikeActive);
sendVote(votingValue);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error while handling the onClick", ex);
LogHelper.printException(ReturnYouTubeDislikes.class, "Error while handling the onClick", ex);
}
}
private static void sendVote(int vote) {
if (!isEnabled) return;
LogHelper.debug("ReturnYoutubeDislikes", "sending vote - " + vote + " for video " + currentVideoId);
LogHelper.debug(ReturnYouTubeDislikes.class, "sending vote - " + vote + " for video " + currentVideoId);
try {
if (_votingThread != null && _votingThread.getState() != Thread.State.TERMINATED) {
LogHelper.debug("ReturnYoutubeDislikes", "Interrupting the thread. Current state " + _votingThread.getState());
LogHelper.debug(ReturnYouTubeDislikes.class, "Interrupting the thread. Current state " + _votingThread.getState());
_votingThread.interrupt();
}
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error in the voting thread", ex);
LogHelper.printException(ReturnYouTubeDislikes.class, "Error in the voting thread", ex);
}
_votingThread = new Thread(() -> {
try {
boolean result = voting.sendVote(currentVideoId, vote);
LogHelper.debug("ReturnYoutubeDislikes", "sendVote status " + result);
LogHelper.debug(ReturnYouTubeDislikes.class, "sendVote status " + result);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Failed to send vote", ex);
LogHelper.printException(ReturnYouTubeDislikes.class, "Failed to send vote", ex);
}
});
_votingThread.start();
@ -261,23 +261,23 @@ public class ReturnYouTubeDislikes {
try {
if (view == null) {
LogHelper.debug("ReturnYoutubeDislikes", "View was empty");
LogHelper.debug(ReturnYouTubeDislikes.class, "View was empty");
return;
}
LogHelper.debug("ReturnYoutubeDislikes", "setTag - " + tag);
LogHelper.debug(ReturnYouTubeDislikes.class, "setTag - " + tag);
view.setTag(tag);
} catch (Exception ex) {
LogHelper.printException("ReturnYoutubeDislikes", "Error while trying to set tag to view", ex);
LogHelper.printException(ReturnYouTubeDislikes.class, "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);
LogHelper.debug("ReturnYoutubeDislikes", "Formatting dislikes - " + dislikes + " - " + formatted);
LogHelper.debug(ReturnYouTubeDislikes.class, "Formatting dislikes - " + dislikes + " - " + formatted);
return formatted;
}
LogHelper.debug("ReturnYoutubeDislikes", "Couldn't format dislikes, using the unformatted count - " + dislikes);
LogHelper.debug(ReturnYouTubeDislikes.class, "Couldn't format dislikes, using the unformatted count - " + dislikes);
return String.valueOf(dislikes);
}
}

View File

@ -1,77 +0,0 @@
package app.revanced.integrations.ryd;
import android.util.Base64;
import java.security.MessageDigest;
import java.security.SecureRandom;
import app.revanced.integrations.utils.LogHelper;
public class 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);
byte[] buffer = new byte[20];
for (int i = 4; i < 20; i++) {
buffer[i] = decodedChallenge[i - 4];
}
try {
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);
byte[] messageDigest = md.digest(buffer);
if (countLeadingZeroes(messageDigest) >= difficulty) {
String encode = Base64.encodeToString(new byte[]{buffer[0], buffer[1], buffer[2], buffer[3]}, Base64.NO_WRAP);
return encode;
}
}
} catch (Exception ex) {
LogHelper.printException("RYD Utils", "Failed to solve puzzle", ex);
}
return null;
}
static int countLeadingZeroes(byte[] uInt8View) {
int zeroes = 0;
int value = 0;
for (int i = 0; i < uInt8View.length; i++) {
value = uInt8View[i] & 0xFF;
if (value == 0) {
zeroes += 8;
} else {
int count = 1;
if (value >>> 4 == 0) {
count += 4;
value <<= 4;
}
if (value >>> 6 == 0) {
count += 2;
value <<= 2;
}
zeroes += count - (value >>> 7);
break;
}
}
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

@ -17,7 +17,7 @@ public class Voting {
public boolean sendVote(String videoId, int vote) {
String userId = registration.getUserId();
LogHelper.debug("Voting", "Trying to vote the following video: " + videoId + " with vote " + vote + " and userId: " + userId);
LogHelper.debug(Voting.class, "Trying to vote the following video: " + videoId + " with vote " + vote + " and userId: " + userId);
return RYDRequester.sendVote(videoId, userId, vote);
}
}

View File

@ -17,7 +17,6 @@ import java.nio.charset.StandardCharsets;
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;
@ -29,25 +28,25 @@ public class RYDRequester {
public static void fetchDislikes(String videoId) {
try {
LogHelper.debug("RYDRequester", "Fetching dislikes for " + videoId);
LogHelper.debug(RYDRequester.class, "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;
LogHelper.debug("RYDRequester", "dislikes fetched - " + dislikeCount);
LogHelper.debug(RYDRequester.class, "dislikes fetched - " + dislikeCount);
// Set the dislikes
new Handler(Looper.getMainLooper()).post(() -> ReturnYouTubeDislikes.trySetDislikes(ReturnYouTubeDislikes.formatDislikes(dislikes)));
} else {
LogHelper.debug("RYDRequester", "dislikes fetch response was " + connection.getResponseCode());
LogHelper.debug(RYDRequester.class, "dislikes fetch response was " + connection.getResponseCode());
}
connection.disconnect();
} catch (Exception ex) {
dislikeCount = null;
LogHelper.printException("RYDRequester", "Failed to fetch dislikes", ex);
LogHelper.printException(RYDRequester.class, "Failed to fetch dislikes", ex);
}
}
@ -59,26 +58,26 @@ public class RYDRequester {
JSONObject json = getJSONObject(connection);
String challenge = json.getString("challenge");
int difficulty = json.getInt("difficulty");
LogHelper.debug("RYDRequester", "Registration challenge - " + challenge + " with difficulty of " + difficulty);
LogHelper.debug(RYDRequester.class, "Registration challenge - " + challenge + " with difficulty of " + difficulty);
// Solve the puzzle
String solution = Utils.solvePuzzle(challenge, difficulty);
LogHelper.debug("RYDRequester", "Registration confirmation solution is " + solution);
String solution = Registration.solvePuzzle(challenge, difficulty);
LogHelper.debug(RYDRequester.class, "Registration confirmation solution is " + solution);
return confirmRegistration(userId, solution, registration);
} else {
LogHelper.debug("RYDRequester", "Registration response was " + connection.getResponseCode());
LogHelper.debug(RYDRequester.class, "Registration response was " + connection.getResponseCode());
}
connection.disconnect();
} catch (Exception ex) {
LogHelper.printException("RYDRequester", "Failed to register userId", ex);
LogHelper.printException(RYDRequester.class, "Failed to register userId", ex);
}
return null;
}
private static String confirmRegistration(String userId, String solution, Registration registration) {
try {
LogHelper.debug("RYDRequester", "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
LogHelper.debug(RYDRequester.class, "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
HttpURLConnection connection = getConnectionFromRoute(RYDRoutes.CONFIRM_REGISTRATION, userId);
applyCommonRequestSettings(connection);
@ -90,20 +89,20 @@ public class RYDRequester {
}
if (connection.getResponseCode() == 200) {
String result = parseJson(connection);
LogHelper.debug("RYDRequester", "Registration confirmation result was " + result);
LogHelper.debug(RYDRequester.class, "Registration confirmation result was " + result);
if (result.equalsIgnoreCase("true")) {
registration.saveUserId(userId);
LogHelper.debug("RYDRequester", "Registration was successful for user " + userId);
LogHelper.debug(RYDRequester.class, "Registration was successful for user " + userId);
return userId;
}
} else {
LogHelper.debug("RYDRequester", "Registration confirmation response was " + connection.getResponseCode());
LogHelper.debug(RYDRequester.class, "Registration confirmation response was " + connection.getResponseCode());
}
connection.disconnect();
} catch (Exception ex) {
LogHelper.printException("RYDRequester", "Failed to confirm registration", ex);
LogHelper.printException(RYDRequester.class, "Failed to confirm registration", ex);
}
return null;
@ -124,20 +123,20 @@ public class RYDRequester {
JSONObject json = getJSONObject(connection);
String challenge = json.getString("challenge");
int difficulty = json.getInt("difficulty");
LogHelper.debug("RYDRequester", "Vote challenge - " + challenge + " with difficulty of " + difficulty);
LogHelper.debug(RYDRequester.class, "Vote challenge - " + challenge + " with difficulty of " + difficulty);
// Solve the puzzle
String solution = Utils.solvePuzzle(challenge, difficulty);
LogHelper.debug("RYDRequester", "Vote confirmation solution is " + solution);
String solution = Registration.solvePuzzle(challenge, difficulty);
LogHelper.debug(RYDRequester.class, "Vote confirmation solution is " + solution);
// Confirm vote
return confirmVote(videoId, userId, solution);
} else {
LogHelper.debug("RYDRequester", "Vote response was " + connection.getResponseCode());
LogHelper.debug(RYDRequester.class, "Vote response was " + connection.getResponseCode());
}
connection.disconnect();
} catch (Exception ex) {
LogHelper.printException("RYDRequester", "Failed to send vote", ex);
LogHelper.printException(RYDRequester.class, "Failed to send vote", ex);
}
return false;
}
@ -154,20 +153,20 @@ public class RYDRequester {
}
if (connection.getResponseCode() == 200) {
String result = parseJson(connection);
LogHelper.debug("RYDRequester", "Vote confirmation result was " + result);
LogHelper.debug(RYDRequester.class, "Vote confirmation result was " + result);
if (result.equalsIgnoreCase("true")) {
LogHelper.debug("RYDRequester", "Vote was successful for user " + userId);
LogHelper.debug(RYDRequester.class, "Vote was successful for user " + userId);
return true;
}
} else {
LogHelper.debug("RYDRequester", "Vote confirmation response was " + connection.getResponseCode());
LogHelper.debug(RYDRequester.class, "Vote confirmation response was " + connection.getResponseCode());
}
connection.disconnect();
} catch (Exception ex) {
LogHelper.printException("RYDRequester", "Failed to confirm vote", ex);
LogHelper.printException(RYDRequester.class, "Failed to confirm vote", ex);
}
return false;
}

View File

@ -71,7 +71,7 @@ public enum SettingsEnum {
} 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());
LogHelper.printException(SettingsEnum.class, "Setting does not end with a valid Type. Name is: " + setting.name());
continue;
}
@ -106,24 +106,24 @@ public enum SettingsEnum {
} 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());
LogHelper.printException(SettingsEnum.class, "Setting does not end with a valid Type. Name is: " + name());
}
value = newValue;
} else {
LogHelper.printException("SettingsEnum", "Context on SaveValue is null!");
LogHelper.printException(SettingsEnum.class, "Context on SaveValue is null!");
}
}
public int getInt() {
SettingsEnum.loadSettings();
if (value == null) value = -1;
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
LogHelper.debug(SettingsEnum.class, "Variable " + name() + " is " + value);
return (int) value;
}
public String getString() {
SettingsEnum.loadSettings();
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
LogHelper.debug(SettingsEnum.class, "Variable " + name() + " is " + value);
return (String) value;
}
@ -136,14 +136,14 @@ public enum SettingsEnum {
public Long getLong() {
SettingsEnum.loadSettings();
if (value == null) value = -1L;
LogHelper.debug("SettingsEnum", "Variable " + name() + " is " + value);
LogHelper.debug(SettingsEnum.class, "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);
LogHelper.debug(SettingsEnum.class, "Variable " + name() + " is " + value);
return (Float) value;
}

View File

@ -0,0 +1,9 @@
<Preference android:title="@string/revanced_ryd_settings_title" android:summary="@string/revanced_ryd_settings_summary">
<intent android:targetPackage="com.revanced.android.youtube" android:data="ryd_settings" android:targetClass="app.revanced.integrations.settingsmenu.ReVancedSettingActivity" />
</Preference>
<Preference android:title="@string/sb_settings" android:summary="@string/sb_summary">
<intent android:targetPackage="com.revanced.android.youtube" android:data="sponsorblock_settings" android:targetClass="app.revanced.integrations.settingsmenu.ReVancedSettingActivity" />
</Preference>
<Preference android:title="@string/revanced_settings">
<intent android:targetPackage="com.revanced.android.youtube" android:data="revanced_settings" android:targetClass="app.revanced.integrations.settingsmenu.ReVancedSettingActivity" />
</Preference>

View File

@ -14,7 +14,7 @@ import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.ThemeHelper;
/* loaded from: classes6.dex */
public class XSettingActivity extends Activity {
public class ReVancedSettingActivity extends Activity {
private static Context context;
private boolean currentTheme;
@ -22,10 +22,10 @@ public class XSettingActivity extends Activity {
protected void onCreate(Bundle bundle) {
this.currentTheme = ThemeHelper.isDarkTheme();
if (currentTheme) {
LogHelper.debug("XSettingsActivity", "set Theme.YouTube.Settings.Dark");
LogHelper.debug(ReVancedSettingActivity.class, "set Theme.YouTube.Settings.Dark");
setTheme(getIdentifier("Theme.YouTube.Settings.Dark", "style"));
} else {
LogHelper.debug("XSettingsActivity", "set Theme.YouTube.Settings");
LogHelper.debug(ReVancedSettingActivity.class, "set Theme.YouTube.Settings");
setTheme(getIdentifier("Theme.YouTube.Settings", "style"));
}
super.onCreate(bundle);
@ -82,7 +82,7 @@ public class XSettingActivity extends Activity {
try {
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(i);
} catch (Exception e) {
LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar title", e);
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar title", e);
}
}
@ -90,22 +90,22 @@ public class XSettingActivity extends Activity {
try {
getTextView((ViewGroup) findViewById(getIdentifier("toolbar", "id"))).setText(str);
} catch (Exception e) {
LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar title", e);
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar title", e);
}
}
private void initImageButton(boolean z) {
try {
ImageButton imageButton = getImageButton((ViewGroup) findViewById(getIdentifier("toolbar", "id")));
imageButton.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.theme.XSettingActivity.1
imageButton.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.theme.ReVancedSettingActivity.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
XSettingActivity.this.onBackPressed();
ReVancedSettingActivity.this.onBackPressed();
}
});
imageButton.setImageDrawable(getResources().getDrawable(getIdentifier(z ? "quantum_ic_arrow_back_white_24" : "quantum_ic_arrow_back_grey600_24", "drawable")));
imageButton.setImageDrawable(getResources().getDrawable(getIdentifier(z ? "quantum_ic_arrow_back_white_24" : "quantum_ic_arrow_back_grey600_24", "drawable"), null));
} catch (Exception e) {
LogHelper.printException("XSettingsActivity", "Couldn't set Toolbar click handler", e);
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar click handler", e);
}
}

View File

@ -306,7 +306,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
this.sharedPreferences.edit().putBoolean("revanced_initialized", true);
this.settingsInitialized = true;
} catch (Throwable th) {
LogHelper.printException("ReVancedSettingsFragment", "Unable to retrieve resourceId for revanced_prefs", th);
LogHelper.printException(ReVancedSettingsFragment.class, "Unable to retrieve resourceId for xfile_prefs", th);
}
}
@ -362,11 +362,11 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
private String getPackageName() {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (context == null) {
LogHelper.printException("Settings", "Context is null, returning com.google.android.youtube!");
LogHelper.printException(ReVancedSettingsFragment.class, "Context is null, returning com.google.android.youtube!");
return "com.google.android.youtube";
}
String PACKAGE_NAME = context.getPackageName();
LogHelper.debug("Settings", "getPackageName: " + PACKAGE_NAME);
LogHelper.debug(ReVancedSettingsFragment.class, "getPackageName: " + PACKAGE_NAME);
return PACKAGE_NAME;
}

View File

@ -14,14 +14,14 @@ import app.revanced.integrations.utils.LogHelper;
public class InjectedPlugin {
public static void printSomething() {
LogHelper.debug("InjectedPlugin", "printSomething called");
LogHelper.debug(InjectedPlugin.class, "printSomething called");
}
public static void printObject(Object o, int recursive) {
if (o == null)
LogHelper.debug("InjectedPlugin", "Printed object is null");
LogHelper.debug(InjectedPlugin.class, "Printed object is null");
else {
LogHelper.debug("InjectedPlugin", "Printed object ("
LogHelper.debug(InjectedPlugin.class, "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()))
LogHelper.debug("InjectedPlugin", "Field: " + field.toString() + " has value " + value);
LogHelper.debug(InjectedPlugin.class, "Field: " + field.toString() + " has value " + value);
} catch (Exception e) {
LogHelper.debug("InjectedPlugin", "Field: " + field.toString() + " has value that thrown an exception in toString method");
LogHelper.debug(InjectedPlugin.class, "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();
LogHelper.debug("InjectedPlugin", "Printing stack trace:");
LogHelper.debug(InjectedPlugin.class, "Printing stack trace:");
for (StackTraceElement element : stackTrace) {
LogHelper.debug("InjectedPlugin", element.toString());
LogHelper.debug(InjectedPlugin.class, element.toString());
}
}
@ -77,19 +77,19 @@ public class InjectedPlugin {
String spacesStr = builder.toString();
if (view == null) {
LogHelper.debug("InjectedPlugin", spacesStr + "Null view");
LogHelper.debug(InjectedPlugin.class, spacesStr + "Null view");
return;
}
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
LogHelper.debug("InjectedPlugin", spacesStr + "View group: " + view);
LogHelper.debug(InjectedPlugin.class, spacesStr + "View group: " + view);
int childCount = group.getChildCount();
LogHelper.debug("InjectedPlugin", spacesStr + "Children count: " + childCount);
LogHelper.debug(InjectedPlugin.class, spacesStr + "Children count: " + childCount);
for (int i = 0; i < childCount; i++) {
printViewStack(group.getChildAt(i), spaces + 1);
}
} else {
LogHelper.debug("InjectedPlugin", spacesStr + "Normal view: " + view);
LogHelper.debug(InjectedPlugin.class, spacesStr + "Normal view: " + view);
}
}
}

View File

@ -33,9 +33,6 @@ import app.revanced.integrations.utils.SharedPrefHelper;
@SuppressLint({"LongLogTag"})
public class PlayerController {
public static final boolean VERBOSE = false;
@SuppressWarnings("PointlessBooleanExpression")
public static final boolean VERBOSE_DRAW_OPTIONS = false && VERBOSE;
private static final Timer sponsorTimer = new Timer("sponsor-skip-timer");
public static WeakReference<Activity> playerActivity = new WeakReference<>(null);
@ -66,10 +63,6 @@ public class PlayerController {
}
Context context = ReVancedUtils.getContext();
if (context == null) {
LogHelper.printException("PlayerController", "context is null");
return;
}
SponsorBlockSettings.update(context);
if (!SponsorBlockSettings.isSponsorBlockEnabled) {
@ -82,8 +75,7 @@ public class PlayerController {
currentVideoId = videoId;
sponsorSegmentsOfCurrentVideo = null;
if (VERBOSE)
LogHelper.debug("PlayerController", "setCurrentVideoId: videoId=" + videoId);
LogHelper.debug(PlayerController.class, "setCurrentVideoId: videoId=" + videoId);
sponsorTimer.schedule(new TimerTask() {
@Override
@ -100,12 +92,11 @@ public class PlayerController {
// "Plugin.printStackTrace();
if (o == null) {
LogHelper.printException("PlayerController", "onCreate called with null object");
LogHelper.printException(PlayerController.class, "onCreate called with null object");
return;
}
if (VERBOSE)
LogHelper.debug("PlayerController", String.format("onCreate called with object %s on thread %s", o.toString(), Thread.currentThread().toString()));
LogHelper.debug(PlayerController.class, String.format("onCreate called with object %s on thread %s", o.toString(), Thread.currentThread().toString()));
try {
setMillisecondMethod = o.getClass().getMethod("replaceMeWithsetMillisecondMethod", Long.TYPE);
@ -119,7 +110,7 @@ public class PlayerController {
SkipSegmentView.hide();
NewSegmentHelperLayout.hide();
} catch (Exception e) {
LogHelper.printException("PlayerController", "Exception while initializing skip method", e);
LogHelper.printException(PlayerController.class, "Exception while initializing skip method", e);
}
}
@ -131,84 +122,19 @@ public class PlayerController {
SponsorSegment[] segments = SBRequester.getSegments(videoId);
Arrays.sort(segments);
if (VERBOSE)
for (SponsorSegment segment : segments) {
LogHelper.debug("PlayerController", "Detected segment: " + segment.toString());
}
for (SponsorSegment segment : segments) {
LogHelper.debug(PlayerController.class, "Detected segment: " + segment.toString());
}
sponsorSegmentsOfCurrentVideo = segments;
// new Handler(Looper.getMainLooper()).post(findAndSkipSegmentRunnable);
}
/**
* Works in 14.x, waits some time of object to me filled with data,
* No longer used, i've found another way to get faster videoId
*/
@Deprecated
public static void asyncGetVideoLinkFromObject(final Object o) {
// code no longer used
// if (currentVideoLink != null) {
// if (VERBOSE)
// Log.w("PlayerController", "asyncGetVideoLinkFromObject: currentVideoLink != null probably share button was clicked");
// return;
// }
//
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// // It used to be "b" in 14.x version, it's "a" in 15.x
// Field b = o.getClass().getDeclaredField("b");
//
// int attempts = 0;
// String videoUrl = null;
// while (true) {
// Object objLink = b.get(o);
// if (objLink == null) {
// if (VERBOSE)
// LogHelper.printException("PlayerController", "asyncGetVideoLinkFromObject: objLink is null");
// } else {
// videoUrl = objLink.toString();
// if (videoUrl.isEmpty())
// videoUrl = null;
// }
//
// if (videoUrl != null)
// break;
//
// if (attempts++ > 5) {
// Log.w("PlayerController", "asyncGetVideoLinkFromObject: attempts++ > 5");
// return;
// }
// Thread.sleep(50);
// }
//
// if (currentVideoLink == null) {
// currentVideoLink = videoUrl;
// if (VERBOSE)
// LogH("PlayerController", "asyncGetVideoLinkFromObject: link set to " + videoUrl);
//
// executeDownloadSegments(substringVideoIdFromLink(videoUrl), false);
// }
//
// } catch (Exception e) {
// LogHelper.printException("PlayerController", "Cannot get link from object", e);
// }
// }
// }).start();
//
// Activity activity = playerActivity.get();
// if (activity != null)
// SponsorBlockUtils.addImageButton(activity);
}
/**
* Called when it's time to update the UI with new second, about once per second, only when playing, also in background
*/
public static void setCurrentVideoTime(long millis) {
if (VERBOSE)
LogHelper.debug("PlayerController", "setCurrentVideoTime: current video time: " + millis);
LogHelper.debug(PlayerController.class, "setCurrentVideoTime: current video time: " + millis);
VideoInformation.lastKnownVideoTime = millis;
if (!SponsorBlockSettings.isSponsorBlockEnabled) return;
lastKnownVideoTime = millis;
@ -235,8 +161,7 @@ public class PlayerController {
break;
if (skipSponsorTask == null) {
if (VERBOSE)
LogHelper.debug("PlayerController", "Scheduling skipSponsorTask");
LogHelper.debug(PlayerController.class, "Scheduling skipSponsorTask");
skipSponsorTask = new TimerTask() {
@Override
public void run() {
@ -248,8 +173,7 @@ public class PlayerController {
};
sponsorTimer.schedule(skipSponsorTask, segment.start - millis);
} else {
if (VERBOSE)
LogHelper.debug("PlayerController", "skipSponsorTask is already scheduled...");
LogHelper.debug(PlayerController.class, "skipSponsorTask is already scheduled...");
}
break;
@ -317,8 +241,7 @@ public class PlayerController {
* Called before onDraw method on time bar object, sets video length in millis
*/
public static void setVideoLength(final long length) {
if (VERBOSE_DRAW_OPTIONS)
LogHelper.debug("PlayerController", "setVideoLength: length=" + length);
LogHelper.debug(PlayerController.class, "setVideoLength: length=" + length);
currentVideoLength = length;
}
@ -328,8 +251,7 @@ public class PlayerController {
}
public static void setSponsorBarAbsoluteLeft(final float left) {
if (VERBOSE_DRAW_OPTIONS)
LogHelper.debug("PlayerController", String.format("setSponsorBarLeft: left=%.2f", left));
LogHelper.debug(PlayerController.class, String.format("setSponsorBarLeft: left=%.2f", left));
sponsorBarLeft = left;
}
@ -353,8 +275,7 @@ public class PlayerController {
}
public static void setSponsorBarAbsoluteRight(final float right) {
if (VERBOSE_DRAW_OPTIONS)
LogHelper.debug("PlayerController", String.format("setSponsorBarRight: right=%.2f", right));
LogHelper.debug(PlayerController.class, String.format("setSponsorBarRight: right=%.2f", right));
sponsorBarRight = right;
}
@ -365,22 +286,20 @@ public class PlayerController {
public static void setSponsorBarThickness(final float thickness) {
// if (VERBOSE_DRAW_OPTIONS)
// LogH("PlayerController", String.format("setSponsorBarThickness: thickness=%.2f", thickness));
// LogH(PlayerController.class, String.format("setSponsorBarThickness: thickness=%.2f", thickness));
sponsorBarThickness = thickness;
}
public static void onSkipSponsorClicked() {
if (VERBOSE)
LogHelper.debug("PlayerController", "Skip segment clicked");
LogHelper.debug(PlayerController.class, "Skip segment clicked");
findAndSkipSegment(true);
}
public static void addSkipSponsorView15(final View view) {
playerActivity = new WeakReference<>((Activity) view.getContext());
if (VERBOSE)
LogHelper.debug("PlayerController", "addSkipSponsorView15: view=" + view.toString());
LogHelper.debug(PlayerController.class, "addSkipSponsorView15: view=" + view.toString());
new Handler(Looper.getMainLooper()).postDelayed(() -> {
final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) view).getChildAt(2);
@ -391,8 +310,7 @@ public class PlayerController {
public static void addSkipSponsorView14(final View view) {
playerActivity = new WeakReference<>((Activity) view.getContext());
if (VERBOSE)
LogHelper.debug("PlayerController", "addSkipSponsorView14: view=" + view.toString());
LogHelper.debug(PlayerController.class, "addSkipSponsorView14: view=" + view.toString());
new Handler(Looper.getMainLooper()).postDelayed(() -> {
final ViewGroup viewGroup = (ViewGroup) view.getParent();
Activity activity = (Activity) viewGroup.getContext();
@ -437,38 +355,34 @@ public class PlayerController {
// I put this block so that skip can be made only once per some time
long now = System.currentTimeMillis();
if (now < allowNextSkipRequestTime) {
if (VERBOSE)
LogHelper.debug("PlayerController", "skipToMillisecond: to fast, slow down, because you'll fail");
LogHelper.debug(PlayerController.class, "skipToMillisecond: to fast, slow down, because you'll fail");
return;
}
allowNextSkipRequestTime = now + 100;
if (setMillisecondMethod == null) {
LogHelper.printException("PlayerController", "setMillisecondMethod is null");
LogHelper.printException(PlayerController.class, "setMillisecondMethod is null");
return;
}
final Object currentObj = currentPlayerController.get();
if (currentObj == null) {
LogHelper.printException("PlayerController", "currentObj is null (might have been collected by GC)");
LogHelper.printException(PlayerController.class, "currentObj is null (might have been collected by GC)");
return;
}
if (VERBOSE)
LogHelper.debug("PlayerController", String.format("Requesting skip to millis=%d on thread %s", millisecond, Thread.currentThread().toString()));
LogHelper.debug(PlayerController.class, 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)
LogHelper.debug("PlayerController", "Skipping to millis=" + finalMillisecond);
LogHelper.debug(PlayerController.class, "Skipping to millis=" + finalMillisecond);
lastKnownVideoTime = finalMillisecond;
VideoInformation.lastKnownVideoTime = lastKnownVideoTime;
setMillisecondMethod.invoke(currentObj, finalMillisecond);
} catch (Exception e) {
LogHelper.printException("PlayerController", "Cannot skip to millisecond", e);
LogHelper.printException(PlayerController.class, "Cannot skip to millisecond", e);
}
});
}
@ -502,8 +416,7 @@ public class PlayerController {
private static void skipSegment(SponsorSegment segment, boolean wasClicked) {
// if (lastSkippedSegment == segment) return;
// lastSkippedSegment = segment;
if (VERBOSE)
LogHelper.debug("PlayerController", "Skipping segment: " + segment.toString());
LogHelper.debug(PlayerController.class, "Skipping segment: " + segment.toString());
if (SponsorBlockSettings.showToastWhenSkippedAutomatically && !wasClicked)
SkipSegmentView.notifySkipped(segment);

View File

@ -27,7 +27,7 @@ public class ShieldButton {
public static void initialize(Object viewStub) {
try {
LogHelper.debug("ShieldButton", "initializing shield button");
LogHelper.debug(ShieldButton.class, "initializing shield button");
_youtubeControlsLayout = (RelativeLayout) viewStub;
@ -35,7 +35,7 @@ public class ShieldButton {
.findViewById(getIdentifier("sponsorblock_button", "id"));
if (imageView == null) {
LogHelper.debug("ShieldButton", "Couldn't find imageView with \"sponsorblock_button\"");
LogHelper.debug(ShieldButton.class, "Couldn't find imageView with \"sponsorblock_button\"");
}
if (imageView == null) return;
imageView.setOnClickListener(SponsorBlockUtils.sponsorBlockBtnListener);
@ -51,7 +51,7 @@ public class ShieldButton {
isShowing = true;
changeVisibilityImmediate(false);
} catch (Exception ex) {
LogHelper.printException("ShieldButton", "Unable to set RelativeLayout", ex);
LogHelper.printException(ShieldButton.class, "Unable to set RelativeLayout", ex);
}
}
@ -78,7 +78,7 @@ public class ShieldButton {
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
return;
}
LogHelper.debug("ShieldButton", "Fading in");
LogHelper.debug(ShieldButton.class, "Fading in");
iView.setVisibility(View.VISIBLE);
if (!immediate)
@ -87,7 +87,7 @@ public class ShieldButton {
}
if (iView.getVisibility() == View.VISIBLE) {
LogHelper.debug("ShieldButton", "Fading out");
LogHelper.debug(ShieldButton.class, "Fading out");
if (!immediate)
iView.startAnimation(fadeOut);
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);

View File

@ -12,7 +12,6 @@ import app.revanced.integrations.utils.ReVancedUtils;
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.hideSkipButton;
import static app.revanced.integrations.sponsorblock.player.ui.SponsorBlockView.showSkipButton;
import static app.revanced.integrations.sponsorblock.PlayerController.VERBOSE;
@SuppressLint({"RtlHardcoded", "SetTextI18n", "LongLogTag", "AppCompatCustomView"})
public class SkipSegmentView {
@ -29,15 +28,13 @@ public class SkipSegmentView {
public static void notifySkipped(SponsorSegment segment) {
if (segment == lastNotifiedSegment) {
if (VERBOSE)
LogHelper.debug("SkipSegmentView", "notifySkipped; segment == lastNotifiedSegment");
LogHelper.debug(SkipSegmentView.class, "notifySkipped; segment == lastNotifiedSegment");
return;
}
lastNotifiedSegment = segment;
String skipMessage = segment.category.skipMessage.toString();
Context context = ReVancedUtils.getContext();
if (VERBOSE)
LogHelper.debug("SkipSegmentView", String.format("notifySkipped; message=%s", skipMessage));
LogHelper.debug(SkipSegmentView.class, String.format("notifySkipped; message=%s", skipMessage));
if (context != null)
Toast.makeText(context, skipMessage, Toast.LENGTH_SHORT).show();

View File

@ -60,12 +60,6 @@ public class SponsorBlockSettings {
public static int skippedSegments;
public static long skippedTime;
@SuppressWarnings("unused")
@Deprecated
public SponsorBlockSettings(Context ignored) {
LogHelper.printException("revanced.Settings", "Do not call SponsorBlockSettings constructor!");
}
public static void setSeenGuidelines(Context context) {
SponsorBlockSettings.seenGuidelinesPopup = true;
SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK).edit().putBoolean(PREFERENCES_KEY_SEEN_GUIDELINES, true).apply();

View File

@ -74,7 +74,6 @@ import app.revanced.integrations.sponsorblock.requests.SBRequester;
@SuppressWarnings({"LongLogTag"})
public abstract class 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);
@ -83,11 +82,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 -> {
LogHelper.debug(TAG, "Shield button clicked");
LogHelper.debug(SponsorBlockUtils.class, "Shield button clicked");
NewSegmentHelperLayout.toggle();
};
public static final View.OnClickListener voteButtonListener = v -> {
LogHelper.debug(TAG, "Vote button clicked");
LogHelper.debug(SponsorBlockUtils.class, "Vote button clicked");
SponsorBlockUtils.onVotingClicked(v.getContext());
};
private static int shareBtnId = -1;
@ -255,13 +254,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) {
LogHelper.printException(TAG, "Unable to submit times, invalid parameters");
LogHelper.printException(SponsorBlockUtils.class, "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) {
LogHelper.printException(TAG, "Unable to submit segment", e);
LogHelper.printException(SponsorBlockUtils.class, "Unable to submit segment", e);
}
if (videoId != null)
@ -458,7 +457,7 @@ public abstract class SponsorBlockUtils {
PlayerController.setCurrentVideoId(null);
}
} catch (Exception ex) {
LogHelper.printException(TAG, "Player type changed caused a crash.", ex);
LogHelper.printException(SponsorBlockUtils.class, "Player type changed caused a crash.", ex);
}
}

View File

@ -105,7 +105,7 @@ public class StringRef {
if (resources != null) {
final int identifier = resources.getIdentifier(value, "string", packageName);
if (identifier == 0)
LogHelper.printException("StringRef", "Resource not found: " + value);
LogHelper.printException(StringRef.class, "Resource not found: " + value);
else
value = resources.getString(identifier);
}

View File

@ -27,14 +27,14 @@ public class VotingButton {
public static void initialize(Object viewStub) {
try {
LogHelper.debug("VotingButton", "initializing voting button");
LogHelper.debug(VotingButton.class, "initializing voting button");
_youtubeControlsLayout = (RelativeLayout) viewStub;
ImageView imageView = (ImageView) _youtubeControlsLayout
.findViewById(getIdentifier("voting_button", "id"));
if (imageView == null) {
LogHelper.debug("VotingButton", "Couldn't find imageView with \"voting_button\"");
LogHelper.debug(VotingButton.class, "Couldn't find imageView with \"voting_button\"");
}
if (imageView == null) return;
imageView.setOnClickListener(SponsorBlockUtils.voteButtonListener);
@ -50,7 +50,7 @@ public class VotingButton {
isShowing = true;
changeVisibilityImmediate(false);
} catch (Exception ex) {
LogHelper.printException("VotingButton", "Unable to set RelativeLayout", ex);
LogHelper.printException(VotingButton.class, "Unable to set RelativeLayout", ex);
}
}
@ -77,7 +77,7 @@ public class VotingButton {
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
return;
}
LogHelper.debug("VotingButton", "Fading in");
LogHelper.debug(VotingButton.class, "Fading in");
iView.setVisibility(View.VISIBLE);
if (!immediate)
iView.startAnimation(fadeIn);
@ -85,7 +85,7 @@ public class VotingButton {
}
if (iView.getVisibility() == View.VISIBLE) {
LogHelper.debug("VotingButton", "Fading out");
LogHelper.debug(VotingButton.class, "Fading out");
if (!immediate)
iView.startAnimation(fadeOut);
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);

View File

@ -22,7 +22,7 @@ public class VideoHelpers {
try {
String videoId = VideoInformation.currentVideoId;
if (videoId == null || videoId.isEmpty()) {
LogHelper.debug("VideoHelpers", "VideoId was empty");
LogHelper.debug(VideoHelpers.class, "VideoId was empty");
return;
}
@ -32,13 +32,13 @@ public class VideoHelpers {
videoUrl += String.format("?t=%s", (videoTime / 1000));
}
LogHelper.debug("VideoHelpers", "Video URL: " + videoUrl);
LogHelper.debug(VideoHelpers.class, "Video URL: " + videoUrl);
setClipboard(ReVancedUtils.getContext(), videoUrl);
Toast.makeText(ReVancedUtils.getContext(), str("share_copy_url_success"), Toast.LENGTH_SHORT).show();
} catch (Exception ex) {
LogHelper.printException("VideoHelpers", "Couldn't generate video url", ex);
LogHelper.printException(VideoHelpers.class, "Couldn't generate video url", ex);
}
}

View File

@ -16,7 +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) {
LogHelper.debug("VideoInformation", "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
LogHelper.debug(VideoInformation.class, "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
clearInformation(true);
return;
}
@ -27,11 +27,11 @@ public class VideoInformation {
}
if (videoId.equals(currentVideoId)) {
LogHelper.debug("VideoInformation", "setCurrentVideoId - new and current video were equal - " + videoId);
LogHelper.debug(VideoInformation.class, "setCurrentVideoId - new and current video were equal - " + videoId);
return;
}
LogHelper.debug("VideoInformation", "setCurrentVideoId - video id updated from " + currentVideoId + " to " + videoId);
LogHelper.debug(VideoInformation.class, "setCurrentVideoId - video id updated from " + currentVideoId + " to " + videoId);
currentVideoId = videoId;

View File

@ -32,7 +32,7 @@ public class AdButton extends SlimButton {
}
public void changeEnabled(boolean enabled) {
LogHelper.debug("AdButton", "changeEnabled " + enabled);
LogHelper.debug(AdButton.class, "changeEnabled " + enabled);
this.button_icon.setEnabled(enabled);
}
@ -53,7 +53,7 @@ public class AdButton extends SlimButton {
Whitelist.removeFromWhitelist(WhitelistType.ADS, this.context, VideoInformation.channelName);
changeEnabled(false);
} catch (Exception ex) {
LogHelper.printException("AdButton", "Failed to remove from whitelist", ex);
LogHelper.printException(AdButton.class, "Failed to remove from whitelist", ex);
return;
}
@ -62,7 +62,7 @@ public class AdButton extends SlimButton {
private void addToWhiteList(View view, ImageView buttonIcon) {
new Thread(() -> {
LogHelper.debug("AdButton", "Fetching channelId for " + currentVideoId);
LogHelper.debug(AdButton.class, "Fetching channelId for " + currentVideoId);
WhitelistRequester.addChannelToWhitelist(WhitelistType.ADS, view, buttonIcon, this.context);
}).start();
}

View File

@ -68,7 +68,7 @@ public class NewSegmentLayout extends FrameLayout {
this.rewindButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LogHelper.debug("NewSegmentLayout", "Rewind button clicked");
LogHelper.debug(NewSegmentLayout.class, "Rewind button clicked");
PlayerController.skipRelativeMilliseconds(-SponsorBlockSettings.adjustNewSegmentMillis);
}
});
@ -79,7 +79,7 @@ public class NewSegmentLayout extends FrameLayout {
this.forwardButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LogHelper.debug("NewSegmentLayout", "Forward button clicked");
LogHelper.debug(NewSegmentLayout.class, "Forward button clicked");
PlayerController.skipRelativeMilliseconds(SponsorBlockSettings.adjustNewSegmentMillis);
}
});
@ -90,7 +90,7 @@ public class NewSegmentLayout extends FrameLayout {
this.adjustButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LogHelper.debug("NewSegmentLayout", "Adjust button clicked");
LogHelper.debug(NewSegmentLayout.class, "Adjust button clicked");
SponsorBlockUtils.onMarkLocationClicked(NewSegmentHelperLayout.context);
}
});
@ -101,7 +101,7 @@ public class NewSegmentLayout extends FrameLayout {
this.compareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LogHelper.debug("NewSegmentLayout", "Compare button clicked");
LogHelper.debug(NewSegmentLayout.class, "Compare button clicked");
SponsorBlockUtils.onPreviewClicked(NewSegmentHelperLayout.context);
}
});
@ -112,7 +112,7 @@ public class NewSegmentLayout extends FrameLayout {
this.editButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LogHelper.debug("NewSegmentLayout", "Edit button clicked");
LogHelper.debug(NewSegmentLayout.class, "Edit button clicked");
SponsorBlockUtils.onEditByHandClicked(NewSegmentHelperLayout.context);
}
});
@ -123,7 +123,7 @@ public class NewSegmentLayout extends FrameLayout {
this.publishButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LogHelper.debug("NewSegmentLayout", "Publish button clicked");
LogHelper.debug(NewSegmentLayout.class, "Publish button clicked");
SponsorBlockUtils.onPublishClicked(NewSegmentHelperLayout.context);
}
});

View File

@ -32,7 +32,7 @@ public class SBWhitelistButton extends SlimButton {
}
public void changeEnabled(boolean enabled) {
LogHelper.debug("SBWhiteListButton", "changeEnabled " + enabled);
LogHelper.debug(SBWhitelistButton.class, "changeEnabled " + enabled);
this.button_icon.setEnabled(!enabled); // enabled == true -> strikethrough (no segments), enabled == false -> clear (segments)
}
@ -53,7 +53,7 @@ public class SBWhitelistButton extends SlimButton {
Whitelist.removeFromWhitelist(WhitelistType.SPONSORBLOCK, this.context, VideoInformation.channelName);
changeEnabled(false);
} catch (Exception ex) {
LogHelper.printException("SBWhiteListButton", "Failed to remove from whitelist", ex);
LogHelper.printException(SBWhitelistButton.class, "Failed to remove from whitelist", ex);
return;
}
@ -62,7 +62,7 @@ public class SBWhitelistButton extends SlimButton {
private void addToWhiteList(View view, ImageView buttonIcon) {
new Thread(() -> {
LogHelper.debug("SBWhiteListButton", "Fetching channelId for " + currentVideoId);
LogHelper.debug(SBWhitelistButton.class, "Fetching channelId for " + currentVideoId);
WhitelistRequester.addChannelToWhitelist(WhitelistType.SPONSORBLOCK, view, buttonIcon, this.context);
}).start();
}

View File

@ -90,7 +90,7 @@ public class SkipSponsorButton extends FrameLayout {
this.skipSponsorBtnContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LogHelper.debug("SkipSponsorButton", "Skip button clicked");
LogHelper.debug(SkipSponsorButton.class, "Skip button clicked");
PlayerController.onSkipSponsorClicked();
}
});

View File

@ -25,7 +25,7 @@ public abstract class SlimButton implements View.OnClickListener {
}
public SlimButton(Context context, ViewGroup container, int id, boolean visible) {
LogHelper.debug("SlimButton", "Adding button with id " + id + " and visibility of " + visible);
LogHelper.debug(SlimButton.class, "Adding button with id " + id + " and visibility of " + visible);
this.context = context;
this.container = container;
view = LayoutInflater.from(context).inflate(id, container, false);
@ -48,7 +48,7 @@ public abstract class SlimButton implements View.OnClickListener {
}
setContainerVisibility();
} catch (Exception ex) {
LogHelper.printException("SlimButton", "Error while changing button visibility", ex);
LogHelper.printException(SlimButton.class, "Error while changing button visibility", ex);
}
}

View File

@ -62,14 +62,14 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
addSharedPrefsChangeListener();
} catch (Exception ex) {
LogHelper.printException("SlimButtonContainer", "Unable to initialize the button container", ex);
LogHelper.printException(SlimButtonContainer.class, "Unable to initialize the button container", ex);
}
}
private void addSharedPrefsChangeListener() {
listener = (sharedPreferences, key) -> {
try {
LogHelper.debug("SlimButtonContainer", String.format("SharedPreference changed with key %s", key));
LogHelper.debug(SlimButtonContainer.class, 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;
@ -112,7 +112,7 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
return;
}
} catch (Exception ex) {
LogHelper.printException("SlimButtonContainer", "Error handling shared preference change", ex);
LogHelper.printException(SlimButtonContainer.class, "Error handling shared preference change", ex);
}
};

View File

@ -23,13 +23,13 @@ public class SponsorBlockView {
public static void initialize(Object viewGroup) {
try {
LogHelper.debug("SponsorblockView", "initializing");
LogHelper.debug(SponsorBlockView.class, "initializing");
_youtubeOverlaysLayout = (ViewGroup) viewGroup;
addView();
} catch (Exception ex) {
LogHelper.printException("SponsorblockView", "Unable to set ViewGroup", ex);
LogHelper.printException(SponsorBlockView.class, "Unable to set ViewGroup", ex);
}
}
@ -62,7 +62,7 @@ public class SponsorBlockView {
setSkipBtnMargins(false);
setNewSegmentLayoutMargins(false);
} catch (Exception ex) {
LogHelper.printException("SponsorblockView", "Player type changed caused a crash.", ex);
LogHelper.printException(SponsorBlockView.class, "Player type changed caused a crash.", ex);
}
}
@ -87,13 +87,13 @@ public class SponsorBlockView {
private static void setSkipBtnMargins(boolean fullScreen) {
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
if (skipSponsorButton == null) {
LogHelper.printException("SponsorblockView", "Unable to setSkipBtnMargins");
LogHelper.printException(SponsorBlockView.class, "Unable to setSkipBtnMargins");
return;
}
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) skipSponsorButton.getLayoutParams();
if (params == null) {
LogHelper.printException("SponsorblockView", "Unable to setSkipBtnMargins");
LogHelper.printException(SponsorBlockView.class, "Unable to setSkipBtnMargins");
return;
}
params.bottomMargin = fullScreen ? skipSponsorButton.ctaBottomMargin : skipSponsorButton.defaultBottomMargin;
@ -103,7 +103,7 @@ public class SponsorBlockView {
private static void skipSponsorButtonVisibility(boolean visible) {
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
if (skipSponsorButton == null) {
LogHelper.printException("SponsorblockView", "Unable to skipSponsorButtonVisibility");
LogHelper.printException(SponsorBlockView.class, "Unable to skipSponsorButtonVisibility");
return;
}
@ -116,13 +116,13 @@ public class SponsorBlockView {
private static void setNewSegmentLayoutMargins(boolean fullScreen) {
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
if (newSegmentLayout == null) {
LogHelper.printException("SponsorblockView", "Unable to setNewSegmentLayoutMargins");
LogHelper.printException(SponsorBlockView.class, "Unable to setNewSegmentLayoutMargins");
return;
}
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) newSegmentLayout.getLayoutParams();
if (params == null) {
LogHelper.printException("SponsorblockView", "Unable to setNewSegmentLayoutMargins");
LogHelper.printException(SponsorBlockView.class, "Unable to setNewSegmentLayoutMargins");
return;
}
params.bottomMargin = fullScreen ? newSegmentLayout.ctaBottomMargin : newSegmentLayout.defaultBottomMargin;
@ -132,7 +132,7 @@ public class SponsorBlockView {
private static void newSegmentLayoutVisibility(boolean visible) {
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
if (newSegmentLayout == null) {
LogHelper.printException("SponsorblockView", "Unable to newSegmentLayoutVisibility");
LogHelper.printException(SponsorBlockView.class, "Unable to newSegmentLayoutVisibility");
return;
}
@ -154,12 +154,12 @@ public class SponsorBlockView {
View layout = SwipeHelper.nextGenWatchLayout.findViewById(getIdentifier("player_overlays", "id"));
if (layout == null) {
LogHelper.debug("Settings", "player_overlays was not found for SB");
LogHelper.debug(SponsorBlockView.class, "player_overlays was not found for SB");
return;
}
initialize(layout);
LogHelper.debug("Settings", "player_overlays refreshed for SB");
LogHelper.debug(SponsorBlockView.class, "player_overlays refreshed for SB");
}
}

View File

@ -7,25 +7,23 @@ import app.revanced.integrations.settings.SettingsEnum;
public class LogHelper {
public static void debug(String tag, String message) {
//ToDo: Get Calling classname using Reflection
public static void debug(Class clazz, String message) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
Log.d(tag, message);
Log.d("ReVanced: " + clazz != null ? clazz.getSimpleName() : "", message);
}
}
public static void printException(String tag, String message, Throwable ex) {
Log.e(tag, message, ex);
public static void printException(Class clazz, String message, Throwable ex) {
Log.e("ReVanced: " + clazz != null ? clazz.getName() : "", message, ex);
}
public static void printException(String tag, String message) {
Log.e(tag, message);
public static void printException(Class clazz, String message) {
Log.e("ReVanced: " + clazz != null ? clazz.getName() : "", message);
}
public static void info(String tag, String message) {
Log.i(tag, message);
}
public static void info(String message) {
info("ReVanced", message);
public static void info(Class clazz, String message) {
Log.i("ReVanced: " + clazz != null ? clazz.getSimpleName() : "", message);
}
}

View File

@ -19,7 +19,7 @@ public class ObjectSerializer {
objStream.close();
return encodeBytes(serialObj.toByteArray());
} catch (Exception e) {
LogHelper.printException("ObjectSerializer", "Serialization error: " + e.getMessage(), e);
LogHelper.printException(ObjectSerializer.class, "Serialization error: " + e.getMessage(), e);
throw new IOException(e);
}
}
@ -31,7 +31,7 @@ public class ObjectSerializer {
ObjectInputStream objStream = new ObjectInputStream(serialObj);
return objStream.readObject();
} catch (Exception e) {
LogHelper.printException("ObjectSerializer", "Deserialization error: " + e.getMessage(), e);
LogHelper.printException(ObjectSerializer.class, "Deserialization error: " + e.getMessage(), e);
throw new IOException(e);
}
}

View File

@ -25,7 +25,7 @@ public class ReVancedUtils {
if (context != null) {
return context;
}
LogHelper.printException("Globals", "Context is null!");
LogHelper.printException(ReVancedUtils.class, "Context is null!");
return null;
}
@ -34,7 +34,7 @@ public class ReVancedUtils {
Resources res = context.getResources();
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
} catch (Throwable exception) {
LogHelper.printException("Settings", "Resource not found.", exception);
LogHelper.printException(ReVancedUtils.class, "Resource not found.", exception);
return "";
}
}
@ -59,7 +59,7 @@ public class ReVancedUtils {
public static void CheckForMicroG(Activity activity) {
AlertDialog.Builder builder;
if (!appInstalledOrNot("com.mgoogle.android.gms")) {
LogHelper.debug("XDebug", "Custom MicroG installation undetected");
LogHelper.debug(ReVancedUtils.class, "Custom MicroG installation undetected");
if (Build.VERSION.SDK_INT >= 21) {
builder = new AlertDialog.Builder(activity, 16974374);
} else {
@ -71,7 +71,7 @@ public class ReVancedUtils {
}
}).show();
} else {
LogHelper.debug("XDebug", "Custom MicroG installation detected");
LogHelper.debug(ReVancedUtils.class, "Custom MicroG installation detected");
}
}
@ -90,7 +90,7 @@ public class ReVancedUtils {
if (context != null) {
return context;
} else {
LogHelper.printException("Settings", "Context is null, returning null!");
LogHelper.printException(ReVancedUtils.class, "Context is null, returning null!");
return null;
}
}

View File

@ -23,7 +23,7 @@ public class SwipeHelper {
isTabletMode = true;
}
} catch (Exception e) {
LogHelper.printException("XError", "Unable to set FrameLayout", e);
LogHelper.printException(SwipeHelper.class, "Unable to set FrameLayout", e);
}
}
@ -31,7 +31,7 @@ public class SwipeHelper {
try {
nextGenWatchLayout = (ViewGroup) obj;
} catch (Exception e) {
LogHelper.printException("XError", "Unable to set _nextGenWatchLayout", e);
LogHelper.printException(SwipeHelper.class, "Unable to set _nextGenWatchLayout", e);
}
}
@ -42,7 +42,7 @@ public class SwipeHelper {
}
try {
} catch (Exception e) {
LogHelper.printException("XError", "Unable to get related_endscreen_results visibility", e);
LogHelper.printException(SwipeHelper.class, "Unable to get related_endscreen_results visibility", e);
}
if (_frameLayout.getChildCount() > 0) {
return _frameLayout.getChildAt(0).getVisibility() == View.VISIBLE;
@ -56,10 +56,10 @@ public class SwipeHelper {
try {
if (isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) {
_frameLayout = (FrameLayout) findViewById.getParent();
LogHelper.debug("Settings", "related_endscreen_results refreshed");
LogHelper.debug(SwipeHelper.class, "related_endscreen_results refreshed");
}
} catch (Exception e) {
LogHelper.printException("XError", "Unable to refresh related_endscreen_results layout", e);
LogHelper.printException(SwipeHelper.class, "Unable to refresh related_endscreen_results layout", e);
}
}

View File

@ -10,12 +10,12 @@ public class ThemeHelper {
public static void setTheme(int value) {
themeValue = value;
LogHelper.debug("XTheme", "Theme value: " + themeValue);
LogHelper.debug(ThemeHelper.class, "Theme value: " + themeValue);
}
public static void setTheme(Object value) {
themeValue = ((Enum) value).ordinal();
LogHelper.debug("XTheme", "Theme value: " + themeValue);
LogHelper.debug(ThemeHelper.class, "Theme value: " + themeValue);
}
public static boolean isDarkTheme() {

View File

@ -31,21 +31,21 @@ public class AutoRepeat {
public static void initializeAutoRepeat(Object constraintLayout) {
try {
LogHelper.debug("AutoRepeat", "initializing auto repeat");
LogHelper.debug(AutoRepeat.class, "initializing auto repeat");
CopyWithTimeStamp.initializeCopyButtonWithTimeStamp(constraintLayout);
Copy.initializeCopyButton(constraintLayout);
_constraintLayout = (ConstraintLayout) constraintLayout;
isAutoRepeatBtnEnabled = shouldBeShown();
ImageView imageView = _constraintLayout.findViewById(getIdentifier("autoreplay_button", "id"));
if (imageView == null) {
LogHelper.debug("AutoRepeat", "Couldn't find imageView with tag \"autoreplay_button\"");
LogHelper.debug(AutoRepeat.class, "Couldn't find imageView with tag \"autoreplay_button\"");
}
if (imageView != null) {
imageView.setSelected(shouldBeSelected());
imageView.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.videoplayer.Autorepeat.AutoRepeat.1
@Override // android.view.View.OnClickListener
public void onClick(View v) {
LogHelper.debug("AutoRepeat", "Auto repeat button clicked");
LogHelper.debug(AutoRepeat.class, "Auto repeat button clicked");
AutoRepeat.changeSelected(!v.isSelected());
}
});
@ -60,7 +60,7 @@ public class AutoRepeat {
changeVisibility(false);
}
} catch (Exception ex) {
LogHelper.printException("XError", "Unable to set FrameLayout", ex);
LogHelper.printException(AutoRepeat.class, "Unable to set FrameLayout", ex);
}
}
@ -72,11 +72,11 @@ public class AutoRepeat {
ImageView iView = _autoRepeatBtn.get();
if (_constraintLayout != null && iView != null) {
if (visible && isAutoRepeatBtnEnabled) {
LogHelper.debug("AutoRepeat", "Fading in");
LogHelper.debug(AutoRepeat.class, "Fading in");
iView.setVisibility(View.VISIBLE);
iView.startAnimation(fadeIn);
} else if (iView.getVisibility() == View.VISIBLE) {
LogHelper.debug("AutoRepeat", "Fading out");
LogHelper.debug(AutoRepeat.class, "Fading out");
iView.startAnimation(fadeOut);
iView.setVisibility(View.GONE);
}
@ -95,7 +95,7 @@ public class AutoRepeat {
StringBuilder sb = new StringBuilder();
sb.append("Changing selected state to: ");
sb.append(selected ? "SELECTED" : "NONE");
LogHelper.debug("AutoRepeat", sb.toString());
LogHelper.debug(AutoRepeat.class, sb.toString());
}
iView.setSelected(selected);
if (!onlyView) {
@ -107,7 +107,7 @@ public class AutoRepeat {
private static boolean shouldBeSelected() {
Context context = ReVancedUtils.getContext();
if (context == null) {
LogHelper.printException("AutoRepeat", "ChangeSelected - context is null!");
LogHelper.printException(AutoRepeat.class, "ChangeSelected - context is null!");
return false;
}
return SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_auto_repeat", false);
@ -121,7 +121,7 @@ public class AutoRepeat {
private static boolean shouldBeShown() {
Context context = ReVancedUtils.getContext();
if (context == null) {
LogHelper.printException("AutoRepeat", "ChangeSelected - context is null!");
LogHelper.printException(AutoRepeat.class, "ChangeSelected - context is null!");
return false;
}
return SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_auto_repeat_button", false);

View File

@ -29,26 +29,26 @@ public class VideoQuality {
Field[] fields;
if (!newVideo || userChangedQuality || qInterface == null) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && userChangedQuality) {
LogHelper.debug("VideoQuality", "Skipping quality change because user changed it: " + quality);
LogHelper.debug(VideoQuality.class, "Skipping quality change because user changed it: " + quality);
}
userChangedQuality = false;
return quality;
}
newVideo = false;
LogHelper.debug("VideoQuality", "Quality: " + quality);
LogHelper.debug(VideoQuality.class, "Quality: " + quality);
Context context = ReVancedUtils.getContext();
if (context == null) {
LogHelper.printException("VideoQuality", "Context is null or settings not initialized, returning quality: " + quality);
LogHelper.printException(VideoQuality.class, "Context is null or settings not initialized, returning quality: " + quality);
return quality;
}
if (Connectivity.isConnectedWifi(context)) {
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.getInt();
LogHelper.debug("VideoQuality", "Wi-Fi connection detected, preferred quality: " + preferredQuality);
LogHelper.debug(VideoQuality.class, "Wi-Fi connection detected, preferred quality: " + preferredQuality);
} else if (Connectivity.isConnectedMobile(context)) {
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.getInt();
LogHelper.debug("VideoQuality", "Mobile data connection detected, preferred quality: " + preferredQuality);
LogHelper.debug(VideoQuality.class, "Mobile data connection detected, preferred quality: " + preferredQuality);
} else {
LogHelper.debug("VideoQuality", "No Internet connection!");
LogHelper.debug(VideoQuality.class, "No Internet connection!");
return quality;
}
if (preferredQuality == -2) {
@ -72,7 +72,7 @@ public class VideoQuality {
Collections.sort(iStreamQualities);
int index = 0;
for (int streamQuality2 : iStreamQualities) {
LogHelper.debug("VideoQuality", "Quality at index " + index + ": " + streamQuality2);
LogHelper.debug(VideoQuality.class, "Quality at index " + index + ": " + streamQuality2);
index++;
}
for (Integer iStreamQuality : iStreamQualities) {
@ -85,15 +85,15 @@ public class VideoQuality {
return quality;
}
int qualityIndex = iStreamQualities.indexOf(quality);
LogHelper.debug("VideoQuality", "Index of quality " + quality + " is " + qualityIndex);
LogHelper.debug(VideoQuality.class, "Index of quality " + quality + " is " + qualityIndex);
try {
Class<?> cl = qInterface.getClass();
Method m = cl.getMethod("x", Integer.TYPE);
m.invoke(qInterface, iStreamQualities.get(qualityIndex));
LogHelper.debug("VideoQuality", "Quality changed to: " + qualityIndex);
LogHelper.debug(VideoQuality.class, "Quality changed to: " + qualityIndex);
return qualityIndex;
} catch (Exception ex) {
LogHelper.printException("VideoQuality", "Failed to set quality", ex);
LogHelper.printException(VideoQuality.class, "Failed to set quality", ex);
return qualityIndex;
}
}

View File

@ -24,9 +24,9 @@ public class VideoSpeed {
return speed;
}
newVideoSpeed = false;
LogHelper.debug("Settings - speeds", "Speed: " + speed);
LogHelper.debug(VideoSpeed.class, "Speed: " + speed);
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat();
LogHelper.debug("Settings", "Preferred speed: " + preferredSpeed);
LogHelper.debug(VideoSpeed.class, "Preferred speed: " + preferredSpeed);
if (preferredSpeed == -2.0f) {
return speed;
}
@ -50,18 +50,18 @@ public class VideoSpeed {
int index = 0;
while (it.hasNext()) {
float streamSpeed2 = it.next();
LogHelper.debug("Settings - speeds", "Speed at index " + index + ": " + streamSpeed2);
LogHelper.debug(VideoSpeed.class, "Speed at index " + index + ": " + streamSpeed2);
index++;
}
int speed3 = -1;
for (float streamSpeed3 : iStreamSpeeds) {
if (streamSpeed3 <= preferredSpeed) {
speed3++;
LogHelper.debug("Settings - speeds", "Speed loop at index " + speed3 + ": " + streamSpeed3);
LogHelper.debug(VideoSpeed.class, "Speed loop at index " + speed3 + ": " + streamSpeed3);
}
}
if (speed3 == -1) {
LogHelper.debug("Settings - speeds", "Speed was not found");
LogHelper.debug(VideoSpeed.class, "Speed was not found");
speed2 = 3;
} else {
speed2 = speed3;
@ -70,14 +70,14 @@ public class VideoSpeed {
Method[] declaredMethods = qInterface.getClass().getDeclaredMethods();
for (Method method : declaredMethods) {
if (method.getName().length() <= 2) {
LogHelper.debug("SPEED - Method", "Method name: " + method.getName());
LogHelper.debug(VideoSpeed.class, "Method name: " + method.getName());
try {
try {
method.invoke(qInterface, videoSpeeds[speed2]);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
} catch (Exception e6) {
e = e6;
LogHelper.printException("XDebug", e.getMessage());
LogHelper.printException(VideoSpeed.class, e.getMessage());
return speed2;
}
} catch (Exception ignored) {
@ -87,7 +87,7 @@ public class VideoSpeed {
} catch (Exception e10) {
e = e10;
}
LogHelper.debug("Settings", "Speed changed to: " + speed2);
LogHelper.debug(VideoSpeed.class, "Speed changed to: " + speed2);
return speed2;
}
@ -99,22 +99,22 @@ public class VideoSpeed {
public static void NewVideoStarted() {
newVideoSpeed = true;
LogHelper.debug("VideoSpeed", "New video started!");
LogHelper.debug(VideoSpeed.class, "New video started!");
}
public static float getSpeedValue(Object[] speeds, int speed) {
int i = 0;
if (!newVideoSpeed || userChangedSpeed) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && userChangedSpeed) {
LogHelper.debug("Settings - speeds", "Skipping speed change because user changed it: " + speed);
LogHelper.debug(VideoSpeed.class, "Skipping speed change because user changed it: " + speed);
}
userChangedSpeed = false;
return -1.0f;
}
newVideoSpeed = false;
LogHelper.debug("Settings - speeds", "Speed: " + speed);
LogHelper.debug(VideoSpeed.class, "Speed: " + speed);
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat();
LogHelper.debug("Settings", "Preferred speed: " + preferredSpeed);
LogHelper.debug(VideoSpeed.class, "Preferred speed: " + preferredSpeed);
if (preferredSpeed == -2.0f) {
return -1.0f;
}
@ -145,7 +145,7 @@ public class VideoSpeed {
int index = 0;
for (Float iStreamSpeed : iStreamSpeeds) {
float streamSpeed2 = iStreamSpeed;
LogHelper.debug("Settings - speeds", "Speed at index " + index + ": " + streamSpeed2);
LogHelper.debug(VideoSpeed.class, "Speed at index " + index + ": " + streamSpeed2);
index++;
}
int newSpeedIndex = -1;
@ -153,18 +153,18 @@ public class VideoSpeed {
float streamSpeed3 = iStreamSpeed;
if (streamSpeed3 <= preferredSpeed) {
newSpeedIndex++;
LogHelper.debug("Settings - speeds", "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
LogHelper.debug(VideoSpeed.class, "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
}
}
if (newSpeedIndex == -1) {
LogHelper.debug("Settings - speeds", "Speed was not found");
LogHelper.debug(VideoSpeed.class, "Speed was not found");
newSpeedIndex = 3;
}
if (newSpeedIndex == speed) {
LogHelper.debug("Settings", "Trying to set speed to what it already is, skipping...: " + newSpeedIndex);
LogHelper.debug(VideoSpeed.class, "Trying to set speed to what it already is, skipping...: " + newSpeedIndex);
return -1.0f;
}
LogHelper.debug("Settings", "Speed changed to: " + newSpeedIndex);
LogHelper.debug(VideoSpeed.class, "Speed changed to: " + newSpeedIndex);
return getSpeedByIndex(newSpeedIndex);
}

View File

@ -28,17 +28,17 @@ public class Copy {
public static void initializeCopyButton(Object obj) {
try {
LogHelper.debug("CopyButton", "initializing");
LogHelper.debug(Copy.class, "initializing");
_constraintLayout = (ConstraintLayout) obj;
isCopyButtonEnabled = shouldBeShown();
ImageView imageView = _constraintLayout.findViewById(getIdentifier("copy_button", "id"));
if (imageView == null) {
LogHelper.debug("CopyButton", "Couldn't find imageView with id \"copy_button\"");
LogHelper.debug(Copy.class, "Couldn't find imageView with id \"copy_button\"");
return;
}
imageView.setOnClickListener(view -> {
LogHelper.debug("CopyButton", "Button clicked");
LogHelper.debug(Copy.class, "Button clicked");
VideoHelpers.copyVideoUrlToClipboard();
});
_button = new WeakReference<>(imageView);
@ -54,7 +54,7 @@ public class Copy {
changeVisibility(false);
} catch (Exception e) {
LogHelper.printException("CopyButton", "Unable to set FrameLayout", e);
LogHelper.printException(Copy.class, "Unable to set FrameLayout", e);
}
}
@ -64,11 +64,11 @@ public class Copy {
ImageView imageView = _button.get();
if (_constraintLayout != null && imageView != null) {
if (z && isCopyButtonEnabled) {
LogHelper.debug("CopyButton", "Fading in");
LogHelper.debug(Copy.class, "Fading in");
imageView.setVisibility(View.VISIBLE);
imageView.startAnimation(fadeIn);
} else if (imageView.getVisibility() == View.VISIBLE) {
LogHelper.debug("CopyButton", "Fading out");
LogHelper.debug(Copy.class, "Fading out");
imageView.startAnimation(fadeOut);
imageView.setVisibility(View.GONE);
}
@ -83,7 +83,7 @@ public class Copy {
private static boolean shouldBeShown() {
Context appContext = ReVancedUtils.getContext();
if (appContext == null) {
LogHelper.printException("CopyButton", "shouldBeShown - context is null!");
LogHelper.printException(Copy.class, "shouldBeShown - context is null!");
return false;
}
String string = SharedPrefHelper.getString(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_copy_video_url_button_list", null);

View File

@ -29,18 +29,18 @@ public class CopyWithTimeStamp {
public static void initializeCopyButtonWithTimeStamp(Object obj) {
try {
LogHelper.debug("CopyButtonWithTimeStamp", "initializing");
LogHelper.debug(CopyWithTimeStamp.class, "initializing");
_constraintLayout = (ConstraintLayout) obj;
isCopyButtonWithTimeStampEnabled = shouldBeShown();
ImageView imageView = (ImageView) _constraintLayout.findViewById(getIdentifier("copy_with_timestamp_button", "id"));
if (imageView == null) {
LogHelper.debug("CopyButtonWithTimeStamp", "Couldn't find imageView with id \"copy_with_timestamp_button\"");
LogHelper.debug(CopyWithTimeStamp.class, "Couldn't find imageView with id \"copy_with_timestamp_button\"");
}
if (imageView != null) {
imageView.setOnClickListener(new View.OnClickListener() { // from class: app.revanced.integrations.videoplayer.VideoUrl.CopyWithTimeStamp.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
LogHelper.debug("CopyButtonWithTimeStamp", "Button clicked");
LogHelper.debug(CopyWithTimeStamp.class, "Button clicked");
VideoHelpers.copyVideoUrlWithTimeStampToClipboard();
}
});
@ -57,7 +57,7 @@ public class CopyWithTimeStamp {
changeVisibility(false);
}
} catch (Exception e) {
LogHelper.printException("CopyButtonWithTimeStamp", "Unable to set FrameLayout", e);
LogHelper.printException(CopyWithTimeStamp.class, "Unable to set FrameLayout", e);
}
}
@ -67,11 +67,11 @@ public class CopyWithTimeStamp {
ImageView imageView = _button.get();
if (_constraintLayout != null && imageView != null) {
if (z && isCopyButtonWithTimeStampEnabled) {
LogHelper.debug("CopyButtonWithTimeStamp", "Fading in");
LogHelper.debug(CopyWithTimeStamp.class, "Fading in");
imageView.setVisibility(View.VISIBLE);
imageView.startAnimation(fadeIn);
} else if (imageView.getVisibility() == View.VISIBLE) {
LogHelper.debug("CopyButtonWithTimeStamp", "Fading out");
LogHelper.debug(CopyWithTimeStamp.class, "Fading out");
imageView.startAnimation(fadeOut);
imageView.setVisibility(View.GONE);
}
@ -86,7 +86,7 @@ public class CopyWithTimeStamp {
private static boolean shouldBeShown() {
Context appContext = ReVancedUtils.getContext();
if (appContext == null) {
LogHelper.printException("CopyButtonWithTimeStamp", "shouldBeShown - context is null!");
LogHelper.printException(CopyWithTimeStamp.class, "shouldBeShown - context is null!");
return false;
}

View File

@ -20,27 +20,27 @@ public class SwipeControlAPI {
public static void InitializeFensterController(Context context, ViewGroup viewGroup, ViewConfiguration viewConfiguration) {
swipeGestureController = new SwipeGestureController();
swipeGestureController.setFensterEventsListener(new XSwipe(context, viewGroup), context, viewConfiguration);
LogHelper.debug("Settings", "XFenster initialized");
swipeGestureController.setFensterEventsListener(new SwipeListener(context, viewGroup), context, viewConfiguration);
LogHelper.debug(SwipeControlAPI.class, "XFenster initialized");
}
public static boolean FensterTouchEvent(MotionEvent motionEvent) {
if (swipeGestureController == null) {
LogHelper.debug("Settings", "fensterGestureController is null");
LogHelper.debug(SwipeControlAPI.class, "fensterGestureController is null");
return false;
} else if (motionEvent == null) {
LogHelper.debug("Settings", "motionEvent is null");
LogHelper.debug(SwipeControlAPI.class, "motionEvent is null");
return false;
} else if (!SwipeHelper.IsControlsShown()) {
return swipeGestureController.onTouchEvent(motionEvent);
} else {
LogHelper.debug("Settings", "skipping onTouchEvent dispatching because controls are shown.");
LogHelper.debug(SwipeControlAPI.class, "skipping onTouchEvent dispatching because controls are shown.");
return false;
}
}
public static void PlayerTypeChanged(PlayerType playerType) {
LogHelper.debug("XDebug", playerType.toString());
LogHelper.debug(SwipeControlAPI.class, playerType.toString());
if (ReVancedUtils.getPlayerType() != playerType) {
if (playerType == PlayerType.WATCH_WHILE_FULLSCREEN) {
EnableSwipeControl();
@ -60,14 +60,14 @@ public class SwipeControlAPI {
if (SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() || SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean()) {
SwipeGestureController swipeGestureController2 = swipeGestureController;
swipeGestureController2.TouchesEnabled = true;
((XSwipe) swipeGestureController2.listener).enable(SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean(), SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean());
((SwipeListener) swipeGestureController2.listener).enable(SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean(), SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getBoolean());
}
}
private static void DisableSwipeControl() {
SwipeGestureController swipeGestureController2 = swipeGestureController;
swipeGestureController2.TouchesEnabled = false;
((XSwipe) swipeGestureController2.listener).disable();
((SwipeListener) swipeGestureController2.listener).disable();
}
}

View File

@ -19,7 +19,7 @@ public class SwipeGestureController {
}
if (event.getAction() == 1) {
this.listener.onUp();
LogHelper.debug("TouchTest", "Touch up");
LogHelper.debug(SwipeGestureController.class, "Touch up");
}
return this.gestureDetector.onTouchEvent(event);
}

View File

@ -27,22 +27,22 @@ public class SwipeGestureListener implements GestureDetector.OnGestureListener {
@Override // android.view.GestureDetector.OnGestureListener
public void onLongPress(MotionEvent e) {
LogHelper.debug("FensterGestureListener", "Long Press");
LogHelper.debug(SwipeGestureListener.class, "Long Press");
}
@Override // android.view.GestureDetector.OnGestureListener
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
LogHelper.debug("FensterGestureListener", "Scroll");
LogHelper.debug(SwipeGestureListener.class, "Scroll");
if (e1 == null || e2 == null) {
if (e1 == null) {
LogHelper.debug("XDebug", "e1 is null");
LogHelper.debug(SwipeGestureListener.class, "e1 is null");
}
if (e2 == null) {
LogHelper.debug("XDebug", "e2 is null");
LogHelper.debug(SwipeGestureListener.class, "e2 is null");
}
return false;
} else if (this.ignoreScroll) {
LogHelper.debug("FensterGestureListener", "Scroll ignored");
LogHelper.debug(SwipeGestureListener.class, "Scroll ignored");
return false;
} else {
float deltaY = e2.getY() - e1.getY();
@ -51,12 +51,12 @@ public class SwipeGestureListener implements GestureDetector.OnGestureListener {
if (Math.abs(deltaX) > SWIPE_THRESHOLD) {
this.listener.onHorizontalScroll(e2, deltaX);
String message = deltaX > 0.0f ? "Slide right" : "Slide left";
LogHelper.debug("FensterGestureListener", message);
LogHelper.debug(SwipeGestureListener.class, message);
}
} else if (Math.abs(deltaY) > SWIPE_THRESHOLD) {
this.listener.onVerticalScroll(e2, deltaY);
String message = deltaY > 0.0f ? "Slide down" : "Slide up";
LogHelper.debug("FensterGestureListener", message);
LogHelper.debug(SwipeGestureListener.class, message);
}
return false;
}
@ -64,7 +64,7 @@ public class SwipeGestureListener implements GestureDetector.OnGestureListener {
@Override // android.view.GestureDetector.OnGestureListener
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
LogHelper.debug("FensterGestureListener", "Fling");
LogHelper.debug(SwipeGestureListener.class, "Fling");
try {
float diffY = e2.getY() - e1.getY();
float diffX = e2.getX() - e1.getX();
@ -92,12 +92,12 @@ public class SwipeGestureListener implements GestureDetector.OnGestureListener {
@Override // android.view.GestureDetector.OnGestureListener
public void onShowPress(MotionEvent e) {
LogHelper.debug("FensterGestureListener", "Show Press");
LogHelper.debug(SwipeGestureListener.class, "Show Press");
}
@Override // android.view.GestureDetector.OnGestureListener
public boolean onDown(MotionEvent e) {
LogHelper.debug("FensterGestureListener", "Down - x: " + e.getX() + " y: " + e.getY());
LogHelper.debug(SwipeGestureListener.class, "Down - x: " + e.getX() + " y: " + e.getY());
this.ignoreScroll = e.getY() <= TOP_PADDING;
this.listener.onDown(e);
return false;

View File

@ -15,7 +15,7 @@ import app.revanced.integrations.utils.SwipeHelper;
import app.revanced.integrations.settingsmenu.ReVancedSettingsFragment;
/* loaded from: classes6.dex */
public class XSwipe implements SwipeEventsListener {
public class SwipeListener implements SwipeEventsListener {
public static final int ONE_FINGER = 1;
Handler handler;
float mBrightnessDownPos;
@ -35,7 +35,7 @@ public class XSwipe implements SwipeEventsListener {
BrightnessSeekBar mBrightness = new BrightnessSeekBar();
VolumeSeekBar mVolume = new VolumeSeekBar();
public XSwipe(Context context, ViewGroup viewGroup) {
public SwipeListener(Context context, ViewGroup viewGroup) {
this.mViewGroup = viewGroup;
this.mBrightness.initialise(context, viewGroup);
this.mVolume.initialise(context, viewGroup);
@ -43,12 +43,12 @@ public class XSwipe implements SwipeEventsListener {
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onTap() {
LogHelper.debug("XDebug", "onTap");
LogHelper.debug(SwipeListener.class, "onTap");
}
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onHorizontalScroll(MotionEvent event, float delta) {
LogHelper.debug("XDebug", "onHorizontalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
LogHelper.debug(SwipeListener.class, "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);
@ -64,7 +64,7 @@ public class XSwipe implements SwipeEventsListener {
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onVerticalScroll(MotionEvent event, float delta) {
LogHelper.debug("XDebug", "onVerticalScroll - y: " + ((int) event.getY()) + " x: " + ((int) event.getX()));
LogHelper.debug(SwipeListener.class, "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);
@ -80,27 +80,27 @@ public class XSwipe implements SwipeEventsListener {
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onSwipeRight() {
LogHelper.debug("XDebug", "onSwipeRight");
LogHelper.debug(SwipeListener.class, "onSwipeRight");
}
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onSwipeLeft() {
LogHelper.debug("XDebug", "onSwipeLeft");
LogHelper.debug(SwipeListener.class, "onSwipeLeft");
}
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onSwipeBottom() {
LogHelper.debug("XDebug", "onSwipeBottom");
LogHelper.debug(SwipeListener.class, "onSwipeBottom");
}
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onSwipeTop() {
LogHelper.debug("XDebug", "onSwipeTop");
LogHelper.debug(SwipeListener.class, "onSwipeTop");
}
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onDown(MotionEvent event) {
LogHelper.debug("XDebug", "onDown");
LogHelper.debug(SwipeListener.class, "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);
@ -121,7 +121,7 @@ public class XSwipe implements SwipeEventsListener {
@Override // app.revanced.integrations.videoplayer.Fenster.FensterEventsListener
public void onUp() {
LogHelper.debug("XDebug", "onUp");
LogHelper.debug(SwipeListener.class, "onUp");
hideNotifications();
}
@ -152,8 +152,8 @@ public class XSwipe implements SwipeEventsListener {
// from class: app.revanced.integrations.videoplayer.Fenster.XFenster.1
// java.lang.Runnable
this.handler.postDelayed(() -> {
XSwipe.this.mVolume.hide();
XSwipe.this.mBrightness.hide();
SwipeListener.this.mVolume.hide();
SwipeListener.this.mBrightness.hide();
}, 2000L);
}
@ -201,20 +201,20 @@ public class XSwipe implements SwipeEventsListener {
private float getProgressVertical(MotionEvent event, int maxSteps) {
float progress = calculateProgressVertical(event, maxSteps);
LogHelper.debug("XDebug", "Progress vertical: " + progress);
LogHelper.debug(SwipeListener.class, "Progress vertical: " + progress);
return progress;
}
private float getProgressHorizontal(MotionEvent event, int maxSteps) {
float progress = calculateProgressHorizontal(event, maxSteps);
LogHelper.debug("XDebug", "Progress horizontal: " + progress);
LogHelper.debug(SwipeListener.class, "Progress horizontal: " + progress);
return progress;
}
private float calculateProgressVertical(MotionEvent event, int maxSteps) {
float scale;
int height = this.mViewGroup.getHeight();
LogHelper.debug("XDebug", "calculateProgressVertical - height: " + height);
LogHelper.debug(SwipeListener.class, "calculateProgressVertical - height: " + height);
int available = (height - this.mPaddingTop) - this.mPaddingBottom;
int y = height - ((int) event.getY());
float progress = 0.0f;
@ -266,13 +266,13 @@ public class XSwipe implements SwipeEventsListener {
this.mViewGroup = (ViewGroup) layout;
this.mBrightness.refreshViewGroup(this.mViewGroup, ReVancedSettingsFragment.overlayContext);
this.mVolume.refreshViewGroup(this.mViewGroup);
LogHelper.debug("Settings", "player_overlays refreshed");
LogHelper.debug(SwipeListener.class, "player_overlays refreshed");
} else {
LogHelper.debug("Settings", "player_overlays was not found");
LogHelper.debug(SwipeListener.class, "player_overlays was not found");
}
}
} catch (Exception ex) {
LogHelper.printException("XError", "Unable to refresh player_overlays layout", ex);
LogHelper.printException(SwipeListener.class, "Unable to refresh player_overlays layout", ex);
}
}

View File

@ -26,7 +26,7 @@ public class BrightnessHelper {
}
public static void setBrightness(Context context, int brightness) {
LogHelper.debug("XDebug", "Setting brightness: " + brightness);
LogHelper.debug(BrightnessHelper.class, "Setting brightness: " + brightness);
float bright = brightness / 100.0f;
WindowManager.LayoutParams lp = ((Activity) context).getWindow().getAttributes();
lp.screenBrightness = bright;
@ -34,7 +34,7 @@ public class BrightnessHelper {
}
public static void setBrightness2(Context context, int brightness) {
LogHelper.debug("XDebug", "Setting brightness: " + brightness);
LogHelper.debug(BrightnessHelper.class, "Setting brightness: " + brightness);
ContentResolver cResolver = context.getContentResolver();
android.provider.Settings.System.putInt(cResolver, "screen_brightness", brightness);
}

View File

@ -59,7 +59,7 @@ public class BrightnessSeekBar {
this.mTextView.setVisibility(View.VISIBLE);
}
}
LogHelper.debug("XDebug", "updateBrightnessProgress: " + this.Progress);
LogHelper.debug(BrightnessSeekBar.class, "updateBrightnessProgress: " + this.Progress);
}
private void disableBrightness() {
@ -113,7 +113,7 @@ public class BrightnessSeekBar {
this.enabled = false;
SharedPrefHelper.saveInt(this.mContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"revanced_brightness_value", Integer.valueOf(this.Progress));
disableBrightness();
LogHelper.debug("XDebug", "Brightness swipe disabled");
LogHelper.debug(BrightnessSeekBar.class, "Brightness swipe disabled");
}
public void enable() {
@ -127,6 +127,6 @@ public class BrightnessSeekBar {
brightness = 100;
}
BrightnessHelper.setBrightness(this.mContext, brightness);
LogHelper.debug("XDebug", "Brightness swipe enabled");
LogHelper.debug(BrightnessSeekBar.class, "Brightness swipe enabled");
}
}

View File

@ -63,7 +63,7 @@ public class VolumeSeekBar {
this.mTextView.setVisibility(View.VISIBLE);
}
}
LogHelper.debug("XDebug", "updateVolumeProgress: " + this.Progress);
LogHelper.debug(VolumeSeekBar.class, "updateVolumeProgress: " + this.Progress);
}
private void setVolume(int volume) {

View File

@ -62,7 +62,6 @@
Default: 5000"</string>
<string name="revanced_rebuffer_title">Rebuffer</string>
<string name="revanced_settings">Vanced settings</string>
<string name="revanced_software_hdr_summary">Tap to enable software HDR</string>
<string name="revanced_software_hdr_title" translatable="false">Google Pixel XL</string>
<string name="revanced_suggestion_summary_off">End screens are hidden</string>

View File

@ -1,9 +0,0 @@
<Preference android:title="@string/revanced_ryd_settings_title" android:summary="@string/revanced_ryd_settings_summary">
<intent android:targetPackage="com.revanced.android.youtube" android:data="ryd_settings" android:targetClass="app.revanced.integrations.settingsmenu.XSettingActivity" />
</Preference>
<Preference android:title="@string/sb_settings" android:summary="@string/sb_summary">
<intent android:targetPackage="com.revanced.android.youtube" android:data="sponsorblock_settings" android:targetClass="app.revanced.integrations.settingsmenu.XSettingActivity" />
</Preference>
<Preference android:title="@string/revanced_settings">
<intent android:targetPackage="com.revanced.android.youtube" android:data="revanced_settings" android:targetClass="app.revanced.integrations.settingsmenu.XSettingActivity" />
</Preference>