From 7e77d07fd71bbc058a42b10a6ae461469b789233 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 8 Jan 2018 16:26:22 +0100 Subject: [PATCH] improve handling of system files on unrooted devices --- .../filemanager/activities/ReadTextActivity.kt | 13 ++++++++----- app/src/main/res/xml/provider_paths.xml | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/ReadTextActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/ReadTextActivity.kt index ff3fafff..4d644106 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/ReadTextActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/ReadTextActivity.kt @@ -3,10 +3,7 @@ package com.simplemobiletools.filemanager.activities import android.os.Bundle import android.view.Menu import android.view.MenuItem -import com.simplemobiletools.commons.extensions.getFileOutputStream -import com.simplemobiletools.commons.extensions.getRealPathFromURI -import com.simplemobiletools.commons.extensions.hideKeyboard -import com.simplemobiletools.commons.extensions.toast +import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.filemanager.R import com.simplemobiletools.filemanager.dialogs.SaveAsDialog @@ -77,7 +74,13 @@ class ReadTextActivity : SimpleActivity() { filePath = uri.path File(uri.path).readText() } else { - contentResolver.openInputStream(uri).bufferedReader().use { it.readText() } + try { + contentResolver.openInputStream(uri).bufferedReader().use { it.readText() } + } catch (e: Exception) { + showErrorToast(e) + finish() + return + } } read_text_view.setText(text) diff --git a/app/src/main/res/xml/provider_paths.xml b/app/src/main/res/xml/provider_paths.xml index ad4a8140..06493350 100644 --- a/app/src/main/res/xml/provider_paths.xml +++ b/app/src/main/res/xml/provider_paths.xml @@ -1,5 +1,5 @@ - +