@@ -7,7 +7,6 @@ import android.content.Context
7
7
import android.graphics.*
8
8
import android.os.Handler
9
9
import android.os.IBinder
10
- import android.text.Html
11
10
import android.text.Spannable
12
11
import android.view.*
13
12
import android.view.ViewGroup
@@ -23,6 +22,7 @@ import androidx.annotation.StringRes
23
22
import androidx.annotation.StyleRes
24
23
import androidx.appcompat.view.ContextThemeWrapper
25
24
import androidx.appcompat.widget.AppCompatTextView
25
+ import androidx.core.text.HtmlCompat
26
26
import androidx.core.view.setPadding
27
27
import timber.log.Timber
28
28
import java.lang.ref.WeakReference
@@ -124,7 +124,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
124
124
offsetBy(
125
125
(mNewLocation[0 ] - mOldLocation!! [0 ]).toFloat(),
126
126
(mNewLocation[1 ] - mOldLocation!! [1 ]).toFloat()
127
- )
127
+ )
128
128
}
129
129
130
130
mOldLocation!! [0 ] = mNewLocation[0 ]
@@ -137,12 +137,12 @@ class Tooltip private constructor(private val context: Context, builder: Builder
137
137
138
138
init {
139
139
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
+ )
146
146
this .mPadding = theme.getDimensionPixelSize(R .styleable.TooltipLayout_ttlm_padding , 30 )
147
147
mOverlayStyle =
148
148
theme.getResourceId(
@@ -156,7 +156,8 @@ class Tooltip private constructor(private val context: Context, builder: Builder
156
156
theme.getResourceId(R .styleable.TooltipLayout_ttlm_animationStyle , android.R .style.Animation_Toast )
157
157
}
158
158
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))
160
161
mEnterAnimation = typedArray.getResourceId(typedArray.getIndex(0 ), 0 )
161
162
mExitAnimation = typedArray.getResourceId(typedArray.getIndex(1 ), 0 )
162
163
typedArray.recycle()
@@ -233,8 +234,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
233
234
mTextView.text = if (text is Spannable ) {
234
235
text
235
236
} else {
236
- @Suppress(" DEPRECATION" )
237
- Html .fromHtml(text as String )
237
+ HtmlCompat .fromHtml(text as String , HtmlCompat .FROM_HTML_MODE_COMPACT )
238
238
}
239
239
}
240
240
}
@@ -326,8 +326,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
326
326
text = if (mText is Spannable ) {
327
327
mText
328
328
} 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 )
331
330
}
332
331
333
332
mMaxWidth?.let { maxWidth = it }
@@ -489,7 +488,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
489
488
contentPosition.y,
490
489
contentPosition.x + w,
491
490
contentPosition.y + h
492
- )
491
+ )
493
492
if (! displayFrame.rectContainsWithTolerance(finalRect, mSizeTolerance.toInt())) {
494
493
Timber .e(" content won't fit! $displayFrame , $finalRect " )
495
494
return findPosition(parent, anchor, offset, gravities, params, fitToScreen)
@@ -637,7 +636,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
637
636
gravities,
638
637
params,
639
638
fitToScreen)
640
- )
639
+ )
641
640
}
642
641
643
642
fun hide () {
@@ -858,12 +857,11 @@ class Tooltip private constructor(private val context: Context, builder: Builder
858
857
859
858
fun styleId (@StyleRes styleId : Int? ): Builder {
860
859
styleId?.let {
861
- this .defStyleAttr = 0
862
860
this .defStyleRes = it
863
861
} ? : run {
864
862
this .defStyleRes = R .style.ToolTipLayoutDefaultStyle
865
- this .defStyleAttr = R .attr.ttlm_defaultStyle
866
863
}
864
+ this .defStyleAttr = R .attr.ttlm_defaultStyle
867
865
return this
868
866
}
869
867
0 commit comments