Skip to content

Commit

Permalink
fix(Return YouTube Dislike): Center align the span if there is unused…
Browse files Browse the repository at this point in the history
… horizontal width
  • Loading branch information
LisoUseInAIKyrios committed Jan 10, 2024
1 parent 12fe186 commit d2eb61a
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ private static void addRollingNumberPatchChanges(TextView view) {
if (view.getCompoundDrawablePadding() == 0) {
Logger.printDebug(() -> "Adding rolling number TextView changes");
view.setCompoundDrawablePadding(ReturnYouTubeDislike.leftSeparatorShapePaddingPixels);
// Liking/disliking can cause the span to grow in size,
// which is ok and is laid out correctly,
// but if the user then undoes their action the layout will not remove the extra padding.
// Use a center alignment to take up any extra space.
view.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
ShapeDrawable separator = ReturnYouTubeDislike.getLeftSeparatorDrawable();
if (Utils.isRightToLeftTextLayout()) {
view.setCompoundDrawables(null, null, separator, null);
Expand All @@ -362,6 +367,7 @@ private static void addRollingNumberPatchChanges(TextView view) {
private static void removeRollingNumberPatchChanges(TextView view) {
if (view.getCompoundDrawablePadding() != 0) {
Logger.printDebug(() -> "Removing rolling number TextView changes");
view.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY); // Default alignment
view.setCompoundDrawablePadding(0);
view.setCompoundDrawables(null, null, null, null);
view.setSingleLine(false);
Expand Down

0 comments on commit d2eb61a

Please sign in to comment.