diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b137f528..69741174 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.simplemobiletools.notes">
+
+
displayNewNoteDialog()
R.id.rename_note -> displayRenameDialog()
R.id.share -> shareText()
- R.id.open_file -> openFile()
+ R.id.open_file -> tryOpenFile()
R.id.save_as_file -> saveAsFile()
R.id.delete_note -> displayDeleteNotePrompt()
R.id.settings -> startActivity(Intent(applicationContext, SettingsActivity::class.java))
@@ -143,8 +146,18 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_STETHO or LICENSE_RTL, BuildConfig.VERSION_NAME)
}
- private fun openFile() {
+ private fun tryOpenFile() {
+ if (hasReadStoragePermission()) {
+ openFile()
+ } else {
+ ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), STORAGE_OPEN_FILE)
+ }
+ }
+ private fun openFile() {
+ FilePickerDialog(this) {
+
+ }
}
private fun saveAsFile() {
@@ -206,6 +219,16 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
}
}
+ override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+
+ if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ if (requestCode == STORAGE_OPEN_FILE) {
+ openFile()
+ }
+ }
+ }
+
override fun onPageScrollStateChanged(state: Int) {
}