Skip to content

Commit

Permalink
Rename openWith to tell that with filter out kDrive
Browse files Browse the repository at this point in the history
  • Loading branch information
tevincent committed Apr 8, 2024
1 parent 918cb04 commit 34729e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/infomaniak/drive/utils/PreviewUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import com.infomaniak.drive.data.models.File
import com.infomaniak.drive.ui.SaveExternalFilesActivity
import com.infomaniak.drive.ui.SaveExternalFilesActivityArgs
import com.infomaniak.drive.utils.Utils.openWith
import com.infomaniak.drive.utils.Utils.openWithIntent
import com.infomaniak.drive.utils.Utils.openWithIntentExceptkDrive
import com.infomaniak.lib.core.utils.lightNavigationBar

fun Activity.setupBottomSheetFileBehavior(
Expand Down Expand Up @@ -91,7 +91,7 @@ fun Context.openWith(

ownerFragment?.apply {
// Show only snackbar for fragment here because we need to do some check before displaying the snackbar for activities
if (requireContext().openWithIntent(currentFile!!).resolveActivity(requireContext().packageManager) == null) {
if (requireContext().openWithIntentExceptkDrive(currentFile!!).resolveActivity(requireContext().packageManager) == null) {
showSnackbar(R.string.errorNoSupportingAppFound, showAboveFab = true)
findNavController().popBackStack()
} else {
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/infomaniak/drive/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ object Utils {
}

fun Context.openWith(uri: Uri, type: String?, flags: Int) {
startActivityFor(openWithIntent(uri, type, flags))
startActivityFor(openWithIntentExceptkDrive(uri, type, flags))
}

fun Context.openWith(file: File, userDrive: UserDrive = UserDrive()) {
startActivityFor(openWithIntent(file, userDrive))
startActivityFor(openWithIntentExceptkDrive(file, userDrive))
}

private fun Context.startActivityFor(openWithIntent: Intent) {
Expand All @@ -255,15 +255,15 @@ object Utils {
}
}

fun Context.openWithIntent(file: File, userDrive: UserDrive = UserDrive()): Intent {
fun Context.openWithIntentExceptkDrive(file: File, userDrive: UserDrive = UserDrive()): Intent {
val (cloudUri, uri) = file.getCloudAndFileUris(this, userDrive)
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or
Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
return openWithIntent(uri, contentResolver.getType(cloudUri), flags)
return openWithIntentExceptkDrive(uri, contentResolver.getType(cloudUri), flags)
}

fun Context.openWithIntent(uri: Uri, type: String?, flags: Int): Intent {
fun Context.openWithIntentExceptkDrive(uri: Uri, type: String?, flags: Int): Intent {
val openWithIntent = Intent().apply {
action = Intent.ACTION_VIEW
this.flags = flags
Expand Down

0 comments on commit 34729e7

Please sign in to comment.