Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ To do this, you can add the attributes to your layout xml:
<!-- ... -->
</LinearLayout>
```

## Compose support
None planned. PRs welcome!

## License

Expand Down
47 changes: 23 additions & 24 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@ 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"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
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 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation('androidx.test.espresso:espresso-core:3.3.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation project(':library')
}
repositories {
mavenCentral()
mavenCentral()
}
55 changes: 17 additions & 38 deletions app/src/main/java/com/teresaholfeld/stories/app/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,76 +1,55 @@
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 {

private var storiesProgressView: StoriesProgressView? = null
private lateinit var storiesProgressView: StoriesProgressView
private var image: ImageView? = null

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)

private var pressTime = 0L
private var limit = 500L

private val onTouchListener = View.OnTouchListener { v, event ->
when (event.action) {
MotionEvent.ACTION_DOWN -> {
pressTime = System.currentTimeMillis()
storiesProgressView?.pause()
return@OnTouchListener false
}
MotionEvent.ACTION_UP -> {
val now = System.currentTimeMillis()
storiesProgressView?.resume()
return@OnTouchListener limit < now - pressTime
}
}
false
}
// private val durations = longArrayOf(500L, 1000L, 1500L, 4000L, 5000L, 1000)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
setContentView(R.layout.activity_main)

storiesProgressView?.setStoriesCount(PROGRESS_COUNT)
storiesProgressView?.setStoryDuration(3000L)
storiesProgressView = findViewById(R.id.stories)
storiesProgressView.setStoriesCount(PROGRESS_COUNT)
storiesProgressView.setStoryDuration(3000L)
// or
// storiesProgressView.setStoriesCountWithDurations(durations);

storiesProgressView?.setStoriesListener(this)
storiesProgressView.setStoriesListener(this)

counter = 2
storiesProgressView?.startStories(counter)
storiesProgressView.startStories(counter)

image = findViewById<View>(R.id.image) as ImageView
image?.setImageResource(resources[counter])

// bind reverse view
val reverse = findViewById<View>(R.id.reverse)
reverse.setOnClickListener { storiesProgressView?.reverse() }
reverse.setOnTouchListener(onTouchListener)
reverse.setOnClickListener { storiesProgressView.reverse() }

// bind skip view
val skip = findViewById<View>(R.id.skip)
skip.setOnClickListener { storiesProgressView?.skip() }
skip.setOnTouchListener(onTouchListener)
skip.setOnClickListener { storiesProgressView.skip() }
}

override fun onNext() {
Expand All @@ -86,7 +65,7 @@ class MainActivity : AppCompatActivity(), StoriesProgressView.StoriesListener {

override fun onDestroy() {
// Very important !
storiesProgressView?.destroy()
storiesProgressView.destroy()
super.onDestroy()
}

Expand Down
20 changes: 11 additions & 9 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="centerCrop"
tools:src="@drawable/sample1"/>
tools:src="@drawable/sample1" />

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -22,23 +22,25 @@
android:id="@+id/reverse"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
android:layout_weight="1" />

<View
android:id="@+id/skip"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
android:layout_weight="1" />
</LinearLayout>

<com.teresaholfeld.stories.StoriesProgressView
android:id="@+id/stories"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_height="8dp"
android:layout_gravity="top"
android:layout_marginTop="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
app:progressBackgroundColor="@color/purple"
app:progressColor="@color/colorAccent"/>
app:cornerRadius="4dp"
app:progressColor="@color/colorAccent"
app:progressGap="4dp" />
</merge>
38 changes: 19 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.21'
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 "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
}
ext.kotlin_version = '1.5.10'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
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
}
}

allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
delete rootProject.buildDir
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
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 @@
#Mon Sep 10 10:57:05 WEST 2018
#Thu Sep 24 18:15:02 BST 2020
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.8.3-all.zip
44 changes: 22 additions & 22 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
group = "com.teresaholfeld.stories"
compileSdkVersion 30
group = "com.teresaholfeld.stories"

defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.1.4"
defaultConfig {
minSdkVersion 15
targetSdkVersion 30
versionCode 2
versionName "1.1.5"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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 "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation('androidx.test.espresso:espresso-core:3.3.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
repositories {
mavenCentral()
mavenCentral()
}
Loading