Skip to content

Commit

Permalink
Major update to core and kotterknife; create mediapicker (#15)
Browse files Browse the repository at this point in the history
* Readme

* Fix kau direction bits

* Truly support transparent ripples

* Update changelog

* Test rect as base

* Replace fab transition with generic fade scale transition

* Add scalexy func

* Add scaleXY

* Add arguments to fadeScaleTransition

* Clean up ink indicator

* Create setOnSingleTapListener

* Fix lint and add rndColor

* Create kotterknife resettables

* Add readme and missing object

* Create lazy resettable registered

* Update core docs

* Opt for separate class for resettable registry

* Clean up resettable registry

* Rename functions

* Add ripple callback listener

* Adjust kprefactivity desc color

* Add more transitions

* Add delete keys option

* Add instrumentation tests

* switch id

* Revert automatic instrumental tests

* Generify imagepickercore and prepare video alternative

* Create working video picker

* Address possible null issue

* Update searchview

* Make layouts public

* Add changelog test

* Update logo link

* Add custom color gif
  • Loading branch information
AllanWang authored Aug 1, 2017
1 parent 8a4e9fd commit 48213d0
Show file tree
Hide file tree
Showing 84 changed files with 1,064 additions and 356 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
compile "ca.allanwang.kau:about:$KAU"
compile "ca.allanwang.kau:colorpicker:$KAU"
compile "ca.allanwang.kau:imagepicker:$KAU"
compile "ca.allanwang.kau:mediapicker:$KAU"
compile "ca.allanwang.kau:kpref-activity:$KAU"
compile "ca.allanwang.kau:searchview:$KAU"
}
Expand Down Expand Up @@ -89,8 +89,8 @@ dependencies {
* Includes `:core`,
[`Material Dialogs (commons)`](https://github.com/afollestad/material-dialogs)

## [Image Picker](imagepicker#readme)
* WIP - Overlaying media chooser
## [Media Picker](mediapicker#readme)
* Fully functional image and video pickers, both as an overlay and as a requested activity.
* Includes `:core-ui`,
[`Glide`](https://github.com/bumptech/glide),
[`Blurry`](https://github.com/wasabeef/Blurry)
Expand All @@ -110,6 +110,7 @@ dependencies {
![About Activity Gif](https://raw.githubusercontent.com/AllanWang/Storage-Hub/master/kau/kau_about_activity.gif)
![Ink Indicator Gif](https://raw.githubusercontent.com/AllanWang/Storage-Hub/master/kau/kau_ink_indicator.gif)
![Color Picker Gif](https://raw.githubusercontent.com/AllanWang/Storage-Hub/master/kau/kau_color_picker.gif)
![Color Picker Custom Gif](https://raw.githubusercontent.com/AllanWang/Storage-Hub/master/kau/kau_color_picker_custom.gif)
![KPref Items Gif](https://raw.githubusercontent.com/AllanWang/Storage-Hub/master/kau/kau_kpref_items.gif)
![SearchView Gif](https://raw.githubusercontent.com/AllanWang/Storage-Hub/master/kau/kau_search_view.gif)

Expand Down
2 changes: 1 addition & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<body>
<div class="wrapper">
<header>
<a href="{{ site.github.url }}"><img src="https://cdn.rawgit.com/AllanWang/KAU/master/files/logo.svg" alt="KAU" width="30%"/></a>
<a href="{{ site.github.url }}"><img src="https://cdn.rawgit.com/AllanWang/KAU/master/files/images/logo.svg" alt="KAU" width="30%"/></a>
<!--<h1><a href="{{ site.github.url }}">{{ site.title | default: site.github.repository_name }}</a></h1>-->
<p>{{ site.description | default: site.github.project_tagline }}</p>

Expand Down
1 change: 0 additions & 1 deletion adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ext.kauSubModuleMinSdk = project.CORE_MIN_SDK
apply from: '../android-lib.gradle'

dependencies {

compile project(':core')

compile "com.mikepenz:fastadapter:${FAST_ADAPTER}@aar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@ package ca.allanwang.kau.animators
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewPropertyAnimator
import ca.allanwang.kau.utils.scaleXY

/**
* Created by Allan Wang on 2017-07-11.
*/
class FadeScaleAnimatorAdd(val scaleFactor: Float = 1.0f, override var itemDelayFactor: Float = 0.125f) : KauAnimatorAdd {

override fun animationPrepare(holder: RecyclerView.ViewHolder): View.() -> Unit = {
scaleX = scaleFactor
scaleY = scaleFactor
scaleXY = scaleFactor
alpha = 0f
}

override fun animation(holder: RecyclerView.ViewHolder): ViewPropertyAnimator.() -> Unit = {
scaleX(1f)
scaleY(1f)
scaleXY(1f)
alpha(1f)
}

override fun animationCleanup(holder: RecyclerView.ViewHolder): View.() -> Unit = {
scaleX = 1f
scaleY = 1f
scaleXY = 1f
alpha = 1f
}

Expand All @@ -34,14 +32,12 @@ class FadeScaleAnimatorAdd(val scaleFactor: Float = 1.0f, override var itemDelay
class FadeScaleAnimatorRemove(val scaleFactor: Float = 1.0f, override var itemDelayFactor: Float = 0.125f) : KauAnimatorRemove {

override fun animation(holder: RecyclerView.ViewHolder): ViewPropertyAnimator.() -> Unit = {
scaleX(scaleFactor)
scaleY(scaleFactor)
scaleXY(scaleFactor)
alpha(0f)
}

override fun animationCleanup(holder: RecyclerView.ViewHolder): View.() -> Unit = {
scaleX = 1f
scaleY = 1f
scaleXY = 1f
alpha = 1f
}

Expand Down
24 changes: 24 additions & 0 deletions android-lib.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ android {
minSdkVersion Integer.parseInt(kauMinSdk)
targetSdkVersion Integer.parseInt(project.TARGET_SDK)
consumerProguardFiles 'progress-proguard.txt'
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand All @@ -52,6 +53,29 @@ android {
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'
}
}
}
}

dependencies {
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
testCompile "org.jetbrains.kotlin:kotlin-test-junit:${KOTLIN}"
}
3 changes: 2 additions & 1 deletion colorpicker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ The color picker also animates the selection, and uses Kotlin's DSL to provide e

To use it, call `Context.colorPickerDialog` and specify and configs as required through the builder.

![Color Picker Gif](https://raw.githubusercontent.com/AllanWang/Storage-Hub/master/kau/kau_color_picker.gif)
![Color Picker Gif](https://raw.githubusercontent.com/AllanWang/Storage-Hub/master/kau/kau_color_picker.gif)
![Color Picker Custom Gif](https://raw.githubusercontent.com/AllanWang/Storage-Hub/master/kau/kau_color_picker_custom.gif)
1 change: 0 additions & 1 deletion core-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ext.kauSubModuleMinSdk = project.CORE_MIN_SDK
apply from: '../android-lib.gradle'

dependencies {

compile project(':core')
compile project(':adapter')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ class ElasticDragDismissFrameLayout @JvmOverloads constructor(
} else { // settle back to natural position
animate()
.translationY(0f)
.scaleX(1f)
.scaleY(1f)
.scaleXY(1f)
.setDuration(200L)
.setInterpolator(AnimHolder.fastOutSlowInInterpolator(context))
.setListener(null)
Expand Down Expand Up @@ -176,11 +175,7 @@ class ElasticDragDismissFrameLayout @JvmOverloads constructor(
}
translationY = dragTo

if (shouldScale) {
val scale = 1 - (1 - dragDismissScale) * dragFraction
scaleX = scale
scaleY = scale
}
if (shouldScale) scaleXY = 1 - (1 - dragDismissScale) * dragFraction

// if we've reversed direction and gone past the settle point then clear the flags to
// allow the list to get the scroll events & reset any transforms
Expand All @@ -191,8 +186,7 @@ class ElasticDragDismissFrameLayout @JvmOverloads constructor(
draggingUp = false
draggingDown = draggingUp
translationY = 0f
scaleX = 1f
scaleY = 1f
scaleXY = 1f
}
dispatchDragCallback(dragFraction, dragTo,
Math.min(1f, Math.abs(totalDrag) / dragDismissDistance), totalDrag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import java.util.Arrays;

import ca.allanwang.kau.logging.KL;
import ca.allanwang.kau.ui.R;
import ca.allanwang.kau.utils.AnimHolder;
import ca.allanwang.kau.utils.ColorUtilsKt;
Expand Down Expand Up @@ -384,7 +385,7 @@ private Path getUnselectedPath(int page,

if ((joiningFraction == 0f || joiningFraction == INVALID_FRACTION)
&& dotRevealFraction == 0f
&& !(page == currentPage && selectedDotInPosition == true)) {
&& !(page == currentPage && selectedDotInPosition)) {

// case #1 – At rest
unselectedDotPath.addCircle(dotCenterX[page], dotCenterY, dotRadius, Path.Direction.CW);
Expand Down Expand Up @@ -632,18 +633,16 @@ public void onAnimationEnd(Animator animation) {
});
// slightly delay the start to give the joins a chance to run
// unless dot isn't in position yet – then don't delay!
moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4l : 0l);
moveSelected.setDuration(animDuration * 3l / 4l);
moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4L : 0L);
moveSelected.setDuration(animDuration * 3L / 4L);
moveSelected.setInterpolator(interpolator);
return moveSelected;
}

private void setJoiningFraction(int leftDot, float fraction) {
if (leftDot < joiningFractions.length) {

if (leftDot == 1) {
Log.d("PageIndicator", "dot 1 fraction:\t" + fraction);
}
if (leftDot == 1) KL.INSTANCE.v("PageIndicator dot 1 fraction:\t$fraction");

joiningFractions[leftDot] = fraction;
postInvalidateOnAnimation();
Expand Down
3 changes: 3 additions & 0 deletions core-ui/src/main/res-public/values/public.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
<public name='kau_elastic_recycler_activity' type='layout' />
<public name='kau_recycler_detached_background' type='layout' />
<public name='kau_recycler_textslider' type='layout' />
<public name='kau_shadow_overlay' type='color' />
<public name='Kau.Translucent' type='style' />
<public name='Kau.Translucent.NoAnimation' type='style' />
Expand Down
33 changes: 32 additions & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

* [KPrefs](#kprefs)
* [Changelog XML](#changelog)
* [Kotterknife](#kotterknife)
* [Ripple Canvas](#ripple-canvas)
* [MeasureSpecDelegate](#measure-spec-delegate)
* [Timber Logger](#timber-logger)
* [Email Builder](#email-builder)
* [Extensions](#extensions)
* [Lazy Resettable](#lazy-resettable)

<a name="kprefs"></a>
## KPrefs
Expand Down Expand Up @@ -103,6 +106,17 @@ Here is a template xml changelog file:
</resources>
```
<a name="kotterknife"></a>
## Kotterknife
KAU comes shipped with [Kotterknife](https://github.com/JakeWharton/kotterknife) by Jake Wharton.
It is a powerful collection of lazy view bindings that only calls the expensive `findViewById` once.
In KAU, there are also resettable versions (suffixed with `Resettable`) for all bindings.
These variants are weakly held in the private `KotterknifeRegistry` object, and can be used to invalidate the lazy
values through the `Kotterknife.reset` method. This is typically useful for Fragments, as they do not follow
the same lifecycle as Activities and Views.
<a name="ripple-canvas"></a>
## Ripple Canvas
Expand All @@ -114,6 +128,13 @@ They can be used as transitions, or as a toolbar background to replicate the loo
Many ripples can be stacked on top of each other to run at the same time from different locations.
The canvas also supports color fading and direct color setting so it can effectively replace any background.
<a name="measure-spec-delegate"></a>
## Measure Spec Delegate
If you ever have a view needing exact aspect ratios with its parent and/or itself, this delegate is here to help.
Implementing this in any view class unlocks its attributes, giving you three layers of view measuring to ensure exact sizing.
More information can be found in the [klass file](https://github.com/AllanWang/KAU/blob/master/core/src/main/kotlin/ca/allanwang/kau/ui/views/MeasureSpecDelegate.kt)
<a name="timber-logger"></a>
## Timber Logger
Expand All @@ -134,4 +155,14 @@ Include your email and subject, along with other optional configurations such as
Note that since KAU depends on [ANKO](https://github.com/Kotlin/anko), all of the extensions in its core package is also in KAU.

KAU's vast collection of extensions is one of its strongest features.
There are too many to explain here, but you may check out the [utils package](https://github.com/AllanWang/KAU/tree/master/core/src/main/kotlin/ca/allanwang/kau/utils)
There are too many to explain here, but you may check out the [utils package](https://github.com/AllanWang/KAU/tree/master/core/src/main/kotlin/ca/allanwang/kau/utils)

<a name="lazy-resettable></a>
## Lazy Resettable

In the spirit of Kotlin's Lazy delegate, KAU supports a resettable version. Calling `lazyResettable` produces the same delegate,
but with an additional `invalidate` method.

To further simplify this, there is also a `LazyResettableRegistry` class that can be used to hold all resettables.
The instance can be passed through the `lazyResettable` method, or classes can provide their own extension functions to
register the delegates by default.
4 changes: 0 additions & 4 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ ext.kauSubModuleMinSdk = project.CORE_MIN_SDK
apply from: '../android-lib.gradle'

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'

compile "org.jetbrains.kotlin:kotlin-stdlib:${KOTLIN}"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:${KOTLIN}"

compile "com.android.support:appcompat-v7:${ANDROID_SUPPORT_LIBS}"
compile "com.android.support:support-v13:${ANDROID_SUPPORT_LIBS}"
Expand Down
Loading

0 comments on commit 48213d0

Please sign in to comment.