Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workaround for resource/folder when ACTION_VIEW fails while pointing to downloads directory #604

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ class SearchVM : ViewModel(), KoinComponent {
fun launchBestMatchOrAction(context: Context) {
val bestMatch = bestMatch.value
if (bestMatch is SavableSearchable) {
bestMatch.launch(context, null)
favoritesService.reportLaunch(bestMatch)
if (bestMatch.launch(context, null))
favoritesService.reportLaunch(bestMatch)
return
} else if (bestMatch is SearchAction) {
}
if (bestMatch is SearchAction) {
bestMatch.start(context)
return
}
Expand Down
2 changes: 1 addition & 1 deletion core/ktx/src/main/java/de/mm20/launcher2/ktx/Context.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ fun Context.tryStartActivity(intent: Intent, bundle: Bundle? = null): Boolean {
} catch (e: SecurityException) {
false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.mm20.launcher2.files.providers

import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.graphics.BitmapFactory
Expand Down Expand Up @@ -186,7 +187,19 @@ internal data class LocalFile(
}

override fun launch(context: Context, options: Bundle?): Boolean {
return context.tryStartActivity(getLaunchIntent(context), options)
if (context.tryStartActivity(getLaunchIntent(context), options))
return true

// startsWith allows path to end with a slash
if (isDirectory && path.startsWith("/storage/emulated/0/Download")) {
val aospViewDownloadsIntent = Intent()
.setComponent(ComponentName("com.android.documentsui", "com.android.documentsui.ViewDownloadsActivity"))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION)

return context.tryStartActivity(aospViewDownloadsIntent, options)
}

return false
}

override val isDeletable: Boolean
Expand Down