Skip to content

Commit

Permalink
Merge pull request #1 from teresaholfeld/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
teresaholfeld authored Oct 26, 2018
2 parents 8361fff + d857aab commit 56416d9
Show file tree
Hide file tree
Showing 15 changed files with 572 additions and 645 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
StoriesProgressView
Stories
====

Library that shows a horizontal progress like Instagram stories.
Stories is a library that shows a horizontal progress like Instagram stories.

This project has been forked and extended from [shts/StoriesProgressView](https://github.com/shts/StoriesProgressView).

[![](https://jitpack.io/v/shts/StoriesProgressView.svg)](https://jitpack.io/#shts/StoriesProgressView)

<img src="image/capture.png" width=200 />

<img src="image/image.gif" width=200 />

^She is [Yui Kobayashi](http://www.keyakizaka46.com/s/k46o/artist/07)
The person in these pictures and the pictures in the sample app is [Yui Kobayashi](http://www.keyakizaka46.com/s/k46o/artist/07).

How to Use
----

To see how a StoriesProgressView can be added to your xml layouts, check the sample project.

```xml
<jp.shts.android.storiesprogressview.StoriesProgressView
<com.teresaholfeld.stories.StoriesProgressView
android:id="@+id/stories"
android:layout_width="match_parent"
android:layout_height="3dp"
Expand Down Expand Up @@ -113,8 +115,10 @@ dependencies {
License
---

Modifications:

```
Copyright (C) 2017 Shota Saito(shts)
Copyright (C) 2018 Teresa Holfeld (teresaholfeld), 2017 Shota Saito (shts)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
49 changes: 27 additions & 22 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "jp.shts.android.storyprogressbar"
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 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'
}
}
}

dependencies {
implementation project(':library')
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 project(':library')
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"
}
repositories {
mavenCentral()
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.shts.android.storyprogressbar">
package="com.teresaholfeld.stories.app">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
96 changes: 96 additions & 0 deletions app/src/main/java/com/teresaholfeld/stories/app/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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 com.teresaholfeld.stories.StoriesProgressView

class MainActivity : AppCompatActivity(), StoriesProgressView.StoriesListener {

private var storiesProgressView: StoriesProgressView? = null
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
)

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
}

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

storiesProgressView = findViewById<View>(R.id.stories) as StoriesProgressView
storiesProgressView!!.setStoriesCount(PROGRESS_COUNT)
storiesProgressView!!.setStoryDuration(3000L)
// or
// storiesProgressView.setStoriesCountWithDurations(durations);
storiesProgressView!!.setStoriesListener(this)
// storiesProgressView.startStories();
counter = 2
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)

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

override fun onNext() {
image!!.setImageResource(resources[++counter])
}

override fun onPrev() {
if (counter - 1 < 0) return
image!!.setImageResource(resources[--counter])
}

override fun onComplete() {}

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

companion object {
private const val PROGRESS_COUNT = 6
}
}
114 changes: 0 additions & 114 deletions app/src/main/java/jp/shts/android/storyprogressbar/MainActivity.java

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
android:layout_weight="1" />
</LinearLayout>

<jp.shts.android.storiesprogressview.StoriesProgressView
<com.teresaholfeld.stories.StoriesProgressView
android:id="@+id/stories"
android:paddingLeft="8dp"
android:paddingRight="8dp"
Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
ext.kotlin_version = '1.2.71'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
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
}
}
Expand Down
Loading

0 comments on commit 56416d9

Please sign in to comment.