mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-02-13 04:26:47 +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);
|
ViewGroup.LayoutParams layoutParams5 = new ViewGroup.LayoutParams(1, 1);
|
||||||
view.setLayoutParams(layoutParams5);
|
view.setLayoutParams(layoutParams5);
|
||||||
} else {
|
} 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 (currentIsActionButton && ActionButton.doNotBlockCounter-- > 0) {
|
||||||
if (SettingsEnum.HIDE_SHARE_BUTTON.getBoolean()) {
|
if (SettingsEnum.HIDE_SHARE_BUTTON.getBoolean()) {
|
||||||
LogHelper.debug(ButtonsPatch.class, "Hiding share button");
|
LogHelper.printDebug(() -> "Hiding share button");
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((currentIsActionButton && ActionButton.doNotBlockCounter <= 0 && actionButtonsRule.isEnabled()) || pathRegister.contains(path)) {
|
if ((currentIsActionButton && ActionButton.doNotBlockCounter <= 0 && actionButtonsRule.isEnabled()) || pathRegister.contains(path)) {
|
||||||
LogHelper.debug(ButtonsPatch.class, "Blocked: " + path);
|
LogHelper.printDebug(() -> "Blocked: " + path);
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ final class CommentsPatch extends Filter {
|
|||||||
boolean filter(String path, String _identifier) {
|
boolean filter(String path, String _identifier) {
|
||||||
if (!pathRegister.contains(path)) return false;
|
if (!pathRegister.contains(path)) return false;
|
||||||
|
|
||||||
LogHelper.debug(CommentsPatch.class, "Blocked: " + path);
|
LogHelper.printDebug(() -> "Blocked: " + path);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public final class FixPlaybackPatch {
|
|||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} 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) {
|
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) {
|
public static void hideCreateButton(View view) {
|
||||||
boolean enabled = SettingsEnum.CREATE_BUTTON_ENABLED.getBoolean();
|
boolean enabled = SettingsEnum.CREATE_BUTTON_ENABLED.getBoolean();
|
||||||
String message = "Create button: " + (enabled ? "shown" : "hidden");
|
String message = "Create button: " + (enabled ? "shown" : "hidden");
|
||||||
LogHelper.debug(HideCreateButtonPatch.class, message);
|
LogHelper.printDebug(() -> message);
|
||||||
view.setVisibility(enabled ? View.VISIBLE : View.GONE);
|
view.setVisibility(enabled ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package app.revanced.integrations.patches;
|
|||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import app.revanced.integrations.adremover.AdRemoverAPI;
|
|
||||||
import app.revanced.integrations.settings.SettingsEnum;
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
import app.revanced.integrations.utils.LogHelper;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ public class HideShortsButtonPatch {
|
|||||||
if (lastPivotTab != null && lastPivotTab.name() == "TAB_SHORTS") {
|
if (lastPivotTab != null && lastPivotTab.name() == "TAB_SHORTS") {
|
||||||
boolean show = SettingsEnum.SHORTS_BUTTON_SHOWN.getBoolean();
|
boolean show = SettingsEnum.SHORTS_BUTTON_SHOWN.getBoolean();
|
||||||
String message = show ? "Shorts button: shown" : "Shorts button: hidden";
|
String message = show ? "Shorts button: shown" : "Shorts button: hidden";
|
||||||
LogHelper.debug(HideShortsButtonPatch.class, message);
|
LogHelper.printDebug(() -> message);
|
||||||
if (!show) {
|
if (!show) {
|
||||||
view.setVisibility(show ? View.VISIBLE : View.GONE);
|
view.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public final class LithoFilterPatch {
|
|||||||
var path = pathBuilder.toString();
|
var path = pathBuilder.toString();
|
||||||
if (path.isEmpty()) return false;
|
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) {
|
for (var filter : filters) {
|
||||||
if (filter.filter(path, identifier)) return true;
|
if (filter.filter(path, identifier)) return true;
|
||||||
|
@ -20,9 +20,9 @@ public class MicroGSupport {
|
|||||||
assert context != null;
|
assert context != null;
|
||||||
try {
|
try {
|
||||||
context.getPackageManager().getPackageInfo(MICROG_PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
|
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) {
|
} 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();
|
Toast.makeText(context, str("microg_not_installed_warning"), Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
var intent = new Intent(Intent.ACTION_VIEW);
|
var intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
@ -26,7 +26,7 @@ public class PlayerTypeHookPatch {
|
|||||||
final PlayerType newType = PlayerType.safeParseFromString(type.toString());
|
final PlayerType newType = PlayerType.safeParseFromString(type.toString());
|
||||||
if (newType != null) {
|
if (newType != null) {
|
||||||
PlayerType.setCurrent(newType);
|
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 = thisRef.getClass().getMethod(SEEK_METHOD_NAME, Long.TYPE);
|
||||||
seekMethod.setAccessible(true);
|
seekMethod.setAccessible(true);
|
||||||
} catch (NoSuchMethodException ex) {
|
} 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.
|
* @param length The length of the video in milliseconds.
|
||||||
*/
|
*/
|
||||||
public static void setVideoLength(final long length) {
|
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;
|
videoLength = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public final class VideoInformation {
|
|||||||
* @param time The time of the video in milliseconds.
|
* @param time The time of the video in milliseconds.
|
||||||
*/
|
*/
|
||||||
public static void setVideoTime(final long time) {
|
public static void setVideoTime(final long time) {
|
||||||
LogHelper.debug(VideoInformation.class, "Current video time " + time);
|
LogHelper.printDebug(() -> "Current video time " + time);
|
||||||
videoTime = time;
|
videoTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,15 +67,15 @@ public final class VideoInformation {
|
|||||||
public static void seekTo(final long millisecond) {
|
public static void seekTo(final long millisecond) {
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
if (seekMethod == null) {
|
if (seekMethod == null) {
|
||||||
LogHelper.debug(VideoInformation.class, "seekMethod was null");
|
LogHelper.printDebug(() -> "seekMethod was null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LogHelper.debug(VideoInformation.class, "Seeking to " + millisecond);
|
LogHelper.printDebug(() -> "Seeking to " + millisecond);
|
||||||
seekMethod.invoke(playerController.get(), millisecond);
|
seekMethod.invoke(playerController.get(), millisecond);
|
||||||
} catch (Exception ex) {
|
} 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;
|
return speed;
|
||||||
}
|
}
|
||||||
ReVancedUtils.setNewVideo(false);
|
ReVancedUtils.setNewVideo(false);
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Speed: " + speed);
|
LogHelper.printDebug(() -> "Speed: " + speed);
|
||||||
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
|
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Preferred speed: " + preferredSpeed);
|
LogHelper.printDebug(() -> "Preferred speed: " + preferredSpeed);
|
||||||
if (preferredSpeed == -2.0f) {
|
if (preferredSpeed == -2.0f) {
|
||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
@ -48,18 +48,20 @@ public class VideoSpeedPatch {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
float streamSpeed2 = it.next();
|
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++;
|
index++;
|
||||||
}
|
}
|
||||||
int speed3 = -1;
|
int speed3 = -1;
|
||||||
for (float streamSpeed3 : iStreamSpeeds) {
|
for (float streamSpeed3 : iStreamSpeeds) {
|
||||||
if (streamSpeed3 <= preferredSpeed) {
|
if (streamSpeed3 <= preferredSpeed) {
|
||||||
speed3++;
|
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) {
|
if (speed3 == -1) {
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Speed was not found");
|
LogHelper.printDebug(() -> "Speed was not found");
|
||||||
speed2 = 3;
|
speed2 = 3;
|
||||||
} else {
|
} else {
|
||||||
speed2 = speed3;
|
speed2 = speed3;
|
||||||
@ -68,14 +70,13 @@ public class VideoSpeedPatch {
|
|||||||
Method[] declaredMethods = qInterface.getClass().getDeclaredMethods();
|
Method[] declaredMethods = qInterface.getClass().getDeclaredMethods();
|
||||||
for (Method method : declaredMethods) {
|
for (Method method : declaredMethods) {
|
||||||
if (method.getName().length() <= 2) {
|
if (method.getName().length() <= 2) {
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Method name: " + method.getName());
|
LogHelper.printDebug(() -> "Method name: " + method.getName());
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
method.invoke(qInterface, videoSpeeds[speed2]);
|
method.invoke(qInterface, videoSpeeds[speed2]);
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
|
||||||
} catch (Exception e6) {
|
} catch (final Exception e6) {
|
||||||
e = e6;
|
LogHelper.printException(() -> (e6.getMessage()));
|
||||||
LogHelper.printException(VideoSpeedPatch.class, e.getMessage());
|
|
||||||
return speed2;
|
return speed2;
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
@ -85,7 +86,7 @@ public class VideoSpeedPatch {
|
|||||||
} catch (Exception e10) {
|
} catch (Exception e10) {
|
||||||
e = e10;
|
e = e10;
|
||||||
}
|
}
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Speed changed to: " + speed2);
|
LogHelper.printDebug(() -> "Speed changed to: " + speed2);
|
||||||
return speed2;
|
return speed2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,15 +98,15 @@ public class VideoSpeedPatch {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
if (!ReVancedUtils.isNewVideoStarted() || userChangedSpeed) {
|
if (!ReVancedUtils.isNewVideoStarted() || userChangedSpeed) {
|
||||||
if (SettingsEnum.DEBUG.getBoolean() && 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;
|
userChangedSpeed = false;
|
||||||
return -1.0f;
|
return -1.0f;
|
||||||
}
|
}
|
||||||
ReVancedUtils.setNewVideo(false);
|
ReVancedUtils.setNewVideo(false);
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Speed: " + speed);
|
LogHelper.printDebug(() -> "Speed: " + speed);
|
||||||
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
|
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Preferred speed: " + preferredSpeed);
|
LogHelper.printDebug(() -> "Preferred speed: " + preferredSpeed);
|
||||||
if (preferredSpeed == -2.0f) {
|
if (preferredSpeed == -2.0f) {
|
||||||
return -1.0f;
|
return -1.0f;
|
||||||
}
|
}
|
||||||
@ -136,7 +137,8 @@ public class VideoSpeedPatch {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (Float iStreamSpeed : iStreamSpeeds) {
|
for (Float iStreamSpeed : iStreamSpeeds) {
|
||||||
float streamSpeed2 = iStreamSpeed;
|
float streamSpeed2 = iStreamSpeed;
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Speed at index " + index + ": " + streamSpeed2);
|
final int indexToLog = index;
|
||||||
|
LogHelper.printDebug(() -> "Speed at index " + indexToLog + ": " + streamSpeed2);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
int newSpeedIndex = -1;
|
int newSpeedIndex = -1;
|
||||||
@ -144,18 +146,21 @@ public class VideoSpeedPatch {
|
|||||||
float streamSpeed3 = iStreamSpeed;
|
float streamSpeed3 = iStreamSpeed;
|
||||||
if (streamSpeed3 <= preferredSpeed) {
|
if (streamSpeed3 <= preferredSpeed) {
|
||||||
newSpeedIndex++;
|
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) {
|
if (newSpeedIndex == -1) {
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Speed was not found");
|
LogHelper.printDebug(() -> "Speed was not found");
|
||||||
newSpeedIndex = 3;
|
newSpeedIndex = 3;
|
||||||
}
|
}
|
||||||
if (newSpeedIndex == speed) {
|
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;
|
return -1.0f;
|
||||||
}
|
}
|
||||||
LogHelper.debug(VideoSpeedPatch.class, "Speed changed to: " + newSpeedIndex);
|
final int newSpeedIndexToLog = newSpeedIndex;
|
||||||
|
LogHelper.printDebug(() -> "Speed changed to: " + newSpeedIndexToLog);
|
||||||
return getSpeedByIndex(newSpeedIndex);
|
return getSpeedByIndex(newSpeedIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ public class DownloadsPatch {
|
|||||||
* @param videoId The current video id
|
* @param videoId The current video id
|
||||||
*/
|
*/
|
||||||
public static void setVideoId(String videoId) {
|
public static void setVideoId(String videoId) {
|
||||||
LogHelper.debug(DownloadsPatch.class, "newVideoLoaded - " + videoId);
|
LogHelper.printDebug(() -> "newVideoLoaded - " + videoId);
|
||||||
|
|
||||||
DownloadsPatch.videoId = videoId;
|
DownloadsPatch.videoId = videoId;
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@ public class OldQualityLayoutPatch {
|
|||||||
listView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
|
listView.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onChildViewAdded(View parent, View child) {
|
public void onChildViewAdded(View parent, View child) {
|
||||||
LogHelper.debug(OldQualityLayoutPatch.class, "Added: " + child);
|
LogHelper.printDebug(() -> "Added: " + child);
|
||||||
|
|
||||||
parent.setVisibility(View.GONE);
|
parent.setVisibility(View.GONE);
|
||||||
|
|
||||||
final var indexOfAdvancedQualityMenuItem = 4;
|
final var indexOfAdvancedQualityMenuItem = 4;
|
||||||
if (listView.indexOfChild(child) != indexOfAdvancedQualityMenuItem) return;
|
if (listView.indexOfChild(child) != indexOfAdvancedQualityMenuItem) return;
|
||||||
|
|
||||||
LogHelper.debug(OldQualityLayoutPatch.class, "Found advanced menu: " + child);
|
LogHelper.printDebug(() -> "Found advanced menu: " + child);
|
||||||
|
|
||||||
final var qualityItemMenuPosition = 4;
|
final var qualityItemMenuPosition = 4;
|
||||||
listView.performItemClick(null, qualityItemMenuPosition, 0);
|
listView.performItemClick(null, qualityItemMenuPosition, 0);
|
||||||
|
@ -27,22 +27,22 @@ public class RememberVideoQualityPatch {
|
|||||||
try {
|
try {
|
||||||
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", defaultQuality + "");
|
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", defaultQuality + "");
|
||||||
} catch (Exception ex) {
|
} 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();
|
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();
|
Toast.makeText(context, "Changing default Wi-Fi quality to: " + defaultQuality, Toast.LENGTH_SHORT).show();
|
||||||
} else if (isConnectedMobile(context)) {
|
} else if (isConnectedMobile(context)) {
|
||||||
try {
|
try {
|
||||||
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", defaultQuality + "");
|
SharedPrefHelper.saveString(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", defaultQuality + "");
|
||||||
} catch (Exception ex) {
|
} 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();
|
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();
|
Toast.makeText(context, "Changing default mobile data quality to:" + defaultQuality, Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
LogHelper.debug(RememberVideoQualityPatch.class, "No internet connection.");
|
LogHelper.printDebug(() -> "No internet connection.");
|
||||||
Toast.makeText(context, "No internet connection.", Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, "No internet connection.", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
userChangedQuality = false;
|
userChangedQuality = false;
|
||||||
@ -76,34 +76,37 @@ public class RememberVideoQualityPatch {
|
|||||||
int selectedQuality2 = qualities.length - selectedQuality1 + 1;
|
int selectedQuality2 = qualities.length - selectedQuality1 + 1;
|
||||||
index++;
|
index++;
|
||||||
if (selectedQuality2 == 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);
|
changeDefaultQuality(convertedQuality);
|
||||||
return selectedQuality2;
|
return selectedQuality2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newVideo = false;
|
newVideo = false;
|
||||||
LogHelper.debug(RememberVideoQualityPatch.class, "Quality: " + quality);
|
final int qualityToLog = quality;
|
||||||
|
LogHelper.printDebug(() -> "Quality: " + qualityToLog);
|
||||||
Context context = ReVancedUtils.getContext();
|
Context context = ReVancedUtils.getContext();
|
||||||
if (context == null) {
|
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;
|
return quality;
|
||||||
}
|
}
|
||||||
if (isConnectedWifi(context)) {
|
if (isConnectedWifi(context)) {
|
||||||
preferredQuality = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "wifi_quality", -2);
|
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)) {
|
} else if (isConnectedMobile(context)) {
|
||||||
preferredQuality = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.REVANCED_PREFS, "mobile_quality", -2);
|
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 {
|
} else {
|
||||||
LogHelper.debug(RememberVideoQualityPatch.class, "No Internet connection!");
|
LogHelper.printDebug(() -> "No Internet connection!");
|
||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
if (preferredQuality == -2) {
|
if (preferredQuality == -2) {
|
||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
for (int streamQuality2 : iStreamQualities) {
|
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++;
|
index++;
|
||||||
}
|
}
|
||||||
for (Integer iStreamQuality : iStreamQualities) {
|
for (Integer iStreamQuality : iStreamQualities) {
|
||||||
@ -116,16 +119,17 @@ public class RememberVideoQualityPatch {
|
|||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
int qualityIndex = iStreamQualities.indexOf(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 {
|
try {
|
||||||
Class<?> cl = qInterface.getClass();
|
Class<?> cl = qInterface.getClass();
|
||||||
Method m = cl.getMethod(qIndexMethod, Integer.TYPE);
|
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));
|
m.invoke(qInterface, iStreamQualities.get(qualityIndex));
|
||||||
LogHelper.debug(RememberVideoQualityPatch.class, "Quality changed to: " + qualityIndex);
|
LogHelper.printDebug(() -> "Quality changed to: " + qualityIndex);
|
||||||
return qualityIndex;
|
return qualityIndex;
|
||||||
} catch (Exception ex) {
|
} 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();
|
Toast.makeText(context, "Failed to set quality", Toast.LENGTH_SHORT).show();
|
||||||
return qualityIndex;
|
return qualityIndex;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class ReturnYouTubeDislike {
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
Context context = ReVancedUtils.getContext();
|
Context context = ReVancedUtils.getContext();
|
||||||
Locale locale = context.getResources().getConfiguration().locale;
|
Locale locale = context.getResources().getConfiguration().locale;
|
||||||
LogHelper.debug(ReturnYouTubeDislike.class, "Locale: " + locale);
|
LogHelper.printDebug(() -> "Locale: " + locale);
|
||||||
compactNumberFormatter = CompactDecimalFormat.getInstance(
|
compactNumberFormatter = CompactDecimalFormat.getInstance(
|
||||||
locale,
|
locale,
|
||||||
CompactDecimalFormat.CompactStyle.SHORT
|
CompactDecimalFormat.CompactStyle.SHORT
|
||||||
@ -104,11 +104,11 @@ public class ReturnYouTubeDislike {
|
|||||||
try {
|
try {
|
||||||
Thread.State dislikeFetchThreadState = _dislikeFetchThread.getState();
|
Thread.State dislikeFetchThreadState = _dislikeFetchThread.getState();
|
||||||
if (dislikeFetchThreadState != Thread.State.TERMINATED) {
|
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();
|
_dislikeFetchThread.interrupt();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} 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 {
|
try {
|
||||||
Thread.State voteThreadState = _votingThread.getState();
|
Thread.State voteThreadState = _votingThread.getState();
|
||||||
if (voteThreadState != Thread.State.TERMINATED) {
|
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();
|
_votingThread.interrupt();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} 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) {
|
public static void newVideoLoaded(String videoId) {
|
||||||
if (!isEnabled) return;
|
if (!isEnabled) return;
|
||||||
LogHelper.debug(ReturnYouTubeDislike.class, "New video loaded: " + videoId);
|
LogHelper.printDebug(() -> "New video loaded: " + videoId);
|
||||||
|
|
||||||
setCurrentVideoId(videoId);
|
setCurrentVideoId(videoId);
|
||||||
interruptDislikeFetchThreadIfRunning();
|
interruptDislikeFetchThreadIfRunning();
|
||||||
@ -140,10 +140,10 @@ public class ReturnYouTubeDislike {
|
|||||||
return; // fetch failed or thread was interrupted
|
return; // fetch failed or thread was interrupted
|
||||||
}
|
}
|
||||||
if (!ReturnYouTubeDislike.setCurrentDislikeCount(videoId, fetchedDislikeCount)) {
|
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) {
|
} 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();
|
_dislikeFetchThread.start();
|
||||||
@ -159,7 +159,7 @@ public class ReturnYouTubeDislike {
|
|||||||
if (conversionContextString.contains("|segmented_like_dislike_button.eml|")) {
|
if (conversionContextString.contains("|segmented_like_dislike_button.eml|")) {
|
||||||
segmentedButton = true;
|
segmentedButton = true;
|
||||||
} else if (!conversionContextString.contains("|dislike_button.eml|")) {
|
} 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,16 +171,17 @@ public class ReturnYouTubeDislike {
|
|||||||
|
|
||||||
Integer fetchedDislikeCount = getDislikeCount();
|
Integer fetchedDislikeCount = getDislikeCount();
|
||||||
if (fetchedDislikeCount == null) {
|
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
|
// There's no point letting the request continue, as there is not another chance to use the result
|
||||||
interruptDislikeFetchThreadIfRunning();
|
interruptDislikeFetchThreadIfRunning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDislike(textRef, dislikeCount);
|
updateDislike(textRef, dislikeCount);
|
||||||
LogHelper.debug(ReturnYouTubeDislike.class, "Updated text on component" + conversionContextString);
|
LogHelper.printDebug(() -> "Updated text on component" + conversionContextString);
|
||||||
} catch (Exception ex) {
|
} 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 {
|
try {
|
||||||
ReturnYouTubeDislikeApi.sendVote(videoIdToVoteFor, getUserId(), vote);
|
ReturnYouTubeDislikeApi.sendVote(videoIdToVoteFor, getUserId(), vote);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogHelper.printException(ReturnYouTubeDislike.class, "Failed to send vote", ex);
|
LogHelper.printException(() -> "Failed to send vote", ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_votingThread.start();
|
_votingThread.start();
|
||||||
@ -212,7 +213,7 @@ public class ReturnYouTubeDislike {
|
|||||||
private static final Object rydUserIdLock = new Object();
|
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
|
* @return ReturnYouTubeDislike user ID. If user registration has never happened
|
||||||
* and the network call fails, this will return NULL
|
* and the network call fails, this will return NULL
|
||||||
@ -259,10 +260,10 @@ public class ReturnYouTubeDislike {
|
|||||||
private static String formatDislikes(int dislikes) {
|
private static String formatDislikes(int dislikes) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && compactNumberFormatter != null) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && compactNumberFormatter != null) {
|
||||||
final String formatted = compactNumberFormatter.format(dislikes);
|
final String formatted = compactNumberFormatter.format(dislikes);
|
||||||
LogHelper.debug(ReturnYouTubeDislike.class, "Formatting dislikes - " + dislikes + " - " + formatted);
|
LogHelper.printDebug(() -> "Formatting dislikes - " + dislikes + " - " + formatted);
|
||||||
return 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);
|
return String.valueOf(dislikes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
}
|
}
|
||||||
final long numberOfSecondsSinceLastRateLimit = (System.currentTimeMillis() - lastTimeLimitWasHit) / 1000;
|
final long numberOfSecondsSinceLastRateLimit = (System.currentTimeMillis() - lastTimeLimitWasHit) / 1000;
|
||||||
if (numberOfSecondsSinceLastRateLimit < RATE_LIMIT_BACKOFF_SECONDS) {
|
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.");
|
+ numberOfSecondsSinceLastRateLimit + " seconds has passed since last rate limit.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -68,19 +68,19 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
* @return True, if the rate limit was reached.
|
* @return True, if the rate limit was reached.
|
||||||
*/
|
*/
|
||||||
private static boolean checkIfRateLimitWasHit(int httpResponseCode) {
|
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;
|
final boolean DEBUG_RATE_LIMIT = false;
|
||||||
if (DEBUG_RATE_LIMIT) {
|
if (DEBUG_RATE_LIMIT) {
|
||||||
final double RANDOM_RATE_LIMIT_PERCENTAGE = 0.1; // 10% chance of a triggering a 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) {
|
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;
|
httpResponseCode = RATE_LIMIT_HTTP_STATUS_CODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpResponseCode == RATE_LIMIT_HTTP_STATUS_CODE) {
|
if (httpResponseCode == RATE_LIMIT_HTTP_STATUS_CODE) {
|
||||||
lastTimeLimitWasHit = System.currentTimeMillis();
|
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");
|
+ RATE_LIMIT_BACKOFF_SECONDS + " seconds");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
if (checkIfRateLimitInEffect("fetchDislikes")) {
|
if (checkIfRateLimitInEffect("fetchDislikes")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Fetching dislikes for " + videoId);
|
LogHelper.printDebug(() -> "Fetching dislikes for " + videoId);
|
||||||
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.GET_DISLIKES, videoId);
|
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.GET_DISLIKES, videoId);
|
||||||
connection.setConnectTimeout(HTTP_CONNECTION_DEFAULT_TIMEOUT);
|
connection.setConnectTimeout(HTTP_CONNECTION_DEFAULT_TIMEOUT);
|
||||||
final int responseCode = connection.getResponseCode();
|
final int responseCode = connection.getResponseCode();
|
||||||
@ -109,15 +109,15 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
} else if (responseCode == 200) {
|
} else if (responseCode == 200) {
|
||||||
JSONObject json = getJSONObject(connection);
|
JSONObject json = getJSONObject(connection);
|
||||||
Integer fetchedDislikeCount = json.getInt("dislikes");
|
Integer fetchedDislikeCount = json.getInt("dislikes");
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Dislikes fetched: " + fetchedDislikeCount);
|
LogHelper.printDebug(() -> "Dislikes fetched: " + fetchedDislikeCount);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
return fetchedDislikeCount;
|
return fetchedDislikeCount;
|
||||||
} else {
|
} else {
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Dislikes fetch response was " + responseCode);
|
LogHelper.printDebug(() -> "Dislikes fetch response was " + responseCode);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to fetch dislikes", ex);
|
LogHelper.printException(() -> "Failed to fetch dislikes", ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String userId = randomString(36);
|
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);
|
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.GET_REGISTRATION, userId);
|
||||||
connection.setConnectTimeout(HTTP_CONNECTION_DEFAULT_TIMEOUT);
|
connection.setConnectTimeout(HTTP_CONNECTION_DEFAULT_TIMEOUT);
|
||||||
@ -145,22 +145,23 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
JSONObject json = getJSONObject(connection);
|
JSONObject json = getJSONObject(connection);
|
||||||
String challenge = json.getString("challenge");
|
String challenge = json.getString("challenge");
|
||||||
int difficulty = json.getInt("difficulty");
|
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();
|
connection.disconnect();
|
||||||
|
|
||||||
// Solve the puzzle
|
// Solve the puzzle
|
||||||
String solution = solvePuzzle(challenge, difficulty);
|
String solution = solvePuzzle(challenge, difficulty);
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration confirmation solution is " + solution);
|
LogHelper.printDebug(() -> "Registration confirmation solution is " + solution);
|
||||||
if (solution == null) {
|
if (solution == null) {
|
||||||
return null; // failed to solve puzzle
|
return null; // failed to solve puzzle
|
||||||
}
|
}
|
||||||
return confirmRegistration(userId, solution);
|
return confirmRegistration(userId, solution);
|
||||||
} else {
|
} else {
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration response was " + responseCode);
|
LogHelper.printDebug(() -> "Registration response was " + responseCode);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to register userId", ex);
|
LogHelper.printException(() -> "Failed to register userId", ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -174,7 +175,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
if (checkIfRateLimitInEffect("confirmRegistration")) {
|
if (checkIfRateLimitInEffect("confirmRegistration")) {
|
||||||
return null;
|
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);
|
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.CONFIRM_REGISTRATION, userId);
|
||||||
applyCommonRequestSettings(connection);
|
applyCommonRequestSettings(connection);
|
||||||
@ -192,19 +193,19 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
|
|
||||||
if (responseCode == 200) {
|
if (responseCode == 200) {
|
||||||
String result = parseJson(connection);
|
String result = parseJson(connection);
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration confirmation result was " + result);
|
LogHelper.printDebug(() -> "Registration confirmation result was " + result);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
|
|
||||||
if (result.equalsIgnoreCase("true")) {
|
if (result.equalsIgnoreCase("true")) {
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration was successful for user " + userId);
|
LogHelper.printDebug(() -> "Registration was successful for user " + userId);
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Registration confirmation response was " + responseCode);
|
LogHelper.printDebug(() -> "Registration confirmation response was " + responseCode);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to confirm registration", ex);
|
LogHelper.printException(() -> "Failed to confirm registration", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -219,7 +220,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
if (checkIfRateLimitInEffect("sendVote")) {
|
if (checkIfRateLimitInEffect("sendVote")) {
|
||||||
return false;
|
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);
|
+ videoId + " with vote " + vote + " and userId: " + userId);
|
||||||
try {
|
try {
|
||||||
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.SEND_VOTE);
|
HttpURLConnection connection = getConnectionFromRoute(ReturnYouTubeDislikeRoutes.SEND_VOTE);
|
||||||
@ -241,21 +242,21 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
JSONObject json = getJSONObject(connection);
|
JSONObject json = getJSONObject(connection);
|
||||||
String challenge = json.getString("challenge");
|
String challenge = json.getString("challenge");
|
||||||
int difficulty = json.getInt("difficulty");
|
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();
|
connection.disconnect();
|
||||||
|
|
||||||
// Solve the puzzle
|
// Solve the puzzle
|
||||||
String solution = solvePuzzle(challenge, difficulty);
|
String solution = solvePuzzle(challenge, difficulty);
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote confirmation solution is " + solution);
|
LogHelper.printDebug(() -> "Vote confirmation solution is " + solution);
|
||||||
|
|
||||||
// Confirm vote
|
// Confirm vote
|
||||||
return confirmVote(videoId, userId, solution);
|
return confirmVote(videoId, userId, solution);
|
||||||
} else {
|
} else {
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote response was " + responseCode);
|
LogHelper.printDebug(() -> "Vote response was " + responseCode);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to send vote", ex);
|
LogHelper.printException(() -> "Failed to send vote", ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -286,22 +287,22 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
|
|
||||||
if (responseCode == 200) {
|
if (responseCode == 200) {
|
||||||
String result = parseJson(connection);
|
String result = parseJson(connection);
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote confirmation result was " + result);
|
LogHelper.printDebug(() -> "Vote confirmation result was " + result);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
|
|
||||||
if (result.equalsIgnoreCase("true")) {
|
if (result.equalsIgnoreCase("true")) {
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote was successful for user " + userId);
|
LogHelper.printDebug(() -> "Vote was successful for user " + userId);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote was unsuccessful for user " + userId);
|
LogHelper.printDebug(() -> "Vote was unsuccessful for user " + userId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogHelper.debug(ReturnYouTubeDislikeApi.class, "Vote confirmation response was " + responseCode);
|
LogHelper.printDebug(() -> "Vote confirmation response was " + responseCode);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to confirm vote", ex);
|
LogHelper.printException(() -> "Failed to confirm vote", ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -349,7 +350,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogHelper.printException(ReturnYouTubeDislikeApi.class, "Failed to solve puzzle", ex);
|
LogHelper.printException(() -> "Failed to solve puzzle", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -201,7 +201,7 @@ public enum SettingsEnum {
|
|||||||
value = SharedPrefHelper.getString(context, setting.sharedPref, setting.getPath(), (String) setting.getDefaultValue());
|
value = SharedPrefHelper.getString(context, setting.sharedPref, setting.getPath(), (String) setting.getDefaultValue());
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
setting.setValue(value);
|
setting.setValue(value);
|
||||||
@ -210,7 +210,7 @@ public enum SettingsEnum {
|
|||||||
Log.d("revanced: SettingsEnum", "Loaded Setting: " + setting.name() + " Value: " + value);
|
Log.d("revanced: SettingsEnum", "Loaded Setting: " + setting.name() + " Value: " + value);
|
||||||
}
|
}
|
||||||
} catch (Throwable th) {
|
} 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;
|
value = newValue;
|
||||||
} else {
|
} 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;
|
final var theme = ThemeHelper.isDarkTheme() ? darkTheme : whiteTheme;
|
||||||
|
|
||||||
LogHelper.debug(ReVancedSettingActivity.class, "Using theme: " + theme);
|
LogHelper.printDebug(() -> "Using theme: " + theme);
|
||||||
base.setTheme(getIdentifier(theme, "style"));
|
base.setTheme(getIdentifier(theme, "style"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class ReVancedSettingActivity {
|
|||||||
try {
|
try {
|
||||||
getTextView((ViewGroup) base.findViewById(getIdentifier("toolbar", "id"))).setText(preferenceIdentifier);
|
getTextView((ViewGroup) base.findViewById(getIdentifier("toolbar", "id"))).setText(preferenceIdentifier);
|
||||||
} catch (Exception e) {
|
} 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();
|
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;
|
if (!setting.getPath().equals(str)) continue;
|
||||||
Preference pref = this.findPreferenceOnScreen(str);
|
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) {
|
if (pref instanceof SwitchPreference) {
|
||||||
SwitchPreference switchPref = (SwitchPreference) pref;
|
SwitchPreference switchPref = (SwitchPreference) pref;
|
||||||
@ -67,7 +67,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
|||||||
value = Integer.parseInt(editPref.getText());
|
value = Integer.parseInt(editPref.getText());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogHelper.printException(ReVancedSettingsFragment.class, "Setting has no valid return type! " + setting.getReturnType());
|
LogHelper.printException(() -> ("Setting has no valid return type! " + setting.getReturnType()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setting.setValue(value);
|
setting.setValue(value);
|
||||||
@ -80,17 +80,17 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
|||||||
listPref.setSummary(videoSpeedEntries[listPref.findIndexOfValue(value)]);
|
listPref.setSummary(videoSpeedEntries[listPref.findIndexOfValue(value)]);
|
||||||
SettingsEnum.PREFERRED_VIDEO_SPEED.saveValue(value);
|
SettingsEnum.PREFERRED_VIDEO_SPEED.saveValue(value);
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
LogHelper.printException(ReVancedSettingsFragment.class, "Error setting value of speed" + th);
|
LogHelper.printException(() -> ("Error setting value of speed" + th));
|
||||||
}
|
}
|
||||||
} else {
|
} 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)) {
|
if ("pref_download_button_list".equals(str)) {
|
||||||
DownloadButton.refreshShouldBeShown();
|
DownloadButton.refreshShouldBeShown();
|
||||||
}
|
}
|
||||||
} else {
|
} 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()) {
|
if (ReVancedUtils.getContext() != null && settingsInitialized && setting.shouldRebootOnChange()) {
|
||||||
@ -115,7 +115,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
|||||||
|
|
||||||
this.settingsInitialized = true;
|
this.settingsInitialized = true;
|
||||||
} catch (Throwable th) {
|
} 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) {
|
private Preference findPreferenceOnScreen(CharSequence key) {
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
LogHelper.printException(ReVancedSettingsFragment.class, "Key cannot be null!");
|
LogHelper.printException(() -> ("Key cannot be null!"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Preference pref = null;
|
Preference pref = null;
|
||||||
@ -141,7 +141,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
|||||||
Preference toCheck = screen.findPreference(key);
|
Preference toCheck = screen.findPreference(key);
|
||||||
if (toCheck == null) continue;
|
if (toCheck == null) continue;
|
||||||
pref = toCheck;
|
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() {
|
private String getPackageName() {
|
||||||
Context context = ReVancedUtils.getContext();
|
Context context = ReVancedUtils.getContext();
|
||||||
if (context == null) {
|
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";
|
return "com.google.android.youtube";
|
||||||
}
|
}
|
||||||
String PACKAGE_NAME = context.getPackageName();
|
String PACKAGE_NAME = context.getPackageName();
|
||||||
LogHelper.debug(ReVancedSettingsFragment.class, "getPackageName: " + PACKAGE_NAME);
|
LogHelper.printDebug(() -> "getPackageName: " + PACKAGE_NAME);
|
||||||
|
|
||||||
return PACKAGE_NAME;
|
return PACKAGE_NAME;
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
|
|||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
|
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
LogHelper.printException(ReVancedUtils.class, "Resource not found.", exception);
|
LogHelper.printException(() -> ("Resource not found."), exception);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,16 @@ import app.revanced.integrations.utils.LogHelper;
|
|||||||
public class InjectedPlugin {
|
public class InjectedPlugin {
|
||||||
|
|
||||||
public static void printSomething() {
|
public static void printSomething() {
|
||||||
LogHelper.debug(InjectedPlugin.class, "printSomething called");
|
LogHelper.printDebug(() -> "printSomething called");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printObject(Object o, int recursive) {
|
public static void printObject(Object o, int recursive) {
|
||||||
if (o == null)
|
if (o == null)
|
||||||
LogHelper.debug(InjectedPlugin.class, "Printed object is null");
|
LogHelper.printDebug(() -> "Printed object is null");
|
||||||
else {
|
else {
|
||||||
LogHelper.debug(InjectedPlugin.class, "Printed object ("
|
LogHelper.printDebug(() -> "Printed object ("
|
||||||
+ o.getClass().getName()
|
+ o.getClass().getName()
|
||||||
+ ") = " + o.toString());
|
+ ") = " + o.toString());
|
||||||
for (Field field : o.getClass().getDeclaredFields()) {
|
for (Field field : o.getClass().getDeclaredFields()) {
|
||||||
if (field.getType().isPrimitive())
|
if (field.getType().isPrimitive())
|
||||||
continue;
|
continue;
|
||||||
@ -32,9 +32,9 @@ public class InjectedPlugin {
|
|||||||
Object value = field.get(o);
|
Object value = field.get(o);
|
||||||
try {
|
try {
|
||||||
// if ("java.lang.String".equals(field.getType().getName()))
|
// 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) {
|
} 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())
|
if (recursive > 0 && value != null && !value.getClass().isPrimitive())
|
||||||
printObject(value, recursive - 1);
|
printObject(value, recursive - 1);
|
||||||
@ -63,9 +63,9 @@ public class InjectedPlugin {
|
|||||||
|
|
||||||
public static void printStackTrace() {
|
public static void printStackTrace() {
|
||||||
StackTraceElement[] stackTrace = (new Throwable()).getStackTrace();
|
StackTraceElement[] stackTrace = (new Throwable()).getStackTrace();
|
||||||
LogHelper.debug(InjectedPlugin.class, "Printing stack trace:");
|
LogHelper.printDebug(() -> "Printing stack trace:");
|
||||||
for (StackTraceElement element : stackTrace) {
|
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();
|
String spacesStr = builder.toString();
|
||||||
|
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
LogHelper.debug(InjectedPlugin.class, spacesStr + "Null view");
|
LogHelper.printDebug(() -> spacesStr + "Null view");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (view instanceof ViewGroup) {
|
if (view instanceof ViewGroup) {
|
||||||
ViewGroup group = (ViewGroup) view;
|
ViewGroup group = (ViewGroup) view;
|
||||||
LogHelper.debug(InjectedPlugin.class, spacesStr + "View group: " + view);
|
LogHelper.printDebug(() -> spacesStr + "View group: " + view);
|
||||||
int childCount = group.getChildCount();
|
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++) {
|
for (int i = 0; i < childCount; i++) {
|
||||||
printViewStack(group.getChildAt(i), spaces + 1);
|
printViewStack(group.getChildAt(i), spaces + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogHelper.debug(InjectedPlugin.class, spacesStr + "Normal view: " + view);
|
LogHelper.printDebug(() -> spacesStr + "Normal view: " + view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class PlayerController {
|
|||||||
|
|
||||||
currentVideoId = videoId;
|
currentVideoId = videoId;
|
||||||
sponsorSegmentsOfCurrentVideo = null;
|
sponsorSegmentsOfCurrentVideo = null;
|
||||||
LogHelper.debug(PlayerController.class, "setCurrentVideoId: videoId=" + videoId);
|
LogHelper.printDebug(() -> "setCurrentVideoId: videoId=" + videoId);
|
||||||
|
|
||||||
sponsorTimer.schedule(new TimerTask() {
|
sponsorTimer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
@ -98,7 +98,7 @@ public class PlayerController {
|
|||||||
Arrays.sort(segments);
|
Arrays.sort(segments);
|
||||||
|
|
||||||
for (SponsorSegment segment : segments) {
|
for (SponsorSegment segment : segments) {
|
||||||
LogHelper.debug(PlayerController.class, "Detected segment: " + segment.toString());
|
LogHelper.printDebug(() -> "Detected segment: " + segment.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
sponsorSegmentsOfCurrentVideo = segments;
|
sponsorSegmentsOfCurrentVideo = segments;
|
||||||
@ -107,7 +107,7 @@ public class PlayerController {
|
|||||||
|
|
||||||
|
|
||||||
public static void setVideoTime(long millis) {
|
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;
|
if (!SettingsEnum.SB_ENABLED.getBoolean()) return;
|
||||||
lastKnownVideoTime = millis;
|
lastKnownVideoTime = millis;
|
||||||
if (millis <= 0) return;
|
if (millis <= 0) return;
|
||||||
@ -133,7 +133,7 @@ public class PlayerController {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (skipSponsorTask == null) {
|
if (skipSponsorTask == null) {
|
||||||
LogHelper.debug(PlayerController.class, "Scheduling skipSponsorTask");
|
LogHelper.printDebug(() -> "Scheduling skipSponsorTask");
|
||||||
skipSponsorTask = new TimerTask() {
|
skipSponsorTask = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -144,7 +144,7 @@ public class PlayerController {
|
|||||||
};
|
};
|
||||||
sponsorTimer.schedule(skipSponsorTask, segment.start - millis);
|
sponsorTimer.schedule(skipSponsorTask, segment.start - millis);
|
||||||
} else {
|
} else {
|
||||||
LogHelper.debug(PlayerController.class, "skipSponsorTask is already scheduled...");
|
LogHelper.printDebug(() -> "skipSponsorTask is already scheduled...");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -209,7 +209,7 @@ public class PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setSponsorBarAbsoluteLeft(final float left) {
|
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;
|
sponsorBarLeft = left;
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ public class PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setSponsorBarAbsoluteRight(final float right) {
|
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;
|
sponsorBarRight = right;
|
||||||
}
|
}
|
||||||
@ -250,14 +250,14 @@ public class PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void onSkipSponsorClicked() {
|
public static void onSkipSponsorClicked() {
|
||||||
LogHelper.debug(PlayerController.class, "Skip segment clicked");
|
LogHelper.printDebug(() -> "Skip segment clicked");
|
||||||
findAndSkipSegment(true);
|
findAndSkipSegment(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void addSkipSponsorView15(final View view) {
|
public static void addSkipSponsorView15(final View view) {
|
||||||
playerActivity = new WeakReference<>((Activity) view.getContext());
|
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(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) view).getChildAt(2);
|
final ViewGroup viewGroup = (ViewGroup) ((ViewGroup) view).getChildAt(2);
|
||||||
@ -268,7 +268,7 @@ public class PlayerController {
|
|||||||
|
|
||||||
public static void addSkipSponsorView14(final View view) {
|
public static void addSkipSponsorView14(final View view) {
|
||||||
playerActivity = new WeakReference<>((Activity) view.getContext());
|
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(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
final ViewGroup viewGroup = (ViewGroup) view.getParent();
|
final ViewGroup viewGroup = (ViewGroup) view.getParent();
|
||||||
Activity activity = (Activity) viewGroup.getContext();
|
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
|
// I put this block so that skip can be made only once per some time
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (now < allowNextSkipRequestTime) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
allowNextSkipRequestTime = now + 100;
|
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;
|
final long finalMillisecond = millisecond;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LogHelper.debug(PlayerController.class, "Skipping to millis=" + finalMillisecond);
|
LogHelper.printDebug(() -> "Skipping to millis=" + finalMillisecond);
|
||||||
lastKnownVideoTime = finalMillisecond;
|
lastKnownVideoTime = finalMillisecond;
|
||||||
VideoInformation.seekTo(finalMillisecond);
|
VideoInformation.seekTo(finalMillisecond);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogHelper.printException(PlayerController.class, "Cannot skip to millisecond", e);
|
LogHelper.printException(() -> ("Cannot skip to millisecond"), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -362,7 +362,7 @@ public class PlayerController {
|
|||||||
private static void skipSegment(SponsorSegment segment, boolean wasClicked) {
|
private static void skipSegment(SponsorSegment segment, boolean wasClicked) {
|
||||||
// if (lastSkippedSegment == segment) return;
|
// if (lastSkippedSegment == segment) return;
|
||||||
// lastSkippedSegment = segment;
|
// 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)
|
if (SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.getBoolean() && !wasClicked)
|
||||||
SkipSegmentView.notifySkipped(segment);
|
SkipSegmentView.notifySkipped(segment);
|
||||||
|
@ -9,7 +9,6 @@ import android.widget.ImageView;
|
|||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength;
|
import static app.revanced.integrations.sponsorblock.PlayerController.getCurrentVideoLength;
|
||||||
import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime;
|
import static app.revanced.integrations.sponsorblock.PlayerController.getLastKnownVideoTime;
|
||||||
@ -29,7 +28,7 @@ public class ShieldButton {
|
|||||||
|
|
||||||
public static void initialize(Object viewStub) {
|
public static void initialize(Object viewStub) {
|
||||||
try {
|
try {
|
||||||
LogHelper.debug(ShieldButton.class, "initializing shield button");
|
LogHelper.printDebug(() -> "initializing shield button");
|
||||||
|
|
||||||
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ public class ShieldButton {
|
|||||||
.findViewById(getIdentifier("sponsorblock_button", "id"));
|
.findViewById(getIdentifier("sponsorblock_button", "id"));
|
||||||
|
|
||||||
if (imageView == null) {
|
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;
|
if (imageView == null) return;
|
||||||
imageView.setOnClickListener(SponsorBlockUtils.sponsorBlockBtnListener);
|
imageView.setOnClickListener(SponsorBlockUtils.sponsorBlockBtnListener);
|
||||||
@ -53,7 +52,7 @@ public class ShieldButton {
|
|||||||
isShowing = true;
|
isShowing = true;
|
||||||
changeVisibilityImmediate(false);
|
changeVisibilityImmediate(false);
|
||||||
} catch (Exception ex) {
|
} 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()) {
|
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogHelper.debug(ShieldButton.class, "Fading in");
|
LogHelper.printDebug(() -> "Fading in");
|
||||||
|
|
||||||
iView.setVisibility(View.VISIBLE);
|
iView.setVisibility(View.VISIBLE);
|
||||||
if (!immediate)
|
if (!immediate)
|
||||||
@ -89,7 +88,7 @@ public class ShieldButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iView.getVisibility() == View.VISIBLE) {
|
if (iView.getVisibility() == View.VISIBLE) {
|
||||||
LogHelper.debug(ShieldButton.class, "Fading out");
|
LogHelper.printDebug(() -> "Fading out");
|
||||||
if (!immediate)
|
if (!immediate)
|
||||||
iView.startAnimation(fadeOut);
|
iView.startAnimation(fadeOut);
|
||||||
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
|
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
|
||||||
|
@ -28,13 +28,13 @@ public class SkipSegmentView {
|
|||||||
|
|
||||||
public static void notifySkipped(SponsorSegment segment) {
|
public static void notifySkipped(SponsorSegment segment) {
|
||||||
if (segment == lastNotifiedSegment) {
|
if (segment == lastNotifiedSegment) {
|
||||||
LogHelper.debug(SkipSegmentView.class, "notifySkipped; segment == lastNotifiedSegment");
|
LogHelper.printDebug(() -> "notifySkipped; segment == lastNotifiedSegment");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastNotifiedSegment = segment;
|
lastNotifiedSegment = segment;
|
||||||
String skipMessage = segment.category.skipMessage.toString();
|
String skipMessage = segment.category.skipMessage.toString();
|
||||||
Context context = ReVancedUtils.getContext();
|
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)
|
if (context != null)
|
||||||
Toast.makeText(context, skipMessage, Toast.LENGTH_SHORT).show();
|
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 int sponsorBtnId = 1234;
|
||||||
private static final String LOCKED_COLOR = "#FFC83D";
|
private static final String LOCKED_COLOR = "#FFC83D";
|
||||||
public static final View.OnClickListener sponsorBlockBtnListener = v -> {
|
public static final View.OnClickListener sponsorBlockBtnListener = v -> {
|
||||||
LogHelper.debug(SponsorBlockUtils.class, "Shield button clicked");
|
LogHelper.printDebug(() -> "Shield button clicked");
|
||||||
NewSegmentHelperLayout.toggle();
|
NewSegmentHelperLayout.toggle();
|
||||||
};
|
};
|
||||||
public static final View.OnClickListener voteButtonListener = v -> {
|
public static final View.OnClickListener voteButtonListener = v -> {
|
||||||
LogHelper.debug(SponsorBlockUtils.class, "Vote button clicked");
|
LogHelper.printDebug(() -> "Vote button clicked");
|
||||||
SponsorBlockUtils.onVotingClicked(v.getContext());
|
SponsorBlockUtils.onVotingClicked(v.getContext());
|
||||||
};
|
};
|
||||||
private static int shareBtnId = -1;
|
private static int shareBtnId = -1;
|
||||||
@ -233,13 +233,13 @@ public abstract class SponsorBlockUtils {
|
|||||||
final SponsorBlockSettings.SegmentInfo segmentType = SponsorBlockUtils.newSponsorBlockSegmentType;
|
final SponsorBlockSettings.SegmentInfo segmentType = SponsorBlockUtils.newSponsorBlockSegmentType;
|
||||||
try {
|
try {
|
||||||
if (start < 0 || end < 0 || start >= end || segmentType == null || videoId == null || uuid == null) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
SBRequester.submitSegments(videoId, uuid, ((float) start) / 1000f, ((float) end) / 1000f, segmentType.key, toastRunnable);
|
SBRequester.submitSegments(videoId, uuid, ((float) start) / 1000f, ((float) end) / 1000f, segmentType.key, toastRunnable);
|
||||||
newSponsorSegmentEndMillis = newSponsorSegmentStartMillis = -1;
|
newSponsorSegmentEndMillis = newSponsorSegmentStartMillis = -1;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogHelper.printException(SponsorBlockUtils.class, "Unable to submit segment", e);
|
LogHelper.printException(() -> ("Unable to submit segment"), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (videoId != null)
|
if (videoId != null)
|
||||||
@ -436,7 +436,7 @@ public abstract class SponsorBlockUtils {
|
|||||||
PlayerController.setCurrentVideoId(null);
|
PlayerController.setCurrentVideoId(null);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} 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) {
|
if (resources != null) {
|
||||||
final int identifier = resources.getIdentifier(value, "string", packageName);
|
final int identifier = resources.getIdentifier(value, "string", packageName);
|
||||||
if (identifier == 0)
|
if (identifier == 0)
|
||||||
LogHelper.printException(StringRef.class, "Resource not found: " + value);
|
LogHelper.printException(() -> ("Resource not found: " + value));
|
||||||
else
|
else
|
||||||
value = resources.getString(identifier);
|
value = resources.getString(identifier);
|
||||||
} else {
|
} else {
|
||||||
LogHelper.printException(StringRef.class, "Could not resolve resources!");
|
LogHelper.printException(() -> ("Could not resolve resources!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -25,7 +25,7 @@ public class SwipeHelper {
|
|||||||
isTabletMode = true;
|
isTabletMode = true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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 {
|
try {
|
||||||
nextGenWatchLayout = (ViewGroup) obj;
|
nextGenWatchLayout = (ViewGroup) obj;
|
||||||
} catch (Exception e) {
|
} 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 {
|
try {
|
||||||
} catch (Exception e) {
|
} 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) {
|
if (_frameLayout.getChildCount() > 0) {
|
||||||
return _frameLayout.getChildAt(0).getVisibility() == View.VISIBLE;
|
return _frameLayout.getChildAt(0).getVisibility() == View.VISIBLE;
|
||||||
@ -58,10 +58,10 @@ public class SwipeHelper {
|
|||||||
try {
|
try {
|
||||||
if (isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) {
|
if (isWatchWhileFullScreen() && (findViewById = nextGenWatchLayout.findViewById(getIdentifier())) != null) {
|
||||||
_frameLayout = (FrameLayout) findViewById.getParent();
|
_frameLayout = (FrameLayout) findViewById.getParent();
|
||||||
LogHelper.debug(SwipeHelper.class, "related_endscreen_results refreshed");
|
LogHelper.printDebug(() -> "related_endscreen_results refreshed");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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) {
|
public static void initialize(Object viewStub) {
|
||||||
try {
|
try {
|
||||||
LogHelper.debug(VotingButton.class, "initializing voting button");
|
LogHelper.printDebug(() -> "initializing voting button");
|
||||||
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
_youtubeControlsLayout = (RelativeLayout) viewStub;
|
||||||
|
|
||||||
ImageView imageView = (ImageView) _youtubeControlsLayout
|
ImageView imageView = (ImageView) _youtubeControlsLayout
|
||||||
.findViewById(getIdentifier("voting_button", "id"));
|
.findViewById(getIdentifier("voting_button", "id"));
|
||||||
|
|
||||||
if (imageView == null) {
|
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;
|
if (imageView == null) return;
|
||||||
imageView.setOnClickListener(SponsorBlockUtils.voteButtonListener);
|
imageView.setOnClickListener(SponsorBlockUtils.voteButtonListener);
|
||||||
@ -51,7 +51,7 @@ public class VotingButton {
|
|||||||
isShowing = true;
|
isShowing = true;
|
||||||
changeVisibilityImmediate(false);
|
changeVisibilityImmediate(false);
|
||||||
} catch (Exception ex) {
|
} 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()) {
|
if (getLastKnownVideoTime() >= getCurrentVideoLength()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogHelper.debug(VotingButton.class, "Fading in");
|
LogHelper.printDebug(() -> "Fading in");
|
||||||
iView.setVisibility(View.VISIBLE);
|
iView.setVisibility(View.VISIBLE);
|
||||||
if (!immediate)
|
if (!immediate)
|
||||||
iView.startAnimation(fadeIn);
|
iView.startAnimation(fadeIn);
|
||||||
@ -86,7 +86,7 @@ public class VotingButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iView.getVisibility() == View.VISIBLE) {
|
if (iView.getVisibility() == View.VISIBLE) {
|
||||||
LogHelper.debug(VotingButton.class, "Fading out");
|
LogHelper.printDebug(() -> "Fading out");
|
||||||
if (!immediate)
|
if (!immediate)
|
||||||
iView.startAnimation(fadeOut);
|
iView.startAnimation(fadeOut);
|
||||||
iView.setVisibility(shouldBeShown() ? View.INVISIBLE : View.GONE);
|
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.utils.LogHelper;
|
||||||
import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout;
|
import app.revanced.integrations.sponsorblock.NewSegmentHelperLayout;
|
||||||
import app.revanced.integrations.sponsorblock.PlayerController;
|
import app.revanced.integrations.sponsorblock.PlayerController;
|
||||||
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
|
|
||||||
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
|
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
|
||||||
|
|
||||||
public class NewSegmentLayout extends FrameLayout {
|
public class NewSegmentLayout extends FrameLayout {
|
||||||
@ -69,7 +68,7 @@ public class NewSegmentLayout extends FrameLayout {
|
|||||||
this.rewindButton.setOnClickListener(new View.OnClickListener() {
|
this.rewindButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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());
|
PlayerController.skipRelativeMilliseconds(-SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getInt());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -80,7 +79,7 @@ public class NewSegmentLayout extends FrameLayout {
|
|||||||
this.forwardButton.setOnClickListener(new View.OnClickListener() {
|
this.forwardButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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());
|
PlayerController.skipRelativeMilliseconds(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getInt());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -91,7 +90,7 @@ public class NewSegmentLayout extends FrameLayout {
|
|||||||
this.adjustButton.setOnClickListener(new View.OnClickListener() {
|
this.adjustButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
LogHelper.debug(NewSegmentLayout.class, "Adjust button clicked");
|
LogHelper.printDebug(() -> "Adjust button clicked");
|
||||||
SponsorBlockUtils.onMarkLocationClicked(NewSegmentHelperLayout.context);
|
SponsorBlockUtils.onMarkLocationClicked(NewSegmentHelperLayout.context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -102,7 +101,7 @@ public class NewSegmentLayout extends FrameLayout {
|
|||||||
this.compareButton.setOnClickListener(new View.OnClickListener() {
|
this.compareButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
LogHelper.debug(NewSegmentLayout.class, "Compare button clicked");
|
LogHelper.printDebug(() -> "Compare button clicked");
|
||||||
SponsorBlockUtils.onPreviewClicked(NewSegmentHelperLayout.context);
|
SponsorBlockUtils.onPreviewClicked(NewSegmentHelperLayout.context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -113,7 +112,7 @@ public class NewSegmentLayout extends FrameLayout {
|
|||||||
this.editButton.setOnClickListener(new View.OnClickListener() {
|
this.editButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
LogHelper.debug(NewSegmentLayout.class, "Edit button clicked");
|
LogHelper.printDebug(() -> "Edit button clicked");
|
||||||
SponsorBlockUtils.onEditByHandClicked(NewSegmentHelperLayout.context);
|
SponsorBlockUtils.onEditByHandClicked(NewSegmentHelperLayout.context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -124,7 +123,7 @@ public class NewSegmentLayout extends FrameLayout {
|
|||||||
this.publishButton.setOnClickListener(new View.OnClickListener() {
|
this.publishButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
LogHelper.debug(NewSegmentLayout.class, "Publish button clicked");
|
LogHelper.printDebug(() -> "Publish button clicked");
|
||||||
SponsorBlockUtils.onPublishClicked(NewSegmentHelperLayout.context);
|
SponsorBlockUtils.onPublishClicked(NewSegmentHelperLayout.context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,7 +5,6 @@ import android.content.res.Resources;
|
|||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Build;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -90,7 +89,7 @@ public class SkipSponsorButton extends FrameLayout {
|
|||||||
this.skipSponsorBtnContainer.setOnClickListener(new View.OnClickListener() {
|
this.skipSponsorBtnContainer.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
LogHelper.debug(SkipSponsorButton.class, "Skip button clicked");
|
LogHelper.printDebug(() -> "Skip button clicked");
|
||||||
PlayerController.onSkipSponsorClicked();
|
PlayerController.onSkipSponsorClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ public abstract class SlimButton implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SlimButton(Context context, ViewGroup container, int id, boolean visible) {
|
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.context = context;
|
||||||
this.container = container;
|
this.container = container;
|
||||||
view = LayoutInflater.from(context).inflate(id, container, false);
|
view = LayoutInflater.from(context).inflate(id, container, false);
|
||||||
@ -48,7 +48,7 @@ public abstract class SlimButton implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
setContainerVisibility();
|
setContainerVisibility();
|
||||||
} catch (Exception ex) {
|
} 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 java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import app.revanced.integrations.settings.SettingsEnum;
|
|
||||||
import app.revanced.integrations.sponsorblock.player.PlayerType;
|
import app.revanced.integrations.sponsorblock.player.PlayerType;
|
||||||
import app.revanced.integrations.utils.LogHelper;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
import app.revanced.integrations.utils.ReVancedUtils;
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
@ -24,13 +23,13 @@ public class SponsorBlockView {
|
|||||||
|
|
||||||
public static void initialize(Object viewGroup) {
|
public static void initialize(Object viewGroup) {
|
||||||
try {
|
try {
|
||||||
LogHelper.debug(SponsorBlockView.class, "initializing");
|
LogHelper.printDebug(() -> "initializing");
|
||||||
|
|
||||||
_youtubeOverlaysLayout = (ViewGroup) viewGroup;
|
_youtubeOverlaysLayout = (ViewGroup) viewGroup;
|
||||||
|
|
||||||
addView();
|
addView();
|
||||||
} catch (Exception ex) {
|
} 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);
|
setSkipBtnMargins(false);
|
||||||
setNewSegmentLayoutMargins(false);
|
setNewSegmentLayoutMargins(false);
|
||||||
} catch (Exception ex) {
|
} 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) {
|
private static void setSkipBtnMargins(boolean fullScreen) {
|
||||||
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
||||||
if (skipSponsorButton == null) {
|
if (skipSponsorButton == null) {
|
||||||
LogHelper.printException(SponsorBlockView.class, "Unable to setSkipBtnMargins");
|
LogHelper.printException(() -> ("Unable to setSkipBtnMargins"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) skipSponsorButton.getLayoutParams();
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) skipSponsorButton.getLayoutParams();
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
LogHelper.printException(SponsorBlockView.class, "Unable to setSkipBtnMargins");
|
LogHelper.printException(() -> ("Unable to setSkipBtnMargins"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
params.bottomMargin = fullScreen ? skipSponsorButton.ctaBottomMargin : skipSponsorButton.defaultBottomMargin;
|
params.bottomMargin = fullScreen ? skipSponsorButton.ctaBottomMargin : skipSponsorButton.defaultBottomMargin;
|
||||||
@ -104,7 +103,7 @@ public class SponsorBlockView {
|
|||||||
private static void skipSponsorButtonVisibility(boolean visible) {
|
private static void skipSponsorButtonVisibility(boolean visible) {
|
||||||
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
SkipSponsorButton skipSponsorButton = _skipSponsorButton.get();
|
||||||
if (skipSponsorButton == null) {
|
if (skipSponsorButton == null) {
|
||||||
LogHelper.printException(SponsorBlockView.class, "Unable to skipSponsorButtonVisibility");
|
LogHelper.printException(() -> ("Unable to skipSponsorButtonVisibility"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,13 +116,13 @@ public class SponsorBlockView {
|
|||||||
private static void setNewSegmentLayoutMargins(boolean fullScreen) {
|
private static void setNewSegmentLayoutMargins(boolean fullScreen) {
|
||||||
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
||||||
if (newSegmentLayout == null) {
|
if (newSegmentLayout == null) {
|
||||||
LogHelper.printException(SponsorBlockView.class, "Unable to setNewSegmentLayoutMargins");
|
LogHelper.printException(() -> ("Unable to setNewSegmentLayoutMargins"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) newSegmentLayout.getLayoutParams();
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) newSegmentLayout.getLayoutParams();
|
||||||
if (params == null) {
|
if (params == null) {
|
||||||
LogHelper.printException(SponsorBlockView.class, "Unable to setNewSegmentLayoutMargins");
|
LogHelper.printException(() -> ("Unable to setNewSegmentLayoutMargins"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
params.bottomMargin = fullScreen ? newSegmentLayout.ctaBottomMargin : newSegmentLayout.defaultBottomMargin;
|
params.bottomMargin = fullScreen ? newSegmentLayout.ctaBottomMargin : newSegmentLayout.defaultBottomMargin;
|
||||||
@ -133,7 +132,7 @@ public class SponsorBlockView {
|
|||||||
private static void newSegmentLayoutVisibility(boolean visible) {
|
private static void newSegmentLayoutVisibility(boolean visible) {
|
||||||
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
NewSegmentLayout newSegmentLayout = _newSegmentLayout.get();
|
||||||
if (newSegmentLayout == null) {
|
if (newSegmentLayout == null) {
|
||||||
LogHelper.printException(SponsorBlockView.class, "Unable to newSegmentLayoutVisibility");
|
LogHelper.printException(() -> ("Unable to newSegmentLayoutVisibility"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,18 +153,18 @@ public class SponsorBlockView {
|
|||||||
if (inlineSponsorOverlay.getHeight() == 0) {
|
if (inlineSponsorOverlay.getHeight() == 0) {
|
||||||
ViewGroup watchLayout = SwipeHelper.nextGenWatchLayout;
|
ViewGroup watchLayout = SwipeHelper.nextGenWatchLayout;
|
||||||
if (watchLayout == null) {
|
if (watchLayout == null) {
|
||||||
LogHelper.debug(SponsorBlockView.class, "nextGenWatchLayout is null!");
|
LogHelper.printDebug(() -> "nextGenWatchLayout is null!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
View layout = watchLayout.findViewById(getIdentifier("player_overlays", "id"));
|
View layout = watchLayout.findViewById(getIdentifier("player_overlays", "id"));
|
||||||
|
|
||||||
if (layout == null) {
|
if (layout == null) {
|
||||||
LogHelper.debug(SponsorBlockView.class, "player_overlays was not found for SB");
|
LogHelper.printDebug(() -> "player_overlays was not found for SB");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize(layout);
|
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.controller.gesture.core.GestureController
|
||||||
import app.revanced.integrations.swipecontrols.misc.Rectangle
|
import app.revanced.integrations.swipecontrols.misc.Rectangle
|
||||||
import app.revanced.integrations.swipecontrols.views.SwipeControlsOverlayLayout
|
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
|
import java.lang.ref.WeakReference
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,10 +108,9 @@ class SwipeControlsHostActivity : Activity() {
|
|||||||
*/
|
*/
|
||||||
private fun ensureInitialized() {
|
private fun ensureInitialized() {
|
||||||
if (!this::config.isInitialized) {
|
if (!this::config.isInitialized) {
|
||||||
LogHelper.printException(
|
printException {
|
||||||
this.javaClass,
|
|
||||||
"swipe controls were not initialized in onCreate, initializing on-the-fly (SDK is ${Build.VERSION.SDK_INT})"
|
"swipe controls were not initialized in onCreate, initializing on-the-fly (SDK is ${Build.VERSION.SDK_INT})"
|
||||||
)
|
}
|
||||||
initialize()
|
initialize()
|
||||||
reAttachOverlays()
|
reAttachOverlays()
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ class SwipeControlsHostActivity : Activity() {
|
|||||||
*/
|
*/
|
||||||
private fun initialize() {
|
private fun initialize() {
|
||||||
// create controllers
|
// create controllers
|
||||||
LogHelper.info(this.javaClass, "initializing swipe controls controllers")
|
printInfo { "initializing swipe controls controllers" }
|
||||||
config = SwipeControlsConfigurationProvider(this)
|
config = SwipeControlsConfigurationProvider(this)
|
||||||
keys = VolumeKeysController(this)
|
keys = VolumeKeysController(this)
|
||||||
audio = createAudioController()
|
audio = createAudioController()
|
||||||
@ -157,7 +157,7 @@ class SwipeControlsHostActivity : Activity() {
|
|||||||
* (re) attaches swipe overlays
|
* (re) attaches swipe overlays
|
||||||
*/
|
*/
|
||||||
private fun reAttachOverlays() {
|
private fun reAttachOverlays() {
|
||||||
LogHelper.info(this.javaClass, "attaching swipe controls overlay")
|
printInfo { "attaching swipe controls overlay" }
|
||||||
contentRoot.removeView(overlay)
|
contentRoot.removeView(overlay)
|
||||||
contentRoot.addView(overlay)
|
contentRoot.addView(overlay)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import android.content.Context
|
|||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import app.revanced.integrations.swipecontrols.misc.clamp
|
import app.revanced.integrations.swipecontrols.misc.clamp
|
||||||
import app.revanced.integrations.utils.LogHelper
|
import app.revanced.integrations.utils.LogHelper.printDebug
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +29,7 @@ class AudioVolumeController(
|
|||||||
// bind audio service
|
// bind audio service
|
||||||
val mgr = context.getSystemService(Context.AUDIO_SERVICE) as? AudioManager
|
val mgr = context.getSystemService(Context.AUDIO_SERVICE) as? AudioManager
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
LogHelper.debug(this.javaClass, "failed to acquire AUDIO_SERVICE")
|
printDebug { "failed to acquire AUDIO_SERVICE" }
|
||||||
} else {
|
} else {
|
||||||
audioManager = mgr
|
audioManager = mgr
|
||||||
maximumVolumeIndex = audioManager.getStreamMaxVolume(targetStream)
|
maximumVolumeIndex = audioManager.getStreamMaxVolume(targetStream)
|
||||||
|
@ -6,23 +6,102 @@ import app.revanced.integrations.settings.SettingsEnum;
|
|||||||
|
|
||||||
public class LogHelper {
|
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()) {
|
* @return For non inner classes, this returns {@link Class#getSimpleName()}.
|
||||||
Log.d("revanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
|
* 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) {
|
public static void setNewVideo(boolean started) {
|
||||||
LogHelper.debug(ReVancedUtils.class, "New video started: " + started);
|
LogHelper.printDebug(() -> "New video started: " + started);
|
||||||
newVideo = started;
|
newVideo = started;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class ReVancedUtils {
|
|||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
return res.getIdentifier(name, type, context.getPackageName());
|
return res.getIdentifier(name, type, context.getPackageName());
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
LogHelper.printException(ReVancedUtils.class, "Resource not found.", exception);
|
LogHelper.printException(() -> ("Resource not found."), exception);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ public class ReVancedUtils {
|
|||||||
if (context != null) {
|
if (context != null) {
|
||||||
return context;
|
return context;
|
||||||
} else {
|
} else {
|
||||||
LogHelper.printException(ReVancedUtils.class, "Context is null, returning null!");
|
LogHelper.printException(() -> ("Context is null, returning null!"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@ public class ThemeHelper {
|
|||||||
|
|
||||||
public static void setTheme(int value) {
|
public static void setTheme(int value) {
|
||||||
themeValue = value;
|
themeValue = value;
|
||||||
LogHelper.debug(ThemeHelper.class, "Theme value: " + themeValue);
|
LogHelper.printDebug(() -> "Theme value: " + themeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTheme(Object value) {
|
public static void setTheme(Object value) {
|
||||||
themeValue = ((Enum) value).ordinal();
|
themeValue = ((Enum) value).ordinal();
|
||||||
LogHelper.debug(ThemeHelper.class, "Theme value: " + themeValue);
|
LogHelper.printDebug(() -> "Theme value: " + themeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDarkTheme() {
|
public static boolean isDarkTheme() {
|
||||||
|
@ -34,17 +34,17 @@ public class DownloadButton {
|
|||||||
|
|
||||||
public static void initializeDownloadButton(Object obj) {
|
public static void initializeDownloadButton(Object obj) {
|
||||||
try {
|
try {
|
||||||
LogHelper.debug(DownloadButton.class, "initializing");
|
LogHelper.printDebug(() -> "initializing");
|
||||||
_constraintLayout = (ConstraintLayout) obj;
|
_constraintLayout = (ConstraintLayout) obj;
|
||||||
isDownloadButtonEnabled = shouldBeShown();
|
isDownloadButtonEnabled = shouldBeShown();
|
||||||
ImageView imageView = _constraintLayout.findViewById(getIdentifier("download_button", "id"));
|
ImageView imageView = _constraintLayout.findViewById(getIdentifier("download_button", "id"));
|
||||||
if (imageView == null) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
imageView.setOnClickListener(view -> {
|
imageView.setOnClickListener(view -> {
|
||||||
LogHelper.debug(DownloadButton.class, "Download button clicked");
|
LogHelper.printDebug(() -> "Download button clicked");
|
||||||
|
|
||||||
final var context = view.getContext();
|
final var context = view.getContext();
|
||||||
var downloaderPackageName = SettingsEnum.DOWNLOADS_PACKAGE_NAME.getString();
|
var downloaderPackageName = SettingsEnum.DOWNLOADS_PACKAGE_NAME.getString();
|
||||||
@ -54,7 +54,7 @@ public class DownloadButton {
|
|||||||
assert context != null;
|
assert context != null;
|
||||||
packageEnabled = context.getPackageManager().getApplicationInfo(downloaderPackageName, 0).enabled;
|
packageEnabled = context.getPackageManager().getApplicationInfo(downloaderPackageName, 0).enabled;
|
||||||
} catch (PackageManager.NameNotFoundException error) {
|
} 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
|
// If the package is not installed, show the toast
|
||||||
@ -73,9 +73,9 @@ public class DownloadButton {
|
|||||||
intent.putExtra("android.intent.extra.TEXT", content);
|
intent.putExtra("android.intent.extra.TEXT", content);
|
||||||
context.startActivity(intent);
|
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) {
|
} 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]);
|
//var options = Arrays.asList("Video", "Audio").toArray(new CharSequence[0]);
|
||||||
@ -100,7 +100,7 @@ public class DownloadButton {
|
|||||||
changeVisibility(false);
|
changeVisibility(false);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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();
|
ImageView imageView = _button.get();
|
||||||
if (_constraintLayout != null && imageView != null) {
|
if (_constraintLayout != null && imageView != null) {
|
||||||
if (z && isDownloadButtonEnabled) {
|
if (z && isDownloadButtonEnabled) {
|
||||||
LogHelper.debug(DownloadButton.class, "Fading in");
|
LogHelper.printDebug(() -> "Fading in");
|
||||||
imageView.setVisibility(View.VISIBLE);
|
imageView.setVisibility(View.VISIBLE);
|
||||||
imageView.startAnimation(fadeIn);
|
imageView.startAnimation(fadeIn);
|
||||||
} else if (imageView.getVisibility() == View.VISIBLE) {
|
} else if (imageView.getVisibility() == View.VISIBLE) {
|
||||||
LogHelper.debug(DownloadButton.class, "Fading out");
|
LogHelper.printDebug(() -> "Fading out");
|
||||||
imageView.startAnimation(fadeOut);
|
imageView.startAnimation(fadeOut);
|
||||||
imageView.setVisibility(View.GONE);
|
imageView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ public class DownloadButton {
|
|||||||
|
|
||||||
Context appContext = ReVancedUtils.getContext();
|
Context appContext = ReVancedUtils.getContext();
|
||||||
if (appContext == null) {
|
if (appContext == null) {
|
||||||
LogHelper.printException(DownloadButton.class, "shouldBeShown - context is null!");
|
LogHelper.printException(() -> ("shouldBeShown - context is null!"));
|
||||||
return false;
|
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 */);
|
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…
x
Reference in New Issue
Block a user