From a101b528efdee74fc1970b7f1fe68263f0b20269 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 18 Aug 2017 14:39:40 -0700 Subject: Create media picker action items (#40) * Create action items * Increment version * Update camera action * Abstract camera action * Add and test * Refactor and add docs --- .../kotlin/ca/allanwang/kau/sample/MainActivity.kt | 4 ++++ .../kotlin/ca/allanwang/kau/sample/MediaPicker.kt | 26 ++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'sample/src/main/kotlin/ca') 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 -- cgit v1.2.3