make sure we have write storage permission before doing anything at editor

This commit is contained in:
tibbi 2017-10-23 11:38:32 +02:00
parent 357286f1c9
commit 5d13b65b03

View file

@ -1,6 +1,8 @@
package com.simplemobiletools.filemanager.activities
import android.os.Bundle
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.filemanager.R
import com.simplemobiletools.filemanager.extensions.config
import kotlinx.android.synthetic.main.activity_read_text.*
@ -11,6 +13,17 @@ class ReadTextActivity : SimpleActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_read_text)
handlePermission(PERMISSION_WRITE_STORAGE) {
if (it) {
checkIntent()
} else {
toast(R.string.no_storage_permissions)
finish()
}
}
}
private fun checkIntent() {
read_text_view.setTextColor(config.textColor)
val uri = intent.data
if (uri.scheme == "file") {