Skip to content
Snippets Groups Projects
Commit 2c8ccf4f authored by Adrien Béraud's avatar Adrien Béraud
Browse files

file utils: show error if no app found to open file

Change-Id: I37e2bf534767521d562ea23c39de2264ff7a07f3
parent 457ecc6d
Branches
Tags
No related merge requests found
......@@ -35,6 +35,8 @@ import android.system.Os
import android.text.TextUtils
import android.util.Log
import android.webkit.MimeTypeMap
import android.widget.Toast
import cx.ring.R
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.schedulers.Schedulers
......@@ -544,14 +546,14 @@ object AndroidFileUtils {
fun openFile(c: Context, uri: Uri, displayName: String) {
try {
//startActivity(Intent.createChooser(sendIntent, null));
c.startActivity(Intent(Intent.ACTION_VIEW).apply {
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
setDataAndType(uri, c.contentResolver.getType(uri.buildUpon().appendPath(displayName).build()))
putExtra(Intent.EXTRA_STREAM, uri)
})
} catch (e: Exception) {
Log.e(TAG, "File of unknown type, could not open: $displayName")
Toast.makeText(c,
c.getString(R.string.error_open_no_app_found, displayName), Toast.LENGTH_SHORT).show()
}
}
......
......@@ -450,6 +450,6 @@ along with this program; if not, write to the Free Software
<string name="picker_btn">Select contacts</string>
<string name="bottomsheet_contact">Contact Jami\n%1$s</string>
<string name="bottomsheet_remove">Remove from the swarm</string>
<string name="error_open_no_app_found">No application found to handle this file: %1$s</string>
</resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment