Add Fabric logs to TextLayoutManager

Summary:
This diff add logging on Text Layout Manager.

changelog: [Internal][Android] Internal changes to extend logging

Reviewed By: JoshuaGross

Differential Revision: D21737356

fbshipit-source-id: f34091722ff95f83ca41c9f17c49d31ce6618c9a
This commit is contained in:
David Vacca
2020-05-28 13:41:56 -07:00
committed by Facebook GitHub Bot
parent 9bb7e06747
commit 6f8fc40195
@@ -21,6 +21,7 @@ import android.text.TextPaint;
import android.util.LayoutDirection;
import android.util.LruCache;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.PixelUtil;
@@ -35,6 +36,11 @@ import java.util.List;
/** Class responsible of creating {@link Spanned} object for the JS representation of Text */
public class TextLayoutManager {
// TODO T67606397: Refactor configuration of fabric logs
private static final boolean ENABLE_MEASURE_LOGGING = false;
private static final String TAG = "TextLayoutManager";
// It's important to pass the ANTI_ALIAS_FLAG flag to the constructor rather than setting it
// later by calling setFlags. This is because the latter approach triggers a bug on Android 4.4.2.
// The bug is that unicode emoticons aren't measured properly which causes text to be clipped.
@@ -421,8 +427,26 @@ public class TextLayoutManager {
}
}
return YogaMeasureOutput.make(
PixelUtil.toSPFromPixel(calculatedWidth), PixelUtil.toSPFromPixel(calculatedHeight));
float widthInSP = PixelUtil.toSPFromPixel(calculatedWidth);
float heightInSP = PixelUtil.toSPFromPixel(calculatedHeight);
if (ENABLE_MEASURE_LOGGING) {
FLog.e(
TAG,
"TextMeasure call ('"
+ text
+ "'): w: "
+ calculatedWidth
+ " px - h: "
+ calculatedHeight
+ " px - w : "
+ widthInSP
+ " sp - h: "
+ heightInSP
+ " sp");
}
return YogaMeasureOutput.make(widthInSP, heightInSP);
}
// TODO T31905686: This class should be private