Skip to content

Commit

Permalink
feat(YouTube & YouTube Music - Return YouTube Dislike): Add `Show est…
Browse files Browse the repository at this point in the history
…imated likes` setting
  • Loading branch information
anddea committed Oct 15, 2024
1 parent e930894 commit c614ed4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.revanced.integrations.music.returnyoutubedislike;

import static app.revanced.integrations.shared.returnyoutubedislike.ReturnYouTubeDislike.Vote;
import static app.revanced.integrations.shared.utils.StringRef.str;
import static app.revanced.integrations.shared.utils.Utils.isSDKAbove;

import android.graphics.Canvas;
Expand Down Expand Up @@ -158,15 +159,21 @@ private static SpannableString createDislikeSpan(@NonNull Spanned oldSpannable,
// and the like count appears as a device language specific string that says 'Like'.
// Check if the string contains any numbers.
if (!Utils.containsNumber(oldLikes)) {
// Likes are hidden by video creator
//
// RYD does not directly provide like data, but can use an estimated likes
// using the same scale factor RYD applied to the raw dislikes.
//
// example video: https://www.youtube.com/watch?v=UnrU5vxCHxw
// RYD data: https://returnyoutubedislikeapi.com/votes?videoId=UnrU5vxCHxw
Logger.printDebug(() -> "Using estimated likes");
oldLikes = formatDislikeCount(voteData.getLikeCount());
if (Settings.RYD_ESTIMATED_LIKE.get()) {
// Likes are hidden by video creator
//
// RYD does not directly provide like data, but can use an estimated likes
// using the same scale factor RYD applied to the raw dislikes.
//
// example video: https://www.youtube.com/watch?v=UnrU5vxCHxw
// RYD data: https://returnyoutubedislikeapi.com/votes?videoId=UnrU5vxCHxw
Logger.printDebug(() -> "Using estimated likes");
oldLikes = formatDislikeCount(voteData.getLikeCount());
} else {
// Change the "Likes" string to show that likes and dislikes are hidden.
String hiddenMessageString = str("revanced_ryd_video_likes_hidden_by_video_owner");
return newSpanUsingStylingOfAnotherSpan(oldSpannable, hiddenMessageString);
}
}

SpannableStringBuilder builder = new SpannableStringBuilder("\u2009\u2009");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public class Settings extends BaseSettings {
public static final StringSetting RYD_USER_ID = new StringSetting("revanced_ryd_user_id", "", false, false);
public static final BooleanSetting RYD_DISLIKE_PERCENTAGE = new BooleanSetting("revanced_ryd_dislike_percentage", FALSE);
public static final BooleanSetting RYD_COMPACT_LAYOUT = new BooleanSetting("revanced_ryd_compact_layout", FALSE);
public static final BooleanSetting RYD_ESTIMATED_LIKE = new BooleanSetting("revanced_ryd_estimated_like", FALSE, true);
public static final BooleanSetting RYD_TOAST_ON_CONNECTION_ERROR = new BooleanSetting("revanced_ryd_toast_on_connection_error", FALSE);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,21 @@ private static SpannableString createDislikeSpan(@NonNull Spanned oldSpannable,
// and the like count appears as a device language specific string that says 'Like'.
// Check if the string contains any numbers.
if (!Utils.containsNumber(oldLikes)) {
// Likes are hidden by video creator
//
// RYD does not directly provide like data, but can use an estimated likes
// using the same scale factor RYD applied to the raw dislikes.
//
// example video: https://www.youtube.com/watch?v=UnrU5vxCHxw
// RYD data: https://returnyoutubedislikeapi.com/votes?videoId=UnrU5vxCHxw
Logger.printDebug(() -> "Using estimated likes");
oldLikes = formatDislikeCount(voteData.getLikeCount());
if (Settings.RYD_ESTIMATED_LIKE.get()) {
// Likes are hidden by video creator
//
// RYD does not directly provide like data, but can use an estimated likes
// using the same scale factor RYD applied to the raw dislikes.
//
// example video: https://www.youtube.com/watch?v=UnrU5vxCHxw
// RYD data: https://returnyoutubedislikeapi.com/votes?videoId=UnrU5vxCHxw
Logger.printDebug(() -> "Using estimated likes");
oldLikes = formatDislikeCount(voteData.getLikeCount());
} else {
// Change the "Likes" string to show that likes and dislikes are hidden.
String hiddenMessageString = str("revanced_ryd_video_likes_hidden_by_video_owner");
return newSpanUsingStylingOfAnotherSpan(oldSpannable, hiddenMessageString);
}
}

SpannableStringBuilder builder = new SpannableStringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting RYD_SHORTS = new BooleanSetting("ryd_shorts", TRUE, parent(RYD_ENABLED));
public static final BooleanSetting RYD_DISLIKE_PERCENTAGE = new BooleanSetting("ryd_dislike_percentage", FALSE, parent(RYD_ENABLED));
public static final BooleanSetting RYD_COMPACT_LAYOUT = new BooleanSetting("ryd_compact_layout", FALSE, parent(RYD_ENABLED));
public static final BooleanSetting RYD_ESTIMATED_LIKE = new BooleanSetting("ryd_estimated_like", FALSE, true, parent(RYD_ENABLED));
public static final BooleanSetting RYD_TOAST_ON_CONNECTION_ERROR = new BooleanSetting("ryd_toast_on_connection_error", FALSE, parent(RYD_ENABLED));


Expand Down

0 comments on commit c614ed4

Please sign in to comment.