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 2 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 @@ -89,10 +89,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
14 changes: 14 additions & 0 deletions core/ktx/src/main/java/de/mm20/launcher2/ktx/Context.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.mm20.launcher2.ktx

import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
Expand All @@ -24,6 +25,19 @@ fun Context.tryStartActivity(intent: Intent, bundle: Bundle? = null): Boolean {
startActivity(intent, bundle)
true
} catch (e: ActivityNotFoundException) {

if (intent.data?.path == "/storage/emulated/0/Download") {
val aospDocsViewDownloadsIntent = Intent()
.setComponent(ComponentName("com.android.documentsui", "com.android.documentsui.ViewDownloadsActivity"))

return try {
startActivity(aospDocsViewDownloadsIntent, bundle)
true
} catch (_: Exception) {
false
}
}

shtrophic marked this conversation as resolved.
Show resolved Hide resolved
false
} catch (e: SecurityException) {
false
Expand Down