aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--README.md17
-rw-r--r--about/build.gradle6
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt9
-rw-r--r--about/src/main/res/layout/kau_iitem_library.xml3
-rw-r--r--about/src/main/res/values/strings_about.xml2
-rw-r--r--android-lib.gradle20
-rw-r--r--build.gradle23
-rw-r--r--core-ui/build.gradle4
-rw-r--r--core-ui/src/main/res-public/layout/kau_elastic_recycler_activity.xml1
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kotlin/Streams.kt17
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt16
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt7
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt37
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt50
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt18
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt10
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/FileUtils.kt33
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt11
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt1
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt2
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt2
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt42
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt2
-rw-r--r--docs/Changelog.md10
-rw-r--r--gradle.properties9
-rw-r--r--kpref-activity/build.gradle1
-rw-r--r--mediapicker/src/main/res/layout/kau_activity_image_picker.xml1
-rw-r--r--sample/build.gradle51
-rw-r--r--sample/src/main/AndroidManifest.xml3
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt5
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt75
-rw-r--r--sample/src/main/res/layout/activity_swipe.xml74
-rw-r--r--sample/src/main/res/values/strings.xml1
-rw-r--r--sample/src/main/res/values/styles.xml5
-rw-r--r--sample/src/main/res/xml/kau_changelog.xml12
-rw-r--r--searchview/build.gradle3
38 files changed, 469 insertions, 117 deletions
diff --git a/.travis.yml b/.travis.yml
index c2b02bf..da9bd5c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,7 +21,6 @@ android:
#- adb shell input keyevent 82 &
script:
- chmod +x gradlew
-- ./gradlew --quiet androidGitVersion
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then ./gradlew lintRelease publishRelease; else ./gradlew lintRelease test; fi
branches:
except:
diff --git a/README.md b/README.md
index 54c3f7e..7ee0e20 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
<img src="https://cdn.rawgit.com/AllanWang/KAU/master/files/images/logo.svg" alt="KAU" width="30%"/>
-Kotlin Android Utils
+An extensive collection of <b>Kotlin Android Utils</b>
This library contains small helper functions used throughout almost all of my other projects. The goal is to make common interactions executable in a single line.
@@ -14,6 +14,8 @@ KAU is available on JitPack
[![](https://jitpack.io/v/ca.allanwang/kau.svg)](https://jitpack.io/#ca.allanwang/kau)
[![Build Status](https://travis-ci.org/AllanWang/KAU.svg?branch=master)](https://travis-ci.org/AllanWang/KAU)
+[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)
+[![Stories in Ready](https://badge.waffle.io/AllanWang/KAU.png?label=ready&title=Ready)](https://waffle.io/AllanWang/KAU?utm_source=badge)
[![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/AllanWang/KAU/master/LICENSE)
To apply, add the following to your root build.gradle:
@@ -69,11 +71,7 @@ dependencies {
## [Core UI](core-ui#readme)
* Collection of complex views and widgets
-* Includes `:core`, `:adapter`,
-[`RxJava`](https://github.com/ReactiveX/RxJava),
-[`RxAndroid`](https://github.com/ReactiveX/RxAndroid),
-[`RxKotlin`](https://github.com/ReactiveX/RxKotlin),
-[`RxBinding`](https://github.com/JakeWharton/RxBinding)
+* Includes `:core`, `:adapter`
## [About](about#readme)
* Implementation of an overlaying about section, along with automatic lib detection; also includes the lib strings for KAU
@@ -90,7 +88,7 @@ dependencies {
* Includes `:core`,
[`Material Dialogs (commons)`](https://github.com/afollestad/material-dialogs)
-## [Kpref Activity](kpref-activity#readme)
+## [KPref Activity](kpref-activity#readme)
* Fully programmatic implementation of a Preference Activity, backed by RecyclerViews
* Includes `:core-ui`, `:adapter`, `colorpicker`
@@ -102,7 +100,10 @@ dependencies {
## [SearchView](searchview#readme)
* Material searchview with kotlin bindings
-* Includes `:core-ui`, `:adapter`
+* Includes `:core-ui`, `:adapter`,
+[`RxAndroid`](https://github.com/ReactiveX/RxAndroid),
+[`RxKotlin`](https://github.com/ReactiveX/RxKotlin),
+[`RxBinding`](https://github.com/JakeWharton/RxBinding)
-----------
diff --git a/about/build.gradle b/about/build.gradle
index 5decae4..3ee1a48 100644
--- a/about/build.gradle
+++ b/about/build.gradle
@@ -1,5 +1,11 @@
apply from: '../android-lib.gradle'
+android {
+ defaultConfig {
+ resValue "string", "kau_version_code", project.VERSION_NAME
+ }
+}
+
dependencies {
compile project(':core-ui')
compile project(':adapter')
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
index 5e00447..629aa52 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
@@ -8,10 +8,7 @@ import android.widget.TextView
import ca.allanwang.kau.adapters.ThemableIItem
import ca.allanwang.kau.adapters.ThemableIItemDelegate
import ca.allanwang.kau.iitems.KauIItem
-import ca.allanwang.kau.utils.bindView
-import ca.allanwang.kau.utils.dpToPx
-import ca.allanwang.kau.utils.parentViewGroup
-import ca.allanwang.kau.utils.setPaddingLeft
+import ca.allanwang.kau.utils.*
import ca.allanwang.kau.xml.FaqItem
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.IItem
@@ -57,7 +54,9 @@ class FaqIItem(val content: FaqItem) : KauIItem<LibraryIItem, FaqIItem.ViewHolde
answer.post { answer.setPaddingLeft(16.dpToPx + number.width) }
bindTextColor(number, question)
bindTextColorSecondary(answer)
- bindDividerColor(answer)
+ val bg2 = backgroundColor?.colorToForeground(0.1f)
+ if (bg2 != null)
+ answer.setBackgroundColor(bg2)
bindBackgroundRipple(questionContainer)
}
}
diff --git a/about/src/main/res/layout/kau_iitem_library.xml b/about/src/main/res/layout/kau_iitem_library.xml
index 3ad4fb4..ed1cceb 100644
--- a/about/src/main/res/layout/kau_iitem_library.xml
+++ b/about/src/main/res/layout/kau_iitem_library.xml
@@ -6,7 +6,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
- android:clickable="true">
+ android:clickable="true"
+ android:focusable="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
diff --git a/about/src/main/res/values/strings_about.xml b/about/src/main/res/values/strings_about.xml
index 8c3dc59..592f9f4 100644
--- a/about/src/main/res/values/strings_about.xml
+++ b/about/src/main/res/values/strings_about.xml
@@ -1,8 +1,8 @@
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="ResourceName">
- <string name="library_kau_libraryVersion">3.2.3</string>
<string name="define_kau"/>
<string name="library_kau_author">Allan Wang</string>
<string name="library_kau_authorWebsite">https://www.allanwang.ca/dev/</string>
+ <string name="library_kau_libraryVersion">@string/kau_version_code</string>
<string name="library_kau_libraryName">KAU</string>
<string name="library_kau_libraryDescription">
<![CDATA[
diff --git a/android-lib.gradle b/android-lib.gradle
index 46de84c..46b74a8 100644
--- a/android-lib.gradle
+++ b/android-lib.gradle
@@ -3,13 +3,6 @@ apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'
group = project.APP_GROUP
-repositories {
- jcenter()
- mavenCentral()
- maven { url "https://jitpack.io" }
- maven { url "https://maven.google.com" }
-}
-
android {
compileSdkVersion Integer.parseInt(project.TARGET_SDK)
buildToolsVersion project.BUILD_TOOLS
@@ -27,6 +20,8 @@ android {
defaultConfig {
minSdkVersion Integer.parseInt(kauMinSdk)
targetSdkVersion Integer.parseInt(project.TARGET_SDK)
+ versionName project.VERSION_NAME
+ versionCode project.VERSION_CODE
consumerProguardFiles 'progress-proguard.txt'
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -50,6 +45,11 @@ android {
'Overdraw'
}
+ packagingOptions {
+ pickFirst 'META-INF/core_release.kotlin_module'
+ pickFirst 'META-INF/library_release.kotlin_module'
+ }
+
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
@@ -71,8 +71,10 @@ android {
}
dependencies {
- androidTestCompile 'com.android.support.test:runner:0.5'
+ androidTestCompile("com.android.support.test:runner:${TEST_RUNNER}") {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ }
androidTestCompile "org.jetbrains.kotlin:kotlin-test-junit:${KOTLIN}"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:${KOTLIN}"
- testCompile 'junit:junit:4.12'
+ testCompile "junit:junit:${JUNIT}"
} \ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 72d35aa..74fb18d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
+// google()
+// maven { url "https://maven.google.com" }
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
@@ -14,6 +16,18 @@ buildscript {
}
}
+def portions = project.VERSION_NAME.tokenize('.')
+int code = 0
+for (i in 1..4) {
+ if (portions.size() >= i && portions[i - 1].isInteger())
+ code += portions[i - 1].toInteger()
+ code *= 100
+}
+code /= 100
+println "KAU Project Version Name: " + project.VERSION_NAME
+println "KAU Project Version Code: " + code
+project.ext.VERSION_CODE = code
+
task clean(type: Delete) {
delete rootProject.buildDir
}
@@ -34,4 +48,13 @@ task generateChangelogMd {
}
def changelogMd = new File("$project.rootDir/docs/Changelog.md")
changelogMd.write(sw.toString())
+}
+
+subprojects {
+ repositories {
+// google()
+ maven { url "https://maven.google.com" }
+ jcenter()
+ maven { url "https://jitpack.io" }
+ }
} \ No newline at end of file
diff --git a/core-ui/build.gradle b/core-ui/build.gradle
index da6715c..68764b5 100644
--- a/core-ui/build.gradle
+++ b/core-ui/build.gradle
@@ -6,10 +6,6 @@ dependencies {
compile project(':core')
compile project(':adapter')
- compile "io.reactivex.rxjava2:rxkotlin:${RX_KOTLIN}"
- compile "io.reactivex.rxjava2:rxandroid:${RX_ANDROID}"
- compile "com.jakewharton.rxbinding2:rxbinding-kotlin:${RX_BINDING}"
- compile "com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:${RX_BINDING}"
}
apply from: '../artifacts.gradle'
diff --git a/core-ui/src/main/res-public/layout/kau_elastic_recycler_activity.xml b/core-ui/src/main/res-public/layout/kau_elastic_recycler_activity.xml
index 055d61d..9fbe447 100644
--- a/core-ui/src/main/res-public/layout/kau_elastic_recycler_activity.xml
+++ b/core-ui/src/main/res-public/layout/kau_elastic_recycler_activity.xml
@@ -41,6 +41,7 @@
android:layout_height="wrap_content"
android:layout_margin="@dimen/kau_fab_margin"
android:clickable="true"
+ android:focusable="true"
android:visibility="gone"
app:backgroundTint="?colorAccent"
app:layout_anchor="@id/kau_recycler"
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kotlin/Streams.kt b/core/src/main/kotlin/ca/allanwang/kau/kotlin/Streams.kt
new file mode 100644
index 0000000..5dc44a8
--- /dev/null
+++ b/core/src/main/kotlin/ca/allanwang/kau/kotlin/Streams.kt
@@ -0,0 +1,17 @@
+package ca.allanwang.kau.kotlin
+
+/**
+ * Created by Allan Wang on 2017-08-05.
+ */
+
+/**
+ * Replica of [Vector.removeIf] in Java
+ * Since we don't have access to the internals of our extended class,
+ * We will simply iterate and remove when the filter returns {@code false}
+ */
+@Synchronized inline fun <T, C : MutableIterable<T>> C.kauRemoveIf(filter: (item: T) -> Boolean): C {
+ val iter = iterator()
+ while (iter.hasNext())
+ if (filter(iter.next())) iter.remove()
+ return this
+} \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt
index e0f6cae..4c6d655 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt
@@ -1,3 +1,5 @@
+@file:Suppress("NOTHING_TO_INLINE")
+
package ca.allanwang.kau.logging
import timber.log.Timber
@@ -9,11 +11,11 @@ import timber.log.Timber
* Timber extension that will embed the tag as part of the message for each log item
*/
open class TimberLogger(tag: String) {
- internal val TAG = "$tag: %s"
- fun e(s: String) = Timber.e(TAG, s)
- fun e(t: Throwable?, s: String = "error") = if (t == null) e(s) else Timber.e(t, TAG, s)
- fun d(s: String) = Timber.d(TAG, s)
- fun i(s: String) = Timber.i(TAG, s)
- fun v(s: String) = Timber.v(TAG, s)
- fun eThrow(s: String) = e(Throwable(s))
+ val TAG = "$tag: %s"
+ inline fun e(s: String) = Timber.e(TAG, s)
+ inline fun e(t: Throwable?, s: String = "error") = if (t == null) e(s) else Timber.e(t, TAG, s)
+ inline fun d(s: String) = Timber.d(TAG, s)
+ inline fun i(s: String) = Timber.i(TAG, s)
+ inline fun v(s: String) = Timber.v(TAG, s)
+ inline fun eThrow(s: String) = e(Throwable(s))
} \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt
index 2ffb2ef..f14f5cf 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt
@@ -1,7 +1,5 @@
package ca.allanwang.kau.swipe
-import ca.allanwang.kau.kotlin.nonReadable
-
/**
* Created by Mr.Jude on 2015/8/26.
*
@@ -9,13 +7,12 @@ import ca.allanwang.kau.kotlin.nonReadable
*
* Helper class to give the previous activity an offset as the main page is pulled
*/
-class RelativeSlider(var curPage: SwipeBackPage) : SwipeListener {
+internal class RelativeSlider(var curPage: SwipeBackPage) : SwipeListener {
var offset = 0f
var enabled: Boolean
- @Deprecated(level = DeprecationLevel.ERROR, message = "Cannot use enabled as getter")
- get() = nonReadable()
+ get() = curPage.hasListener(this)
set(value) {
if (value) curPage.addListener(this)
else curPage.removeListener(this)
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt
index 503f1fc..0859ac5 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt
@@ -2,27 +2,27 @@ package ca.allanwang.kau.swipe
import android.app.Activity
import ca.allanwang.kau.R
+import ca.allanwang.kau.kotlin.kauRemoveIf
+import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.swipe.SwipeBackHelper.onDestroy
import java.util.*
-class SwipeBackException(message: String = "You Should call kauSwipeOnCreate() first") : RuntimeException(message)
+internal class SwipeBackException(message: String = "You Should call kauSwipeOnCreate() first") : RuntimeException(message)
/**
* Singleton to hold our swipe stack
* All activity pages held with strong references, so it is crucial to call
* [onDestroy] whenever an activity should be disposed
*/
-object SwipeBackHelper {
+internal object SwipeBackHelper {
private val pageStack = Stack<SwipeBackPage>()
- private operator fun get(activity: Activity): SwipeBackPage
- = pageStack.firstOrNull { it.activity === activity } ?: throw SwipeBackException()
-
- fun getCurrentPage(activity: Activity): SwipeBackPage = this[activity]
+ private operator fun get(activity: Activity): SwipeBackPage?
+ = pageStack.firstOrNull { it.activityRef.get() === activity }
fun onCreate(activity: Activity, builder: SwipeBackContract.() -> Unit = {}) {
- val page = pageStack.firstOrNull { it.activity === activity } ?: pageStack.push(SwipeBackPage(activity).apply { builder() })
+ val page = this[activity] ?: pageStack.push(SwipeBackPage(activity).apply { builder() })
val startAnimation: Int = when (page.edgeFlag) {
SWIPE_EDGE_LEFT -> R.anim.kau_slide_in_right
SWIPE_EDGE_RIGHT -> R.anim.kau_slide_in_left
@@ -30,23 +30,28 @@ object SwipeBackHelper {
else -> R.anim.kau_slide_in_top
}
activity.overridePendingTransition(startAnimation, 0)
+ KL.v("KauSwipe onCreate ${activity.localClassName}")
}
- fun onPostCreate(activity: Activity) = this[activity].onPostCreate()
+ fun onPostCreate(activity: Activity) {
+ this[activity]?.onPostCreate() ?: throw SwipeBackException()
+ KL.v("KauSwipe onPostCreate ${activity.localClassName}")
+ }
fun onDestroy(activity: Activity) {
- val page: SwipeBackPage = this[activity]
- pageStack.remove(page)
- page.activity = null
+ val page: SwipeBackPage? = this[activity]
+ pageStack.kauRemoveIf { it.activityRef.get() == null || it === page }
+ page?.activityRef?.clear()
+ KL.v("KauSwipe onDestroy ${activity.localClassName}")
}
- fun finish(activity: Activity) = this[activity].scrollToFinishActivity()
+ fun finish(activity: Activity) = this[activity]?.scrollToFinishActivity()
- internal fun getPrePage(activity: SwipeBackPage): SwipeBackPage? {
- val index = pageStack.indexOf(activity)
- return if (index > 0) pageStack[index - 1] else null
+ internal fun getPrePage(page: SwipeBackPage): SwipeBackPage? {
+ //clean invalid pages
+ pageStack.kauRemoveIf { it.activityRef.get() == null }
+ return pageStack.getOrNull(pageStack.indexOf(page) - 1)
}
-
}
/**
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt
index 1474c1a..51cd17f 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt
@@ -10,6 +10,7 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
+import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.utils.adjustAlpha
import ca.allanwang.kau.utils.navigationBarColor
import ca.allanwang.kau.utils.statusBarColor
@@ -22,8 +23,8 @@ import java.lang.ref.WeakReference
* If an edge detection occurs, this layout consumes all the touch events
* Use the [swipeEnabled] toggle if you need the scroll events on the same axis
*/
-class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0
-) : FrameLayout(context, attrs, defStyle), SwipeBackContract {
+internal class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0
+) : FrameLayout(context, attrs, defStyle), SwipeBackContract, SwipeBackContractInternal {
override val swipeBackLayout: SwipeBackLayout
get() = this
@@ -51,7 +52,7 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
override var disallowIntercept = false
- private var contentView: View? = null
+ private lateinit var contentViewRef: WeakReference<View>
private val dragHelper: ViewDragHelper
@@ -156,16 +157,6 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
addListener(chromeFadeListener)
}
-
- /**
- * Set up contentView which will be moved by user gesture
-
- * @param view
- */
- private fun setContentView(view: View) {
- contentView = view
- }
-
override fun setEdgeSizePercent(swipeEdgePercent: Float) {
edgeSize = ((if (horizontal) resources.displayMetrics.widthPixels else resources.displayMetrics.heightPixels) * swipeEdgePercent).toInt()
}
@@ -181,6 +172,7 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
/**
* Removes a listener from the set of listeners
+ * and scans our list for invalid ones
* @param listener
*/
@@ -194,10 +186,27 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
}
/**
+ * Checks if a listener exists in our list,
+ * and remove invalid ones at the same time
+ */
+ override fun hasListener(listener: SwipeListener): Boolean {
+ val iter = listeners.iterator()
+ while (iter.hasNext()) {
+ val l = iter.next().get()
+ if (l == null)
+ iter.remove()
+ else if (l == listener)
+ return true
+ }
+ return false
+ }
+
+ /**
* Scroll out contentView and finish the activity
*/
override fun scrollToFinishActivity() {
- val childWidth = contentView!!.width
+ val contentView = contentViewRef.get() ?: return KL.e("KauSwipe cannot scroll to finish as contentView is null. Is onPostCreate called?")
+ val childWidth = contentView.width
val top = 0
val left = childWidth + OVERSCROLL_DISTANCE
dragHelper.smoothSlideViewTo(contentView, left, top)
@@ -224,6 +233,7 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
}
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
+ val contentView = contentViewRef.get() ?: return KL.e("KauSwipe cannot change layout as contentView is null. Is onPostCreate called?")
inLayout = true
val xOffset: Int
val yOffset: Int
@@ -234,7 +244,7 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
xOffset = 0
yOffset = contentOffset
}
- contentView?.layout(xOffset, yOffset, xOffset + contentView!!.measuredWidth, yOffset + contentView!!.measuredHeight)
+ contentView.layout(xOffset, yOffset, xOffset + contentView.measuredWidth, yOffset + contentView.measuredHeight)
inLayout = false
}
@@ -243,7 +253,7 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
}
override fun drawChild(canvas: Canvas, child: View, drawingTime: Long): Boolean {
- val drawContent = child === contentView
+ val drawContent = child === contentViewRef.get()
val ret = super.drawChild(canvas, child, drawingTime)
if (scrimOpacity > 0 && drawContent && dragHelper.viewDragState != ViewDragHelper.STATE_IDLE)
drawScrim(canvas, child)
@@ -272,7 +282,7 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
val contentChild = content.getChildAt(0)
content.removeView(contentChild)
addView(contentChild)
- setContentView(contentChild)
+ contentViewRef = WeakReference(contentChild)
content.addView(this)
}
@@ -286,6 +296,7 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
content.removeView(this)
removeView(contentChild)
content.addView(contentChild)
+ contentViewRef.clear()
}
override fun computeScroll() {
@@ -324,10 +335,11 @@ class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs: Attribu
override fun onViewPositionChanged(changedView: View, left: Int, top: Int, dx: Int, dy: Int) {
super.onViewPositionChanged(changedView, left, top, dx, dy)
+ val contentView = contentViewRef.get() ?: return KL.e("KauSwipe cannot change view position as contentView is null; is onPostCreate called?")
//make sure that we are using the proper axis
scrollPercent = Math.abs(
- if (horizontal) left.toFloat() / contentView!!.width
- else (top.toFloat() / contentView!!.height))
+ if (horizontal) left.toFloat() / contentView.width
+ else (top.toFloat() / contentView.height))
contentOffset = if (horizontal) left else top
invalidate()
if (scrollPercent < scrollThreshold && !isScrollOverValid)
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
index 81ddb62..3132f8c 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt
@@ -4,15 +4,17 @@ import android.app.Activity
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.ViewGroup
+import ca.allanwang.kau.logging.KL
+import java.lang.ref.WeakReference
/**
* Created by Mr.Jude on 2015/8/3.
*
* Updated by Allan Wang on 2017/07/05
*/
-class SwipeBackPage(activity: Activity) : SwipeBackContract by SwipeBackLayout(activity) {
+internal class SwipeBackPage(activity: Activity) : SwipeBackContractInternal by SwipeBackLayout(activity) {
- var activity: Activity? = activity
+ var activityRef = WeakReference(activity)
var slider: RelativeSlider
/**
@@ -38,8 +40,9 @@ class SwipeBackPage(activity: Activity) : SwipeBackContract by SwipeBackLayout(a
}
private fun handleLayout() {
- if (swipeEnabled) swipeBackLayout.attachToActivity(activity!!)
- else swipeBackLayout.removeFromActivity(activity!!)
+ val activity = activityRef.get() ?: return KL.v("KauSwipe activity ref gone during handleLayout")
+ if (swipeEnabled) swipeBackLayout.attachToActivity(activity)
+ else swipeBackLayout.removeFromActivity(activity)
}
fun setClosePercent(percent: Float): SwipeBackPage {
@@ -49,6 +52,10 @@ class SwipeBackPage(activity: Activity) : SwipeBackContract by SwipeBackLayout(a
}
+internal interface SwipeBackContractInternal : SwipeBackContract {
+ val swipeBackLayout: SwipeBackLayout
+}
+
interface SwipeBackContract {
/**
* Toggle main touch intercept
@@ -59,7 +66,6 @@ interface SwipeBackContract {
* This dynamically fades as the page gets closer to exiting
*/
var scrimColor: Int
- val swipeBackLayout: SwipeBackLayout
var edgeSize: Int
/**
* Set the flag for which edge the page is scrolling from
@@ -92,7 +98,9 @@ interface SwipeBackContract {
* Sets edge size based on screen size
*/
fun setEdgeSizePercent(swipeEdgePercent: Float)
+
fun addListener(listener: SwipeListener)
fun removeListener(listener: SwipeListener)
+ fun hasListener(listener: SwipeListener): Boolean
fun scrollToFinishActivity()
} \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java b/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java
index 3368e10..566e9e5 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java
+++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java
@@ -28,7 +28,7 @@ import static ca.allanwang.kau.swipe.SwipeBackHelperKt.SWIPE_EDGE_TOP;
* This is an extension of {@link android.support.v4.widget.ViewDragHelper}
* Along with additional methods defined in {@link ViewDragHelperExtras}
*/
-public class ViewDragHelper implements ViewDragHelperExtras {
+class ViewDragHelper implements ViewDragHelperExtras {
private static final String TAG = "ViewDragHelper";
/**
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt
index dad01f1..889f347 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt
@@ -1,14 +1,16 @@
package ca.allanwang.kau.utils
+import android.support.v4.widget.ViewDragHelper
+
/**
* Created by Allan Wang on 2017-06-08.
*/
const val ANDROID_NAMESPACE = "http://schemas.android.com/apk/res/android"
-const val KAU_LEFT = 1
-const val KAU_TOP = 2
-const val KAU_RIGHT = 4
-const val KAU_BOTTOM = 8
+const val KAU_LEFT = ViewDragHelper.EDGE_LEFT
+const val KAU_RIGHT = ViewDragHelper.EDGE_RIGHT
+const val KAU_TOP = ViewDragHelper.EDGE_TOP
+const val KAU_BOTTOM = ViewDragHelper.EDGE_BOTTOM
const val KAU_HORIZONTAL = KAU_LEFT or KAU_RIGHT
const val KAU_VERTICAL = KAU_TOP or KAU_BOTTOM
const val KAU_ALL = KAU_HORIZONTAL or KAU_VERTICAL
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/FileUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/FileUtils.kt
new file mode 100644
index 0000000..25e0519
--- /dev/null
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/FileUtils.kt
@@ -0,0 +1,33 @@
+package ca.allanwang.kau.utils
+
+import android.content.Context
+import android.os.Environment
+import java.io.File
+import java.io.IOException
+import java.io.InputStream
+import java.text.SimpleDateFormat
+import java.util.*
+
+/**
+ * Created by Allan Wang on 2017-08-04.
+ */
+@Throws(IOException::class)
+fun createMediaFile(prefix: String, extension: String): File {
+ val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
+ val imageFileName = "${prefix}_${timeStamp}_"
+ val storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
+ val frostDir = File(storageDir, prefix)
+ if (!frostDir.exists()) frostDir.mkdirs()
+ return File.createTempFile(imageFileName, extension, frostDir)
+}
+
+@Throws(IOException::class)
+fun Context.createPrivateMediaFile(prefix: String, extension: String): File {
+ val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
+ val imageFileName = "${prefix}_${timeStamp}_"
+ val storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES)
+ return File.createTempFile(imageFileName, extension, storageDir)
+}
+
+fun File.copyFromInputStream(inputStream: InputStream)
+ = inputStream.use { input -> outputStream().use { output -> input.copyTo(output) } } \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt
new file mode 100644
index 0000000..23a8370
--- /dev/null
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt
@@ -0,0 +1,11 @@
+package ca.allanwang.kau.utils
+
+import android.content.Context
+import android.support.v4.app.NotificationManagerCompat
+
+
+/**
+ * Created by Allan Wang on 2017-08-04.
+ */
+fun Context.cancelNotification(notifId: Int)
+ = NotificationManagerCompat.from(this).cancel(notifId) \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt
index 42d150e..538208d 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/PackageUtils.kt
@@ -1,6 +1,5 @@
package ca.allanwang.kau.utils
-import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt
index fa062f7..1f4536b 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt
@@ -6,9 +6,9 @@ import android.support.annotation.TransitionRes
import android.support.transition.AutoTransition
import android.support.transition.TransitionInflater
import android.support.transition.TransitionManager
-import android.support.transition.Transition as SupportTransition
import android.transition.Transition
import android.view.ViewGroup
+import android.support.transition.Transition as SupportTransition
/**
* Created by Allan Wang on 2017-06-24.
diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt
index 1997bd1..2025422 100644
--- a/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt
+++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt
@@ -7,6 +7,8 @@ import kotlin.test.assertNotEquals
/**
* Created by Allan Wang on 2017-07-29.
+ *
+ * Test code for [LazyResettable]
*/
class LazyResettableTest {
diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt
new file mode 100644
index 0000000..1c40f57
--- /dev/null
+++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt
@@ -0,0 +1,42 @@
+package ca.allanwang.kau.kotlin
+
+import org.junit.Test
+import kotlin.test.assertEquals
+
+/**
+ * Created by Allan Wang on 2017-08-05.
+ *
+ * Test code for [kauRemoveIf]
+ */
+class StreamsTest {
+
+ @Test
+ fun basic() {
+ val items = mutableListOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+ items.kauRemoveIf { it % 2 == 0 }
+ assertEquals(listOf(1, 3, 5, 7, 9), items)
+ }
+
+ @Test
+ fun objectReference() {
+ data class Potato(val id: Int)
+
+ val thePotato = Potato(9)
+ val items = mutableListOf<Potato>()
+ val result = mutableListOf<Potato>()
+ for (i in 0..11) {
+ val potato = Potato(i)
+ items.add(potato)
+ result.add(potato)
+ }
+ items.add(3, thePotato)
+ assertEquals(result.size + 1, items.size, "Invalid list addition")
+ assertEquals(2, items.filter { it.id == 9 }.size, "Invalid number of potatoes with id 9")
+ items.kauRemoveIf { it === thePotato } //removal by reference
+ assertEquals(result.size, items.size, "Invalid list size after removal")
+ assertEquals(result, items)
+ items.kauRemoveIf { it == thePotato } //removal by equality
+ assertEquals(result.size - 1, items.size, "Invalid list removal based on equality")
+ }
+
+} \ No newline at end of file
diff --git a/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt b/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt
index 071ee9c..ce2b757 100644
--- a/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt
+++ b/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt
@@ -6,6 +6,8 @@ import kotlin.test.assertEquals
/**
* Created by Allan Wang on 2017-06-23.
+ *
+ * Misc test code
*/
class UtilsTest {
diff --git a/docs/Changelog.md b/docs/Changelog.md
index e27936d..4867681 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -1,9 +1,15 @@
# Changelog
+## v3.2.4
+* :core: Fix FAQ background
+* :core: Create FileUtils
+* :core: Create NotificationUtils
+* :core-ui: Move reactive libs to :searchview:
+
## v3.2.3
* :about: Modularize everything
-* :about: Create faq panel
-* :core: Create faq parser
+* :about: Create FAQ panel
+* :core: Create FAQ parser
* :core: Create collapsible view delegate
* :mediapicker: Allow for prefetching by default for videos
diff --git a/gradle.properties b/gradle.properties
index 004ae9b..55ce4e2 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -15,7 +15,7 @@ org.gradle.jvmargs=-Xmx1536m
# 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
-APP_ID=KPrefs
+APP_ID=KAU
APP_GROUP=ca.allanwang
CORE_MIN_SDK=19
MIN_SDK=21
@@ -23,6 +23,8 @@ TARGET_SDK=26
BUILD_TOOLS=26.0.1
ANDROID_SUPPORT_LIBS=26.0.0
+VERSION_NAME=3.2.4
+
KOTLIN=1.1.3-2
ABOUT_LIBRARIES=5.9.7
ANKO=0.10.1
@@ -31,7 +33,7 @@ CONSTRAINT_LAYOUT=1.1.0-beta1
FAST_ADAPTER=2.6.3
FAST_ADAPTER_COMMONS=2.6.3
GLIDE=4.0.0
-ICONICS=2.9.0
+ICONICS=2.9.1
IICON_GOOGLE=3.0.1.1
MATERIAL_DIALOG=0.9.4.5
RX_ANDROID=2.0.1
@@ -40,3 +42,6 @@ RX_JAVA=2.1.2
RX_KOTLIN=2.1.0
TIMBER=4.5.1
+ESPRESSO=3.0.0
+JUNIT=4.12
+TEST_RUNNER=1.0.0
diff --git a/kpref-activity/build.gradle b/kpref-activity/build.gradle
index 8375e91..ab2a7de 100644
--- a/kpref-activity/build.gradle
+++ b/kpref-activity/build.gradle
@@ -8,7 +8,6 @@ dependencies {
compile project(':core-ui')
compile project(':adapter')
compile project(':colorpicker')
-
}
apply from: '../artifacts.gradle'
diff --git a/mediapicker/src/main/res/layout/kau_activity_image_picker.xml b/mediapicker/src/main/res/layout/kau_activity_image_picker.xml
index 6d991b0..1b46097 100644
--- a/mediapicker/src/main/res/layout/kau_activity_image_picker.xml
+++ b/mediapicker/src/main/res/layout/kau_activity_image_picker.xml
@@ -47,6 +47,7 @@
android:layout_height="wrap_content"
android:layout_margin="@dimen/kau_fab_margin"
android:clickable="true"
+ android:focusable="true"
app:backgroundTint="?colorAccent"
app:layout_anchor="@id/kau_recyclerview"
app:layout_anchorGravity="bottom|right|end" />
diff --git a/sample/build.gradle b/sample/build.gradle
index d20a972..ac6ee20 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -1,17 +1,7 @@
-plugins {
- id 'com.gladed.androidgitversion' version '0.3.4'
-}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.triplet.play'
-repositories {
- jcenter()
- mavenCentral()
- maven { url "https://jitpack.io" }
- maven { url "https://maven.google.com" }
-}
-
play {
jsonFile = file('../files/gplay-keys.json')
track = 'beta'
@@ -24,16 +14,12 @@ android {
compileSdkVersion Integer.parseInt(project.TARGET_SDK)
buildToolsVersion project.BUILD_TOOLS
- androidGitVersion {
- codeFormat = 'MMNNPPBB'
- }
-
defaultConfig {
applicationId "ca.allanwang.kau.sample"
minSdkVersion Integer.parseInt(project.MIN_SDK)
targetSdkVersion Integer.parseInt(project.TARGET_SDK)
- versionCode androidGitVersion.code()
- versionName androidGitVersion.name()
+ versionName project.VERSION_NAME
+ versionCode project.VERSION_CODE
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
@@ -69,9 +55,28 @@ android {
checkReleaseBuilds false
}
+ packagingOptions {
+ pickFirst 'META-INF/core_release.kotlin_module'
+ pickFirst 'META-INF/library_release.kotlin_module'
+ }
+
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
+ androidTest.java.srcDirs += 'src/androidTest/kotlin'
+ main.res.srcDirs += 'src/main/res-public'
+ }
+
+ testOptions.unitTests {
+ // Don't throw runtime exceptions for android calls that are not mocked
+ returnDefaultValues = true
+
+ // Always show the result of every unit test, even if it passes.
+ all {
+ testLogging {
+ events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
+ }
+ }
}
}
@@ -85,10 +90,16 @@ dependencies {
compile project(':kpref-activity')
compile project(':searchview')
compile project(':mediapicker')
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- testCompile 'junit:junit:4.12'
compile "com.mikepenz:google-material-typeface:${IICON_GOOGLE}.original@aar"
compile "org.jetbrains.kotlin:kotlin-stdlib:${KOTLIN}"
+
+ androidTestCompile("com.android.support.test.espresso:espresso-core:${ESPRESSO}") {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ }
+ androidTestCompile("com.android.support.test:runner:${TEST_RUNNER}") {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ }
+ androidTestCompile "org.jetbrains.kotlin:kotlin-test-junit:${KOTLIN}"
+ testCompile "org.jetbrains.kotlin:kotlin-test-junit:${KOTLIN}"
+ testCompile "junit:junit:${JUNIT}"
}
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index a3bbf45..ee6cc86 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -26,6 +26,9 @@
android:name=".AnimActivity"
android:theme="@style/Kau.Translucent" />
<activity
+ android:name=".SwipeActivity"
+ android:theme="@style/Kau.Translucent" />
+ <activity
android:name=".AboutActivity"
android:theme="@style/Kau.About" />
<activity
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
index 62ca8a3..51b8530 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -14,6 +14,7 @@ import ca.allanwang.kau.mediapicker.kauOnMediaPickerResult
import ca.allanwang.kau.searchview.SearchItem
import ca.allanwang.kau.searchview.SearchView
import ca.allanwang.kau.searchview.bindSearchView
+import ca.allanwang.kau.swipe.SWIPE_EDGE_LEFT
import ca.allanwang.kau.ui.views.RippleCanvas
import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.navigationBarColor
@@ -164,8 +165,8 @@ class MainActivity : KPrefActivity() {
descRes = R.string.sub_item_desc
}
- plainText(R.string.image_showcase) {
- onClick = { _, _, _ -> kauLaunchMediaPicker(ImagePickerActivity::class.java, REQUEST_MEDIA); false }
+ plainText(R.string.swipe_showcase) {
+ onClick = { _, _, _ -> startActivityWithEdge(SWIPE_EDGE_LEFT); false }
}
plainText(R.string.video_overlay_showcase) {
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt
new file mode 100644
index 0000000..cba9ccd
--- /dev/null
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt
@@ -0,0 +1,75 @@
+package ca.allanwang.kau.sample
+
+import android.app.Activity
+import android.os.Bundle
+import android.support.v7.widget.Toolbar
+import android.view.ViewGroup
+import android.widget.Button
+import ca.allanwang.kau.internal.KauBaseActivity
+import ca.allanwang.kau.swipe.*
+import ca.allanwang.kau.utils.*
+
+/**
+ * Created by Allan Wang on 2017-08-05.
+ */
+private const val SWIPE_EDGE = "swipe_edge"
+
+fun Activity.startActivityWithEdge(flag: Int) {
+ startActivity(SwipeActivity::class.java) {
+ putExtra(SWIPE_EDGE, flag)
+ }
+}
+
+class SwipeActivity : KauBaseActivity() {
+
+ val toolbar: Toolbar by bindView(R.id.swipe_toolbar)
+ val container: ViewGroup by bindView(R.id.swipe_container)
+ val directions: List<Button> by bindViews(R.id.swipe_from_left, R.id.swipe_from_right, R.id.swipe_from_top, R.id.swipe_from_bottom)
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_swipe)
+ directions.forEach {
+ val swipeEdge = when (it.id) {
+ R.id.swipe_from_left -> SWIPE_EDGE_LEFT
+ R.id.swipe_from_right -> SWIPE_EDGE_RIGHT
+ R.id.swipe_from_top -> SWIPE_EDGE_TOP
+ R.id.swipe_from_bottom -> SWIPE_EDGE_BOTTOM
+ else -> -1
+ }
+ it.setOnClickListener { startActivityWithEdge(swipeEdge) }
+ }
+ val flag = intent.getIntExtra(SWIPE_EDGE, -1)
+ kauSwipeOnCreate {
+ edgeFlag = flag
+ }
+ toolbar.title = when (flag) {
+ SWIPE_EDGE_LEFT -> "Left Edge Swipe"
+ SWIPE_EDGE_RIGHT -> "Right Edge Swipe"
+ SWIPE_EDGE_TOP -> "Top Edge Swipe"
+ SWIPE_EDGE_BOTTOM -> "Bottom Edge Swipe"
+ else -> "Invalid Edge Swipe"
+ }
+ setSupportActionBar(toolbar)
+ val headerColor = rndColor.darken(0.6f)
+ toolbar.setBackgroundColor(headerColor)
+ statusBarColor = headerColor
+ val bg = headerColor.darken(0.2f)
+ container.setBackgroundColor(bg)
+ navigationBarColor = bg
+ }
+
+ override fun onPostCreate(savedInstanceState: Bundle?) {
+ super.onPostCreate(savedInstanceState)
+ kauSwipeOnPostCreate()
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ kauSwipeOnDestroy()
+ }
+
+ override fun onBackPressed() {
+ kauSwipeFinish()
+ }
+} \ No newline at end of file
diff --git a/sample/src/main/res/layout/activity_swipe.xml b/sample/src/main/res/layout/activity_swipe.xml
new file mode 100644
index 0000000..c65bebc
--- /dev/null
+++ b/sample/src/main/res/layout/activity_swipe.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout 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:id="@+id/swipe_container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".SwipeActivity"
+ tools:ignore="HardcodedText">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/swipe_toolbar"
+ android:layout_width="0dp"
+ android:layout_height="?attr/actionBarSize"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <Button
+ android:id="@+id/swipe_from_left"
+ style="@style/ClearButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="With left"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.25"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/swipe_toolbar"
+ app:layout_constraintVertical_bias="0.5" />
+
+ <Button
+ android:id="@+id/swipe_from_right"
+ style="@style/ClearButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="With right"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.75"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/swipe_toolbar"
+ app:layout_constraintVertical_bias="0.5" />
+
+
+ <Button
+ android:id="@+id/swipe_from_top"
+ style="@style/ClearButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="With top"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/swipe_toolbar"
+ app:layout_constraintVertical_bias="0.25" />
+
+
+ <Button
+ android:id="@+id/swipe_from_bottom"
+ style="@style/ClearButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="With bottom"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/swipe_toolbar"
+ app:layout_constraintVertical_bias="0.75" />
+
+
+</android.support.constraint.ConstraintLayout> \ No newline at end of file
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
index 11a897a..086b27b 100644
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -19,6 +19,7 @@
<string name="sub_item_desc">Press this to view the next subset of preferences</string>
<string name="your_email">your.email@here.com</string>
<string name="your_subject">Your subject</string>
+ <string name="swipe_showcase">Swipe Showcase</string>
<string name="image_showcase">Image Showcase</string>
<string name="video_overlay_showcase">Video Overlay Showcase</string>
<string name="adapter_showcase">Adapter Showcase</string>
diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml
index 15c1745..e488cec 100644
--- a/sample/src/main/res/values/styles.xml
+++ b/sample/src/main/res/values/styles.xml
@@ -23,4 +23,9 @@
<item name="android:windowAnimationStyle">@style/KauSlideInSlideOutRight</item>
</style>
+ <style name="ClearButton">
+ <item name="android:background">?android:selectableItemBackground</item>
+ <item name="android:padding">@dimen/kau_padding_normal</item>
+ </style>
+
</resources>
diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml
index df6ec2b..d505bcf 100644
--- a/sample/src/main/res/xml/kau_changelog.xml
+++ b/sample/src/main/res/xml/kau_changelog.xml
@@ -6,10 +6,18 @@
<item text="" />
-->
+ <version title="v3.2.4"/>
+ <item text=":core: Fix FAQ background" />
+ <item text=":core: Create FileUtils" />
+ <item text=":core: Create NotificationUtils" />
+ <item text=":core-ui: Move reactive libs to :searchview:" />
+ <item text="" />
+ <item text="" />
+
<version title="v3.2.3"/>
<item text=":about: Modularize everything" />
- <item text=":about: Create faq panel" />
- <item text=":core: Create faq parser" />
+ <item text=":about: Create FAQ panel" />
+ <item text=":core: Create FAQ parser" />
<item text=":core: Create collapsible view delegate" />
<item text=":mediapicker: Allow for prefetching by default for videos" />
diff --git a/searchview/build.gradle b/searchview/build.gradle
index b76a61a..0f691b0 100644
--- a/searchview/build.gradle
+++ b/searchview/build.gradle
@@ -6,6 +6,9 @@ dependencies {
compile project(':core-ui')
compile project(':adapter')
+ compile "io.reactivex.rxjava2:rxkotlin:${RX_KOTLIN}"
+ compile "io.reactivex.rxjava2:rxandroid:${RX_ANDROID}"
+ compile "com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:${RX_BINDING}"
}
apply from: '../artifacts.gradle'