cap the filesize at 10MB

This commit is contained in:
tibbi
2017-03-07 19:58:20 +01:00
parent 4e845db003
commit 87a17a671a
10 changed files with 17 additions and 4 deletions

View File

@ -161,10 +161,14 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
private fun openFile() {
FilePickerDialog(this) {
val filename = it.getFilenameFromPath()
val content = File(it).readText()
val note = Note(0, filename, content, TYPE_NOTE)
addNewNote(note)
if (File(it).length() > 10) {
toast(R.string.file_too_large)
} else {
val filename = it.getFilenameFromPath()
val content = File(it).readText()
val note = Note(0, filename, content, TYPE_NOTE)
addNewNote(note)
}
}
}