aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/contracts
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-08-03 22:21:51 -0700
committerGitHub <noreply@github.com>2017-08-03 22:21:51 -0700
commit7746e63373c905faa6d7e45e45fffc48d3ffff85 (patch)
tree5d1bd4338a722619bb892abb308b369abc61f396 /app/src/main/kotlin/com/pitchedapps/frost/contracts
parent5583f519dd7c4843f045029b0e48fd882dd79c71 (diff)
downloadfrost-7746e63373c905faa6d7e45e45fffc48d3ffff85.tar.gz
frost-7746e63373c905faa6d7e45e45fffc48d3ffff85.tar.bz2
frost-7746e63373c905faa6d7e45e45fffc48d3ffff85.zip
Add IM notifications, FAQ, video uploading, and geolocations (#107)
* Test canary * Update activities to use kau base * Update dependencies * Cherry pick faq * Update kau and add faq * Add readme badges * Add im notifications and video uploading * Update theme * Update and fix unit tests * Add geolocation * Prepare alpha test * Remove explicit nonnull request
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/contracts')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt23
1 files changed, 13 insertions, 10 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt
index bd31d6ce..fd8a3677 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt
@@ -5,16 +5,18 @@ import android.content.Intent
import android.net.Uri
import android.webkit.ValueCallback
import android.webkit.WebChromeClient
-import ca.allanwang.kau.imagepicker.kauLaunchImagePicker
-import ca.allanwang.kau.imagepicker.kauOnImagePickerResult
+import ca.allanwang.kau.mediapicker.MediaPickerActivityOverlayBase
+import ca.allanwang.kau.mediapicker.MediaType
+import ca.allanwang.kau.mediapicker.kauLaunchMediaPicker
+import ca.allanwang.kau.mediapicker.kauOnMediaPickerResult
import com.pitchedapps.frost.activities.ImagePickerActivity
+import com.pitchedapps.frost.activities.VideoPickerActivity
import com.pitchedapps.frost.utils.L
-import java.io.File
/**
* Created by Allan Wang on 2017-07-04.
*/
-const val IMAGE_CHOOSER_REQUEST = 67
+const val MEDIA_CHOOSER_RESULT = 67
interface FileChooserActivityContract {
fun openFileChooser(filePathCallback: ValueCallback<Array<Uri>>, fileChooserParams: WebChromeClient.FileChooserParams)
@@ -22,7 +24,7 @@ interface FileChooserActivityContract {
interface FileChooserContract {
var filePathCallback: ValueCallback<Array<Uri>>?
- fun Activity.openImagePicker(filePathCallback: ValueCallback<Array<Uri>>, fileChooserParams: WebChromeClient.FileChooserParams)
+ fun Activity.openMediaPicker(filePathCallback: ValueCallback<Array<Uri>>, fileChooserParams: WebChromeClient.FileChooserParams)
fun Activity.onActivityResultWeb(requestCode: Int, resultCode: Int, intent: Intent?): Boolean
}
@@ -30,16 +32,17 @@ class FileChooserDelegate : FileChooserContract {
override var filePathCallback: ValueCallback<Array<Uri>>? = null
- override fun Activity.openImagePicker(filePathCallback: ValueCallback<Array<Uri>>, fileChooserParams: WebChromeClient.FileChooserParams) {
+ override fun Activity.openMediaPicker(filePathCallback: ValueCallback<Array<Uri>>, fileChooserParams: WebChromeClient.FileChooserParams) {
this@FileChooserDelegate.filePathCallback = filePathCallback
- kauLaunchImagePicker(ImagePickerActivity::class.java, IMAGE_CHOOSER_REQUEST)
+ val isVideo = fileChooserParams.acceptTypes.firstOrNull() == "video/*"
+ kauLaunchMediaPicker(if (isVideo) VideoPickerActivity::class.java else ImagePickerActivity::class.java, MEDIA_CHOOSER_RESULT)
}
override fun Activity.onActivityResultWeb(requestCode: Int, resultCode: Int, intent: Intent?): Boolean {
L.d("FileChooser On activity results web $requestCode")
- if (requestCode != IMAGE_CHOOSER_REQUEST) return false
- val results = kauOnImagePickerResult(resultCode, intent).map { it.uri }.toTypedArray()
- L.d("FileChooser result ${results.contentToString()}")
+ if (requestCode != MEDIA_CHOOSER_RESULT) return false
+ val results = kauOnMediaPickerResult(resultCode, intent).map { it.uri }.toTypedArray()
+ L.i("FileChooser result ${results.contentToString()}")
//proper path content://com.android.providers.media.documents/document/image%3A36341
L.d("FileChooser Callback received; ${filePathCallback != null}")
filePathCallback?.onReceiveValue(results)