1
0
Fork 0

Closes #8544: Activity should be reused when opening intents from other apps (#8547)

master
Roger Yang 2020-02-21 09:02:13 -05:00 committed by GitHub
parent da0148b8bd
commit 0630e2482f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 4 deletions

View File

@ -108,7 +108,14 @@
android:taskAffinity=""
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity android:name=".IntentReceiverActivity" android:theme="@style/Theme.Transparent">
<activity
android:name=".IntentReceiverActivity"
android:theme="@style/Theme.Transparent"
android:relinquishTaskIdentity="true"
android:taskAffinity=""
android:exported="true"
android:excludeFromRecents="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View File

@ -57,6 +57,15 @@ class IntentReceiverActivity : Activity() {
modeDependentProcessors +
NewTabShortcutIntentProcessor()
// Explicitly remove the new task and clear task flags (Our browser activity is a single
// task activity and we never want to start a second task here).
intent.flags = intent.flags and Intent.FLAG_ACTIVITY_NEW_TASK.inv()
intent.flags = intent.flags and Intent.FLAG_ACTIVITY_CLEAR_TASK.inv()
// IntentReceiverActivity is started with the "excludeFromRecents" flag (set in manifest). We
// do not want to propagate this flag from the intent receiver activity to the browser.
intent.flags = intent.flags and Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.inv()
// Call process for side effects, short on the first that returns true
intentProcessors.any { it.process(intent) }
@ -66,8 +75,8 @@ class IntentReceiverActivity : Activity() {
intent.setClassName(applicationContext, intentProcessorType.activityClassName)
intent.putExtra(HomeActivity.OPEN_TO_BROWSER, intentProcessorType.shouldOpenToBrowser(intent))
// finish() before starting another activity. Don't keep this on the activities back stack.
finish()
startActivity(intent)
// must finish() after starting the other activity
finish()
}
}

View File

@ -191,7 +191,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
},
openInFenixIntent = Intent(context, IntentReceiverActivity::class.java).apply {
action = Intent.ACTION_VIEW
flags = Intent.FLAG_ACTIVITY_NEW_TASK
},
bookmarkTapped = { lifecycleScope.launch { bookmarkTapped(it) } },
scope = lifecycleScope,