Skip to content

Commit

Permalink
update foreground and background color spans
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlntn committed Feb 1, 2024
1 parent 366001c commit 6344460
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.facebook.react.views.text;

import android.graphics.Color;
import android.text.style.BackgroundColorSpan;

/*
Expand All @@ -16,4 +17,8 @@ public class ReactBackgroundColorSpan extends BackgroundColorSpan implements Rea
public ReactBackgroundColorSpan(int color) {
super(color);
}

public ReactBackgroundColorSpan(long color) {
super(Color.toArgb(color));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected Spannable spannedFromShadowNode(
protected boolean mIsColorSet = false;
protected long mColor;
protected boolean mIsBackgroundColorSet = false;
protected int mBackgroundColor;
protected long mBackgroundColor;

protected @Nullable AccessibilityRole mAccessibilityRole = null;
protected @Nullable Role mRole = null;
Expand Down Expand Up @@ -471,7 +471,7 @@ public void setBackgroundColor(@Nullable Long color) {
if (isVirtual()) {
mIsBackgroundColorSet = (color != null);
if (mIsBackgroundColorSet) {
mBackgroundColor = Color.toArgb(color);
mBackgroundColor = color;
}
markUpdated();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

package com.facebook.react.views.text;

import androidx.annotation.NonNull;
import android.graphics.Color;
import android.os.Parcel;
import android.text.style.ForegroundColorSpan;
import android.text.TextPaint;
import com.facebook.common.logging.FLog;
import androidx.annotation.NonNull;

/*
* Wraps {@link ForegroundColorSpan} as a {@link ReactSpan}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class TextAttributeProps {
protected boolean mAllowFontScaling = true;
protected long mColor;
protected boolean mIsBackgroundColorSet = false;
protected int mBackgroundColor;
protected long mBackgroundColor;

protected int mNumberOfLines = UNSET;
protected int mFontSize = UNSET;
Expand Down Expand Up @@ -428,7 +428,7 @@ private void setBackgroundColor(Long color) {
// if (!isVirtualAnchor()) {
mIsBackgroundColorSet = (color != null);
if (mIsBackgroundColorSet) {
mBackgroundColor = Color.valueOf(color).toArgb();
mBackgroundColor = color;
}
// }
}
Expand Down

0 comments on commit 6344460

Please sign in to comment.