Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.view.AccessibilityDelegateCompat;
Expand All @@ -47,12 +46,10 @@
import com.facebook.react.uimanager.style.BorderStyle;
import com.facebook.react.uimanager.style.LogicalEdge;
import com.facebook.react.uimanager.style.Overflow;
import com.facebook.react.util.AndroidVersion;
import com.facebook.react.views.text.internal.span.CanvasEffectSpan;
import com.facebook.react.views.text.internal.span.ReactFragmentIndexSpan;
import com.facebook.react.views.text.internal.span.ReactTagSpan;
import com.facebook.yoga.YogaMeasureMode;
import java.lang.reflect.Method;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class ReactTextView extends AppCompatTextView implements ReactCompoundView {
Expand All @@ -63,10 +60,6 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
// https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java#L854
private static final int DEFAULT_GRAVITY = Gravity.TOP | Gravity.START;

// TextView.setUseBoundsForWidth (API 35+). Looked up reflectively because some internal targets
// compile against an SDK older than 35 (see AndroidVersion).
private static final @Nullable Method SET_USE_BOUNDS_FOR_WIDTH = resolveSetUseBoundsForWidth();

private int mNumberOfLines;
private @Nullable TextUtils.TruncateAt mEllipsizeLocation;
private boolean mAdjustsFontSizeToFit;
Expand All @@ -87,17 +80,6 @@ public ReactTextView(Context context) {
initView();
}

private static @Nullable Method resolveSetUseBoundsForWidth() {
if (Build.VERSION.SDK_INT < AndroidVersion.VERSION_CODE_VANILLA_ICE_CREAM) {
return null;
}
try {
return TextView.class.getMethod("setUseBoundsForWidth", boolean.class);
} catch (NoSuchMethodException e) {
return null;
}
}

/**
* Keeps this view's line breaking on the same basis as TextLayoutManager's measurement.
*
Expand All @@ -109,13 +91,8 @@ public ReactTextView(Context context) {
* one.
*/
private void matchLineBreakingToMeasurement() {
if (SET_USE_BOUNDS_FOR_WIDTH == null) {
return;
}
try {
SET_USE_BOUNDS_FOR_WIDTH.invoke(this, false);
} catch (ReflectiveOperationException e) {
FLog.w(ReactConstants.TAG, "Could not disable useBoundsForWidth on ReactTextView", e);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
setUseBoundsForWidth(false);
}
}

Expand Down
Loading