Skip to content

Commit

Permalink
Use the UNSET constant more consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
cubuspl42 committed Nov 1, 2023
1 parent 4f59241 commit 6bc6966
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package com.facebook.react.common.assets;

import static com.facebook.react.views.text.TextAttributeProps.UNSET;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
Expand Down Expand Up @@ -167,7 +169,6 @@ public static class TypefaceStyle {

public static final int BOLD = 700;
public static final int NORMAL = 400;
public static final int UNSET = -1;

private static final int MIN_WEIGHT = 1;
private static final int MAX_WEIGHT = 1000;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.facebook.react.internal.views.text

import com.facebook.react.common.assets.ReactFontManager
import com.facebook.react.views.text.TextAttributeProps.UNSET
import com.facebook.react.views.text.TextTransform

/**
* Interface for an entity providing effective text attributes of a text node/fragment
*/
interface EffectiveTextAttributeProvider : BasicTextAttributeProvider {
companion object {
const val UNSET = ReactFontManager.TypefaceStyle.UNSET
}

val textTransform: TextTransform

val effectiveLetterSpacing: Float
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.react.internal.views.text

import com.facebook.react.views.text.ReactBaseTextShadowNode
import com.facebook.react.views.text.TextAttributeProps.UNSET
import com.facebook.react.views.text.TextAttributes
import com.facebook.react.views.text.TextTransform

Expand Down Expand Up @@ -37,7 +38,7 @@ class HierarchicTextAttributeProvider(
return if (parentTextAttributes == null || parentTextAttributes.effectiveFontSize != fontSize) {
fontSize
} else {
EffectiveTextAttributeProvider.UNSET
UNSET
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ import android.content.Context
import android.graphics.Color
import android.text.*
import android.view.View
import com.facebook.react.common.assets.ReactFontManager
import com.facebook.react.uimanager.PixelUtil
import com.facebook.react.uimanager.ReactAccessibilityDelegate
import com.facebook.react.internal.views.text.fragments.TextFragmentList
import com.facebook.react.views.text.*
import com.facebook.react.views.text.TextAttributeProps.UNSET

/**
* Utility methods for building [Spannable]s
*/
object TextLayoutUtils {
private const val INLINE_VIEW_PLACEHOLDER = "0"
private const val UNSET = ReactFontManager.TypefaceStyle.UNSET

fun buildSpannableFromTextFragmentList(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package com.facebook.react.views.text;

import static com.facebook.react.views.text.TextAttributeProps.UNSET;

import android.content.res.AssetManager;
import android.graphics.Paint;
import android.graphics.Typeface;
Expand Down Expand Up @@ -61,11 +63,11 @@ public void updateMeasureState(TextPaint paint) {
}

public int getStyle() {
return mStyle == ReactFontManager.TypefaceStyle.UNSET ? Typeface.NORMAL : mStyle;
return mStyle == UNSET ? Typeface.NORMAL : mStyle;
}

public int getWeight() {
return mWeight == ReactFontManager.TypefaceStyle.UNSET
return mWeight == UNSET
? ReactFontManager.TypefaceStyle.NORMAL
: mWeight;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

package com.facebook.react.views.text;


import static com.facebook.react.views.text.TextAttributeProps.UNSET;

import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
Expand All @@ -21,7 +24,6 @@
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.assets.ReactFontManager;
import com.facebook.react.internal.views.text.BasicTextAttributeProvider;
import com.facebook.react.internal.views.text.HierarchicTextAttributeProvider;
import com.facebook.react.internal.views.text.TextLayoutUtils;
Expand Down Expand Up @@ -59,7 +61,6 @@ public abstract class ReactBaseTextShadowNode extends LayoutShadowNode implement
// character.
// https://en.wikipedia.org/wiki/Bi-directional_text#weak_characters
private static final String INLINE_VIEW_PLACEHOLDER = "0";
public static final int UNSET = ReactFontManager.TypefaceStyle.UNSET;

public static final String PROP_SHADOW_OFFSET = "textShadowOffset";
public static final String PROP_SHADOW_OFFSET_WIDTH = "width";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package com.facebook.react.views.text;

import static com.facebook.react.views.text.TextAttributeProps.UNSET;

import android.os.Build;
import android.text.BoringLayout;
import android.text.Layout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

package com.facebook.react.views.text;

import static com.facebook.react.views.text.TextAttributeProps.UNSET;

import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.assets.ReactFontManager;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -45,7 +48,7 @@ public static int parseFontWeight(@Nullable String fontWeightString) {
return 900;
}
}
return ReactFontManager.TypefaceStyle.UNSET;
return UNSET;
}

public static int parseFontStyle(@Nullable String fontStyleString) {
Expand All @@ -57,7 +60,7 @@ public static int parseFontStyle(@Nullable String fontStyleString) {
return Typeface.NORMAL;
}
}
return ReactFontManager.TypefaceStyle.UNSET;
return UNSET;
}

public static @Nullable String parseFontVariant(@Nullable ReadableArray fontVariantArray) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package com.facebook.react.views.textinput;

import static com.facebook.react.views.text.TextAttributeProps.UNSET;

import android.text.Layout;
import android.util.TypedValue;
import android.view.ViewGroup;
Expand Down

0 comments on commit 6bc6966

Please sign in to comment.