From fcee4a8d2d8d97b49d23befd44dce6918f1428a7 Mon Sep 17 00:00:00 2001 From: Adrian Renner Date: Thu, 22 Apr 2021 14:57:59 +0200 Subject: [PATCH] Update library (#1) * Disable jetifier * Update dependencies * Update targetSdkVersion * Update library version to 1.2.0 * Update readme * Remove travis --- .travis.yml | 16 ------- README.md | 2 +- app/build.gradle | 42 +++++++---------- .../teresaholfeld/stories/app/MainActivity.kt | 16 ++++--- build.gradle | 7 +-- gradle.properties | 6 +-- gradle/wrapper/gradle-wrapper.properties | 4 +- library/build.gradle | 41 +++++++--------- .../stories/PausableProgressBar.kt | 47 +++++++++++-------- .../stories/StoriesProgressView.kt | 23 +++++---- 10 files changed, 90 insertions(+), 114 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4121be2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: android -android: - components: - - platform-tools - - tools - - build-tools-28.0.3 - - android-28 - - extra-google-m2repository - - extra-android-m2repository - licenses: - - android-sdk-preview-license-.+ - - android-sdk-license-.+ - - google-gdk-license-.+ - -script: -- ./gradlew check lint test assemble diff --git a/README.md b/README.md index 839e5dc..326103a 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Add the dependency in your app `build.gradle`: ``` dependencies { - implementation 'com.github.teresaholfeld:Stories:1.1.4' + implementation 'com.github.teresaholfeld:Stories:1.2.0' } ``` diff --git a/app/build.gradle b/app/build.gradle index 4b1b752..cb1405f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,34 +2,28 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { - compileSdkVersion 28 - buildToolsVersion '28.0.3' - defaultConfig { - applicationId "com.teresaholfeld.stories.app" - minSdkVersion 15 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + compileSdkVersion 30 + defaultConfig { + applicationId "com.teresaholfeld.stories.app" + minSdkVersion 15 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } } - } } dependencies { - implementation 'com.github.teresaholfeld:Stories:1.1.2' - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' - testImplementation 'junit:junit:4.12' - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation project(':library') + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' } + repositories { - mavenCentral() + mavenCentral() } diff --git a/app/src/main/java/com/teresaholfeld/stories/app/MainActivity.kt b/app/src/main/java/com/teresaholfeld/stories/app/MainActivity.kt index 7172626..a92a55a 100644 --- a/app/src/main/java/com/teresaholfeld/stories/app/MainActivity.kt +++ b/app/src/main/java/com/teresaholfeld/stories/app/MainActivity.kt @@ -1,11 +1,11 @@ package com.teresaholfeld.stories.app import android.os.Bundle -import android.support.v7.app.AppCompatActivity import android.view.MotionEvent import android.view.View import android.view.WindowManager import android.widget.ImageView +import androidx.appcompat.app.AppCompatActivity import com.teresaholfeld.stories.StoriesProgressView class MainActivity : AppCompatActivity(), StoriesProgressView.StoriesListener { @@ -15,12 +15,12 @@ class MainActivity : AppCompatActivity(), StoriesProgressView.StoriesListener { private var counter = 0 private val resources = intArrayOf( - R.drawable.sample1, - R.drawable.sample2, - R.drawable.sample3, - R.drawable.sample4, - R.drawable.sample5, - R.drawable.sample6 + R.drawable.sample1, + R.drawable.sample2, + R.drawable.sample3, + R.drawable.sample4, + R.drawable.sample5, + R.drawable.sample6 ) private val durations = longArrayOf(500L, 1000L, 1500L, 4000L, 5000L, 1000) @@ -49,6 +49,8 @@ class MainActivity : AppCompatActivity(), StoriesProgressView.StoriesListener { window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) setContentView(R.layout.activity_main) + storiesProgressView = findViewById(R.id.stories) + storiesProgressView?.setStoriesCount(PROGRESS_COUNT) storiesProgressView?.setStoryDuration(3000L) // or diff --git a/build.gradle b/build.gradle index 330b58c..b0c1c05 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.21' + ext.kotlin_version = '1.4.32' repositories { google() - jcenter() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.1' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath 'com.android.tools.build:gradle:4.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -19,7 +17,6 @@ buildscript { allprojects { repositories { google() - jcenter() maven { url "https://jitpack.io" } } } diff --git a/gradle.properties b/gradle.properties index aac7c9b..f651ae6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,15 @@ # Project-wide Gradle settings. - # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. - # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html - # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx1536m - # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true +android.enableJetifier=false +android.useAndroidX=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 096f39d..40a73f7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Sep 10 10:57:05 WEST 2018 +#Wed Mar 31 12:35:12 CEST 2021 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip diff --git a/library/build.gradle b/library/build.gradle index 98a57f5..e1e6eb8 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,37 +1,28 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' -apply plugin: 'com.github.dcendents.android-maven' android { - compileSdkVersion 28 - buildToolsVersion '28.0.3' - group = "com.teresaholfeld.stories" + compileSdkVersion 30 - defaultConfig { - minSdkVersion 15 - targetSdkVersion 28 - versionCode 1 - versionName "1.1.4" - - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + defaultConfig { + minSdkVersion 15 + targetSdkVersion 30 + versionCode 1 + versionName "1.2.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } } - } } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'com.android.support:appcompat-v7:28.0.0' - testImplementation 'junit:junit:4.12' - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) + implementation 'androidx.appcompat:appcompat:1.2.0' + + } repositories { - mavenCentral() + mavenCentral() } diff --git a/library/src/main/java/com/teresaholfeld/stories/PausableProgressBar.kt b/library/src/main/java/com/teresaholfeld/stories/PausableProgressBar.kt index 7921f3a..f00f351 100644 --- a/library/src/main/java/com/teresaholfeld/stories/PausableProgressBar.kt +++ b/library/src/main/java/com/teresaholfeld/stories/PausableProgressBar.kt @@ -12,11 +12,12 @@ import android.view.animation.Transformation import android.widget.FrameLayout @SuppressLint("ViewConstructor") -internal class PausableProgressBar constructor(context: Context, - attrs: AttributeSet? = null, - progressColor: Int, - progressBackgroundColor: Int) - : FrameLayout(context, attrs) { +internal class PausableProgressBar constructor( + context: Context, + attrs: AttributeSet? = null, + progressColor: Int, + progressBackgroundColor: Int +) : FrameLayout(context, attrs) { private val frontProgressView: View? private val backProgressView: View? @@ -30,10 +31,12 @@ internal class PausableProgressBar constructor(context: Context, fun onFinishProgress() } - constructor(context: Context, - progressColor: Int, - progressBackgroundColor: Int) - : this(context, null, progressColor, progressBackgroundColor) + constructor( + context: Context, + progressColor: Int, + progressBackgroundColor: Int + ) : + this(context, null, progressColor, progressBackgroundColor) init { LayoutInflater.from(context).inflate(R.layout.pausable_progress, this) @@ -81,8 +84,10 @@ internal class PausableProgressBar constructor(context: Context, } fun startProgress() { - animation = PausableScaleAnimation(0f, 1f, 1f, 1f, Animation.ABSOLUTE, 0f, - Animation.RELATIVE_TO_SELF, 0f) + animation = PausableScaleAnimation( + 0f, 1f, 1f, 1f, Animation.ABSOLUTE, 0f, + Animation.RELATIVE_TO_SELF, 0f + ) animation?.duration = duration animation?.interpolator = LinearInterpolator() animation?.setAnimationListener(object : Animation.AnimationListener { @@ -115,15 +120,17 @@ internal class PausableProgressBar constructor(context: Context, animation = null } - private inner class PausableScaleAnimation internal constructor(fromX: Float, - toX: Float, - fromY: Float, - toY: Float, - pivotXType: Int, - pivotXValue: Float, - pivotYType: Int, - pivotYValue: Float) - : ScaleAnimation(fromX, toX, fromY, toY, pivotXType, pivotXValue, pivotYType, pivotYValue) { + private inner class PausableScaleAnimation internal constructor( + fromX: Float, + toX: Float, + fromY: Float, + toY: Float, + pivotXType: Int, + pivotXValue: Float, + pivotYType: Int, + pivotYValue: Float + ) : + ScaleAnimation(fromX, toX, fromY, toY, pivotXType, pivotXValue, pivotYType, pivotYValue) { private var mElapsedAtPause: Long = 0 private var mPaused = false diff --git a/library/src/main/java/com/teresaholfeld/stories/StoriesProgressView.kt b/library/src/main/java/com/teresaholfeld/stories/StoriesProgressView.kt index 36d3f5f..55febb1 100644 --- a/library/src/main/java/com/teresaholfeld/stories/StoriesProgressView.kt +++ b/library/src/main/java/com/teresaholfeld/stories/StoriesProgressView.kt @@ -5,11 +5,10 @@ package com.teresaholfeld.stories import android.annotation.TargetApi import android.content.Context import android.os.Build -import android.support.v4.content.ContextCompat import android.util.AttributeSet import android.view.View import android.widget.LinearLayout -import java.util.ArrayList +import androidx.core.content.ContextCompat class StoriesProgressView : LinearLayout { @@ -24,6 +23,7 @@ class StoriesProgressView : LinearLayout { private val progressBars = ArrayList() private var storiesCount = -1 + /** * pointer of running animation */ @@ -42,7 +42,8 @@ class StoriesProgressView : LinearLayout { fun onComplete() } - @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : super(context, attrs) { + @JvmOverloads + constructor(context: Context, attrs: AttributeSet? = null) : super(context, attrs) { init(context, attrs) } @@ -51,18 +52,20 @@ class StoriesProgressView : LinearLayout { } @TargetApi(Build.VERSION_CODES.LOLLIPOP) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) - : super(context, attrs, defStyleAttr, defStyleRes) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : + super(context, attrs, defStyleAttr, defStyleRes) { + init(context, attrs) + } private fun init(context: Context, attrs: AttributeSet?) { - orientation = LinearLayout.HORIZONTAL + orientation = HORIZONTAL val typedArray = context.obtainStyledAttributes(attrs, R.styleable.StoriesProgressView) storiesCount = typedArray.getInt(R.styleable.StoriesProgressView_progressCount, 0) progressColor = typedArray.getColor(R.styleable.StoriesProgressView_progressColor, defaultColor) - progressBackgroundColor = typedArray.getColor(R.styleable.StoriesProgressView_progressBackgroundColor, - defaultBackgroundColor) + progressBackgroundColor = typedArray.getColor( + R.styleable.StoriesProgressView_progressBackgroundColor, + defaultBackgroundColor + ) typedArray.recycle() bindViews() }