chore: Lint code

This commit is contained in:
inotia00 2024-12-17 14:17:15 +09:00
parent e0b6d33df5
commit b32301fd85
14 changed files with 47 additions and 39 deletions

View File

@ -2,11 +2,11 @@ package app.revanced.extension.music.patches.components;
import androidx.annotation.Nullable;
import app.revanced.extension.music.settings.Settings;
import app.revanced.extension.shared.patches.components.ByteArrayFilterGroup;
import app.revanced.extension.shared.patches.components.ByteArrayFilterGroupList;
import app.revanced.extension.shared.patches.components.Filter;
import app.revanced.extension.shared.patches.components.StringFilterGroup;
import app.revanced.extension.music.settings.Settings;
@SuppressWarnings("unused")
public final class ActionButtonsFilter extends Filter {

View File

@ -8,15 +8,11 @@ import android.annotation.SuppressLint;
import android.graphics.Color;
import android.view.View;
import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.Objects;
import app.revanced.extension.music.settings.Settings;
import app.revanced.extension.music.shared.VideoType;
import app.revanced.extension.music.utils.VideoUtils;
import app.revanced.extension.shared.utils.Logger;
import app.revanced.extension.shared.utils.Utils;
@SuppressWarnings({"unused"})

View File

@ -6,7 +6,6 @@ import android.app.Activity;
import androidx.annotation.NonNull;
import app.revanced.extension.music.utils.ExtendedUtils;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.shared.utils.Utils;

View File

@ -30,7 +30,7 @@ public class ReturnYouTubeDislikePatch {
* This method is sometimes called on the main thread, but it usually is called _off_ the main thread.
* This method can be called multiple times for the same UI element (including after dislikes was added).
*
* @param original Original char sequence was created or reused by Litho.
* @param original Original char sequence was created or reused by Litho.
* @return The original char sequence (if nothing should change), or a replacement char sequence that contains dislikes.
*/
public static CharSequence onLithoTextLoaded(@NonNull Object conversionContext,

View File

@ -3,9 +3,9 @@ package app.revanced.extension.shared.patches;
import android.net.Uri;
import app.revanced.extension.music.settings.Settings;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.shared.utils.Logger;
import app.revanced.extension.shared.utils.PackageUtils;
import app.revanced.extension.shared.settings.BaseSettings;
@SuppressWarnings("unused")
public class BlockRequestPatch {

View File

@ -39,14 +39,14 @@ public class ReturnYouTubeUsernamePatch {
*/
@NonNull
public static CharSequence onLithoTextLoaded(@NonNull Object conversionContext,
@NonNull CharSequence original) {
@NonNull CharSequence original) {
return onLithoTextLoaded(conversionContext, original, false);
}
@NonNull
private static CharSequence onLithoTextLoaded(@NonNull Object conversionContext,
@NonNull CharSequence original,
boolean fetchNeeded) {
@NonNull CharSequence original,
boolean fetchNeeded) {
try {
if (!RETURN_YOUTUBE_USERNAME_ENABLED) {
return original;

View File

@ -31,7 +31,7 @@ public abstract class Filter {
protected final List<StringFilterGroup> callbacks = new ArrayList<>();
/**
* Adds callbacks to {@link #skip(String, SpannableString , Object, int, int, int, boolean, SpanType, StringFilterGroup)}
* Adds callbacks to {@link #skip(String, SpannableString, Object, int, int, int, boolean, SpanType, StringFilterGroup)}
* if any of the groups are found.
*/
protected final void addCallbacks(StringFilterGroup... groups) {

View File

@ -22,7 +22,8 @@ import app.revanced.extension.shared.utils.StringTrieSearch;
/**
* Placeholder for actual filters.
*/
final class DummyFilter extends Filter { }
final class DummyFilter extends Filter {
}
@SuppressWarnings("unused")
public final class InclusiveSpanPatch {
@ -107,7 +108,7 @@ public final class InclusiveSpanPatch {
: spanType.type;
}
private static final Filter[] filters = new Filter[] {
private static final Filter[] filters = new Filter[]{
new DummyFilter() // Replaced by patch.
};
@ -185,12 +186,12 @@ public final class InclusiveSpanPatch {
/**
* Injection point.
*
* @param spannableString Original SpannableString.
* @param span Span such as {@link ClickableSpan}, {@link ForegroundColorSpan},
* {@link AbsoluteSizeSpan}, {@link TypefaceSpan}, {@link ImageSpan}.
* @param start Start index of {@link Spannable#setSpan(Object, int, int, int)}.
* @param end End index of {@link Spannable#setSpan(Object, int, int, int)}.
* @param flags Flags of {@link Spannable#setSpan(Object, int, int, int)}.
* @param spannableString Original SpannableString.
* @param span Span such as {@link ClickableSpan}, {@link ForegroundColorSpan},
* {@link AbsoluteSizeSpan}, {@link TypefaceSpan}, {@link ImageSpan}.
* @param start Start index of {@link Spannable#setSpan(Object, int, int, int)}.
* @param end End index of {@link Spannable#setSpan(Object, int, int, int)}.
* @param flags Flags of {@link Spannable#setSpan(Object, int, int, int)}.
*/
public static void setSpan(SpannableString spannableString, Object span, int start, int end, int flags) {
if (returnEarly(spannableString, span, start, end, flags)) {

View File

@ -15,10 +15,10 @@ import java.util.Map;
import app.revanced.extension.shared.patches.BlockRequestPatch;
import app.revanced.extension.shared.patches.client.AppClient.ClientType;
import app.revanced.extension.shared.patches.spoof.requests.StreamingDataRequest;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.shared.utils.Logger;
import app.revanced.extension.shared.utils.Utils;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.shared.patches.spoof.requests.StreamingDataRequest;
@SuppressWarnings("unused")
public class SpoofStreamingDataPatch extends BlockRequestPatch {
@ -101,7 +101,7 @@ public class SpoofStreamingDataPatch extends BlockRequestPatch {
* Fix playback by replace the streaming data.
* Called after {@link #fetchStreams(String, Map)}.
*
* @param originalStreamingData Original StreamingData.
* @param originalStreamingData Original StreamingData.
*/
@Nullable
public static ByteBuffer getStreamingData(String videoId, StreamingDataOuterClass$StreamingData originalStreamingData) {
@ -149,7 +149,7 @@ public class SpoofStreamingDataPatch extends BlockRequestPatch {
* <p>
* Called after {@link #getStreamingData(String, StreamingDataOuterClass$StreamingData)}.
*
* @param spoofedStreamingData Spoofed StreamingData.
* @param spoofedStreamingData Spoofed StreamingData.
*/
public static StreamingDataOuterClass$StreamingData getOriginalStreamingData(String videoId, StreamingDataOuterClass$StreamingData spoofedStreamingData) {
if (SPOOF_STREAMING_DATA) {

View File

@ -15,17 +15,19 @@ import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import app.revanced.extension.shared.patches.client.AppClient.ClientType;
import app.revanced.extension.shared.settings.BaseSettings;
import app.revanced.extension.shared.utils.Logger;
import app.revanced.extension.shared.utils.Utils;
import app.revanced.extension.shared.settings.BaseSettings;
/**
* Video streaming data. Fetching is tied to the behavior YT uses,

View File

@ -2,7 +2,6 @@ package app.revanced.extension.shared.settings;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static app.revanced.extension.shared.patches.PatchStatus.HideFullscreenAdsDefaultBoolean;
import static app.revanced.extension.shared.patches.PatchStatus.SpoofStreamingDataDefaultClient;

View File

@ -1,7 +1,11 @@
package app.revanced.extension.youtube.patches.general;
import static app.revanced.extension.shared.utils.StringRef.str;
import static app.revanced.extension.youtube.patches.general.MiniplayerPatch.MiniplayerType.*;
import static app.revanced.extension.youtube.patches.general.MiniplayerPatch.MiniplayerType.DISABLED;
import static app.revanced.extension.youtube.patches.general.MiniplayerPatch.MiniplayerType.MODERN_1;
import static app.revanced.extension.youtube.patches.general.MiniplayerPatch.MiniplayerType.MODERN_2;
import static app.revanced.extension.youtube.patches.general.MiniplayerPatch.MiniplayerType.MODERN_3;
import static app.revanced.extension.youtube.patches.general.MiniplayerPatch.MiniplayerType.ORIGINAL;
import static app.revanced.extension.youtube.utils.ExtendedUtils.IS_19_20_OR_GREATER;
import static app.revanced.extension.youtube.utils.ExtendedUtils.IS_19_21_OR_GREATER;
import static app.revanced.extension.youtube.utils.ExtendedUtils.IS_19_26_OR_GREATER;
@ -16,10 +20,10 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import app.revanced.extension.shared.settings.Setting;
import app.revanced.extension.shared.utils.Logger;
import app.revanced.extension.shared.utils.ResourceUtils;
import app.revanced.extension.shared.utils.Utils;
import app.revanced.extension.shared.settings.Setting;
import app.revanced.extension.youtube.settings.Settings;
@SuppressWarnings({"unused", "SpellCheckingInspection"})
@ -34,7 +38,9 @@ public final class MiniplayerPatch {
* Only available with 19.43+
*/
DISABLED(false, null),
/** Unmodified type, and same as un-patched. */
/**
* Unmodified type, and same as un-patched.
*/
ORIGINAL(null, null),
/**
* Exactly the same as MINIMAL and only here for migration of user settings.

View File

@ -6,14 +6,14 @@ import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.AnimatedVectorDrawable;
import java.util.Arrays;
import java.util.Locale;
import app.revanced.extension.shared.utils.Logger;
import app.revanced.extension.shared.utils.ResourceUtils;
import app.revanced.extension.shared.utils.Utils;
import app.revanced.extension.youtube.settings.Settings;
import java.util.Arrays;
import java.util.Locale;
@SuppressWarnings("unused")
public class SeekbarColorPatch {
@ -29,12 +29,12 @@ public class SeekbarColorPatch {
/**
* Default colors of the gradient seekbar.
*/
private static final int[] ORIGINAL_SEEKBAR_GRADIENT_COLORS = { 0xFFFF0033, 0xFFFF2791 };
private static final int[] ORIGINAL_SEEKBAR_GRADIENT_COLORS = {0xFFFF0033, 0xFFFF2791};
/**
* Default positions of the gradient seekbar.
*/
private static final float[] ORIGINAL_SEEKBAR_GRADIENT_POSITIONS = { 0.8f, 1.0f };
private static final float[] ORIGINAL_SEEKBAR_GRADIENT_POSITIONS = {0.8f, 1.0f};
/**
* Default YouTube seekbar color brightness.
@ -240,7 +240,7 @@ public class SeekbarColorPatch {
final int replacementAlpha = clamp(Color.alpha(seekbarColor) + alphaDifference, 0, 255);
final int replacementColor = Color.HSVToColor(replacementAlpha, hsv);
Logger.printDebug(() -> String.format("Original color: #%08X replacement color: #%08X",
originalColor, replacementColor));
originalColor, replacementColor));
return replacementColor;
} catch (Exception ex) {
Logger.printException(() -> "getSeekbarColorValue failure", ex);
@ -248,12 +248,16 @@ public class SeekbarColorPatch {
}
}
/** @noinspection SameParameterValue */
/**
* @noinspection SameParameterValue
*/
private static int clamp(int value, int lower, int upper) {
return Math.max(lower, Math.min(value, upper));
}
/** @noinspection SameParameterValue */
/**
* @noinspection SameParameterValue
*/
private static float clamp(float value, float lower, float upper) {
return Math.max(lower, Math.min(value, upper));
}

View File

@ -42,6 +42,7 @@ public class PlayerTypeHookPatch {
public void onViewAttachedToWindow(@Nullable View v) {
ShortsPlayerState.set(ShortsPlayerState.OPEN);
}
@Override
public void onViewDetachedFromWindow(@Nullable View v) {
ShortsPlayerState.set(ShortsPlayerState.CLOSED);