2022-09-30 21:22:37 +02:00
|
|
|
package sushi.hardcore.droidfs.explorers
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.content.Intent
|
|
|
|
import sushi.hardcore.droidfs.filesystems.EncryptedVolume
|
|
|
|
import sushi.hardcore.droidfs.util.IntentUtils
|
|
|
|
|
|
|
|
class ExplorerRouter(private val context: Context, private val intent: Intent) {
|
|
|
|
var pickMode = intent.action == "pick"
|
|
|
|
var dropMode = (intent.action == Intent.ACTION_SEND || intent.action == Intent.ACTION_SEND_MULTIPLE) && intent.extras != null
|
|
|
|
|
2023-03-07 23:25:17 +01:00
|
|
|
fun getExplorerIntent(volumeId: Int, volumeShortName: String): Intent {
|
2022-09-30 21:22:37 +02:00
|
|
|
var explorerIntent: Intent? = null
|
|
|
|
if (dropMode) { //import via android share menu
|
|
|
|
explorerIntent = Intent(context, ExplorerActivityDrop::class.java)
|
|
|
|
IntentUtils.forwardIntent(intent, explorerIntent)
|
|
|
|
} else if (pickMode) {
|
|
|
|
explorerIntent = Intent(context, ExplorerActivityPick::class.java)
|
|
|
|
explorerIntent.putExtra("destinationVolume", IntentUtils.getParcelableExtra<EncryptedVolume>(intent, "volume")!!)
|
|
|
|
explorerIntent.flags = Intent.FLAG_ACTIVITY_FORWARD_RESULT
|
|
|
|
}
|
|
|
|
if (explorerIntent == null) {
|
|
|
|
explorerIntent = Intent(context, ExplorerActivity::class.java) //default opening
|
|
|
|
}
|
2023-03-07 23:25:17 +01:00
|
|
|
explorerIntent.putExtra("volumeId", volumeId)
|
|
|
|
explorerIntent.putExtra("volumeName", volumeShortName)
|
2022-09-30 21:22:37 +02:00
|
|
|
return explorerIntent
|
|
|
|
}
|
|
|
|
}
|