Skip to content

Commit

Permalink
feat(youtube/return-youtube-dislike): support for shorts (#312)
Browse files Browse the repository at this point in the history
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
LisoUseInAIKyrios and oSumAtrIX committed Feb 24, 2023
1 parent fb1a69a commit 0aef5e6
Show file tree
Hide file tree
Showing 5 changed files with 417 additions and 255 deletions.
@@ -1,39 +1,48 @@
package app.revanced.integrations.patches;

import java.util.concurrent.atomic.AtomicReference;

import android.text.Spanned;
import app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike;

import java.util.concurrent.atomic.AtomicReference;

/**
* Used by app.revanced.patches.youtube.layout.returnyoutubedislike.patch.ReturnYouTubeDislikePatch
*/
public class ReturnYouTubeDislikePatch {

/**
* Called when the video id changes
* Injection point
*/
public static void newVideoLoaded(String videoId) {
ReturnYouTubeDislike.newVideoLoaded(videoId);
}

/**
* Injection point
*
* Called when a litho text component is created
*/
public static void onComponentCreated(Object conversionContext, AtomicReference<Object> textRef) {
ReturnYouTubeDislike.onComponentCreated(conversionContext, textRef);
}

/**
* Injection point
*
* Called when a Shorts dislike Spannable is created
*/
public static Spanned onShortsComponentCreated(Spanned dislike) {
return ReturnYouTubeDislike.onShortsComponentCreated(dislike);
}

/**
* Injection point
*
* Called when the like/dislike button is clicked
*
* @param vote -1 (dislike), 0 (none) or 1 (like)
*/
public static void sendVote(int vote) {
for (ReturnYouTubeDislike.Vote v : ReturnYouTubeDislike.Vote.values()) {
if (v.value == vote) {
ReturnYouTubeDislike.sendVote(v);
return;
}
}
ReturnYouTubeDislike.sendVote(vote);
}
}

0 comments on commit 0aef5e6

Please sign in to comment.