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