diff --git a/extensions/shared/src/main/java/app/revanced/extension/music/returnyoutubedislike/ReturnYouTubeDislike.java b/extensions/shared/src/main/java/app/revanced/extension/music/returnyoutubedislike/ReturnYouTubeDislike.java index faffaad72..7958e4019 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/music/returnyoutubedislike/ReturnYouTubeDislike.java +++ b/extensions/shared/src/main/java/app/revanced/extension/music/returnyoutubedislike/ReturnYouTubeDislike.java @@ -295,11 +295,10 @@ public class ReturnYouTubeDislike { private static String formatDislikeCount(long dislikeCount) { if (isSDKAbove(24)) { if (dislikeCountFormatter == null) { - // Note: Java number formatters will use the locale specific number characters. - // such as Arabic which formats "1.234" into "۱,۲۳٤" - // But YouTube disregards locale specific number characters - // and instead shows english number characters everywhere. - Locale locale = Objects.requireNonNull(Utils.getContext()).getResources().getConfiguration().getLocales().get(0); + // Must use default locale and not Utils context locale, + // otherwise if using a different settings language then the + // formatting will use that of the different language. + Locale locale = Locale.getDefault(); Logger.printDebug(() -> "Locale: " + locale); dislikeCountFormatter = CompactDecimalFormat.getInstance(locale, CompactDecimalFormat.CompactStyle.SHORT); } @@ -313,7 +312,7 @@ public class ReturnYouTubeDislike { if (isSDKAbove(24)) { synchronized (ReturnYouTubeDislike.class) { // number formatter is not thread safe, must synchronize if (dislikePercentageFormatter == null) { - Locale locale = Objects.requireNonNull(Utils.getContext()).getResources().getConfiguration().getLocales().get(0); + Locale locale = Locale.getDefault(); Logger.printDebug(() -> "Locale: " + locale); dislikePercentageFormatter = NumberFormat.getPercentInstance(locale); } diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/returnyoutubedislike/ReturnYouTubeDislike.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/returnyoutubedislike/ReturnYouTubeDislike.java index c2d727885..16a3ef066 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/returnyoutubedislike/ReturnYouTubeDislike.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/returnyoutubedislike/ReturnYouTubeDislike.java @@ -352,13 +352,16 @@ public class ReturnYouTubeDislike { private static String formatDislikeCount(long dislikeCount) { if (isSDKAbove(24)) { - synchronized (ReturnYouTubeDislike.class) { // number formatter is not thread safe, must synchronize + synchronized (ReturnYouTubeDislike.class) { // Number formatter is not thread safe. if (dislikeCountFormatter == null) { - Locale locale = Objects.requireNonNull(Utils.getContext()).getResources().getConfiguration().getLocales().get(0); + // Must use default locale and not Utils context locale, + // otherwise if using a different settings language then the + // formatting will use that of the different language. + Locale locale = Locale.getDefault(); dislikeCountFormatter = CompactDecimalFormat.getInstance(locale, CompactDecimalFormat.CompactStyle.SHORT); // YouTube disregards locale specific number characters - // and instead shows english number characters everywhere. + // and instead shows English number characters everywhere. // To use the same behavior, override the digit characters to use English // so languages such as Arabic will show "1.234" instead of the native "۱,۲۳٤" if (isSDKAbove(28)) { @@ -379,7 +382,7 @@ public class ReturnYouTubeDislike { if (isSDKAbove(24)) { synchronized (ReturnYouTubeDislike.class) { // number formatter is not thread safe, must synchronize if (dislikePercentageFormatter == null) { - Locale locale = Objects.requireNonNull(Utils.getContext()).getResources().getConfiguration().getLocales().get(0); + Locale locale = Locale.getDefault(); dislikePercentageFormatter = NumberFormat.getPercentInstance(locale); // Want to set the digit strings, and the simplest way is to cast to the implementation NumberFormat returns. @@ -597,6 +600,15 @@ public class ReturnYouTubeDislike { } if (spanIsForLikes) { + if (!Utils.containsNumber(original)) { + if (!Settings.RYD_ESTIMATED_LIKE.get()) { + Logger.printDebug(() -> "Likes are hidden"); + return original; + } else { + Logger.printDebug(() -> "Using estimated likes"); + } + } + // Scrolling Shorts does not cause the Spans to be reloaded, // so there is no need to cache the likes for this situations. Logger.printDebug(() -> "Creating likes span for: " + votingData.videoId);