This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2021-02-18T06:09:40.064Z","extensionVersion":"v3.4.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun handleSendImage(intent: Intent) { | |
val imageUri = intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM) | |
if (imageUri.toString().contains("com.google.android.apps.docs")) { //From Google Drive | |
// show the progress bar until the you get the file | |
this.createTempFile(imageUri, DriveTempFileCallback { | |
// hide the progress bar | |
// file -- handle the file as you want | |
}) | |
} else { //From gallery intent | |
// handle signle image from gallary intent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val action = intent.action | |
val type = intent.type | |
if (Intent.ACTION_SEND == action && type != null) { | |
if (type.startsWith("image/")) { | |
handleSendImage(intent) | |
} | |
} else if (Intent.ACTION_SEND_MULTIPLE == action && type != null) { | |
if (type.startsWith("image/")) { | |
handleSendMultipleImages(intent) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface DriveTempFileCallback { | |
fun onFileCreated(file: File) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface DriveImageCallback { | |
fun onSuccess(list: ArrayList<Uri>) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Activity?.createTempFile(uri: Uri, callback: DriveTempFileCallback) { | |
val startTime = System.currentTimeMillis() // Just for debugging purpose | |
this.doAsyncResult { // Here I have used the Anko library to simplify things | |
var stream: InputStream? = null | |
try { | |
stream = this@createTempFile?.contentResolver?.openInputStream(uri) | |
} catch (e: FileNotFoundException) { | |
e.printStackTrace() | |
} |