Skip to content

Commit

Permalink
Fixes mozilla-mobile#706: Adds launchMode singleInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Mar 4, 2019
1 parent 000a223 commit 5918739
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
android:usesCleartextTraffic="true"
tools:ignore="UnusedAttribute">
<activity android:name=".HomeActivity"
android:launchMode="singleInstance"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
16 changes: 13 additions & 3 deletions app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package org.mozilla.fenix

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.AttributeSet
import android.view.View
Expand Down Expand Up @@ -51,9 +52,12 @@ open class HomeActivity : AppCompatActivity() {
setSupportActionBar(navigationToolbar)
NavigationUI.setupWithNavController(navigationToolbar, hostNavController, appBarConfiguration)

if (intent?.extras?.getBoolean(OPEN_TO_BROWSER) == true) {
handleOpenedFromExternalSource()
}
handleOpenedFromExternalSourceIfNecessary()
}

override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
handleOpenedFromExternalSourceIfNecessary()
}

override fun onCreateView(
Expand Down Expand Up @@ -90,6 +94,12 @@ open class HomeActivity : AppCompatActivity() {
}
}

private fun handleOpenedFromExternalSourceIfNecessary() {
if (intent?.extras?.getBoolean(OPEN_TO_BROWSER) == true) {
handleOpenedFromExternalSource()
}
}

private fun handleOpenedFromExternalSource() {
intent?.putExtra(OPEN_TO_BROWSER, false)
openToBrowser(SafeIntent(intent).getStringExtra(IntentProcessor.ACTIVE_SESSION_ID))
Expand Down

0 comments on commit 5918739

Please sign in to comment.