@@ -7,7 +7,6 @@ import android.content.Context
77import android.graphics.*
88import android.os.Handler
99import android.os.IBinder
10- import android.text.Html
1110import android.text.Spannable
1211import android.view.*
1312import android.view.ViewGroup
@@ -23,6 +22,7 @@ import androidx.annotation.StringRes
2322import androidx.annotation.StyleRes
2423import androidx.appcompat.view.ContextThemeWrapper
2524import androidx.appcompat.widget.AppCompatTextView
25+ import androidx.core.text.HtmlCompat
2626import androidx.core.view.setPadding
2727import timber.log.Timber
2828import java.lang.ref.WeakReference
@@ -124,7 +124,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
124124 offsetBy(
125125 (mNewLocation[0 ] - mOldLocation!! [0 ]).toFloat(),
126126 (mNewLocation[1 ] - mOldLocation!! [1 ]).toFloat()
127- )
127+ )
128128 }
129129
130130 mOldLocation!! [0 ] = mNewLocation[0 ]
@@ -137,12 +137,12 @@ class Tooltip private constructor(private val context: Context, builder: Builder
137137
138138 init {
139139 val theme = context.theme
140- .obtainStyledAttributes(
141- null ,
142- R .styleable.TooltipLayout ,
143- builder.defStyleAttr,
144- builder.defStyleRes
145- )
140+ .obtainStyledAttributes(
141+ null ,
142+ R .styleable.TooltipLayout ,
143+ builder.defStyleAttr,
144+ builder.defStyleRes
145+ )
146146 this .mPadding = theme.getDimensionPixelSize(R .styleable.TooltipLayout_ttlm_padding , 30 )
147147 mOverlayStyle =
148148 theme.getResourceId(
@@ -156,7 +156,8 @@ class Tooltip private constructor(private val context: Context, builder: Builder
156156 theme.getResourceId(R .styleable.TooltipLayout_ttlm_animationStyle , android.R .style.Animation_Toast )
157157 }
158158
159- val typedArray = context.theme.obtainStyledAttributes(mAnimationStyleResId, intArrayOf(android.R .attr.windowEnterAnimation, android.R .attr.windowExitAnimation))
159+ val typedArray =
160+ context.theme.obtainStyledAttributes(mAnimationStyleResId, intArrayOf(android.R .attr.windowEnterAnimation, android.R .attr.windowExitAnimation))
160161 mEnterAnimation = typedArray.getResourceId(typedArray.getIndex(0 ), 0 )
161162 mExitAnimation = typedArray.getResourceId(typedArray.getIndex(1 ), 0 )
162163 typedArray.recycle()
@@ -233,8 +234,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
233234 mTextView.text = if (text is Spannable ) {
234235 text
235236 } else {
236- @Suppress(" DEPRECATION" )
237- Html .fromHtml(text as String )
237+ HtmlCompat .fromHtml(text as String , HtmlCompat .FROM_HTML_MODE_COMPACT )
238238 }
239239 }
240240 }
@@ -326,8 +326,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
326326 text = if (mText is Spannable ) {
327327 mText
328328 } else {
329- @Suppress(" DEPRECATION" )
330- Html .fromHtml(this @Tooltip.mText as String )
329+ HtmlCompat .fromHtml(this @Tooltip.mText as String , HtmlCompat .FROM_HTML_MODE_COMPACT )
331330 }
332331
333332 mMaxWidth?.let { maxWidth = it }
@@ -489,7 +488,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
489488 contentPosition.y,
490489 contentPosition.x + w,
491490 contentPosition.y + h
492- )
491+ )
493492 if (! displayFrame.rectContainsWithTolerance(finalRect, mSizeTolerance.toInt())) {
494493 Timber .e(" content won't fit! $displayFrame , $finalRect " )
495494 return findPosition(parent, anchor, offset, gravities, params, fitToScreen)
@@ -637,7 +636,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
637636 gravities,
638637 params,
639638 fitToScreen)
640- )
639+ )
641640 }
642641
643642 fun hide () {
@@ -858,12 +857,11 @@ class Tooltip private constructor(private val context: Context, builder: Builder
858857
859858 fun styleId (@StyleRes styleId : Int? ): Builder {
860859 styleId?.let {
861- this .defStyleAttr = 0
862860 this .defStyleRes = it
863861 } ? : run {
864862 this .defStyleRes = R .style.ToolTipLayoutDefaultStyle
865- this .defStyleAttr = R .attr.ttlm_defaultStyle
866863 }
864+ this .defStyleAttr = R .attr.ttlm_defaultStyle
867865 return this
868866 }
869867
0 commit comments