Skip to content

Commit b314acf

Browse files
committed
fix #241, check all third party intents at onNewIntent too
1 parent 13dd616 commit b314acf

File tree

1 file changed

+25
-21
lines changed
  • app/src/main/kotlin/com/simplemobiletools/notes/pro/activities

1 file changed

+25
-21
lines changed

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

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,7 @@ class MainActivity : SimpleActivity() {
6060
pager_title_strip.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
6161
pager_title_strip.layoutParams.height = (pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2).toInt()
6262
checkWhatsNewDialog()
63-
64-
intent.apply {
65-
if (action == Intent.ACTION_SEND && type == MIME_TEXT_PLAIN) {
66-
getStringExtra(Intent.EXTRA_TEXT)?.let {
67-
handleTextIntent(it)
68-
intent.removeExtra(Intent.EXTRA_TEXT)
69-
}
70-
}
71-
72-
if (action == Intent.ACTION_VIEW) {
73-
val realPath = intent.getStringExtra(REAL_FILE_PATH)
74-
if (realPath != null) {
75-
val file = File(realPath)
76-
handleUri(Uri.fromFile(file))
77-
} else {
78-
handleUri(data)
79-
}
80-
intent.removeCategory(Intent.CATEGORY_DEFAULT)
81-
intent.action = null
82-
}
83-
}
63+
checkIntents(intent)
8464

8565
storeStateVariables()
8666
if (config.showNotePicker && savedInstanceState == null) {
@@ -207,6 +187,30 @@ class MainActivity : SimpleActivity() {
207187
super.onNewIntent(intent)
208188
val wantedNoteId = intent.getLongExtra(OPEN_NOTE_ID, -1L)
209189
view_pager.currentItem = getWantedNoteIndex(wantedNoteId)
190+
checkIntents(intent)
191+
}
192+
193+
private fun checkIntents(intent: Intent) {
194+
intent.apply {
195+
if (action == Intent.ACTION_SEND && type == MIME_TEXT_PLAIN) {
196+
getStringExtra(Intent.EXTRA_TEXT)?.let {
197+
handleTextIntent(it)
198+
intent.removeExtra(Intent.EXTRA_TEXT)
199+
}
200+
}
201+
202+
if (action == Intent.ACTION_VIEW) {
203+
val realPath = intent.getStringExtra(REAL_FILE_PATH)
204+
if (realPath != null) {
205+
val file = File(realPath)
206+
handleUri(Uri.fromFile(file))
207+
} else {
208+
handleUri(data)
209+
}
210+
intent.removeCategory(Intent.CATEGORY_DEFAULT)
211+
intent.action = null
212+
}
213+
}
210214
}
211215

212216
private fun storeStateVariables() {

0 commit comments

Comments
 (0)