1
0
Fork 0

For #5733 - Private mode notification - wrong home screen (#6188)

- added PRIVATE MODE intent extra to the notification action
 (could use also the OPEN_FROM_NOTIFICATION, but I considered this one to
 be more explicit. Kept the old one in case other checks will be done
 filtering for it)
- added intent? param to the getPrivateModeFromIntent method, because
onNewIntent() method does not set the activities intent, and it was needed
to be used both in onCreate() and onNewIntent()
master
Mihai Branescu 2019-10-26 07:41:31 +03:00 committed by Tiger Oakes
parent 27cac54d53
commit 4efc661db8
2 changed files with 5 additions and 4 deletions

View File

@ -86,7 +86,7 @@ open class HomeActivity : AppCompatActivity() {
final override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val mode = getPrivateModeFromIntent()
val mode = getPrivateModeFromIntent(intent)
components.publicSuffixList.prefetch()
setupThemeAndBrowsingMode(mode)
@ -150,6 +150,7 @@ open class HomeActivity : AppCompatActivity() {
val intentProcessors = listOf(CrashReporterIntentProcessor()) + externalSourceIntentProcessors
intentProcessors.any { it.process(intent, navHost.navController, this.intent) }
browsingModeManager.mode = getPrivateModeFromIntent(intent)
}
/**
@ -192,7 +193,7 @@ open class HomeActivity : AppCompatActivity() {
* External sources such as 3rd party links and shortcuts use this function to enter
* private mode directly before the content view is created.
*/
private fun getPrivateModeFromIntent(): BrowsingMode {
private fun getPrivateModeFromIntent(intent: Intent?): BrowsingMode {
intent?.toSafeIntent()?.let {
if (it.hasExtra(PRIVATE_BROWSING_MODE)) {
val startPrivateMode = it.getBooleanExtra(PRIVATE_BROWSING_MODE, false)

View File

@ -18,9 +18,8 @@ import androidx.core.content.ContextCompat
import androidx.core.content.getSystemService
import mozilla.components.browser.session.SessionManager
import mozilla.components.support.utils.ThreadUtils
import org.mozilla.fenix.R
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.metrics
@ -104,6 +103,7 @@ class SessionNotificationService : Service() {
private fun createOpenActionIntent(): PendingIntent {
val intent = Intent(this, HomeActivity::class.java)
intent.putExtra(HomeActivity.EXTRA_OPENED_FROM_NOTIFICATION, true)
intent.putExtra(HomeActivity.PRIVATE_BROWSING_MODE, true)
return PendingIntent.getActivity(this, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}