Skip to content

Commit

Permalink
Merge pull request #120 from sephiroth74/feature/update_text_and_posi…
Browse files Browse the repository at this point in the history
…tion

Feature/update text and position
  • Loading branch information
sephiroth74 authored Jan 25, 2019
2 parents 0cd52be + dafe1a7 commit 505051a
Show file tree
Hide file tree
Showing 20 changed files with 421 additions and 269 deletions.
63 changes: 18 additions & 45 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,36 @@
language: android

jdk:
- oraclejdk8

env:
global:
# install timeout in minutes (2 minutes by default)
- ADB_INSTALL_TIMEOUT=16
- oraclejdk8

android:
components:
- tools
- tools
- build-tools-28.0.3
- android-25
- extra-android-m2repository
- extra-android-suppor
- add-on
- extra

licenses:
- 'android-sdk-license-.+'
- 'android-sdk-preview-license-.+'
- 'google-gdk-license-.+'
- 'intel-android-extra-license-.+'
- 'google-gdk-license-.+'
- 'android-googletv-license-.+'

notifications:
email:
- [email protected]
- platform-tools

before_install:
before_script:
- mkdir "$ANDROID_HOME/licenses" || true
- echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > "$ANDROID_HOME/licenses/android-sdk-license"
- sdkmanager tools
- sdkmanager --update
- sdkmanager emulator
- sdkmanager "system-images;android-25;google_apis;armeabi-v7a"
- sdkmanager --update
- echo no | avdmanager create avd --force -n test -k "system-images;android-25;google_apis;armeabi-v7a" --device "pixel"
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"

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

script:
- adb logcat > logcat.log &
- ./gradlew clean build lint assemble
# - ./gradlew app:connectedCheck
notifications:
email:
- [email protected]

after_script:
- cat logcat.log
cache: false
sudo: false

after_failure:
- cat logcat.log
install:
- chmod +x ./gradlew; ls -l gradlew; ./gradlew wrapper -v

sudo: false
script:
- ./gradlew clean build lint assemble

cache:
directories:
- $HOME/.m2
- $HOME/.gradle
19 changes: 12 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
compileSdkVersion 28
defaultConfig {
applicationId "it.sephiroth.android.library.tooltip_demo"
minSdkVersion 18
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
Expand All @@ -34,18 +34,23 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.google.android.material:material:1.1.0-alpha01'
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.jakewharton.timber:timber:4.7.1'
implementation 'androidx.core:core-ktx:1.0.1'

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


implementation project(':xtooltip')

testImplementation 'junit:junit:4.12'

androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package it.sephiroth.android.library.tooltip_demo
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.text.toSpannable
import it.sephiroth.android.library.numberpicker.doOnProgressChanged
import it.sephiroth.android.library.xtooltip.ClosePolicy
import it.sephiroth.android.library.xtooltip.Tooltip
import it.sephiroth.android.library.xtooltip.Typefaces
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.content_main.*
import timber.log.Timber

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

tooltip?.dismiss()

tooltip = Tooltip.Builder(this)
.anchor(button, 0, 0, false)
.text(text)
.styleId(style)
.typeface(typeface)
.maxWidth(metrics.widthPixels / 2)
.arrow(arrow)
.floatingAnimation(animation)
.closePolicy(closePolicy)
.showDuration(showDuration)
.fadeDuration(fadeDuration)
.overlay(overlay)
.create()
.anchor(button, 0, 0, false)
.text(text)
.styleId(style)
.typeface(typeface)
.maxWidth(metrics.widthPixels / 2)
.arrow(arrow)
.floatingAnimation(animation)
.closePolicy(closePolicy)
.showDuration(showDuration)
.overlay(overlay)
.create()

tooltip
?.doOnHidden {
tooltip = null
}
?.doOnFailure { }
?.doOnShown {}
?.show(button, gravity, true)
?.doOnHidden {
tooltip = null
}
?.doOnFailure { }
?.doOnShown {}
?.show(button, gravity, true)
}

button2.setOnClickListener {
val fragment = TestDialogFragment.newInstance()
fragment.showNow(supportFragmentManager, "test_dialog_fragment")
}

seekbar_duration.doOnProgressChanged { numberPicker, progress, formUser ->
text_duration.text = "Duration: ${progress}ms"
}

}

private fun getClosePolicy(): ClosePolicy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class TestDialogFragment : DialogFragment() {
Tooltip.Builder(context!!)
.anchor(button, 0, 0, false)
.closePolicy(ClosePolicy.TOUCH_ANYWHERE_CONSUME)
.fadeDuration(200)
.showDuration(0)
.text("This is a dialog")
.create()
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/anim/custom_anim_enter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_shortAnimTime"
android:interpolator="@android:interpolator/decelerate_quint"
android:shareInterpolator="true">

<scale
android:fromXScale="0.7"
android:fromYScale="0.7"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" />

<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
19 changes: 19 additions & 0 deletions app/src/main/res/anim/custom_anim_exit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_shortAnimTime"
android:interpolator="@android:interpolator/decelerate_quint"
android:shareInterpolator="true">

<scale
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.7"
android:toYScale="0.7" />

<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
48 changes: 18 additions & 30 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,50 +105,38 @@
android:text="Custom Style" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_columnSpan="2"
android:layout_marginTop="6dp"
android:layout_row="4"
android:gravity="center_vertical"
android:orientation="horizontal">

<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show" />

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="3"
android:gravity="right"
android:inputType="number"
android:text="3000" />

</LinearLayout>
android:lines="2"
android:text="Duration: 3000ms" />


<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="right"
android:layout_row="4"
android:orientation="horizontal">

<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Fade" />
android:layout_weight="1" />

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/text_fade"
<it.sephiroth.android.library.numberpicker.NumberPicker
android:id="@+id/seekbar_duration"
style="@style/NumberPicker.Filled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="3"
android:gravity="right"
android:inputType="number"
android:text="200" />
android:progress="3000"
app:picker_max="5000"
app:picker_min="0"
app:picker_orientation="vertical"
app:picker_stepSize="50"
app:picker_tracker="exponential" />

</LinearLayout>

Expand Down
11 changes: 7 additions & 4 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">@color/colorPrimaryDark</item>
Expand All @@ -23,15 +23,18 @@
<item name="ttlm_backgroundColor">#FF9800</item>
<item name="ttlm_cornerRadius">6dp</item>
<item name="ttlm_arrowRatio">1.2</item>
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
<item name="android:gravity">center</item>
<item name="ttlm_overlayStyle">@style/ToolTipOverlayAltStyle</item>
<item name="ttlm_elevation">0dp</item>
<item name="ttlm_animationStyle">@style/ToolTipAltAnimation</item>
</style>

<style name="ToolTipOverlayAltStyle" parent="ToolTipOverlayDefaultStyle">
<item name="android:color">#FF333333</item>
<item name="android:alpha">0.3</item>
</style>

<style name="ToolTipAltAnimation">
<item name="android:windowExitAnimation">@anim/custom_anim_exit</item>
<item name="android:windowEnterAnimation">@anim/custom_anim_enter</item>
</style>

</resources>
5 changes: 3 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.11'
ext.kotlin_version = '1.3.20'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:3.4.0-beta02'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -19,6 +19,7 @@ allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

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.3
VERSION_CODE=104
VERSION_NAME=2.0.4
VERSION_CODE=105
GROUP=it.sephiroth.android.library.targettooltip

POM_DESCRIPTION=Custom tooltips for android
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Jan 16 15:11:44 EST 2019
#Fri Jan 25 16:35:02 EST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-milestone-1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Loading

0 comments on commit 505051a

Please sign in to comment.