aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/res/transition/kau_enter_slide_bottom.xml38
-rw-r--r--docs/Changelog.md4
-rw-r--r--imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivityBase.kt72
-rw-r--r--imagepicker/src/main/res/layout/kau_activity_image_picker.xml29
-rw-r--r--imagepicker/src/main/res/layout/kau_iitem_image.xml16
-rw-r--r--imagepicker/src/main/res/values/styles.xml8
-rw-r--r--sample/src/main/AndroidManifest.xml3
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt14
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/ImageActivity.kt8
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt2
-rw-r--r--sample/src/main/res/menu/menu_main.xml2
-rw-r--r--sample/src/main/res/xml/changelog.xml4
12 files changed, 149 insertions, 51 deletions
diff --git a/core/src/main/res/transition/kau_enter_slide_bottom.xml b/core/src/main/res/transition/kau_enter_slide_bottom.xml
new file mode 100644
index 0000000..7eb2097
--- /dev/null
+++ b/core/src/main/res/transition/kau_enter_slide_bottom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2015 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<transitionSet
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:transitionOrdering="together"
+ android:duration="400"
+ android:interpolator="@android:interpolator/linear_out_slow_in">
+
+ <slide android:slideEdge="bottom">
+ <targets>
+ <target android:excludeId="@android:id/navigationBarBackground" />
+ <target android:excludeId="@android:id/statusBarBackground" />
+ </targets>
+ </slide>
+
+ <fade android:duration="@android:integer/config_mediumAnimTime">
+ <targets>
+ <target android:targetId="@android:id/navigationBarBackground" />
+ <target android:targetId="@android:id/statusBarBackground" />
+ </targets>
+ </fade>
+
+</transitionSet>
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 08b6529..9161280 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -8,8 +8,8 @@
## v1.4
* Added about activities
-* Added themed fast item adapter
-* Added chained adapter
+* Added themed fast item imageAdapter
+* Added chained imageAdapter
* Added item animators
* Ported some views over from Plaid
* Add string arg option for sendEmail
diff --git a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivityBase.kt b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivityBase.kt
index 216939f..d5562aa 100644
--- a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivityBase.kt
+++ b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivityBase.kt
@@ -1,39 +1,77 @@
package ca.allanwang.kau.imagepicker
-import android.graphics.drawable.Drawable
+import android.database.Cursor
import android.os.Bundle
+import android.provider.MediaStore
+import android.support.v4.app.LoaderManager
+import android.support.v4.content.CursorLoader
+import android.support.v4.content.Loader
import android.support.v7.app.AppCompatActivity
+import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.Toolbar
import android.transition.TransitionInflater
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import ca.allanwang.kau.R
-import ca.allanwang.kau.adapters.FastItemThemedAdapter
-import ca.allanwang.kau.adapters.ThemableIItemColors
-import ca.allanwang.kau.adapters.ThemableIItemColorsDelegate
-import ca.allanwang.kau.iitems.LibraryIItem
+import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.utils.bindView
-import ca.allanwang.kau.utils.string
import ca.allanwang.kau.widgets.ElasticDragDismissFrameLayout
-import com.mikepenz.aboutlibraries.Libs
-import com.mikepenz.aboutlibraries.entity.Library
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
-import java.security.InvalidParameterException
+
/**
* Created by Allan Wang on 2017-07-04.
*
*/
-abstract class ImagePickerActivityBase : AppCompatActivity() {
+abstract class ImagePickerActivityBase : AppCompatActivity(), LoaderManager.LoaderCallbacks<Cursor> {
- val toolbar:Toolbar by bindView(R.id.kau_toolbar)
- val recycler:RecyclerView by bindView(R.id.kau_recycler)
- val adapter = FastItemAdapter<ImageItem>()
+ val toolbar: Toolbar by bindView(R.id.kau_toolbar)
+ val draggableFrame: ElasticDragDismissFrameLayout by bindView(R.id.kau_draggable)
+ val recycler: RecyclerView by bindView(R.id.kau_recycler)
+ val imageAdapter = FastItemAdapter<ImageItem>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.kau_activity_image_picker)
+ with(recycler) {
+ layoutManager = GridLayoutManager(this@ImagePickerActivityBase, 3)
+ adapter = this@ImagePickerActivityBase.imageAdapter
+ }
+ imageAdapter.add(arrayOf("a", "b", "c").map { ImageItem(it) })
+ draggableFrame.addListener(object : ElasticDragDismissFrameLayout.SystemChromeFader(this) {
+ override fun onDragDismissed() {
+ if (draggableFrame.translationY < 0) {
+ window.returnTransition = TransitionInflater.from(this@ImagePickerActivityBase)
+ .inflateTransition(R.transition.kau_about_return_upwards)
+ }
+ finishAfterTransition()
+ }
+ })
+ }
+
+ override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> {
+ val columns = arrayOf(
+ MediaStore.Images.Media._ID,
+ MediaStore.Images.Media.DATA,
+ MediaStore.Images.Media.DISPLAY_NAME,
+ MediaStore.Images.Media.DATE_MODIFIED)
+
+ return CursorLoader(this, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, null, null)
+ }
+
+ override fun onLoadFinished(loader: Loader<Cursor>, data: Cursor) {
+ val dataIndex = data.getColumnIndex(MediaStore.Images.Media.DATA)
+ val alstPhotos = mutableListOf<String>()
+
+ data.moveToLast()
+ while (!data.isBeforeFirst) {
+ val photoPath = data.getString(dataIndex)
+ KL.d(photoPath)
+ alstPhotos.add(photoPath)
+ data.moveToPrevious()
+ }
+ imageAdapter.add(alstPhotos.map { ImageItem(it) })
+ }
+
+ override fun onLoaderReset(loader: Loader<Cursor>) {
+ imageAdapter.clear()
}
} \ No newline at end of file
diff --git a/imagepicker/src/main/res/layout/kau_activity_image_picker.xml b/imagepicker/src/main/res/layout/kau_activity_image_picker.xml
index d3739dd..3c12a84 100644
--- a/imagepicker/src/main/res/layout/kau_activity_image_picker.xml
+++ b/imagepicker/src/main/res/layout/kau_activity_image_picker.xml
@@ -1,18 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<ca.allanwang.kau.widgets.ElasticDragDismissFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/kau_drag_dismiss_distance">
+ android:id="@+id/kau_draggable"
+ app:dragDismissDistance="@dimen/kau_drag_dismiss_distance"
+ app:dragDismissScale="0.95">
- <android.support.v7.widget.Toolbar
- android:id="@+id/kau_toolbar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize" />
-
- <android.support.v7.widget.RecyclerView
- android:id="@+id/kau_recycler"
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="?attr/actionBarSize" />
+ android:layout_marginTop="@dimen/kau_drag_dismiss_distance"
+ android:orientation="vertical">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/kau_toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize" />
+
+ <android.support.v7.widget.RecyclerView
+ android:id="@+id/kau_recycler"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?android:colorBackground" />
+
+ </LinearLayout>
</ca.allanwang.kau.widgets.ElasticDragDismissFrameLayout> \ No newline at end of file
diff --git a/imagepicker/src/main/res/layout/kau_iitem_image.xml b/imagepicker/src/main/res/layout/kau_iitem_image.xml
index 824ae7b..22cc998 100644
--- a/imagepicker/src/main/res/layout/kau_iitem_image.xml
+++ b/imagepicker/src/main/res/layout/kau_iitem_image.xml
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="80dp"
- android:layout_height="80dp">
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
<ImageView
android:id="@+id/kau_image"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:scaleType="centerCrop"
+ android:background="#f0f"
+ app:layout_constraintDimensionRatio="1:1" />
-</FrameLayout> \ No newline at end of file
+</android.support.constraint.ConstraintLayout> \ No newline at end of file
diff --git a/imagepicker/src/main/res/values/styles.xml b/imagepicker/src/main/res/values/styles.xml
new file mode 100644
index 0000000..1dc5149
--- /dev/null
+++ b/imagepicker/src/main/res/values/styles.xml
@@ -0,0 +1,8 @@
+<resources>
+
+ <style name="Kau.Translucent.ImagePicker">
+ <item name="android:windowEnterTransition">@transition/kau_enter_slide_bottom</item>
+ <item name="android:windowReturnTransition">@transition/kau_about_return_downward</item>
+ </style>
+
+</resources>
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index 5a364b6..0ab360e 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -28,6 +28,9 @@
<activity
android:name=".AboutActivity"
android:theme="@style/Kau.Translucent.About" />
+ <activity
+ android:name=".ImageActivity"
+ android:theme="@style/Kau.Translucent.ImagePicker" />
</application>
</manifest> \ No newline at end of file
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
index 2ba7731..fbcb88f 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
@@ -26,7 +26,7 @@ class AnimActivity : AppCompatActivity() {
PERMISSION_ACCESS_COARSE_LOCATION,
PERMISSION_ACCESS_FINE_LOCATION
).map { PermissionCheckbox(it) })
- val withOnClickListener = adapter.withOnClickListener { _, _, item, _ ->
+ adapter.withOnClickListener { _, _, item, _ ->
KL.d("Perm Click")
kauRequestPermissions(item.permission) {
granted, deniedPerm ->
@@ -35,18 +35,6 @@ class AnimActivity : AppCompatActivity() {
}
true
}
- kauRequestPermissions(PERMISSION_READ_EXTERNAL_STORAGE) {
- granted, deniedPerm ->
- if (!granted) return@kauRequestPermissions
- val cursor = contentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
- arrayOf(MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA, MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATE_MODIFIED),
- null, null, MediaStore.Images.Media.DEFAULT_SORT_ORDER, null)
- while (!cursor.isLast) {
- cursor.moveToNext()
- KL.d(cursor.getString(1))
- }
- cursor.close()
- }
}
override fun onBackPressed() {
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/ImageActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/ImageActivity.kt
new file mode 100644
index 0000000..a0b3dc5
--- /dev/null
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/ImageActivity.kt
@@ -0,0 +1,8 @@
+package ca.allanwang.kau.sample
+
+import ca.allanwang.kau.imagepicker.ImagePickerActivityBase
+
+/**
+ * Created by Allan Wang on 2017-07-04.
+ */
+class ImageActivity : ImagePickerActivityBase() \ No newline at end of file
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 53fa68e..d0a5ee1 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -212,7 +212,7 @@ class MainActivity : KPrefActivity() {
when (item.itemId) {
R.id.action_settings -> startActivity(AnimActivity::class.java, clearStack = true)
R.id.action_email -> sendEmail(R.string.your_email, R.string.your_subject)
- R.id.test -> prefHolder.showNext()
+ R.id.test -> startActivity(ImageActivity::class.java, transition = true)
else -> return super.onOptionsItemSelected(item)
}
return true
diff --git a/sample/src/main/res/menu/menu_main.xml b/sample/src/main/res/menu/menu_main.xml
index 0481ae5..039c2c9 100644
--- a/sample/src/main/res/menu/menu_main.xml
+++ b/sample/src/main/res/menu/menu_main.xml
@@ -24,7 +24,7 @@
<item
android:id="@+id/test"
android:orderInCategory="300"
- android:title="@string/kau_menu"
+ android:title="Test"
app:showAsAction="never" />
</menu>
diff --git a/sample/src/main/res/xml/changelog.xml b/sample/src/main/res/xml/changelog.xml
index 1fe0a61..f4ac5bf 100644
--- a/sample/src/main/res/xml/changelog.xml
+++ b/sample/src/main/res/xml/changelog.xml
@@ -18,8 +18,8 @@
<version title="v1.4"/>
<item text="Added about activities" />
- <item text="Added themed fast item adapter" />
- <item text="Added chained adapter" />
+ <item text="Added themed fast item imageAdapter" />
+ <item text="Added chained imageAdapter" />
<item text="Added item animators" />
<item text="Ported some views over from Plaid" />
<item text="Add string arg option for sendEmail" />