Skip to content

Commit 505051a

Browse files
authored
Merge pull request sephiroth74#120 from sephiroth74/feature/update_text_and_position
Feature/update text and position
2 parents 0cd52be + dafe1a7 commit 505051a

File tree

20 files changed

+421
-269
lines changed

20 files changed

+421
-269
lines changed

.travis.yml

Lines changed: 18 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,36 @@
11
language: android
22

33
jdk:
4-
- oraclejdk8
5-
6-
env:
7-
global:
8-
# install timeout in minutes (2 minutes by default)
9-
- ADB_INSTALL_TIMEOUT=16
4+
- oraclejdk8
105

116
android:
127
components:
8+
- tools
9+
- tools
1310
- build-tools-28.0.3
14-
- android-25
15-
- extra-android-m2repository
16-
- extra-android-suppor
17-
- add-on
18-
- extra
19-
20-
licenses:
21-
- 'android-sdk-license-.+'
22-
- 'android-sdk-preview-license-.+'
23-
- 'google-gdk-license-.+'
24-
- 'intel-android-extra-license-.+'
25-
- 'google-gdk-license-.+'
26-
- 'android-googletv-license-.+'
27-
28-
notifications:
29-
email:
30-
11+
- platform-tools
3112

32-
before_install:
13+
before_script:
3314
- mkdir "$ANDROID_HOME/licenses" || true
34-
- echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license"
35-
- sdkmanager tools
36-
- sdkmanager --update
37-
- sdkmanager emulator
38-
- sdkmanager "system-images;android-25;google_apis;armeabi-v7a"
39-
- sdkmanager --update
40-
- echo no | avdmanager create avd --force -n test -k "system-images;android-25;google_apis;armeabi-v7a" --device "pixel"
15+
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"
4116

42-
before_script:
43-
# - $ANDROID_HOME/emulator/emulator -avd test -no-audio -skin 1440x2560 &
44-
# - $ANDROID_HOME/emulator/emulator -avd test -gpu swiftshader_indirect -no-audio -no-window -verbose &
45-
# - android-wait-for-emulator
46-
# - adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
17+
before_install:
18+
- yes | sdkmanager "platforms;android-28"
4719

48-
script:
49-
- adb logcat > logcat.log &
50-
- ./gradlew clean build lint assemble
51-
# - ./gradlew app:connectedCheck
20+
notifications:
21+
email:
22+
5223

53-
after_script:
54-
- cat logcat.log
24+
cache: false
25+
sudo: false
5526

56-
after_failure:
57-
- cat logcat.log
27+
install:
28+
- chmod +x ./gradlew; ls -l gradlew; ./gradlew wrapper -v
5829

59-
sudo: false
30+
script:
31+
- ./gradlew clean build lint assemble
6032

6133
cache:
6234
directories:
35+
- $HOME/.m2
6336
- $HOME/.gradle

app/build.gradle

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
compileSdkVersion 28
99
defaultConfig {
1010
applicationId "it.sephiroth.android.library.tooltip_demo"
11-
minSdkVersion 18
11+
minSdkVersion 21
1212
targetSdkVersion 28
1313
versionCode 1
1414
versionName "1.0"
@@ -34,18 +34,23 @@ android {
3434
dependencies {
3535
implementation fileTree(dir: 'libs', include: ['*.jar'])
3636
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
37-
implementation 'androidx.appcompat:appcompat:1.0.1'
38-
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
39-
implementation 'com.google.android.material:material:1.1.0-alpha01'
37+
implementation 'androidx.appcompat:appcompat:1.0.2'
38+
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
39+
implementation 'com.google.android.material:material:1.1.0-alpha02'
4040
implementation 'com.jakewharton.timber:timber:4.7.1'
4141
implementation 'androidx.core:core-ktx:1.0.1'
4242

43+
implementation('com.github.sephiroth74:NumberSlidingPicker:v1.0.0') {
44+
exclude module: 'android-target-tooltip'
45+
}
46+
47+
4348
implementation project(':xtooltip')
4449

4550
testImplementation 'junit:junit:4.12'
4651

47-
androidTestImplementation 'androidx.test:runner:1.1.0'
48-
androidTestImplementation 'androidx.test:rules:1.1.0'
49-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
52+
androidTestImplementation 'androidx.test:runner:1.1.1'
53+
androidTestImplementation 'androidx.test:rules:1.1.1'
54+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
5055
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
5156
}

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

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package it.sephiroth.android.library.tooltip_demo
33
import android.os.Bundle
44
import androidx.appcompat.app.AppCompatActivity
55
import androidx.core.text.toSpannable
6+
import it.sephiroth.android.library.numberpicker.doOnProgressChanged
67
import it.sephiroth.android.library.xtooltip.ClosePolicy
78
import it.sephiroth.android.library.xtooltip.Tooltip
89
import it.sephiroth.android.library.xtooltip.Typefaces
9-
import kotlinx.android.synthetic.main.activity_main.*
1010
import kotlinx.android.synthetic.main.content_main.*
1111
import timber.log.Timber
1212

@@ -26,8 +26,7 @@ class MainActivity : AppCompatActivity() {
2626
val closePolicy = getClosePolicy()
2727
val typeface = if (checkbox_font.isChecked) Typefaces[this, "fonts/GillSans.ttc"] else null
2828
val animation = if (checkbox_animation.isChecked) Tooltip.Animation.DEFAULT else null
29-
val showDuration = if (text_duration.text.isNullOrEmpty()) 0 else text_duration.text.toString().toLong()
30-
val fadeDuration = if (text_fade.text.isNullOrEmpty()) 0 else text_fade.text.toString().toLong()
29+
val showDuration = seekbar_duration.progress.toLong()
3130
val arrow = checkbox_arrow.isChecked
3231
val overlay = checkbox_overlay.isChecked
3332
val style = if (checkbox_style.isChecked) R.style.ToolTipAltStyle else null
@@ -37,33 +36,39 @@ class MainActivity : AppCompatActivity() {
3736
Timber.v("gravity: $gravity")
3837
Timber.v("closePolicy: $closePolicy")
3938

39+
tooltip?.dismiss()
40+
4041
tooltip = Tooltip.Builder(this)
41-
.anchor(button, 0, 0, false)
42-
.text(text)
43-
.styleId(style)
44-
.typeface(typeface)
45-
.maxWidth(metrics.widthPixels / 2)
46-
.arrow(arrow)
47-
.floatingAnimation(animation)
48-
.closePolicy(closePolicy)
49-
.showDuration(showDuration)
50-
.fadeDuration(fadeDuration)
51-
.overlay(overlay)
52-
.create()
42+
.anchor(button, 0, 0, false)
43+
.text(text)
44+
.styleId(style)
45+
.typeface(typeface)
46+
.maxWidth(metrics.widthPixels / 2)
47+
.arrow(arrow)
48+
.floatingAnimation(animation)
49+
.closePolicy(closePolicy)
50+
.showDuration(showDuration)
51+
.overlay(overlay)
52+
.create()
5353

5454
tooltip
55-
?.doOnHidden {
56-
tooltip = null
57-
}
58-
?.doOnFailure { }
59-
?.doOnShown {}
60-
?.show(button, gravity, true)
55+
?.doOnHidden {
56+
tooltip = null
57+
}
58+
?.doOnFailure { }
59+
?.doOnShown {}
60+
?.show(button, gravity, true)
6161
}
6262

6363
button2.setOnClickListener {
6464
val fragment = TestDialogFragment.newInstance()
6565
fragment.showNow(supportFragmentManager, "test_dialog_fragment")
6666
}
67+
68+
seekbar_duration.doOnProgressChanged { numberPicker, progress, formUser ->
69+
text_duration.text = "Duration: ${progress}ms"
70+
}
71+
6772
}
6873

6974
private fun getClosePolicy(): ClosePolicy {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class TestDialogFragment : DialogFragment() {
2222
Tooltip.Builder(context!!)
2323
.anchor(button, 0, 0, false)
2424
.closePolicy(ClosePolicy.TOUCH_ANYWHERE_CONSUME)
25-
.fadeDuration(200)
2625
.showDuration(0)
2726
.text("This is a dialog")
2827
.create()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<set xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:duration="@android:integer/config_shortAnimTime"
5+
android:interpolator="@android:interpolator/decelerate_quint"
6+
android:shareInterpolator="true">
7+
8+
<scale
9+
android:fromXScale="0.7"
10+
android:fromYScale="0.7"
11+
android:pivotX="50%"
12+
android:pivotY="50%"
13+
android:toXScale="1"
14+
android:toYScale="1" />
15+
16+
<alpha
17+
android:fromAlpha="0.0"
18+
android:toAlpha="1.0" />
19+
</set>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<set xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:duration="@android:integer/config_shortAnimTime"
5+
android:interpolator="@android:interpolator/decelerate_quint"
6+
android:shareInterpolator="true">
7+
8+
<scale
9+
android:fromXScale="1"
10+
android:fromYScale="1"
11+
android:pivotX="50%"
12+
android:pivotY="50%"
13+
android:toXScale="0.7"
14+
android:toYScale="0.7" />
15+
16+
<alpha
17+
android:fromAlpha="1.0"
18+
android:toAlpha="0.0" />
19+
</set>

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

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -105,50 +105,38 @@
105105
android:text="Custom Style" />
106106

107107
<LinearLayout
108-
android:layout_width="wrap_content"
108+
android:layout_width="match_parent"
109109
android:layout_height="wrap_content"
110110
android:layout_column="0"
111+
android:layout_columnSpan="2"
112+
android:layout_marginTop="6dp"
111113
android:layout_row="4"
114+
android:gravity="center_vertical"
112115
android:orientation="horizontal">
113116

114117
<androidx.appcompat.widget.AppCompatTextView
115-
android:layout_width="wrap_content"
116-
android:layout_height="wrap_content"
117-
android:text="Show" />
118-
119-
<com.google.android.material.textfield.TextInputEditText
120118
android:id="@+id/text_duration"
121119
android:layout_width="wrap_content"
122120
android:layout_height="wrap_content"
123-
android:ems="3"
124-
android:gravity="right"
125-
android:inputType="number"
126-
android:text="3000" />
127-
128-
</LinearLayout>
121+
android:lines="2"
122+
android:text="Duration: 3000ms" />
129123

130-
131-
<LinearLayout
132-
android:layout_width="wrap_content"
133-
android:layout_height="wrap_content"
134-
android:layout_column="1"
135-
android:layout_gravity="right"
136-
android:layout_row="4"
137-
android:orientation="horizontal">
138-
139-
<androidx.appcompat.widget.AppCompatTextView
140-
android:layout_width="wrap_content"
124+
<Space
125+
android:layout_width="0dp"
141126
android:layout_height="wrap_content"
142-
android:text="Fade" />
127+
android:layout_weight="1" />
143128

144-
<com.google.android.material.textfield.TextInputEditText
145-
android:id="@+id/text_fade"
129+
<it.sephiroth.android.library.numberpicker.NumberPicker
130+
android:id="@+id/seekbar_duration"
131+
style="@style/NumberPicker.Filled"
146132
android:layout_width="wrap_content"
147133
android:layout_height="wrap_content"
148-
android:ems="3"
149-
android:gravity="right"
150-
android:inputType="number"
151-
android:text="200" />
134+
android:progress="3000"
135+
app:picker_max="5000"
136+
app:picker_min="0"
137+
app:picker_orientation="vertical"
138+
app:picker_stepSize="50"
139+
app:picker_tracker="exponential" />
152140

153141
</LinearLayout>
154142

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<resources xmlns:tools="http://schemas.android.com/tools">
1+
<resources>
22

33
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
44
<item name="colorPrimary">@color/colorPrimaryDark</item>
@@ -23,15 +23,18 @@
2323
<item name="ttlm_backgroundColor">#FF9800</item>
2424
<item name="ttlm_cornerRadius">6dp</item>
2525
<item name="ttlm_arrowRatio">1.2</item>
26-
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
27-
<item name="android:gravity">center</item>
2826
<item name="ttlm_overlayStyle">@style/ToolTipOverlayAltStyle</item>
29-
<item name="ttlm_elevation">0dp</item>
27+
<item name="ttlm_animationStyle">@style/ToolTipAltAnimation</item>
3028
</style>
3129

3230
<style name="ToolTipOverlayAltStyle" parent="ToolTipOverlayDefaultStyle">
3331
<item name="android:color">#FF333333</item>
3432
<item name="android:alpha">0.3</item>
3533
</style>
3634

35+
<style name="ToolTipAltAnimation">
36+
<item name="android:windowExitAnimation">@anim/custom_anim_exit</item>
37+
<item name="android:windowEnterAnimation">@anim/custom_anim_enter</item>
38+
</style>
39+
3740
</resources>

build.gradle

Lines changed: 3 additions & 2 deletions
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.11'
4+
ext.kotlin_version = '1.3.20'
55
repositories {
66
google()
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.3.0'
10+
classpath 'com.android.tools.build:gradle:3.4.0-beta02'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong
@@ -19,6 +19,7 @@ allprojects {
1919
repositories {
2020
google()
2121
jcenter()
22+
maven { url 'https://jitpack.io' }
2223
}
2324
}
2425

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VERSION_NAME=2.0.3
2-
VERSION_CODE=104
1+
VERSION_NAME=2.0.4
2+
VERSION_CODE=105
33
GROUP=it.sephiroth.android.library.targettooltip
44

55
POM_DESCRIPTION=Custom tooltips for android

0 commit comments

Comments
 (0)