do not allow opening videos and images

This commit is contained in:
tibbi 2017-03-08 19:44:21 +01:00
parent 0c8003105a
commit d29473aa47
2 changed files with 9 additions and 3 deletions

View File

@ -32,7 +32,7 @@ android {
}
dependencies {
compile 'com.simplemobiletools:commons:2.9.2'
compile 'com.simplemobiletools:commons:2.9.3'
compile 'com.facebook.stetho:stetho:1.4.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

View File

@ -164,14 +164,20 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
private fun openFile() {
FilePickerDialog(this) {
if (File(it).length() > 10 * 1000 * 1000) {
val file = File(it)
if (file.isImageVideoGif()) {
toast(R.string.invalid_file_format)
return@FilePickerDialog
}
if (file.length() > 10 * 1000 * 1000) {
toast(R.string.file_too_large)
} else {
val filename = it.getFilenameFromPath()
if (mDb.doesTitleExist(filename)) {
toast(R.string.title_taken)
} else {
val content = File(it).readText()
val content = file.readText()
val note = Note(0, filename, content, TYPE_NOTE)
addNewNote(note)
}