Skip to content

Commit

Permalink
Merge pull request #126 from sephiroth74/hotfix/fixed_style
Browse files Browse the repository at this point in the history
Hotfix/fixed style
  • Loading branch information
sephiroth74 authored Mar 15, 2019
2 parents 505051a + 0f727e0 commit aa4b128
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 25 deletions.
8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@ android {
adbOptions {
timeOutInMs 60 * 20 * 1000
}

lintOptions {
abortOnError false
}
}

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

implementation('com.github.sephiroth74:NumberSlidingPicker:v1.0.0') {
implementation('com.github.sephiroth74:NumberSlidingPicker:v1.0.2') {
exclude module: 'android-target-tooltip'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MainActivity : AppCompatActivity() {
val overlay = checkbox_overlay.isChecked
val style = if (checkbox_style.isChecked) R.style.ToolTipAltStyle else null
val text =
if (text_tooltip.text.isNullOrEmpty()) text_tooltip.hint else text_tooltip.text!!.toSpannable()
if (text_tooltip.text.isNullOrEmpty()) text_tooltip.hint else text_tooltip.text!!.toString()

Timber.v("gravity: $gravity")
Timber.v("closePolicy: $closePolicy")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/dialog_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:padding="16dp">

<androidx.appcompat.widget.AppCompatTextView
style="@style/AlertDialog.MaterialComponents.Title.Text"
style="@style/MaterialAlertDialog.MaterialComponents.Title.Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dialog Fragment" />
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<item name="ttlm_arrowRatio">1.2</item>
<item name="ttlm_overlayStyle">@style/ToolTipOverlayAltStyle</item>
<item name="ttlm_animationStyle">@style/ToolTipAltAnimation</item>
<item name="ttlm_textStyle">@style/ToolTipAltTextStyle</item>
</style>

<style name="ToolTipAltTextStyle" parent="ToolTipTextStyle">
<item name="android:textColor">@android:color/black</item>
</style>

<style name="ToolTipOverlayAltStyle" parent="ToolTipOverlayDefaultStyle">
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.20'
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-beta02'
classpath 'com.android.tools.build:gradle:3.4.0-rc02'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=2.0.4
VERSION_CODE=105
VERSION_NAME=2.0.5
VERSION_CODE=106
GROUP=it.sephiroth.android.library.targettooltip

POM_DESCRIPTION=Custom tooltips for android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.content.Context
import android.graphics.*
import android.os.Handler
import android.os.IBinder
import android.text.Html
import android.text.Spannable
import android.view.*
import android.view.ViewGroup
Expand All @@ -23,6 +22,7 @@ import androidx.annotation.StringRes
import androidx.annotation.StyleRes
import androidx.appcompat.view.ContextThemeWrapper
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.text.HtmlCompat
import androidx.core.view.setPadding
import timber.log.Timber
import java.lang.ref.WeakReference
Expand Down Expand Up @@ -124,7 +124,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
offsetBy(
(mNewLocation[0] - mOldLocation!![0]).toFloat(),
(mNewLocation[1] - mOldLocation!![1]).toFloat()
)
)
}

mOldLocation!![0] = mNewLocation[0]
Expand All @@ -137,12 +137,12 @@ class Tooltip private constructor(private val context: Context, builder: Builder

init {
val theme = context.theme
.obtainStyledAttributes(
null,
R.styleable.TooltipLayout,
builder.defStyleAttr,
builder.defStyleRes
)
.obtainStyledAttributes(
null,
R.styleable.TooltipLayout,
builder.defStyleAttr,
builder.defStyleRes
)
this.mPadding = theme.getDimensionPixelSize(R.styleable.TooltipLayout_ttlm_padding, 30)
mOverlayStyle =
theme.getResourceId(
Expand All @@ -156,7 +156,8 @@ class Tooltip private constructor(private val context: Context, builder: Builder
theme.getResourceId(R.styleable.TooltipLayout_ttlm_animationStyle, android.R.style.Animation_Toast)
}

val typedArray = context.theme.obtainStyledAttributes(mAnimationStyleResId, intArrayOf(android.R.attr.windowEnterAnimation, android.R.attr.windowExitAnimation))
val typedArray =
context.theme.obtainStyledAttributes(mAnimationStyleResId, intArrayOf(android.R.attr.windowEnterAnimation, android.R.attr.windowExitAnimation))
mEnterAnimation = typedArray.getResourceId(typedArray.getIndex(0), 0)
mExitAnimation = typedArray.getResourceId(typedArray.getIndex(1), 0)
typedArray.recycle()
Expand Down Expand Up @@ -233,8 +234,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
mTextView.text = if (text is Spannable) {
text
} else {
@Suppress("DEPRECATION")
Html.fromHtml(text as String)
HtmlCompat.fromHtml(text as String, HtmlCompat.FROM_HTML_MODE_COMPACT)
}
}
}
Expand Down Expand Up @@ -326,8 +326,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
text = if (mText is Spannable) {
mText
} else {
@Suppress("DEPRECATION")
Html.fromHtml(this@Tooltip.mText as String)
HtmlCompat.fromHtml(this@Tooltip.mText as String, HtmlCompat.FROM_HTML_MODE_COMPACT)
}

mMaxWidth?.let { maxWidth = it }
Expand Down Expand Up @@ -489,7 +488,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
contentPosition.y,
contentPosition.x + w,
contentPosition.y + h
)
)
if (!displayFrame.rectContainsWithTolerance(finalRect, mSizeTolerance.toInt())) {
Timber.e("content won't fit! $displayFrame, $finalRect")
return findPosition(parent, anchor, offset, gravities, params, fitToScreen)
Expand Down Expand Up @@ -637,7 +636,7 @@ class Tooltip private constructor(private val context: Context, builder: Builder
gravities,
params,
fitToScreen)
)
)
}

fun hide() {
Expand Down Expand Up @@ -858,12 +857,11 @@ class Tooltip private constructor(private val context: Context, builder: Builder

fun styleId(@StyleRes styleId: Int?): Builder {
styleId?.let {
this.defStyleAttr = 0
this.defStyleRes = it
} ?: run {
this.defStyleRes = R.style.ToolTipLayoutDefaultStyle
this.defStyleAttr = R.attr.ttlm_defaultStyle
}
this.defStyleAttr = R.attr.ttlm_defaultStyle
return this
}

Expand Down
2 changes: 2 additions & 0 deletions xtooltip/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:autoLink">all</item>
<item name="android:linksClickable">true</item>
<item name="android:textAppearance">?android:attr/textAppearanceSmallInverse</item>
<item name="android:textColorLink">?android:attr/textColorPrimaryInverse</item>
<item name="android:gravity">start|top</item>
<item name="android:elevation" tools:ignore="NewApi">@dimen/ttlm_default_elevation</item>
<item name="android:translationZ" tools:ignore="NewApi">@dimen/ttlm_default_elevation</item>
Expand Down

0 comments on commit aa4b128

Please sign in to comment.