Skip to content

Commit aa4b128

Browse files
authored
Merge pull request sephiroth74#126 from sephiroth74/hotfix/fixed_style
Hotfix/fixed style
2 parents 505051a + 0f727e0 commit aa4b128

File tree

8 files changed

+34
-25
lines changed

8 files changed

+34
-25
lines changed

app/build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@ android {
2929
adbOptions {
3030
timeOutInMs 60 * 20 * 1000
3131
}
32+
33+
lintOptions {
34+
abortOnError false
35+
}
3236
}
3337

3438
dependencies {
3539
implementation fileTree(dir: 'libs', include: ['*.jar'])
3640
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3741
implementation 'androidx.appcompat:appcompat:1.0.2'
3842
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
39-
implementation 'com.google.android.material:material:1.1.0-alpha02'
43+
implementation 'com.google.android.material:material:1.1.0-alpha04'
4044
implementation 'com.jakewharton.timber:timber:4.7.1'
4145
implementation 'androidx.core:core-ktx:1.0.1'
4246

43-
implementation('com.github.sephiroth74:NumberSlidingPicker:v1.0.0') {
47+
implementation('com.github.sephiroth74:NumberSlidingPicker:v1.0.2') {
4448
exclude module: 'android-target-tooltip'
4549
}
4650

app/src/main/java/it/sephiroth/android/library/tooltip_demo/MainActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class MainActivity : AppCompatActivity() {
3131
val overlay = checkbox_overlay.isChecked
3232
val style = if (checkbox_style.isChecked) R.style.ToolTipAltStyle else null
3333
val text =
34-
if (text_tooltip.text.isNullOrEmpty()) text_tooltip.hint else text_tooltip.text!!.toSpannable()
34+
if (text_tooltip.text.isNullOrEmpty()) text_tooltip.hint else text_tooltip.text!!.toString()
3535

3636
Timber.v("gravity: $gravity")
3737
Timber.v("closePolicy: $closePolicy")

app/src/main/res/layout/dialog_fragment.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
android:padding="16dp">
88

99
<androidx.appcompat.widget.AppCompatTextView
10-
style="@style/AlertDialog.MaterialComponents.Title.Text"
10+
style="@style/MaterialAlertDialog.MaterialComponents.Title.Text"
1111
android:layout_width="match_parent"
1212
android:layout_height="wrap_content"
1313
android:text="Dialog Fragment" />

app/src/main/res/values/styles.xml

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
<item name="ttlm_arrowRatio">1.2</item>
2626
<item name="ttlm_overlayStyle">@style/ToolTipOverlayAltStyle</item>
2727
<item name="ttlm_animationStyle">@style/ToolTipAltAnimation</item>
28+
<item name="ttlm_textStyle">@style/ToolTipAltTextStyle</item>
29+
</style>
30+
31+
<style name="ToolTipAltTextStyle" parent="ToolTipTextStyle">
32+
<item name="android:textColor">@android:color/black</item>
2833
</style>
2934

3035
<style name="ToolTipOverlayAltStyle" parent="ToolTipOverlayDefaultStyle">

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.20'
4+
ext.kotlin_version = '1.3.21'
55
repositories {
66
google()
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.4.0-beta02'
10+
classpath 'com.android.tools.build:gradle:3.4.0-rc02'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VERSION_NAME=2.0.4
2-
VERSION_CODE=105
1+
VERSION_NAME=2.0.5
2+
VERSION_CODE=106
33
GROUP=it.sephiroth.android.library.targettooltip
44

55
POM_DESCRIPTION=Custom tooltips for android

xtooltip/src/main/java/it/sephiroth/android/library/xtooltip/Tooltip.kt

+15-17
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import android.content.Context
77
import android.graphics.*
88
import android.os.Handler
99
import android.os.IBinder
10-
import android.text.Html
1110
import android.text.Spannable
1211
import android.view.*
1312
import android.view.ViewGroup
@@ -23,6 +22,7 @@ import androidx.annotation.StringRes
2322
import androidx.annotation.StyleRes
2423
import androidx.appcompat.view.ContextThemeWrapper
2524
import androidx.appcompat.widget.AppCompatTextView
25+
import androidx.core.text.HtmlCompat
2626
import androidx.core.view.setPadding
2727
import timber.log.Timber
2828
import 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

xtooltip/src/main/res/values/styles.xml

+2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<item name="android:layout_width">match_parent</item>
1818
<item name="android:layout_height">match_parent</item>
1919
<item name="android:autoLink">all</item>
20+
<item name="android:linksClickable">true</item>
2021
<item name="android:textAppearance">?android:attr/textAppearanceSmallInverse</item>
22+
<item name="android:textColorLink">?android:attr/textColorPrimaryInverse</item>
2123
<item name="android:gravity">start|top</item>
2224
<item name="android:elevation" tools:ignore="NewApi">@dimen/ttlm_default_elevation</item>
2325
<item name="android:translationZ" tools:ignore="NewApi">@dimen/ttlm_default_elevation</item>

0 commit comments

Comments
 (0)