mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-11-14 16:09:37 +01:00
fix(YouTube - ReturnYouTubeDislike): Revert support for 18.37.36 (#488)
This commit is contained in:
parent
78bea48e40
commit
165b061fa9
@ -1,25 +1,31 @@
|
|||||||
package app.revanced.integrations.patches;
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
|
import static app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike.Vote;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.*;
|
import android.text.Editable;
|
||||||
|
import android.text.Spannable;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.Spanned;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike;
|
|
||||||
import app.revanced.integrations.returnyoutubedislike.requests.ReturnYouTubeDislikeApi;
|
|
||||||
import app.revanced.integrations.settings.SettingsEnum;
|
|
||||||
import app.revanced.integrations.shared.PlayerType;
|
|
||||||
import app.revanced.integrations.utils.LogHelper;
|
|
||||||
import app.revanced.integrations.utils.ReVancedUtils;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike.Vote;
|
import app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike;
|
||||||
|
import app.revanced.integrations.returnyoutubedislike.requests.ReturnYouTubeDislikeApi;
|
||||||
|
import app.revanced.integrations.settings.SettingsEnum;
|
||||||
|
import app.revanced.integrations.shared.PlayerType;
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles all interaction of UI patch components.
|
* Handles all interaction of UI patch components.
|
||||||
@ -143,27 +149,23 @@ public class ReturnYouTubeDislikePatch {
|
|||||||
@NonNull AtomicReference<CharSequence> textRef,
|
@NonNull AtomicReference<CharSequence> textRef,
|
||||||
@NonNull CharSequence original) {
|
@NonNull CharSequence original) {
|
||||||
try {
|
try {
|
||||||
if (!SettingsEnum.RYD_ENABLED.getBoolean()) {
|
if (!SettingsEnum.RYD_ENABLED.getBoolean() || PlayerType.getCurrent().isNoneOrHidden()) {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
String conversionContextString = conversionContext.toString();
|
String conversionContextString = conversionContext.toString();
|
||||||
LogHelper.printDebug(() -> "conversionContext: " + conversionContextString);
|
LogHelper.printDebug(() -> "conversionContext: " + conversionContextString);
|
||||||
|
|
||||||
final Spanned replacement;
|
final boolean isSegmentedButton;
|
||||||
if (conversionContextString.contains("|segmented_like_dislike_button.eml|")) {
|
if (conversionContextString.contains("|segmented_like_dislike_button.eml|")) {
|
||||||
replacement = ReturnYouTubeDislike.getDislikesSpanForRegularVideo((Spannable) original, true);
|
isSegmentedButton = true;
|
||||||
} else if (conversionContextString.contains("|dislike_button.eml|") ) {
|
} else if (conversionContextString.contains("|dislike_button.eml|")) {
|
||||||
// This code path is basically dead because it's only used when spoofing between 17.09.xx and 17.30.xx
|
isSegmentedButton = false;
|
||||||
// but spoofing to that range gives a broken UI layout.
|
|
||||||
// Keep this check here anyways just in case the old litho layout is somehow still used.
|
|
||||||
replacement = ReturnYouTubeDislike.getDislikesSpanForRegularVideo((Spannable) original, false);
|
|
||||||
} else if (conversionContextString.contains("|shorts_dislike_button.eml|")) {
|
|
||||||
replacement = ReturnYouTubeDislike.getDislikeSpanForShort((Spannable) original);
|
|
||||||
} else {
|
} else {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spanned replacement = ReturnYouTubeDislike.getDislikesSpanForRegularVideo((Spannable) original, isSegmentedButton);
|
||||||
textRef.set(replacement);
|
textRef.set(replacement);
|
||||||
return replacement;
|
return replacement;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user