Skip to content

Commit

Permalink
fix(YouTube - Return YouTube Dislike): Fix dislikes sometimes not sho…
Browse files Browse the repository at this point in the history
…wing for non English language
  • Loading branch information
LisoUseInAIKyrios committed Dec 3, 2023
1 parent 3a56431 commit 5d4c8b0
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -318,8 +318,12 @@ public static float onRollingNumberMeasured(String text, float measuredTextWidth
try {
if (SettingsEnum.RYD_ENABLED.getBoolean() && !SettingsEnum.RYD_COMPACT_LAYOUT.getBoolean()) {
if (ReturnYouTubeDislike.isPreviouslyCreatedSegmentedSpan(text)) {
// +1 pixel is needed for some foreign languages that measure
// the text different from what is used for layout (Greek in particular).
// Probably a bug in Android, but who knows.
// Single line mode is also used as an additional fix for this issue.
return measuredTextWidth + ReturnYouTubeDislike.leftSeparatorBounds.right
+ ReturnYouTubeDislike.leftSeparatorShapePaddingPixels;
+ ReturnYouTubeDislike.leftSeparatorShapePaddingPixels + 1;
}
}
} catch (Exception ex) {
Expand All @@ -342,6 +346,10 @@ private static void addRollingNumberPatchChanges(TextView view) {
} else {
view.setCompoundDrawables(separator, null, null, null);
}
// Single line mode does not clip words if the span is larger than the view bounds.
// The styled span applied to the view should always have the same bounds,
// but use this feature just in case the measurements are somehow off by a few pixels.
view.setSingleLine(true);
}
}

Expand All @@ -354,6 +362,7 @@ private static void removeRollingNumberPatchChanges(TextView view) {
LogHelper.printDebug(() -> "Removing rolling number TextView changes");
view.setCompoundDrawablePadding(0);
view.setCompoundDrawables(null, null, null, null);
view.setSingleLine(false);
}
}

Expand Down

0 comments on commit 5d4c8b0

Please sign in to comment.