mirror of
https://github.com/revanced/revanced-integrations
synced 2024-11-16 22:50:31 +01:00
refactor: improve logging (#222)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
1351358268
commit
617a4eb5d0
@ -35,7 +35,7 @@ public class AdRemoverAPI {
|
||||
ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1);
|
||||
view.setLayoutParams(layoutParams5);
|
||||
} else {
|
||||
LogHelper.debug(AdRemoverAPI.class, "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
|
||||
LogHelper.printDebug(() -> "HideViewWithLayout1dp - Id: " + view.getId() + " Type: " + view.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,13 @@ final class ButtonsPatch extends Filter {
|
||||
|
||||
if (currentIsActionButton && ActionButton.doNotBlockCounter-- > 0) {
|
||||
if (SettingsEnum.HIDE_SHARE_BUTTON.getBoolean()) {
|
||||
LogHelper.debug(ButtonsPatch.class, "Hiding share button");
|
||||
LogHelper.printDebug(() -> "Hiding share button");
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
if ((currentIsActionButton && ActionButton.doNotBlockCounter <= 0 && actionButtonsRule.isEnabled()) || pathRegister.contains(path)) {
|
||||
LogHelper.debug(ButtonsPatch.class, "Blocked: " + path);
|
||||
LogHelper.printDebug(() -> "Blocked: " + path);
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ final class CommentsPatch extends Filter {
|
||||
boolean filter(String path, String _identifier) {
|
||||
if (!pathRegister.contains(path)) return false;
|
||||
|
||||
LogHelper.debug(CommentsPatch.class, "Blocked: " + path);
|
||||
LogHelper.printDebug(() -> "Blocked: " + path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public final class FixPlaybackPatch {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
LogHelper.debug(FixPlaybackPatch.class, "Thread was interrupted");
|
||||
LogHelper.printDebug(() -> "Thread was interrupted");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -168,6 +168,6 @@ public final class GeneralAdsPatch extends Filter {
|
||||
}
|
||||
|
||||
private static void log(String message) {
|
||||
LogHelper.debug(GeneralAdsPatch.class, message);
|
||||
LogHelper.printDebug(() -> message);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class HideCreateButtonPatch {
|
||||
public static void hideCreateButton(View view) {
|
||||
boolean enabled = SettingsEnum.CREATE_BUTTON_ENABLED.getBoolean();
|
||||
String message = "Create button: " + (enabled ? "shown" : "hidden");
|
||||
LogHelper.debug(HideCreateButtonPatch.class, message);
|
||||
LogHelper.printDebug(() -> message);
|
||||
view.setVisibility(enabled ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package app.revanced.integrations.patches;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import app.revanced.integrations.adremover.AdRemoverAPI;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
|
||||
@ -14,7 +13,7 @@ public class HideShortsButtonPatch {
|
||||
if (lastPivotTab != null && lastPivotTab.name() == "TAB_SHORTS") {
|
||||
boolean show = SettingsEnum.SHORTS_BUTTON_SHOWN.getBoolean();
|
||||
String message = show ? "Shorts button: shown" : "Shorts button: hidden";
|
||||
LogHelper.debug(HideShortsButtonPatch.class, message);
|
||||
LogHelper.printDebug(() -> message);
|
||||
if (!show) {
|
||||
view.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public final class LithoFilterPatch {
|
||||
var path = pathBuilder.toString();
|
||||
if (path.isEmpty()) return false;
|
||||
|
||||
LogHelper.debug(LithoFilterPatch.class, String.format("Searching (ID: %s): %s", identifier, path));
|
||||
LogHelper.printDebug(() -> String.format("Searching (ID: %s): %s", identifier, path));
|
||||
|
||||
for (var filter : filters) {
|
||||
if (filter.filter(path, identifier)) return true;
|
||||
|
@ -20,9 +20,9 @@ public class MicroGSupport {
|
||||
assert context != null;
|
||||
try {
|
||||
context.getPackageManager().getPackageInfo(MICROG_PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
|
||||
LogHelper.debug(ReVancedUtils.class, "MicroG is installed on the device");
|
||||
LogHelper.printDebug(() -> "MicroG is installed on the device");
|
||||
} catch (PackageManager.NameNotFoundException exception) {
|
||||
LogHelper.printException(ReVancedUtils.class, "MicroG was not found", exception);
|
||||
LogHelper.printException(() -> ("MicroG was not found"), exception);
|
||||
Toast.makeText(context, str("microg_not_installed_warning"), Toast.LENGTH_LONG).show();
|
||||
|
||||
var intent = new Intent(Intent.ACTION_VIEW);
|
||||
|
@ -26,7 +26,7 @@ public class PlayerTypeHookPatch {
|
||||
final PlayerType newType = PlayerType.safeParseFromString(type.toString());
|
||||
if (newType != null) {
|
||||
PlayerType.setCurrent(newType);
|
||||
LogHelper.debug(PlayerTypeHookPatch.class, "YouTubePlayerOverlaysLayout player type was updated to " + newType);
|
||||
LogHelper.printDebug(() -> "YouTubePlayerOverlaysLayout player type was updated to " + newType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public final class VideoInformation {
|
||||
seekMethod = thisRef.getClass().getMethod(SEEK_METHOD_NAME, Long.TYPE);
|
||||
seekMethod.setAccessible(true);
|
||||
} catch (NoSuchMethodException ex) {
|
||||
LogHelper.debug(VideoInformation.class, "Failed to initialize: " + ex.getMessage());
|
||||
LogHelper.printDebug(() -> "Failed to initialize: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public final class VideoInformation {
|
||||
* @param length The length of the video in milliseconds.
|
||||
*/
|
||||
public static void setVideoLength(final long length) {
|
||||
LogHelper.debug(VideoInformation.class, "Setting current video length to " + length);
|
||||
LogHelper.printDebug(() -> "Setting current video length to " + length);
|
||||
videoLength = length;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public final class VideoInformation {
|
||||
* @param time The time of the video in milliseconds.
|
||||
*/
|
||||
public static void setVideoTime(final long time) {
|
||||
LogHelper.debug(VideoInformation.class, "Current video time " + time);
|
||||
LogHelper.printDebug(() -> "Current video time " + time);
|
||||
videoTime = time;
|
||||
}
|
||||
|
||||
@ -67,15 +67,15 @@ public final class VideoInformation {
|
||||
public static void seekTo(final long millisecond) {
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
if (seekMethod == null) {
|
||||
LogHelper.debug(VideoInformation.class, "seekMethod was null");
|
||||
LogHelper.printDebug(() -> "seekMethod was null");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
LogHelper.debug(VideoInformation.class, "Seeking to " + millisecond);
|
||||
LogHelper.printDebug(() -> "Seeking to " + millisecond);
|
||||
seekMethod.invoke(playerController.get(), millisecond);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.debug(VideoInformation.class, "Failed to seek: " + ex.getMessage());
|
||||
LogHelper.printDebug(() -> "Failed to seek: " + ex.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ public class VideoSpeedPatch {
|
||||
return speed;
|
||||
}
|
||||
ReVancedUtils.setNewVideo(false);
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed: " + speed);
|
||||
LogHelper.printDebug(() -> "Speed: " + speed);
|
||||
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Preferred speed: " + preferredSpeed);
|
||||
LogHelper.printDebug(() -> "Preferred speed: " + preferredSpeed);
|
||||
if (preferredSpeed == -2.0f) {
|
||||
return speed;
|
||||
}
|
||||
@ -48,18 +48,20 @@ public class VideoSpeedPatch {
|
||||
int index = 0;
|
||||
while (it.hasNext()) {
|
||||
float streamSpeed2 = it.next();
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed at index " + index + ": " + streamSpeed2);
|
||||
final int logIndex = index;
|
||||
LogHelper.printDebug(() -> "Speed at index " + logIndex + ": " + streamSpeed2);
|
||||
index++;
|
||||
}
|
||||
int speed3 = -1;
|
||||
for (float streamSpeed3 : iStreamSpeeds) {
|
||||
if (streamSpeed3 <= preferredSpeed) {
|
||||
speed3++;
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed loop at index " + speed3 + ": " + streamSpeed3);
|
||||
final int speed3ToLog = speed3;
|
||||
LogHelper.printDebug(() -> "Speed loop at index " + speed3ToLog + ": " + streamSpeed3);
|
||||
}
|
||||
}
|
||||
if (speed3 == -1) {
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed was not found");
|
||||
LogHelper.printDebug(() -> "Speed was not found");
|
||||
speed2 = 3;
|
||||
} else {
|
||||
speed2 = speed3;
|
||||
@ -68,14 +70,13 @@ public class VideoSpeedPatch {
|
||||
Method[] declaredMethods = qInterface.getClass().getDeclaredMethods();
|
||||
for (Method method : declaredMethods) {
|
||||
if (method.getName().length() <= 2) {
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Method name: " + method.getName());
|
||||
LogHelper.printDebug(() -> "Method name: " + method.getName());
|
||||
try {
|
||||
try {
|
||||
method.invoke(qInterface, videoSpeeds[speed2]);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
|
||||
} catch (Exception e6) {
|
||||
e = e6;
|
||||
LogHelper.printException(VideoSpeedPatch.class, e.getMessage());
|
||||
} catch (final Exception e6) {
|
||||
LogHelper.printException(() -> (e6.getMessage()));
|
||||
return speed2;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
@ -85,7 +86,7 @@ public class VideoSpeedPatch {
|
||||
} catch (Exception e10) {
|
||||
e = e10;
|
||||
}
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed changed to: " + speed2);
|
||||
LogHelper.printDebug(() -> "Speed changed to: " + speed2);
|
||||
return speed2;
|
||||
}
|
||||
|
||||
@ -97,15 +98,15 @@ public class VideoSpeedPatch {
|
||||
int i = 0;
|
||||
if (!ReVancedUtils.isNewVideoStarted() || userChangedSpeed) {
|
||||
if (SettingsEnum.DEBUG.getBoolean() && userChangedSpeed) {
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Skipping speed change because user changed it: " + speed);
|
||||
LogHelper.printDebug(() -> "Skipping speed change because user changed it: " + speed);
|
||||
}
|
||||
userChangedSpeed = false;
|
||||
return -1.0f;
|
||||
}
|
||||
ReVancedUtils.setNewVideo(false);
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed: " + speed);
|
||||
LogHelper.printDebug(() -> "Speed: " + speed);
|
||||
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Preferred speed: " + preferredSpeed);
|
||||
LogHelper.printDebug(() -> "Preferred speed: " + preferredSpeed);
|
||||
if (preferredSpeed == -2.0f) {
|
||||
return -1.0f;
|
||||
}
|
||||
@ -136,7 +137,8 @@ public class VideoSpeedPatch {
|
||||
int index = 0;
|
||||
for (Float iStreamSpeed : iStreamSpeeds) {
|
||||
float streamSpeed2 = iStreamSpeed;
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed at index " + index + ": " + streamSpeed2);
|
||||
final int indexToLog = index;
|
||||
LogHelper.printDebug(() -> "Speed at index " + indexToLog + ": " + streamSpeed2);
|
||||
index++;
|
||||
}
|
||||
int newSpeedIndex = -1;
|
||||
@ -144,18 +146,21 @@ public class VideoSpeedPatch {
|
||||
float streamSpeed3 = iStreamSpeed;
|
||||
if (streamSpeed3 <= preferredSpeed) {
|
||||
newSpeedIndex++;
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
|
||||
final int newSpeedIndexToLog = newSpeedIndex;
|
||||
LogHelper.printDebug(() -> "Speed loop at index " + newSpeedIndexToLog + ": " + streamSpeed3);
|
||||
}
|
||||
}
|
||||
if (newSpeedIndex == -1) {
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed was not found");
|
||||
LogHelper.printDebug(() -> "Speed was not found");
|
||||
newSpeedIndex = 3;
|
||||
}
|
||||
if (newSpeedIndex == speed) {
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Trying to set speed to what it already is, skipping...: " + newSpeedIndex);
|
||||
final int newSpeedIndexToLog = newSpeedIndex;
|
||||
LogHelper.printDebug(() -> "Trying to set speed to what it already is, skipping...: " + newSpeedIndexToLog);
|
||||
return -1.0f;
|
||||
}
|
||||
LogHelper.debug(VideoSpeedPatch.class, "Speed changed to: " + newSpeedIndex);
|
||||
final int newSpeedIndexToLog = newSpeedIndex;
|
||||
LogHelper.printDebug(() -> "Speed changed to: " + newSpeedIndexToLog);
|
||||
return getSpeedByIndex(newSpeedIndex);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ public class DownloadsPatch {
|
||||
* @param videoId The current video id
|
||||
*/
|
||||
public static void setVideoId(String videoId) {
|
||||
LogHelper.debug(DownloadsPatch.class, "newVideoLoaded - " + videoId);
|
||||
LogHelper.printDebug(() -> "newVideoLoaded - " + videoId);
|
||||
|
||||
DownloadsPatch.videoId = videoId;
|
||||
}
|
||||
|
@ -15,14 +15,14 @@ public class OldQualityLayoutPatch {
|
||||
listView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
|
||||
@Override
|
||||
public void onChildViewAdded(View parent, View child) {
|
||||
LogHelper.debug(OldQualityLayoutPatch.class, "Added: " + child);
|
||||
LogHelper.printDebug(() -> "Added: " + child);
|
||||
|
||||
parent.setVisibility(View.GONE);
|
||||
|
||||
final var indexOfAdvancedQualityMenuItem = 4;
|
||||
if (listView.indexOfChild(child) != indexOfAdvancedQualityMenuItem) return;
|
||||
|
||||
LogHelper.debug(OldQualityLayoutPatch.class, "Found advanced menu: " + child);
|
||||
LogHelper.printDebug(() -> "Found advanced menu: " + child);
|
||||
|
||||
final var qualityItemMenuPosition = 4;
|
||||
listView.performItemClick(null, qualityItemMenuPosition, 0);
|
||||
|
@ -27,22 +27,22 @@ public class RememberVideoQualityPatch {
|
||||
try {
|
||||
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", defaultQuality + "");
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(RememberVideoQualityPatch.class, "Failed to change default WI-FI quality:" + ex);
|
||||
LogHelper.printException(() -> ("Failed to change default WI-FI quality:" + ex));
|
||||
Toast.makeText(context, "Failed to change default WI-FI quality:", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Changing default Wi-Fi quality to: " + defaultQuality);
|
||||
LogHelper.printDebug(() -> "Changing default Wi-Fi quality to: " + defaultQuality);
|
||||
Toast.makeText(context, "Changing default Wi-Fi quality to: " + defaultQuality, Toast.LENGTH_SHORT).show();
|
||||
} else if (isConnectedMobile(context)) {
|
||||
try {
|
||||
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", defaultQuality + "");
|
||||
} catch (Exception ex) {
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Failed to change default mobile data quality" + ex);
|
||||
LogHelper.printDebug(() -> "Failed to change default mobile data quality" + ex);
|
||||
Toast.makeText(context, "Failed to change default mobile data quality", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Changing default mobile data quality to:" + defaultQuality);
|
||||
LogHelper.printDebug(() -> "Changing default mobile data quality to:" + defaultQuality);
|
||||
Toast.makeText(context, "Changing default mobile data quality to:" + defaultQuality, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "No internet connection.");
|
||||
LogHelper.printDebug(() -> "No internet connection.");
|
||||
Toast.makeText(context, "No internet connection.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
userChangedQuality = false;
|
||||
@ -76,34 +76,37 @@ public class RememberVideoQualityPatch {
|
||||
int selectedQuality2 = qualities.length - selectedQuality1 + 1;
|
||||
index++;
|
||||
if (selectedQuality2 == index) {
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Quality index is: " + index + " and corresponding value is: " + convertedQuality);
|
||||
final int indexToLog = index; // must be final for lambda
|
||||
LogHelper.printDebug(() -> "Quality index is: " + indexToLog + " and corresponding value is: " + convertedQuality);
|
||||
changeDefaultQuality(convertedQuality);
|
||||
return selectedQuality2;
|
||||
}
|
||||
}
|
||||
}
|
||||
newVideo = false;
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Quality: " + quality);
|
||||
final int qualityToLog = quality;
|
||||
LogHelper.printDebug(() -> "Quality: " + qualityToLog);
|
||||
Context context = ReVancedUtils.getContext();
|
||||
if (context == null) {
|
||||
LogHelper.printException(RememberVideoQualityPatch.class, "Context is null or settings not initialized, returning quality: " + quality);
|
||||
LogHelper.printException(() -> ("Context is null or settings not initialized, returning quality: " + qualityToLog));
|
||||
return quality;
|
||||
}
|
||||
if (isConnectedWifi(context)) {
|
||||
preferredQuality = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", -2);
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Wi-Fi connection detected, preferred quality: " + preferredQuality);
|
||||
LogHelper.printDebug(() -> "Wi-Fi connection detected, preferred quality: " + preferredQuality);
|
||||
} else if (isConnectedMobile(context)) {
|
||||
preferredQuality = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", -2);
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Mobile data connection detected, preferred quality: " + preferredQuality);
|
||||
LogHelper.printDebug(() -> "Mobile data connection detected, preferred quality: " + preferredQuality);
|
||||
} else {
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "No Internet connection!");
|
||||
LogHelper.printDebug(() -> "No Internet connection!");
|
||||
return quality;
|
||||
}
|
||||
if (preferredQuality == -2) {
|
||||
return quality;
|
||||
}
|
||||
for (int streamQuality2 : iStreamQualities) {
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Quality at index " + index + ": " + streamQuality2);
|
||||
final int indexToLog = index;
|
||||
LogHelper.printDebug(() -> "Quality at index " + indexToLog + ": " + streamQuality2);
|
||||
index++;
|
||||
}
|
||||
for (Integer iStreamQuality : iStreamQualities) {
|
||||
@ -116,16 +119,17 @@ public class RememberVideoQualityPatch {
|
||||
return quality;
|
||||
}
|
||||
int qualityIndex = iStreamQualities.indexOf(quality);
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Index of quality " + quality + " is " + qualityIndex);
|
||||
final int qualityToLog2 = quality;
|
||||
LogHelper.printDebug(() -> "Index of quality " + qualityToLog2 + " is " + qualityIndex);
|
||||
try {
|
||||
Class<?> cl = qInterface.getClass();
|
||||
Method m = cl.getMethod(qIndexMethod, Integer.TYPE);
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Method is: " + qIndexMethod);
|
||||
LogHelper.printDebug(() -> "Method is: " + qIndexMethod);
|
||||
m.invoke(qInterface, iStreamQualities.get(qualityIndex));
|
||||
LogHelper.debug(RememberVideoQualityPatch.class, "Quality changed to: " + qualityIndex);
|
||||
LogHelper.printDebug(() -> "Quality changed to: " + qualityIndex);
|
||||
return qualityIndex;
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(RememberVideoQualityPatch.class, "Failed to set quality", ex);
|
||||
LogHelper.printException(() -> ("Failed to set quality"), ex);
|
||||
Toast.makeText(context, "Failed to set quality", Toast.LENGTH_SHORT).show();
|
||||
return qualityIndex;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class ReturnYouTubeDislike {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "Locale: " + locale);
|
||||
LogHelper.printDebug(() -> "Locale: " + locale);
|
||||
compactNumberFormatter = CompactDecimalFormat.getInstance(
|
||||
locale,
|
||||
CompactDecimalFormat.CompactStyle.SHORT
|
||||
@ -104,11 +104,11 @@ public class ReturnYouTubeDislike {
|
||||
try {
|
||||
Thread.State dislikeFetchThreadState = _dislikeFetchThread.getState();
|
||||
if (dislikeFetchThreadState != Thread.State.TERMINATED) {
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "Interrupting the fetch dislike thread of state: " + dislikeFetchThreadState);
|
||||
LogHelper.printDebug(() -> "Interrupting the fetch dislike thread of state: " + dislikeFetchThreadState);
|
||||
_dislikeFetchThread.interrupt();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislike.class, "Error in the fetch dislike thread", ex);
|
||||
LogHelper.printException(() -> "Error in the fetch dislike thread", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,17 +117,17 @@ public class ReturnYouTubeDislike {
|
||||
try {
|
||||
Thread.State voteThreadState = _votingThread.getState();
|
||||
if (voteThreadState != Thread.State.TERMINATED) {
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "Interrupting the voting thread of state: " + voteThreadState);
|
||||
LogHelper.printDebug(() -> "Interrupting the voting thread of state: " + voteThreadState);
|
||||
_votingThread.interrupt();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislike.class, "Error in the voting thread", ex);
|
||||
LogHelper.printException(() -> "Error in the voting thread", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void newVideoLoaded(String videoId) {
|
||||
if (!isEnabled) return;
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "New video loaded: " + videoId);
|
||||
LogHelper.printDebug(() -> "New video loaded: " + videoId);
|
||||
|
||||
setCurrentVideoId(videoId);
|
||||
interruptDislikeFetchThreadIfRunning();
|
||||
@ -140,10 +140,10 @@ public class ReturnYouTubeDislike {
|
||||
return; // fetch failed or thread was interrupted
|
||||
}
|
||||
if (!ReturnYouTubeDislike.setCurrentDislikeCount(videoId, fetchedDislikeCount)) {
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "Ignoring stale dislike fetched call for video " + videoId);
|
||||
LogHelper.printDebug(() -> "Ignoring stale dislike fetched call for video " + videoId);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislike.class, "Failed to fetch dislikes for videoId: " + videoId, ex);
|
||||
LogHelper.printException(() -> "Failed to fetch dislikes for videoId: " + videoId, ex);
|
||||
}
|
||||
});
|
||||
_dislikeFetchThread.start();
|
||||
@ -159,7 +159,7 @@ public class ReturnYouTubeDislike {
|
||||
if (conversionContextString.contains("|segmented_like_dislike_button.eml|")) {
|
||||
segmentedButton = true;
|
||||
} else if (!conversionContextString.contains("|dislike_button.eml|")) {
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "could not find a dislike button in " + conversionContextString);
|
||||
LogHelper.printDebug(() -> "could not find a dislike button in " + conversionContextString);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,16 +171,17 @@ public class ReturnYouTubeDislike {
|
||||
|
||||
Integer fetchedDislikeCount = getDislikeCount();
|
||||
if (fetchedDislikeCount == null) {
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "Cannot add dislike count to UI (dislike count not available)");
|
||||
LogHelper.printDebug(() -> "Cannot add dislike count to UI (dislike count not available)");
|
||||
|
||||
// There's no point letting the request continue, as there is not another chance to use the result
|
||||
interruptDislikeFetchThreadIfRunning();
|
||||
return;
|
||||
}
|
||||
|
||||
updateDislike(textRef, dislikeCount);
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "Updated text on component" + conversionContextString);
|
||||
LogHelper.printDebug(() -> "Updated text on component" + conversionContextString);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislike.class, "Error while trying to set dislikes text", ex);
|
||||
LogHelper.printException(() -> "Error while trying to set dislikes text", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +201,7 @@ public class ReturnYouTubeDislike {
|
||||
try {
|
||||
ReturnYouTubeDislikeApi.sendVote(videoIdToVoteFor, getUserId(), vote);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislike.class, "Failed to send vote", ex);
|
||||
LogHelper.printException(() -> "Failed to send vote", ex);
|
||||
}
|
||||
});
|
||||
_votingThread.start();
|
||||
@ -212,7 +213,7 @@ public class ReturnYouTubeDislike {
|
||||
private static final Object rydUserIdLock = new Object();
|
||||
|
||||
/**
|
||||
* Must call off main thread, as this will make a network call if user has not yet been registered yet
|
||||
* Must call off main thread, as this will make a network call if user has not yet been registered
|
||||
*
|
||||
* @return ReturnYouTubeDislike user ID. If user registration has never happened
|
||||
* and the network call fails, this will return NULL
|
||||
@ -259,10 +260,10 @@ public class ReturnYouTubeDislike {
|
||||
private static String formatDislikes(int dislikes) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && compactNumberFormatter != null) {
|
||||
final String formatted = compactNumberFormatter.format(dislikes);
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "Formatting dislikes - " + dislikes + " - " + formatted);
|
||||
LogHelper.printDebug(() -> "Formatting dislikes - " + dislikes + " - " + formatted);
|
||||
return formatted;
|
||||
}
|
||||
LogHelper.debug(ReturnYouTubeDislike.class, "Couldn't format dislikes, using the unformatted count - " + dislikes);
|
||||
LogHelper.printDebug(() -> "Could not format dislikes, using the unformatted count - " + dislikes);
|
||||
return String.valueOf(dislikes);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class ReturnYouTubeDislikeApi {
|
||||
}
|
||||
final long numberOfSecondsSinceLastRateLimit = (System.currentTimeMillis() - lastTimeLimitWasHit) / 1000;
|
||||
if (numberOfSecondsSinceLastRateLimit < RATE_LIMIT_BACKOFF_SECONDS) {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Ignoring api call " + apiEndPointName + " as only "
|
||||
LogHelper.printDebug(() -> "Ignoring api call " + apiEndPointName + " as only "
|
||||
+ numberOfSecondsSinceLastRateLimit + " seconds has passed since last rate limit.");
|
||||
return true;
|
||||
}
|
||||
@ -68,19 +68,19 @@ public class ReturnYouTubeDislikeApi {
|
||||
* @return True, if the rate limit was reached.
|
||||
*/
|
||||
private static boolean checkIfRateLimitWasHit(int httpResponseCode) {
|
||||
// set to true, to verify rate limit works
|
||||
// set to true, to verify rate limit logic is working.
|
||||
final boolean DEBUG_RATE_LIMIT = false;
|
||||
if (DEBUG_RATE_LIMIT) {
|
||||
final double RANDOM_RATE_LIMIT_PERCENTAGE = 0.1; // 10% chance of a triggering a rate limit
|
||||
if (Math.random() < RANDOM_RATE_LIMIT_PERCENTAGE) {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Artificially triggering rate limit for debug purposes");
|
||||
LogHelper.printDebug(() -> "Artificially triggering rate limit for debug purposes");
|
||||
httpResponseCode = RATE_LIMIT_HTTP_STATUS_CODE;
|
||||
}
|
||||
}
|
||||
|
||||
if (httpResponseCode == RATE_LIMIT_HTTP_STATUS_CODE) {
|
||||
lastTimeLimitWasHit = System.currentTimeMillis();
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "API rate limit was hit. Stopping API calls for the next "
|
||||
LogHelper.printDebug(() -> "API rate limit was hit. Stopping API calls for the next "
|
||||
+ RATE_LIMIT_BACKOFF_SECONDS + " seconds");
|
||||
return true;
|
||||
}
|
||||
@ -99,7 +99,7 @@ public class ReturnYouTubeDislikeApi {
|
||||
if (checkIfRateLimitInEffect("fetchDislikes")) {
|
||||
return null;
|
||||
}
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Fetching dislikes for " + videoId);
|
||||
LogHelper.printDebug(() -> "Fetching dislikes for " + videoId);
|
||||
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.GET_DISLIKES, videoId);
|
||||
connection.setConnectTimeout(HTTP_CONNECTION_DEFAULT_TIMEOUT);
|
||||
final int responseCode = connection.getResponseCode();
|
||||
@ -109,15 +109,15 @@ public class ReturnYouTubeDislikeApi {
|
||||
} else if (responseCode == 200) {
|
||||
JSONObject json = getJSONObject(connection);
|
||||
Integer fetchedDislikeCount = json.getInt("dislikes");
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Dislikes fetched: " + fetchedDislikeCount);
|
||||
LogHelper.printDebug(() -> "Dislikes fetched: " + fetchedDislikeCount);
|
||||
connection.disconnect();
|
||||
return fetchedDislikeCount;
|
||||
} else {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Dislikes fetch response was " + responseCode);
|
||||
LogHelper.printDebug(() -> "Dislikes fetch response was " + responseCode);
|
||||
connection.disconnect();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to fetch dislikes", ex);
|
||||
LogHelper.printException(() -> "Failed to fetch dislikes", ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -133,7 +133,7 @@ public class ReturnYouTubeDislikeApi {
|
||||
return null;
|
||||
}
|
||||
String userId = randomString(36);
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Trying to register the following userId: " + userId);
|
||||
LogHelper.printDebug(() -> "Trying to register the following userId: " + userId);
|
||||
|
||||
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.GET_REGISTRATION, userId);
|
||||
connection.setConnectTimeout(HTTP_CONNECTION_DEFAULT_TIMEOUT);
|
||||
@ -145,22 +145,23 @@ public class ReturnYouTubeDislikeApi {
|
||||
JSONObject json = getJSONObject(connection);
|
||||
String challenge = json.getString("challenge");
|
||||
int difficulty = json.getInt("difficulty");
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration challenge - " + challenge + " with difficulty of " + difficulty);
|
||||
|
||||
LogHelper.printDebug(() -> "Registration challenge - " + challenge + " with difficulty of " + difficulty);
|
||||
connection.disconnect();
|
||||
|
||||
// Solve the puzzle
|
||||
String solution = solvePuzzle(challenge, difficulty);
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration confirmation solution is " + solution);
|
||||
LogHelper.printDebug(() -> "Registration confirmation solution is " + solution);
|
||||
if (solution == null) {
|
||||
return null; // failed to solve puzzle
|
||||
}
|
||||
return confirmRegistration(userId, solution);
|
||||
} else {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration response was " + responseCode);
|
||||
LogHelper.printDebug(() -> "Registration response was " + responseCode);
|
||||
connection.disconnect();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to register userId", ex);
|
||||
LogHelper.printException(() -> "Failed to register userId", ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -174,7 +175,7 @@ public class ReturnYouTubeDislikeApi {
|
||||
if (checkIfRateLimitInEffect("confirmRegistration")) {
|
||||
return null;
|
||||
}
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
|
||||
LogHelper.printDebug(() -> "Trying to confirm registration for the following userId: " + userId + " with solution: " + solution);
|
||||
|
||||
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.CONFIRM_REGISTRATION, userId);
|
||||
applyCommonRequestSettings(connection);
|
||||
@ -192,19 +193,19 @@ public class ReturnYouTubeDislikeApi {
|
||||
|
||||
if (responseCode == 200) {
|
||||
String result = parseJson(connection);
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration confirmation result was " + result);
|
||||
LogHelper.printDebug(() -> "Registration confirmation result was " + result);
|
||||
connection.disconnect();
|
||||
|
||||
if (result.equalsIgnoreCase("true")) {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration was successful for user " + userId);
|
||||
LogHelper.printDebug(() -> "Registration was successful for user " + userId);
|
||||
return userId;
|
||||
}
|
||||
} else {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration confirmation response was " + responseCode);
|
||||
LogHelper.printDebug(() -> "Registration confirmation response was " + responseCode);
|
||||
connection.disconnect();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to confirm registration", ex);
|
||||
LogHelper.printException(() -> "Failed to confirm registration", ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -219,7 +220,7 @@ public class ReturnYouTubeDislikeApi {
|
||||
if (checkIfRateLimitInEffect("sendVote")) {
|
||||
return false;
|
||||
}
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Trying to vote the following video: "
|
||||
LogHelper.printDebug(() -> "Trying to vote the following video: "
|
||||
+ videoId + " with vote " + vote + " and userId: " + userId);
|
||||
try {
|
||||
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.SEND_VOTE);
|
||||
@ -241,21 +242,21 @@ public class ReturnYouTubeDislikeApi {
|
||||
JSONObject json = getJSONObject(connection);
|
||||
String challenge = json.getString("challenge");
|
||||
int difficulty = json.getInt("difficulty");
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote challenge - " + challenge + " with difficulty of " + difficulty);
|
||||
LogHelper.printDebug(() -> "Vote challenge - " + challenge + " with difficulty of " + difficulty);
|
||||
connection.disconnect();
|
||||
|
||||
// Solve the puzzle
|
||||
String solution = solvePuzzle(challenge, difficulty);
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote confirmation solution is " + solution);
|
||||
LogHelper.printDebug(() -> "Vote confirmation solution is " + solution);
|
||||
|
||||
// Confirm vote
|
||||
return confirmVote(videoId, userId, solution);
|
||||
} else {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote response was " + responseCode);
|
||||
LogHelper.printDebug(() -> "Vote response was " + responseCode);
|
||||
connection.disconnect();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to send vote", ex);
|
||||
LogHelper.printException(() -> "Failed to send vote", ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -286,22 +287,22 @@ public class ReturnYouTubeDislikeApi {
|
||||
|
||||
if (responseCode == 200) {
|
||||
String result = parseJson(connection);
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote confirmation result was " + result);
|
||||
LogHelper.printDebug(() -> "Vote confirmation result was " + result);
|
||||
connection.disconnect();
|
||||
|
||||
if (result.equalsIgnoreCase("true")) {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote was successful for user " + userId);
|
||||
LogHelper.printDebug(() -> "Vote was successful for user " + userId);
|
||||
return true;
|
||||
} else {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote was unsuccessful for user " + userId);
|
||||
LogHelper.printDebug(() -> "Vote was unsuccessful for user " + userId);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote confirmation response was " + responseCode);
|
||||
LogHelper.printDebug(() -> "Vote confirmation response was " + responseCode);
|
||||
connection.disconnect();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to confirm vote", ex);
|
||||
LogHelper.printException(() -> "Failed to confirm vote", ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -349,7 +350,7 @@ public class ReturnYouTubeDislikeApi {
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to solve puzzle", ex);
|
||||
LogHelper.printException(() -> "Failed to solve puzzle", ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -201,7 +201,7 @@ public enum SettingsEnum {
|
||||
value = SharedPrefHelper.getString(context, setting.sharedPref, setting.getPath(), (String) setting.getDefaultValue());
|
||||
break;
|
||||
default:
|
||||
LogHelper.printException(SettingsEnum.class, "Setting does not have a valid Type. Name is: " + setting.name());
|
||||
LogHelper.printException(() -> ("Setting does not have a valid Type. Name is: " + setting.name()));
|
||||
break;
|
||||
}
|
||||
setting.setValue(value);
|
||||
@ -210,7 +210,7 @@ public enum SettingsEnum {
|
||||
Log.d("revanced: SettingsEnum", "Loaded Setting: " + setting.name() + " Value: " + value);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
LogHelper.printException(SettingsEnum.class, "Error during load()!", th);
|
||||
LogHelper.printException(() -> ("Error during load()!"), th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,7 +239,7 @@ public enum SettingsEnum {
|
||||
}
|
||||
value = newValue;
|
||||
} else {
|
||||
LogHelper.printException(SettingsEnum.class, "Context on SaveValue is null!");
|
||||
LogHelper.printException(() -> ("Context on SaveValue is null!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class ReVancedSettingActivity {
|
||||
|
||||
final var theme = ThemeHelper.isDarkTheme() ? darkTheme : whiteTheme;
|
||||
|
||||
LogHelper.debug(ReVancedSettingActivity.class, "Using theme: " + theme);
|
||||
LogHelper.printDebug(() -> "Using theme: " + theme);
|
||||
base.setTheme(getIdentifier(theme, "style"));
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class ReVancedSettingActivity {
|
||||
try {
|
||||
getTextView((ViewGroup) base.findViewById(getIdentifier("toolbar", "id"))).setText(preferenceIdentifier);
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar title", e);
|
||||
LogHelper.printException(() -> ("Couldn't set Toolbar title"), e);
|
||||
}
|
||||
|
||||
base.getFragmentManager().beginTransaction().replace(getIdentifier("revanced_settings_fragments", "id"), preferenceFragment).commit();
|
||||
|
@ -45,7 +45,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
if (!setting.getPath().equals(str)) continue;
|
||||
Preference pref = this.findPreferenceOnScreen(str);
|
||||
|
||||
LogHelper.debug(ReVancedSettingsFragment.class, "Setting " + setting.name() + " was changed. Preference " + str + ": " + pref.toString());
|
||||
LogHelper.printDebug(() -> "Setting " + setting.name() + " was changed. Preference " + str + ": " + pref.toString());
|
||||
|
||||
if (pref instanceof SwitchPreference) {
|
||||
SwitchPreference switchPref = (SwitchPreference) pref;
|
||||
@ -67,7 +67,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
value = Integer.parseInt(editPref.getText());
|
||||
break;
|
||||
default:
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Setting has no valid return type! " + setting.getReturnType());
|
||||
LogHelper.printException(() -> ("Setting has no valid return type! " + setting.getReturnType()));
|
||||
break;
|
||||
}
|
||||
setting.setValue(value);
|
||||
@ -80,17 +80,17 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
listPref.setSummary(videoSpeedEntries[listPref.findIndexOfValue(value)]);
|
||||
SettingsEnum.PREFERRED_VIDEO_SPEED.saveValue(value);
|
||||
} catch (Throwable th) {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Error setting value of speed" + th);
|
||||
LogHelper.printException(() -> ("Error setting value of speed" + th));
|
||||
}
|
||||
} else {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "No valid setting found: " + setting.toString());
|
||||
LogHelper.printException(() -> ("No valid setting found: " + setting.toString()));
|
||||
}
|
||||
|
||||
if ("pref_download_button_list".equals(str)) {
|
||||
DownloadButton.refreshShouldBeShown();
|
||||
}
|
||||
} else {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Setting cannot be handled! " + pref.toString());
|
||||
LogHelper.printException(() -> ("Setting cannot be handled! " + pref.toString()));
|
||||
}
|
||||
|
||||
if (ReVancedUtils.getContext() != null && settingsInitialized && setting.shouldRebootOnChange()) {
|
||||
@ -115,7 +115,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
|
||||
this.settingsInitialized = true;
|
||||
} catch (Throwable th) {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Error during onCreate()", th);
|
||||
LogHelper.printException(() -> ("Error during onCreate()"), th);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
|
||||
private Preference findPreferenceOnScreen(CharSequence key) {
|
||||
if (key == null) {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Key cannot be null!");
|
||||
LogHelper.printException(() -> ("Key cannot be null!"));
|
||||
return null;
|
||||
}
|
||||
Preference pref = null;
|
||||
@ -141,7 +141,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
Preference toCheck = screen.findPreference(key);
|
||||
if (toCheck == null) continue;
|
||||
pref = toCheck;
|
||||
LogHelper.debug(ReVancedSettingsFragment.class, "Found preference " + key + " on screen: " + screen.getTitle());
|
||||
LogHelper.printDebug(() -> "Found preference " + key + " on screen: " + screen.getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,11 +163,11 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
private String getPackageName() {
|
||||
Context context = ReVancedUtils.getContext();
|
||||
if (context == null) {
|
||||
LogHelper.printException(ReVancedSettingsFragment.class, "Context is null, returning com.google.android.youtube!");
|
||||
LogHelper.printException(() -> ("Context is null, returning com.google.android.youtube!"));
|
||||
return "com.google.android.youtube";
|
||||
}
|
||||
String PACKAGE_NAME = context.getPackageName();
|
||||
LogHelper.debug(ReVancedSettingsFragment.class, "getPackageName: " + PACKAGE_NAME);
|
||||
LogHelper.printDebug(() -> "getPackageName: " + PACKAGE_NAME);
|
||||
|
||||
return PACKAGE_NAME;
|
||||
}
|
||||
@ -188,7 +188,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
||||
Resources res = context.getResources();
|
||||
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
|
||||
} catch (Throwable exception) {
|
||||
LogHelper.printException(ReVancedUtils.class, "Resource not found.", exception);
|
||||
LogHelper.printException(() -> ("Resource not found."), exception);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -14,16 +14,16 @@ import app.revanced.integrations.utils.LogHelper;
|
||||
public class InjectedPlugin {
|
||||
|
||||
public static void printSomething() {
|
||||
LogHelper.debug(InjectedPlugin.class, "printSomething called");
|
||||
LogHelper.printDebug(() -> "printSomething called");
|
||||
}
|
||||
|
||||
public static void printObject(Object o, int recursive) {
|
||||
if (o == null)
|
||||
LogHelper.debug(InjectedPlugin.class, "Printed object is null");
|
||||
LogHelper.printDebug(() -> "Printed object is null");
|
||||
else {
|
||||
LogHelper.debug(InjectedPlugin.class, "Printed object ("
|
||||
+ o.getClass().getName()
|
||||
+ ") = " + o.toString());
|
||||
LogHelper.printDebug(() -> "Printed object ("
|
||||
+ o.getClass().getName()
|
||||
+ ") = " + o.toString());
|
||||
for (Field field : o.getClass().getDeclaredFields()) {
|
||||
if (field.getType().isPrimitive())
|
||||
continue;
|
||||
@ -32,9 +32,9 @@ public class InjectedPlugin {
|
||||
Object value = field.get(o);
|
||||
try {
|
||||
// if ("java.lang.String".equals(field.getType().getName()))
|
||||
LogHelper.debug(InjectedPlugin.class, "Field: " + field.toString() + " has value " + value);
|
||||
LogHelper.printDebug(() -> "Field: " + field.toString() + " has value " + value);
|
||||
} catch (Exception e) {
|
||||
LogHelper.debug(InjectedPlugin.class, "Field: " + field.toString() + " has value that thrown an exception in toString method");
|
||||
LogHelper.printDebug(() -> "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.class, "Printing stack trace:");
|
||||
LogHelper.printDebug(() -> "Printing stack trace:");
|
||||
for (StackTraceElement element : stackTrace) {
|
||||
LogHelper.debug(InjectedPlugin.class, element.toString());
|
||||
LogHelper.printDebug(() -> element.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,19 +77,19 @@ public class InjectedPlugin {
|
||||
String spacesStr = builder.toString();
|
||||
|
||||
if (view == null) {
|
||||
LogHelper.debug(InjectedPlugin.class, spacesStr + "Null view");
|
||||
LogHelper.printDebug(() -> spacesStr + "Null view");
|
||||
return;
|
||||
}
|
||||
if (view instanceof ViewGroup) {
|
||||
ViewGroup group = (ViewGroup) view;
|
||||
LogHelper.debug(InjectedPlugin.class, spacesStr + "View group: " + view);
|
||||
LogHelper.printDebug(() -> spacesStr + "View group: " + view);
|
||||
int childCount = group.getChildCount();
|
||||
LogHelper.debug(InjectedPlugin.class, spacesStr + "Children count: " + childCount);
|
||||
LogHelper.printDebug(() -> spacesStr + "Children count: " + childCount);
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
printViewStack(group.getChildAt(i), spaces + 1);
|
||||
}
|
||||
} else {
|
||||
LogHelper.debug(InjectedPlugin.class, spacesStr + "Normal view: " + view);
|
||||
LogHelper.printDebug(() -> spacesStr + "Normal view: " + view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class PlayerController {
|
||||
|
||||
currentVideoId = videoId;
|
||||
sponsorSegmentsOfCurrentVideo = null;
|
||||
LogHelper.debug(PlayerController.class, "setCurrentVideoId: videoId=" + videoId);
|
||||
LogHelper.printDebug(() -> "setCurrentVideoId: videoId=" + videoId);
|
||||
|
||||
sponsorTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
@ -98,7 +98,7 @@ public class PlayerController {
|
||||
Arrays.sort(segments);
|
||||
|
||||
for (SponsorSegment segment : segments) {
|
||||
LogHelper.debug(PlayerController.class, "Detected segment: " + segment.toString());
|
||||
LogHelper.printDebug(() -> "Detected segment: " + segment.toString());
|
||||
}
|
||||
|
||||
sponsorSegmentsOfCurrentVideo = segments;
|
||||
@ -107,7 +107,7 @@ public class PlayerController {
|
||||
|
||||
|
||||
public static void setVideoTime(long millis) {
|
||||
LogHelper.debug(PlayerController.class, "setCurrentVideoTime: current video time: " + millis);
|
||||
LogHelper.printDebug(() -> "setCurrentVideoTime: current video time: " + millis);
|
||||
if (!SettingsEnum.SB_ENABLED.getBoolean()) return;
|
||||
lastKnownVideoTime = millis;
|
||||
if (millis <= 0) return;
|
||||
@ -133,7 +133,7 @@ public class PlayerController {
|
||||
break;
|
||||
|
||||
if (skipSponsorTask == null) {
|
||||
LogHelper.debug(PlayerController.class, "Scheduling skipSponsorTask");
|
||||
LogHelper.printDebug(() -> "Scheduling skipSponsorTask");
|
||||
skipSponsorTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -144,7 +144,7 @@ public class PlayerController {
|
||||
};
|
||||
sponsorTimer.schedule(skipSponsorTask, segment.start - millis);
|
||||
} else {
|
||||
LogHelper.debug(PlayerController.class, "skipSponsorTask is already scheduled...");
|
||||
LogHelper.printDebug(() -> "skipSponsorTask is already scheduled...");
|
||||
}
|
||||
|
||||
break;
|
||||
@ -209,7 +209,7 @@ public class PlayerController {
|
||||
}
|
||||
|
||||
public static void setSponsorBarAbsoluteLeft(final float left) {
|
||||
LogHelper.debug(PlayerController.class, String.format("setSponsorBarLeft: left=%.2f", left));
|
||||
LogHelper.printDebug(() -> String.format("setSponsorBarLeft: left=%.2f", left));
|
||||
|
||||
sponsorBarLeft = left;
|
||||
}
|
||||
@ -233,7 +233,7 @@ public class PlayerController {
|
||||
}
|
||||
|
||||
public static void setSponsorBarAbsoluteRight(final float right) {
|
||||
LogHelper.debug(PlayerController.class, String.format("setSponsorBarRight: right=%.2f", right));
|
||||
LogHelper.printDebug(() -> String.format("setSponsorBarRight: right=%.2f", right));
|
||||
|
||||
sponsorBarRight = right;
|
||||
}
|
||||
@ -250,14 +250,14 @@ public class PlayerController {
|
||||
}
|
||||
|
||||
public static void onSkipSponsorClicked() {
|
||||
LogHelper.debug(PlayerController.class, "Skip segment clicked");
|
||||
LogHelper.printDebug(() -> "Skip segment clicked");
|
||||
findAndSkipSegment(true);
|
||||
}
|
||||
|
||||
|
||||
public static void addSkipSponsorView15(final View view) {
|
||||
playerActivity = new WeakReference<>((Activity) view.getContext());
|
||||
LogHelper.debug(PlayerController.class, "addSkipSponsorView15: view=" + view.toString());
|
||||
LogHelper.printDebug(() -> "addSkipSponsorView15: view=" + view.toString());
|
||||
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) view).getChildAt(2);
|
||||
@ -268,7 +268,7 @@ public class PlayerController {
|
||||
|
||||
public static void addSkipSponsorView14(final View view) {
|
||||
playerActivity = new WeakReference<>((Activity) view.getContext());
|
||||
LogHelper.debug(PlayerController.class, "addSkipSponsorView14: view=" + view.toString());
|
||||
LogHelper.printDebug(() -> "addSkipSponsorView14: view=" + view.toString());
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
final ViewGroup viewGroup = (ViewGroup) view.getParent();
|
||||
Activity activity = (Activity) viewGroup.getContext();
|
||||
@ -313,21 +313,21 @@ 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) {
|
||||
LogHelper.debug(PlayerController.class, "skipToMillisecond: to fast, slow down, because you'll fail");
|
||||
LogHelper.printDebug(() -> "skipToMillisecond: to fast, slow down, because you'll fail");
|
||||
return false;
|
||||
}
|
||||
allowNextSkipRequestTime = now + 100;
|
||||
|
||||
LogHelper.debug(PlayerController.class, String.format("Requesting skip to millis=%d on thread %s", millisecond, Thread.currentThread().toString()));
|
||||
LogHelper.printDebug(() -> String.format("Requesting skip to millis=%d on thread %s", millisecond, Thread.currentThread().toString()));
|
||||
|
||||
final long finalMillisecond = millisecond;
|
||||
|
||||
try {
|
||||
LogHelper.debug(PlayerController.class, "Skipping to millis=" + finalMillisecond);
|
||||
LogHelper.printDebug(() -> "Skipping to millis=" + finalMillisecond);
|
||||
lastKnownVideoTime = finalMillisecond;
|
||||
VideoInformation.seekTo(finalMillisecond);
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(PlayerController.class, "Cannot skip to millisecond", e);
|
||||
LogHelper.printException(() -> ("Cannot skip to millisecond"), e);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -362,7 +362,7 @@ public class PlayerController {
|
||||
private static void skipSegment(SponsorSegment segment, boolean wasClicked) {
|
||||
// if (lastSkippedSegment == segment) return;
|
||||
// lastSkippedSegment = segment;
|
||||
LogHelper.debug(PlayerController.class, "Skipping segment: " + segment.toString());
|
||||
LogHelper.printDebug(() -> "Skipping segment: " + segment.toString());
|
||||
|
||||
if (SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.getBoolean() && !wasClicked)
|
||||
SkipSegmentView.notifySkipped(segment);
|
||||
|
@ -9,7 +9,6 @@ import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Set;
|
||||
|
||||
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength;
|
||||
import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime;
|
||||
@ -29,7 +28,7 @@ public class ShieldButton {
|
||||
|
||||
public static void initialize(Object viewStub) {
|
||||
try {
|
||||
LogHelper.debug(ShieldButton.class, "initializing shield button");
|
||||
LogHelper.printDebug(() -> "initializing shield button");
|
||||
|
||||
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
||||
|
||||
@ -37,7 +36,7 @@ public class ShieldButton {
|
||||
.findViewById(getIdentifier("sponsorblock_button", "id"));
|
||||
|
||||
if (imageView == null) {
|
||||
LogHelper.debug(ShieldButton.class, "Couldn't find imageView with \"sponsorblock_button\"");
|
||||
LogHelper.printDebug(() -> "Couldn't find imageView with \"sponsorblock_button\"");
|
||||
}
|
||||
if (imageView == null) return;
|
||||
imageView.setOnClickListener(SponsorBlockUtils.sponsorBlockBtnListener);
|
||||
@ -53,7 +52,7 @@ public class ShieldButton {
|
||||
isShowing = true;
|
||||
changeVisibilityImmediate(false);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(ShieldButton.class, "Unable to set RelativeLayout", ex);
|
||||
LogHelper.printException(() -> ("Unable to set RelativeLayout"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +79,7 @@ public class ShieldButton {
|
||||
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
|
||||
return;
|
||||
}
|
||||
LogHelper.debug(ShieldButton.class, "Fading in");
|
||||
LogHelper.printDebug(() -> "Fading in");
|
||||
|
||||
iView.setVisibility(View.VISIBLE);
|
||||
if (!immediate)
|
||||
@ -89,7 +88,7 @@ public class ShieldButton {
|
||||
}
|
||||
|
||||
if (iView.getVisibility() == View.VISIBLE) {
|
||||
LogHelper.debug(ShieldButton.class, "Fading out");
|
||||
LogHelper.printDebug(() -> "Fading out");
|
||||
if (!immediate)
|
||||
iView.startAnimation(fadeOut);
|
||||
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
|
||||
|
@ -28,13 +28,13 @@ public class SkipSegmentView {
|
||||
|
||||
public static void notifySkipped(SponsorSegment segment) {
|
||||
if (segment == lastNotifiedSegment) {
|
||||
LogHelper.debug(SkipSegmentView.class, "notifySkipped; segment == lastNotifiedSegment");
|
||||
LogHelper.printDebug(() -> "notifySkipped; segment == lastNotifiedSegment");
|
||||
return;
|
||||
}
|
||||
lastNotifiedSegment = segment;
|
||||
String skipMessage = segment.category.skipMessage.toString();
|
||||
Context context = ReVancedUtils.getContext();
|
||||
LogHelper.debug(SkipSegmentView.class, String.format("notifySkipped; message=%s", skipMessage));
|
||||
LogHelper.printDebug(() -> String.format("notifySkipped; message=%s", skipMessage));
|
||||
|
||||
if (context != null)
|
||||
Toast.makeText(context, skipMessage, Toast.LENGTH_SHORT).show();
|
||||
|
@ -61,11 +61,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(SponsorBlockUtils.class, "Shield button clicked");
|
||||
LogHelper.printDebug(() -> "Shield button clicked");
|
||||
NewSegmentHelperLayout.toggle();
|
||||
};
|
||||
public static final View.OnClickListener voteButtonListener = v -> {
|
||||
LogHelper.debug(SponsorBlockUtils.class, "Vote button clicked");
|
||||
LogHelper.printDebug(() -> "Vote button clicked");
|
||||
SponsorBlockUtils.onVotingClicked(v.getContext());
|
||||
};
|
||||
private static int shareBtnId = -1;
|
||||
@ -233,13 +233,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(SponsorBlockUtils.class, "Unable to submit times, invalid parameters");
|
||||
LogHelper.printException(() -> ("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(SponsorBlockUtils.class, "Unable to submit segment", e);
|
||||
LogHelper.printException(() -> ("Unable to submit segment"), e);
|
||||
}
|
||||
|
||||
if (videoId != null)
|
||||
@ -436,7 +436,7 @@ public abstract class SponsorBlockUtils {
|
||||
PlayerController.setCurrentVideoId(null);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(SponsorBlockUtils.class, "Player type changed caused a crash.", ex);
|
||||
LogHelper.printException(() -> ("Player type changed caused a crash."), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,11 +97,11 @@ public class StringRef {
|
||||
if (resources != null) {
|
||||
final int identifier = resources.getIdentifier(value, "string", packageName);
|
||||
if (identifier == 0)
|
||||
LogHelper.printException(StringRef.class, "Resource not found: " + value);
|
||||
LogHelper.printException(() -> ("Resource not found: " + value));
|
||||
else
|
||||
value = resources.getString(identifier);
|
||||
} else {
|
||||
LogHelper.printException(StringRef.class, "Could not resolve resources!");
|
||||
LogHelper.printException(() -> ("Could not resolve resources!"));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
|
@ -25,7 +25,7 @@ public class SwipeHelper {
|
||||
isTabletMode = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(SwipeHelper.class, "Unable to set FrameLayout", e);
|
||||
LogHelper.printException(() -> ("Unable to set FrameLayout"), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ public class SwipeHelper {
|
||||
try {
|
||||
nextGenWatchLayout = (ViewGroup) obj;
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(SwipeHelper.class, "Unable to set _nextGenWatchLayout", e);
|
||||
LogHelper.printException(() -> ("Unable to set _nextGenWatchLayout"), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public class SwipeHelper {
|
||||
}
|
||||
try {
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(SwipeHelper.class, "Unable to get related_endscreen_results visibility", e);
|
||||
LogHelper.printException(() -> ("Unable to get related_endscreen_results visibility"), e);
|
||||
}
|
||||
if (_frameLayout.getChildCount() > 0) {
|
||||
return _frameLayout.getChildAt(0).getVisibility() == View.VISIBLE;
|
||||
@ -58,10 +58,10 @@ public class SwipeHelper {
|
||||
try {
|
||||
if (isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) {
|
||||
_frameLayout = (FrameLayout) findViewById.getParent();
|
||||
LogHelper.debug(SwipeHelper.class, "related_endscreen_results refreshed");
|
||||
LogHelper.printDebug(() -> "related_endscreen_results refreshed");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(SwipeHelper.class, "Unable to refresh related_endscreen_results layout", e);
|
||||
LogHelper.printException(() -> ("Unable to refresh related_endscreen_results layout"), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,14 +28,14 @@ public class VotingButton {
|
||||
|
||||
public static void initialize(Object viewStub) {
|
||||
try {
|
||||
LogHelper.debug(VotingButton.class, "initializing voting button");
|
||||
LogHelper.printDebug(() -> "initializing voting button");
|
||||
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
||||
|
||||
ImageView imageView = (ImageView) _youtubeControlsLayout
|
||||
.findViewById(getIdentifier("voting_button", "id"));
|
||||
|
||||
if (imageView == null) {
|
||||
LogHelper.debug(VotingButton.class, "Couldn't find imageView with \"voting_button\"");
|
||||
LogHelper.printDebug(() -> "Couldn't find imageView with \"voting_button\"");
|
||||
}
|
||||
if (imageView == null) return;
|
||||
imageView.setOnClickListener(SponsorBlockUtils.voteButtonListener);
|
||||
@ -51,7 +51,7 @@ public class VotingButton {
|
||||
isShowing = true;
|
||||
changeVisibilityImmediate(false);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(VotingButton.class, "Unable to set RelativeLayout", ex);
|
||||
LogHelper.printException(() -> ("Unable to set RelativeLayout"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ public class VotingButton {
|
||||
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
|
||||
return;
|
||||
}
|
||||
LogHelper.debug(VotingButton.class, "Fading in");
|
||||
LogHelper.printDebug(() -> "Fading in");
|
||||
iView.setVisibility(View.VISIBLE);
|
||||
if (!immediate)
|
||||
iView.startAnimation(fadeIn);
|
||||
@ -86,7 +86,7 @@ public class VotingButton {
|
||||
}
|
||||
|
||||
if (iView.getVisibility() == View.VISIBLE) {
|
||||
LogHelper.debug(VotingButton.class, "Fading out");
|
||||
LogHelper.printDebug(() -> "Fading out");
|
||||
if (!immediate)
|
||||
iView.startAnimation(fadeOut);
|
||||
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
|
||||
|
@ -17,7 +17,6 @@ import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout;
|
||||
import app.revanced.integrations.sponsorblock.PlayerController;
|
||||
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
|
||||
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
|
||||
|
||||
public class NewSegmentLayout extends FrameLayout {
|
||||
@ -69,7 +68,7 @@ public class NewSegmentLayout extends FrameLayout {
|
||||
this.rewindButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogHelper.debug(NewSegmentLayout.class, "Rewind button clicked");
|
||||
LogHelper.printDebug(() -> "Rewind button clicked");
|
||||
PlayerController.skipRelativeMilliseconds(-SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getInt());
|
||||
}
|
||||
});
|
||||
@ -80,7 +79,7 @@ public class NewSegmentLayout extends FrameLayout {
|
||||
this.forwardButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogHelper.debug(NewSegmentLayout.class, "Forward button clicked");
|
||||
LogHelper.printDebug(() -> "Forward button clicked");
|
||||
PlayerController.skipRelativeMilliseconds(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getInt());
|
||||
}
|
||||
});
|
||||
@ -91,7 +90,7 @@ public class NewSegmentLayout extends FrameLayout {
|
||||
this.adjustButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogHelper.debug(NewSegmentLayout.class, "Adjust button clicked");
|
||||
LogHelper.printDebug(() -> "Adjust button clicked");
|
||||
SponsorBlockUtils.onMarkLocationClicked(NewSegmentHelperLayout.context);
|
||||
}
|
||||
});
|
||||
@ -102,7 +101,7 @@ public class NewSegmentLayout extends FrameLayout {
|
||||
this.compareButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogHelper.debug(NewSegmentLayout.class, "Compare button clicked");
|
||||
LogHelper.printDebug(() -> "Compare button clicked");
|
||||
SponsorBlockUtils.onPreviewClicked(NewSegmentHelperLayout.context);
|
||||
}
|
||||
});
|
||||
@ -113,7 +112,7 @@ public class NewSegmentLayout extends FrameLayout {
|
||||
this.editButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogHelper.debug(NewSegmentLayout.class, "Edit button clicked");
|
||||
LogHelper.printDebug(() -> "Edit button clicked");
|
||||
SponsorBlockUtils.onEditByHandClicked(NewSegmentHelperLayout.context);
|
||||
}
|
||||
});
|
||||
@ -124,7 +123,7 @@ public class NewSegmentLayout extends FrameLayout {
|
||||
this.publishButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogHelper.debug(NewSegmentLayout.class, "Publish button clicked");
|
||||
LogHelper.printDebug(() -> "Publish button clicked");
|
||||
SponsorBlockUtils.onPublishClicked(NewSegmentHelperLayout.context);
|
||||
}
|
||||
});
|
||||
|
@ -5,7 +5,6 @@ import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -90,7 +89,7 @@ public class SkipSponsorButton extends FrameLayout {
|
||||
this.skipSponsorBtnContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogHelper.debug(SkipSponsorButton.class, "Skip button clicked");
|
||||
LogHelper.printDebug(() -> "Skip button clicked");
|
||||
PlayerController.onSkipSponsorClicked();
|
||||
}
|
||||
});
|
||||
|
@ -25,7 +25,7 @@ public abstract class SlimButton implements View.OnClickListener {
|
||||
}
|
||||
|
||||
public SlimButton(Context context, ViewGroup container, int id, boolean visible) {
|
||||
LogHelper.debug(SlimButton.class, "Adding button with id " + id + " and visibility of " + visible);
|
||||
LogHelper.printDebug(() -> "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.class, "Error while changing button visibility", ex);
|
||||
LogHelper.printException(() -> ("Error while changing button visibility"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ import android.widget.RelativeLayout;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
import app.revanced.integrations.sponsorblock.player.PlayerType;
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
import app.revanced.integrations.utils.ReVancedUtils;
|
||||
@ -24,13 +23,13 @@ public class SponsorBlockView {
|
||||
|
||||
public static void initialize(Object viewGroup) {
|
||||
try {
|
||||
LogHelper.debug(SponsorBlockView.class, "initializing");
|
||||
LogHelper.printDebug(() -> "initializing");
|
||||
|
||||
_youtubeOverlaysLayout = (ViewGroup) viewGroup;
|
||||
|
||||
addView();
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(SponsorBlockView.class, "Unable to set ViewGroup", ex);
|
||||
LogHelper.printException(() -> ("Unable to set ViewGroup"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +62,7 @@ public class SponsorBlockView {
|
||||
setSkipBtnMargins(false);
|
||||
setNewSegmentLayoutMargins(false);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.printException(SponsorBlockView.class, "Player type changed caused a crash.", ex);
|
||||
LogHelper.printException(() -> ("Player type changed caused a crash."), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,13 +87,13 @@ public class SponsorBlockView {
|
||||
private static void setSkipBtnMargins(boolean fullScreen) {
|
||||
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
||||
if (skipSponsorButton == null) {
|
||||
LogHelper.printException(SponsorBlockView.class, "Unable to setSkipBtnMargins");
|
||||
LogHelper.printException(() -> ("Unable to setSkipBtnMargins"));
|
||||
return;
|
||||
}
|
||||
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) skipSponsorButton.getLayoutParams();
|
||||
if (params == null) {
|
||||
LogHelper.printException(SponsorBlockView.class, "Unable to setSkipBtnMargins");
|
||||
LogHelper.printException(() -> ("Unable to setSkipBtnMargins"));
|
||||
return;
|
||||
}
|
||||
params.bottomMargin = fullScreen ? skipSponsorButton.ctaBottomMargin : skipSponsorButton.defaultBottomMargin;
|
||||
@ -104,7 +103,7 @@ public class SponsorBlockView {
|
||||
private static void skipSponsorButtonVisibility(boolean visible) {
|
||||
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
||||
if (skipSponsorButton == null) {
|
||||
LogHelper.printException(SponsorBlockView.class, "Unable to skipSponsorButtonVisibility");
|
||||
LogHelper.printException(() -> ("Unable to skipSponsorButtonVisibility"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -117,13 +116,13 @@ public class SponsorBlockView {
|
||||
private static void setNewSegmentLayoutMargins(boolean fullScreen) {
|
||||
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
||||
if (newSegmentLayout == null) {
|
||||
LogHelper.printException(SponsorBlockView.class, "Unable to setNewSegmentLayoutMargins");
|
||||
LogHelper.printException(() -> ("Unable to setNewSegmentLayoutMargins"));
|
||||
return;
|
||||
}
|
||||
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) newSegmentLayout.getLayoutParams();
|
||||
if (params == null) {
|
||||
LogHelper.printException(SponsorBlockView.class, "Unable to setNewSegmentLayoutMargins");
|
||||
LogHelper.printException(() -> ("Unable to setNewSegmentLayoutMargins"));
|
||||
return;
|
||||
}
|
||||
params.bottomMargin = fullScreen ? newSegmentLayout.ctaBottomMargin : newSegmentLayout.defaultBottomMargin;
|
||||
@ -133,7 +132,7 @@ public class SponsorBlockView {
|
||||
private static void newSegmentLayoutVisibility(boolean visible) {
|
||||
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
||||
if (newSegmentLayout == null) {
|
||||
LogHelper.printException(SponsorBlockView.class, "Unable to newSegmentLayoutVisibility");
|
||||
LogHelper.printException(() -> ("Unable to newSegmentLayoutVisibility"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -154,18 +153,18 @@ public class SponsorBlockView {
|
||||
if (inlineSponsorOverlay.getHeight() == 0) {
|
||||
ViewGroup watchLayout = SwipeHelper.nextGenWatchLayout;
|
||||
if (watchLayout == null) {
|
||||
LogHelper.debug(SponsorBlockView.class, "nextGenWatchLayout is null!");
|
||||
LogHelper.printDebug(() -> "nextGenWatchLayout is null!");
|
||||
return;
|
||||
}
|
||||
View layout = watchLayout.findViewById(getIdentifier("player_overlays", "id"));
|
||||
|
||||
if (layout == null) {
|
||||
LogHelper.debug(SponsorBlockView.class, "player_overlays was not found for SB");
|
||||
LogHelper.printDebug(() -> "player_overlays was not found for SB");
|
||||
return;
|
||||
}
|
||||
|
||||
initialize(layout);
|
||||
LogHelper.debug(SponsorBlockView.class, "player_overlays refreshed for SB");
|
||||
LogHelper.printDebug(() -> "player_overlays refreshed for SB");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,8 @@ import app.revanced.integrations.swipecontrols.controller.gesture.PressToSwipeCo
|
||||
import app.revanced.integrations.swipecontrols.controller.gesture.core.GestureController
|
||||
import app.revanced.integrations.swipecontrols.misc.Rectangle
|
||||
import app.revanced.integrations.swipecontrols.views.SwipeControlsOverlayLayout
|
||||
import app.revanced.integrations.utils.LogHelper
|
||||
import app.revanced.integrations.utils.LogHelper.printException
|
||||
import app.revanced.integrations.utils.LogHelper.printInfo
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
/**
|
||||
@ -107,10 +108,9 @@ class SwipeControlsHostActivity : Activity() {
|
||||
*/
|
||||
private fun ensureInitialized() {
|
||||
if (!this::config.isInitialized) {
|
||||
LogHelper.printException(
|
||||
this.javaClass,
|
||||
printException {
|
||||
"swipe controls were not initialized in onCreate, initializing on-the-fly (SDK is ${Build.VERSION.SDK_INT})"
|
||||
)
|
||||
}
|
||||
initialize()
|
||||
reAttachOverlays()
|
||||
}
|
||||
@ -121,7 +121,7 @@ class SwipeControlsHostActivity : Activity() {
|
||||
*/
|
||||
private fun initialize() {
|
||||
// create controllers
|
||||
LogHelper.info(this.javaClass, "initializing swipe controls controllers")
|
||||
printInfo { "initializing swipe controls controllers" }
|
||||
config = SwipeControlsConfigurationProvider(this)
|
||||
keys = VolumeKeysController(this)
|
||||
audio = createAudioController()
|
||||
@ -157,7 +157,7 @@ class SwipeControlsHostActivity : Activity() {
|
||||
* (re) attaches swipe overlays
|
||||
*/
|
||||
private fun reAttachOverlays() {
|
||||
LogHelper.info(this.javaClass, "attaching swipe controls overlay")
|
||||
printInfo { "attaching swipe controls overlay" }
|
||||
contentRoot.removeView(overlay)
|
||||
contentRoot.addView(overlay)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import android.content.Context
|
||||
import android.media.AudioManager
|
||||
import android.os.Build
|
||||
import app.revanced.integrations.swipecontrols.misc.clamp
|
||||
import app.revanced.integrations.utils.LogHelper
|
||||
import app.revanced.integrations.utils.LogHelper.printDebug
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ class AudioVolumeController(
|
||||
// bind audio service
|
||||
val mgr = context.getSystemService(Context.AUDIO_SERVICE) as? AudioManager
|
||||
if (mgr == null) {
|
||||
LogHelper.debug(this.javaClass, "failed to acquire AUDIO_SERVICE")
|
||||
printDebug { "failed to acquire AUDIO_SERVICE" }
|
||||
} else {
|
||||
audioManager = mgr
|
||||
maximumVolumeIndex = audioManager.getStreamMaxVolume(targetStream)
|
||||
|
@ -6,23 +6,102 @@ import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
public class LogHelper {
|
||||
|
||||
//ToDo: Get Calling classname using Reflection
|
||||
/**
|
||||
* Log messages using lambdas.
|
||||
*/
|
||||
public interface LogMessage {
|
||||
String buildMessageString();
|
||||
|
||||
public static void debug(Class clazz, String message) {
|
||||
if (SettingsEnum.DEBUG.getBoolean()) {
|
||||
Log.d("revanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
|
||||
/**
|
||||
* @return For non inner classes, this returns {@link Class#getSimpleName()}.
|
||||
* For inner classes (static and anonymous), this returns the enclosing class simple name.<br>
|
||||
* <br>
|
||||
* For example, each of these classes return 'SomethingView':<br>
|
||||
* com.company.SomethingView<br>
|
||||
* com.company.SomethingView$StaticClass<br>
|
||||
* com.company.SomethingView$1<br>
|
||||
*/
|
||||
private String findOuterClassSimpleName() {
|
||||
var selfClass = this.getClass();
|
||||
|
||||
String fullClassName = selfClass.getName();
|
||||
final int dollarSignIndex = fullClassName.indexOf('$');
|
||||
if (dollarSignIndex == -1) {
|
||||
return selfClass.getSimpleName(); // already an outer class
|
||||
}
|
||||
// else, class is inner class (static or anonymous)
|
||||
|
||||
// parse the simple name full name
|
||||
// a class with no package returns index of -1, but incrementing gives index zero which is correct
|
||||
final int simpleClassNameStartIndex = fullClassName.lastIndexOf('.') + 1;
|
||||
return fullClassName.substring(simpleClassNameStartIndex, dollarSignIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void printException(Class clazz, String message, Throwable ex) {
|
||||
Log.e("revanced: " + (clazz != null ? clazz.getSimpleName() : ""), message, ex);
|
||||
/**
|
||||
* Logs information messages with the most outer class name of the code that is calling this method.
|
||||
*/
|
||||
public static void printInfo(LogMessage message) {
|
||||
Log.i("revanced: " + message.findOuterClassSimpleName(), message.buildMessageString());
|
||||
}
|
||||
|
||||
public static void printException(Class clazz, String message) {
|
||||
Log.e("revanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
|
||||
/**
|
||||
* Logs debug messages with the most outer class name of the code that is calling this method.
|
||||
*/
|
||||
public static void printDebug(LogMessage message) {
|
||||
if (SettingsEnum.DEBUG.getBoolean()) {
|
||||
Log.d("revanced: " + message.findOuterClassSimpleName(), message.buildMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void info(Class clazz, String message) {
|
||||
Log.i("revanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
|
||||
/**
|
||||
* Logs messages with the most outer class name of the code that is calling this method.
|
||||
*/
|
||||
public static void printException(LogMessage message) {
|
||||
Log.e("revanced: " + message.findOuterClassSimpleName(), message.buildMessageString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs exceptions with the most outer class name of the code that is calling this method.
|
||||
*/
|
||||
public static void printException(LogMessage message, Throwable ex) {
|
||||
Log.e("revanced: " + message.findOuterClassSimpleName(), message.buildMessageString(), ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated. Instead call {@link #printDebug(LogMessage)},
|
||||
* which does not cause log messages to be constructed unless logging is enabled.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void debug(Class _clazz, String message) {
|
||||
printDebug(() -> message); // this fails to show the correct calling class name, but it's deprecated who cares
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated. Instead call {@link #printException(LogMessage, Throwable)}
|
||||
* or {@link #printException(LogMessage)}
|
||||
* which does not cause log messages to be constructed unless logging is enabled.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void printException(Class _clazz, String message, Throwable ex) {
|
||||
printException(() -> message, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated. Instead call {@link #printException(LogMessage)},
|
||||
* which does not cause log messages to be constructed unless logging is enabled.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void printException(Class _clazz, String message) {
|
||||
printException(() -> message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated. Instead call {@link #printInfo(LogMessage)},
|
||||
* which does not cause log messages to be constructed unless logging is enabled.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void info(Class _clazz, String message) {
|
||||
printInfo(() -> message);
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ public class ReVancedUtils {
|
||||
}
|
||||
|
||||
public static void setNewVideo(boolean started) {
|
||||
LogHelper.debug(ReVancedUtils.class, "New video started: " + started);
|
||||
LogHelper.printDebug(() -> "New video started: " + started);
|
||||
newVideo = started;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public class ReVancedUtils {
|
||||
Resources res = context.getResources();
|
||||
return res.getIdentifier(name, type, context.getPackageName());
|
||||
} catch (Throwable exception) {
|
||||
LogHelper.printException(ReVancedUtils.class, "Resource not found.", exception);
|
||||
LogHelper.printException(() -> ("Resource not found."), exception);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class ReVancedUtils {
|
||||
if (context != null) {
|
||||
return context;
|
||||
} else {
|
||||
LogHelper.printException(ReVancedUtils.class, "Context is null, returning null!");
|
||||
LogHelper.printException(() -> ("Context is null, returning null!"));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ public class ThemeHelper {
|
||||
|
||||
public static void setTheme(int value) {
|
||||
themeValue = value;
|
||||
LogHelper.debug(ThemeHelper.class, "Theme value: " + themeValue);
|
||||
LogHelper.printDebug(() -> "Theme value: " + themeValue);
|
||||
}
|
||||
|
||||
public static void setTheme(Object value) {
|
||||
themeValue = ((Enum) value).ordinal();
|
||||
LogHelper.debug(ThemeHelper.class, "Theme value: " + themeValue);
|
||||
LogHelper.printDebug(() -> "Theme value: " + themeValue);
|
||||
}
|
||||
|
||||
public static boolean isDarkTheme() {
|
||||
|
@ -34,17 +34,17 @@ public class DownloadButton {
|
||||
|
||||
public static void initializeDownloadButton(Object obj) {
|
||||
try {
|
||||
LogHelper.debug(DownloadButton.class, "initializing");
|
||||
LogHelper.printDebug(() -> "initializing");
|
||||
_constraintLayout = (ConstraintLayout) obj;
|
||||
isDownloadButtonEnabled = shouldBeShown();
|
||||
ImageView imageView = _constraintLayout.findViewById(getIdentifier("download_button", "id"));
|
||||
if (imageView == null) {
|
||||
LogHelper.debug(DownloadButton.class, "Couldn't find imageView with id \"download_button\"");
|
||||
LogHelper.printDebug(() -> "Couldn't find imageView with id \"download_button\"");
|
||||
return;
|
||||
}
|
||||
|
||||
imageView.setOnClickListener(view -> {
|
||||
LogHelper.debug(DownloadButton.class, "Download button clicked");
|
||||
LogHelper.printDebug(() -> "Download button clicked");
|
||||
|
||||
final var context = view.getContext();
|
||||
var downloaderPackageName = SettingsEnum.DOWNLOADS_PACKAGE_NAME.getString();
|
||||
@ -54,7 +54,7 @@ public class DownloadButton {
|
||||
assert context != null;
|
||||
packageEnabled = context.getPackageManager().getApplicationInfo(downloaderPackageName, 0).enabled;
|
||||
} catch (PackageManager.NameNotFoundException error) {
|
||||
LogHelper.debug(DownloadButton.class, "Downloader could not be found: " + error);
|
||||
LogHelper.printDebug(() -> "Downloader could not be found: " + error);
|
||||
}
|
||||
|
||||
// If the package is not installed, show the toast
|
||||
@ -73,9 +73,9 @@ public class DownloadButton {
|
||||
intent.putExtra("android.intent.extra.TEXT", content);
|
||||
context.startActivity(intent);
|
||||
|
||||
LogHelper.debug(DownloadButton.class, "Launched the intent with the content: " + content);
|
||||
LogHelper.printDebug(() -> "Launched the intent with the content: " + content);
|
||||
} catch (Exception error) {
|
||||
LogHelper.debug(DownloadButton.class, "Failed to launch the intent: " + error);
|
||||
LogHelper.printDebug(() -> "Failed to launch the intent: " + error);
|
||||
}
|
||||
|
||||
//var options = Arrays.asList("Video", "Audio").toArray(new CharSequence[0]);
|
||||
@ -100,7 +100,7 @@ public class DownloadButton {
|
||||
changeVisibility(false);
|
||||
|
||||
} catch (Exception e) {
|
||||
LogHelper.printException(DownloadButton.class, "Unable to set FrameLayout", e);
|
||||
LogHelper.printException(() -> ("Unable to set FrameLayout"), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,11 +111,11 @@ public class DownloadButton {
|
||||
ImageView imageView = _button.get();
|
||||
if (_constraintLayout != null && imageView != null) {
|
||||
if (z && isDownloadButtonEnabled) {
|
||||
LogHelper.debug(DownloadButton.class, "Fading in");
|
||||
LogHelper.printDebug(() -> "Fading in");
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
imageView.startAnimation(fadeIn);
|
||||
} else if (imageView.getVisibility() == View.VISIBLE) {
|
||||
LogHelper.debug(DownloadButton.class, "Fading out");
|
||||
LogHelper.printDebug(() -> "Fading out");
|
||||
imageView.startAnimation(fadeOut);
|
||||
imageView.setVisibility(View.GONE);
|
||||
}
|
||||
@ -133,7 +133,7 @@ public class DownloadButton {
|
||||
|
||||
Context appContext = ReVancedUtils.getContext();
|
||||
if (appContext == null) {
|
||||
LogHelper.printException(DownloadButton.class, "shouldBeShown - context is null!");
|
||||
LogHelper.printException(() -> ("shouldBeShown - context is null!"));
|
||||
return false;
|
||||
}
|
||||
String string = SharedPrefHelper.getString(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE, "pref_download_button_list", "PLAYER" /* TODO: set the default to null, as this will be set by the settings page later */);
|
||||
|
Loading…
Reference in New Issue
Block a user