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

Analyzer: Better error handling if content can't opened #1356

Merged
merged 1 commit into from
Aug 8, 2024
Merged
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
@@ -1,5 +1,6 @@
package eu.darken.sdmse.analyzer.ui.storage.content

import android.content.ActivityNotFoundException
import android.os.Bundle
import android.text.format.Formatter
import android.view.MenuItem
Expand All @@ -16,6 +17,7 @@ import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint
import eu.darken.sdmse.R
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.error.asErrorDialogBuilder
import eu.darken.sdmse.common.getQuantityString2
import eu.darken.sdmse.common.lists.differ.update
import eu.darken.sdmse.common.lists.installListSelection
Expand Down Expand Up @@ -140,6 +142,14 @@ class ContentFragment : Fragment3(R.layout.analyzer_content_fragment) {
),
Snackbar.LENGTH_LONG
).show()

is ContentItemEvents.OpenContent -> {
try {
startActivity(event.intent)
} catch (e: ActivityNotFoundException) {
e.asErrorDialogBuilder(requireActivity()).show()
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package eu.darken.sdmse.analyzer.ui.storage.content

import android.content.Intent
import eu.darken.sdmse.analyzer.core.content.ContentItem

sealed class ContentItemEvents {
data class ShowNoAccessHint(val item: ContentItem) : ContentItemEvents()
data class ExclusionsCreated(val count: Int) : ContentItemEvents()
data class ContentDeleted(val count: Int, val freedSpace: Long) : ContentItemEvents()
data class OpenContent(val intent: Intent) : ContentItemEvents()
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class ContentViewModel @Inject constructor(
}

log(TAG) { "open() launching chooser $chooserIntent" }
context.startActivity(chooserIntent)
events.postValue(ContentItemEvents.OpenContent(chooserIntent))
}

fun delete(items: Set<ContentItem>) = launch {
Expand Down
Loading