diff --git a/build.gradle b/build.gradle index 4790727acb..3a1f67eef9 100644 --- a/build.gradle +++ b/build.gradle @@ -37,8 +37,8 @@ def getVersionCode = { -> allprojects { ext { androidApplicationId = 'org.cryptomator' - androidVersionCode = 3132 // must be getVersionCode(). only at release tag set the actual value - androidVersionName = '2.0.1' + androidVersionCode = getVersionCode() // must be getVersionCode(). only at release tag set the actual value + androidVersionName = '2.1.0-SNAPSHOT' } repositories { mavenCentral() diff --git a/presentation/src/main/java/org/cryptomator/presentation/presenter/BrowseFilesPresenter.kt b/presentation/src/main/java/org/cryptomator/presentation/presenter/BrowseFilesPresenter.kt index 913a931672..3d1f1b38ef 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/presenter/BrowseFilesPresenter.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/presenter/BrowseFilesPresenter.kt @@ -509,6 +509,11 @@ class BrowseFilesPresenter @Inject constructor( // private fun viewFile(cloudFile: CloudFileModel) { val lowerFileName = cloudFile.name.lowercase() if (lowerFileName.endsWith(".txt") || lowerFileName.endsWith(".md") || lowerFileName.endsWith(".todo")) { + if ((cloudFile.size ?: 0) > MAX_TEXT_EDITOR_FILE_SIZE) { + view?.showMessage(R.string.screen_file_browser_msg_text_file_too_large_for_editor) + viewExternalFile(cloudFile) + return + } val intent = Intents.textEditorIntent() .withTextFile(cloudFile) .withHubWriteAllowed(licenseEnforcer.hasWriteAccessForVault(view?.folder?.vault())) @@ -1273,6 +1278,10 @@ class BrowseFilesPresenter @Inject constructor( // const val OPEN_FILE_FINISHED = 12 + // The built-in text editor reads the whole file into a String and hands it to an EditText, + // so memory use scales with file size. Files above this size are opened with an external app instead. + private const val MAX_TEXT_EDITOR_FILE_SIZE = 2L shl 20 // 2 MiB + val EXPORT_AFTER_APP_CHOOSER: ExportOperation = object : ExportOperation { override fun export(presenter: BrowseFilesPresenter, downloadFiles: List) { presenter.copyFile(downloadFiles) diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index b5c41279c3..3bd2bcb079 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -174,6 +174,7 @@ Move Empty folder + File is too large for the built-in editor, opening with another app %1$s modified %1$s ago