Skip to content
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 @@ -27,8 +27,6 @@ import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NO_HISTORY
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.net.Uri
import android.text.method.LinkMovementMethod
import android.util.TypedValue
Expand Down Expand Up @@ -222,24 +220,10 @@ private fun getExposedFileUri(context: Context, localPath: String): Uri? {

fun Activity.openFileWithIntent(intentForSavedMimeType: Intent, intentForGuessedMimeType: Intent?) {
val openFileWithIntent: Intent = intentForGuessedMimeType ?: intentForSavedMimeType
val launchables: List<ResolveInfo> =
this.packageManager.queryIntentActivities(openFileWithIntent, PackageManager.MATCH_DEFAULT_ONLY)
if (launchables.isNotEmpty()) {
try {
this.startActivity(
Intent.createChooser(
openFileWithIntent, this.getString(R.string.actionbar_open_with)
)
)
} catch (anfe: ActivityNotFoundException) {
Timber.i(anfe, "No app found for file type")
showMessageInSnackbar(
message = this.getString(
R.string.file_list_no_app_for_file_type
)
)
}
} else {
try {
startActivity(openFileWithIntent)
} catch (anfe: ActivityNotFoundException) {
Timber.i(anfe, "No app found for file type")
showMessageInSnackbar(
message = this.getString(
R.string.file_list_no_app_for_file_type
Expand Down Expand Up @@ -474,7 +458,7 @@ fun Activity.openOCFile(ocFile: OCFile) {
}

try {
startActivity(Intent.createChooser(intentForSavedMimeType, getString(R.string.actionbar_open_with)))
startActivity(intentForSavedMimeType)
} catch (anfe: ActivityNotFoundException) {
showErrorInSnackbar(genericErrorMessageId = R.string.file_list_no_app_for_file_type, anfe)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void openFile(OCFile ocFile) {

private void openFileWithIntent(Intent openFileWithIntent) {
try {
mFileActivity.startActivity(Intent.createChooser(openFileWithIntent, mFileActivity.getString(R.string.actionbar_open_with)));
mFileActivity.startActivity(openFileWithIntent);
} catch (ActivityNotFoundException anfe) {
mFileActivity.showSnackMessage(mFileActivity.getString(
R.string.file_list_no_app_for_file_type
Expand Down