Skip to content

Commit 22f9db4

Browse files
committed
fix some glitches related to opening third party intents
1 parent 05ee03f commit 22f9db4

File tree

1 file changed

+18
-4
lines changed
  • app/src/main/kotlin/com/simplemobiletools/notes/pro/activities

1 file changed

+18
-4
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.simplemobiletools.commons.extensions.*
1717
import com.simplemobiletools.commons.helpers.LICENSE_RTL
1818
import com.simplemobiletools.commons.helpers.PERMISSION_READ_STORAGE
1919
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
20+
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
2021
import com.simplemobiletools.commons.models.FAQItem
2122
import com.simplemobiletools.commons.models.FileDirItem
2223
import com.simplemobiletools.commons.models.RadioItem
@@ -72,7 +73,13 @@ class MainActivity : SimpleActivity() {
7273
}
7374

7475
if (action == Intent.ACTION_VIEW) {
75-
handleUri(data)
76+
val realPath = intent.getStringExtra(REAL_FILE_PATH)
77+
if (realPath != null) {
78+
val file = File(realPath)
79+
handleUri(Uri.fromFile(file))
80+
} else {
81+
handleUri(data)
82+
}
7683
intent.removeCategory(Intent.CATEGORY_DEFAULT)
7784
intent.action = null
7885
}
@@ -291,9 +298,16 @@ class MainActivity : SimpleActivity() {
291298

292299
private fun updateSelectedNote(id: Long) {
293300
config.currentNoteId = id
294-
val index = getNoteIndexWithId(id)
295-
view_pager.currentItem = index
296-
mCurrentNote = mNotes[index]
301+
if (mNotes.isEmpty()) {
302+
NotesHelper(this).getNotes {
303+
mNotes = it
304+
updateSelectedNote(id)
305+
}
306+
} else {
307+
val index = getNoteIndexWithId(id)
308+
view_pager.currentItem = index
309+
mCurrentNote = mNotes[index]
310+
}
297311
}
298312

299313
private fun displayNewNoteDialog(value: String = "") {

0 commit comments

Comments
 (0)