Skip to content

Commit

Permalink
Merge pull request #527 from skydoves/feature/includeFontPadding
Browse files Browse the repository at this point in the history
Support setting includeFontPadding for the default text
  • Loading branch information
skydoves authored Nov 3, 2023
2 parents 6ae76a8 + bfa47c8 commit 90c1ec4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions balloon/api/balloon.api
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public final class com/skydoves/balloon/Balloon$Builder {
public final fun getIconHeight ()I
public final fun getIconSpace ()I
public final fun getIconWidth ()I
public final fun getIncludeFontPadding ()Z
public final fun getLayout ()Landroid/view/View;
public final fun getLayoutRes ()Ljava/lang/Integer;
public final fun getLifecycleObserver ()Landroidx/lifecycle/LifecycleObserver;
Expand Down Expand Up @@ -415,6 +416,8 @@ public final class com/skydoves/balloon/Balloon$Builder {
public final fun setIconWidth (I)Lcom/skydoves/balloon/Balloon$Builder;
public final synthetic fun setIconWidth (I)V
public final fun setIconWidthResource (I)Lcom/skydoves/balloon/Balloon$Builder;
public final fun setIncludeFontPadding (Z)Lcom/skydoves/balloon/Balloon$Builder;
public final synthetic fun setIncludeFontPadding (Z)V
public final fun setIsAttachedInDecor (Z)Lcom/skydoves/balloon/Balloon$Builder;
public final fun setIsComposableContent (Z)Lcom/skydoves/balloon/Balloon$Builder;
public final fun setIsStatusBarVisible (Z)Lcom/skydoves/balloon/Balloon$Builder;
Expand Down Expand Up @@ -823,6 +826,7 @@ public final class com/skydoves/balloon/PlacementType : java/lang/Enum {

public final class com/skydoves/balloon/TextForm {
public synthetic fun <init> (Lcom/skydoves/balloon/TextForm$Builder;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getIncludeFontPadding ()Z
public final fun getMovementMethod ()Landroid/text/method/MovementMethod;
public final fun getText ()Ljava/lang/CharSequence;
public final fun getTextColor ()I
Expand All @@ -839,6 +843,7 @@ public final class com/skydoves/balloon/TextForm$Builder {
public fun <init> (Landroid/content/Context;)V
public final fun build ()Lcom/skydoves/balloon/TextForm;
public final fun getContext ()Landroid/content/Context;
public final fun getIncludeFontPadding ()Z
public final fun getMovementMethod ()Landroid/text/method/MovementMethod;
public final fun getText ()Ljava/lang/CharSequence;
public final fun getTextColor ()I
Expand All @@ -849,6 +854,8 @@ public final class com/skydoves/balloon/TextForm$Builder {
public final fun getTextSize ()F
public final fun getTextTypeface ()I
public final fun getTextTypefaceObject ()Landroid/graphics/Typeface;
public final fun setIncludeFontPadding (Z)Lcom/skydoves/balloon/TextForm$Builder;
public final synthetic fun setIncludeFontPadding (Z)V
public final fun setMovementMethod (Landroid/text/method/MovementMethod;)Lcom/skydoves/balloon/TextForm$Builder;
public final synthetic fun setMovementMethod (Landroid/text/method/MovementMethod;)V
public final fun setText (Ljava/lang/CharSequence;)Lcom/skydoves/balloon/TextForm$Builder;
Expand Down
8 changes: 8 additions & 0 deletions balloon/src/main/kotlin/com/skydoves/balloon/Balloon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,9 @@ public class Balloon private constructor(
@set:JvmSynthetic
public var textLetterSpacing: Float? = null

@set:JvmSynthetic
public var includeFontPadding: Boolean = true

@set:JvmSynthetic
public var textGravity: Int = Gravity.CENTER

Expand Down Expand Up @@ -2606,6 +2609,11 @@ public class Balloon private constructor(
this.textLetterSpacing = context.dimen(value)
}

/** includes the font paddings of the text. */
public fun setIncludeFontPadding(value: Boolean): Builder = apply {
this.includeFontPadding = value
}

/**
* sets gravity of the text.
* this only works when the width or setWidthRatio set explicitly.
Expand Down
9 changes: 9 additions & 0 deletions balloon/src/main/kotlin/com/skydoves/balloon/TextForm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class TextForm private constructor(

public val textLineSpacing: Float? = builder.textLineSpacing

public val includeFontPadding: Boolean = builder.includeFontPadding

public val textLetterSpacing: Float? = builder.textLetterSpacing

public val textGravity: Int = builder.textGravity
Expand Down Expand Up @@ -107,6 +109,9 @@ public class TextForm private constructor(
@set:JvmSynthetic
public var textLineSpacing: Float? = null

@set:JvmSynthetic
public var includeFontPadding: Boolean = true

@set:JvmSynthetic
public var textLetterSpacing: Float? = null

Expand Down Expand Up @@ -153,6 +158,10 @@ public class TextForm private constructor(
public fun setTextLetterSpacing(@Dp value: Float?): Builder =
apply { this.textLetterSpacing = value }

/** includes the font paddings of the text. */
public fun setIncludeFontPadding(value: Boolean): Builder =
apply { this.includeFontPadding = value }

/** sets the line spacing value resource of the text. */
public fun setTextLineSpacingResource(@DimenRes value: Int): Builder = apply {
this.textLineSpacing = context.dimen(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ internal fun TextView.applyTextForm(textForm: TextForm) {
textSize = textForm.textSize
gravity = textForm.textGravity
setTextColor(textForm.textColor)
includeFontPadding = textForm.includeFontPadding
textForm.textLineSpacing?.let { setLineSpacing(it, 1.0f) }
textForm.textLetterSpacing?.let { letterSpacing = it }
textForm.textTypeface?.let { typeface = it } ?: setTypeface(typeface, textForm.textStyle)
Expand Down

0 comments on commit 90c1ec4

Please sign in to comment.