aboutsummaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/src/main/AndroidManifest.xml11
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt4
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt26
-rw-r--r--sample/src/main/res/xml/kau_file_paths.xml9
4 files changed, 43 insertions, 7 deletions
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index ee6cc86..d8bbe51 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".SampleApp"
@@ -46,6 +47,16 @@
<activity
android:name=".AdapterActivity"
android:theme="@style/Kau.Translucent.SlideBottom" />
+
+ <provider
+ android:name="android.support.v4.content.FileProvider"
+ android:authorities="${applicationId}.provider"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/kau_file_paths" />
+ </provider>
</application>
</manifest> \ 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 5d0bd36..09002d4 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -169,6 +169,10 @@ class MainActivity : KPrefActivity() {
onClick = { _, _, _ -> startActivityWithEdge(SWIPE_EDGE_LEFT); false }
}
+ plainText(R.string.image_showcase) {
+ onClick = { _, _, _ -> kauLaunchMediaPicker(ImagePickerActivity::class.java, REQUEST_MEDIA); false }
+ }
+
plainText(R.string.video_overlay_showcase) {
onClick = { _, _, _ -> kauLaunchMediaPicker(VideoPickerActivityOverlay::class.java, REQUEST_MEDIA); false }
}
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt
index 7aac0ef..618ca07 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt
@@ -1,16 +1,28 @@
package ca.allanwang.kau.sample
-import ca.allanwang.kau.mediapicker.MediaPickerActivityBase
-import ca.allanwang.kau.mediapicker.MediaPickerActivityOverlayBase
-import ca.allanwang.kau.mediapicker.MediaType
+import android.content.Context
+import android.net.Uri
+import android.support.v4.content.FileProvider
+import ca.allanwang.kau.mediapicker.*
+import java.io.File
/**
* Created by Allan Wang on 2017-07-23.
*/
-class ImagePickerActivity : MediaPickerActivityBase(MediaType.IMAGE)
+private fun actions(multiple: Boolean) = listOf(object : MediaActionCamera() {
-class ImagePickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.IMAGE)
+ override fun createFile(context: Context): File
+ = createMediaFile("KAU", ".jpg")
-class VideoPickerActivity : MediaPickerActivityBase(MediaType.VIDEO)
+ override fun createUri(context: Context, file: File): Uri
+ = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file)
-class VideoPickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.VIDEO) \ No newline at end of file
+}, MediaActionGallery(multiple))
+
+class ImagePickerActivity : MediaPickerActivityBase(MediaType.IMAGE, actions(true))
+
+class ImagePickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.IMAGE, actions(false))
+
+class VideoPickerActivity : MediaPickerActivityBase(MediaType.VIDEO, actions(true))
+
+class VideoPickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.VIDEO, actions(false)) \ No newline at end of file
diff --git a/sample/src/main/res/xml/kau_file_paths.xml b/sample/src/main/res/xml/kau_file_paths.xml
new file mode 100644
index 0000000..83b00bb
--- /dev/null
+++ b/sample/src/main/res/xml/kau_file_paths.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths>
+ <external-path
+ name="KAU_images"
+ path="Android/data/ca.allanwang.kau.sample/files/Pictures" />
+ <external-path
+ name="KAU_public_images"
+ path="Pictures/KAU" />
+</paths> \ No newline at end of file