Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove obsolete code #692

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import androidx.annotation.RequiresApi;

@SuppressWarnings("unused")
public final class RemoveScreencaptureRestrictionPatch {
// Member of AudioAttributes.Builder
@RequiresApi(api = Build.VERSION_CODES.Q)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.view.Window;
import android.view.WindowManager;

@SuppressWarnings("unused")
public class RemoveScreenshotRestrictionPatch {

public static void addFlags(Window window, int flags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("unused")
public final class FilterPromotedLinksPatch {

/**
* Injection point.
*
* Filters list from promoted links.
**/
public static List<?> filterChildren(final Iterable<?> links) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ private static String getGmsCoreDownload() {
}
}

// Modified by a patch. Do not touch.
/**
* Modified by a patch. Do not touch.
*
* @noinspection SameReturnValue
*/
private static String getGmsCoreVendorGroupId() {
return "app.revanced";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private Utils() {
* Injection point.
*
* @return The manifest 'Version' entry of the patches.jar used during patching.
* @noinspection SameReturnValue
*/
@SuppressWarnings("SameReturnValue")
public static String getPatchesReleaseVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import app.revanced.integrations.tiktok.settings.Settings;
import com.ss.android.ugc.aweme.feed.model.Aweme;

/** @noinspection unused*/
public class AdsFilter implements IFilter {
@Override
public boolean getEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Iterator;
import java.util.List;

@SuppressWarnings("unused")
public final class FeedItemsFilter {
private static final List<IFilter> FILTERS = List.of(
new AdsFilter(),
Expand All @@ -16,6 +17,9 @@ public final class FeedItemsFilter {
new LikeCountFilter()
);

/**
* Injection point.
*/
public static void filter(FeedItemList feedItemList) {
Iterator<Aweme> feedItemListIterator = feedItemList.items.iterator();
while (feedItemListIterator.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import app.revanced.integrations.tiktok.settings.Settings;
import com.ss.android.ugc.aweme.feed.model.Aweme;

@SuppressWarnings("unused")
public class ImageVideoFilter implements IFilter {
@Override
public boolean getEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import app.revanced.integrations.tiktok.settings.Settings;
import com.ss.android.ugc.aweme.feed.model.Aweme;

@SuppressWarnings("unused")
public class LiveFilter implements IFilter {
@Override
public boolean getEnabled() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.revanced.integrations.tiktok.settings;

@SuppressWarnings("unused")
public class SettingsStatus {
public static boolean feedFilterEnabled = false;
public static boolean downloadEnabled = false;
Expand All @@ -17,6 +18,7 @@ public static void enableSimSpoof() {
simSpoofEnabled = true;
}

/** @noinspection EmptyMethod*/
public static void load() {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Preference fragment for ReVanced settings
*/
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "unused"})
public class ReVancedPreferenceFragment extends AbstractPreferenceFragment {

@Override
Expand All @@ -33,6 +33,7 @@ protected void syncSettingWithPreference(@NonNull @NotNull Preference pref,
}

@Override
@SuppressWarnings("unused")
protected void initialize() {
final var context = getContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;

@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "unused"})
public abstract class ConditionalPreferenceCategory extends PreferenceCategory {
public ConditionalPreferenceCategory(Context context, PreferenceScreen screen) {
super(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import app.revanced.integrations.tiktok.settings.preference.DownloadPathPreference;
import app.revanced.integrations.tiktok.settings.preference.TogglePreference;

@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "unused"})
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved
public class DownloadsPreferenceCategory extends ConditionalPreferenceCategory {
public DownloadsPreferenceCategory(Context context, PreferenceScreen screen) {
super(context, screen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import app.revanced.integrations.tiktok.settings.SettingsStatus;
import app.revanced.integrations.tiktok.settings.preference.TogglePreference;

@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "unused"})
public class FeedFilterPreferenceCategory extends ConditionalPreferenceCategory {
public FeedFilterPreferenceCategory(Context context, PreferenceScreen screen) {
super(context, screen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import app.revanced.integrations.shared.settings.BaseSettings;
import app.revanced.integrations.tiktok.settings.preference.TogglePreference;

@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "unused"})
public class IntegrationsPreferenceCategory extends ConditionalPreferenceCategory {
public IntegrationsPreferenceCategory(Context context, PreferenceScreen screen) {
super(context, screen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import app.revanced.integrations.tiktok.settings.Settings;

@SuppressWarnings("unused")
public class PlaybackSpeedPatch {

public static void rememberPlaybackSpeed(float newSpeed) {
Settings.REMEMBERED_SPEED.save(newSpeed);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.view.View;
import android.widget.TextView;

/** @noinspection unused*/
public class CustomPreferenceCategory extends PreferenceCategory {
public CustomPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class ReVancedPreferenceFragment extends AbstractPreferenceFragment {

@Override
@SuppressWarnings("unused")
protected void initialize() {
super.initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import android.content.Intent;
import android.util.Log;

@SuppressWarnings("unused")
public final class OpenLinksWithAppChooserPatch {

public static void openWithChooser(final Context context, final Intent intent) {
Log.d("ReVanced", "Opening intent with chooser: " + intent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static void setActivityTheme(Activity activity) {

/**
* Injection point.
* @noinspection SameReturnValue
*/
@SuppressWarnings("SameReturnValue")
private static String darkThemeResourceName() {
Expand All @@ -58,6 +59,7 @@ public static int getDarkThemeColor() {

/**
* Injection point.
* @noinspection SameReturnValue
*/
@SuppressWarnings("SameReturnValue")
private static String lightThemeResourceName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class BypassURLRedirectsPatch {
public static Uri parseRedirectUri(String uri) {
final var parsed = Uri.parse(uri);

if (Settings.BYPASS_URL_REDIRECTS.get() && parsed.getPath().equals(YOUTUBE_REDIRECT_PATH)) {
if (Settings.BYPASS_URL_REDIRECTS.get() && YOUTUBE_REDIRECT_PATH.equals(parsed.getPath())) {
var query = Uri.parse(Uri.decode(parsed.getQueryParameter("q")));

Logger.printDebug(() -> "Bypassing YouTube redirect URI: " + query);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -91,99 +91,6 @@ private static void clearData() {
// while a regular video is on screen.
}

//
// 17.x non litho regular video player.
//

/**
* Resource identifier of old UI dislike button.
*/
private static final int OLD_UI_DISLIKE_BUTTON_RESOURCE_ID
= Utils.getResourceIdentifier("dislike_button", "id");

/**
* Dislikes text label used by old UI.
*/
@NonNull
private static WeakReference<TextView> oldUITextViewRef = new WeakReference<>(null);

/**
* Original old UI 'Dislikes' text before patch modifications.
* Required to reset the dislikes when changing videos and RYD is not available.
* Set only once during the first load.
*/
private static Spanned oldUIOriginalSpan;

/**
* Replacement span that contains dislike value. Used by {@link #oldUiTextWatcher}.
*/
@Nullable
private static Spanned oldUIReplacementSpan;

/**
* Old UI dislikes can be set multiple times by YouTube.
* To prevent reverting changes made here, this listener overrides any future changes YouTube makes.
*/
private static final TextWatcher oldUiTextWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
public void afterTextChanged(Editable s) {
if (oldUIReplacementSpan == null || oldUIReplacementSpan.toString().equals(s.toString())) {
return;
}
s.replace(0, s.length(), oldUIReplacementSpan); // Causes a recursive call back into this listener
}
};

private static void updateOldUIDislikesTextView() {
ReturnYouTubeDislike videoData = currentVideoData;
if (videoData == null) {
return;
}
TextView oldUITextView = oldUITextViewRef.get();
if (oldUITextView == null) {
return;
}
oldUIReplacementSpan = videoData.getDislikesSpanForRegularVideo(oldUIOriginalSpan, false, false);
if (!oldUIReplacementSpan.equals(oldUITextView.getText())) {
oldUITextView.setText(oldUIReplacementSpan);
}
}

/**
* Injection point. Called on main thread.
*
* Used when spoofing to 16.x and 17.x versions.
*/
public static void setOldUILayoutDislikes(int buttonViewResourceId, @Nullable TextView textView) {
try {
if (!Settings.RYD_ENABLED.get()
|| buttonViewResourceId != OLD_UI_DISLIKE_BUTTON_RESOURCE_ID
|| textView == null) {
return;
}
Logger.printDebug(() -> "setOldUILayoutDislikes");

if (oldUIOriginalSpan == null) {
// Use value of the first instance, as it appears TextViews can be recycled
// and might contain dislikes previously added by the patch.
oldUIOriginalSpan = (Spanned) textView.getText();
}
oldUITextViewRef = new WeakReference<>(textView);
// No way to check if a listener is already attached, so remove and add again.
textView.removeTextChangedListener(oldUiTextWatcher);
textView.addTextChangedListener(oldUiTextWatcher);

updateOldUIDislikesTextView();

} catch (Exception ex) {
Logger.printException(() -> "setOldUILayoutDislikes failure", ex);
}
}


//
// Litho player for both regular videos and Shorts.
//
Expand Down Expand Up @@ -713,11 +620,8 @@ public static void sendVote(int vote) {
if (v.value == vote) {
videoData.sendVote(v);

if (isNoneHiddenOrMinimized) {
if (lastLithoShortsVideoData != null) {
lithoShortsShouldUseCurrentData = true;
}
updateOldUIDislikesTextView();
if (isNoneHiddenOrMinimized && lastLithoShortsVideoData != null) {
lithoShortsShouldUseCurrentData = true;
}

return;
Expand Down
Loading
Loading