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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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<DownloadFile>) {
presenter.copyFile(downloadFiles)
Expand Down
1 change: 1 addition & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<string name="screen_file_browser_move_button_text">Move</string>

<string name="screen_file_browser_msg_empty_folder">Empty folder</string>
<string name="screen_file_browser_msg_text_file_too_large_for_editor">File is too large for the built-in editor, opening with another app</string>
<string name="screen_file_browser_file_info_label_size" translatable="false">%1$s</string>
<string name="screen_file_browser_file_info_label_date">modified %1$s ago</string>

Expand Down