1
0
Fork 0

For #5972 - Fixes bugs when launching in private mode on Android 5 (#6702)

master
Jeff Boek 2019-11-26 14:53:03 -08:00 committed by GitHub
parent db02fc6ef8
commit 5f7b3bd4d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 88 deletions

View File

@ -131,62 +131,6 @@
android:resource="@mipmap/ic_launcher" /> android:resource="@mipmap/ic_launcher" />
</activity> </activity>
<!-- Launch in private mode alias -->
<activity-alias
android:name="org.mozilla.fenix.alias.IntentReceiverActivity"
android:label="@string/app_name_private_2"
android:icon="@mipmap/ic_launcher_private"
android:roundIcon="@mipmap/ic_launcher_private_round"
android:targetActivity=".IntentReceiverActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:mimeType="text/html" />
<data android:mimeType="text/plain" />
<data android:mimeType="application/xhtml+xml" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.ASSIST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<meta-data
android:name="com.android.systemui.action_assist_icon"
android:resource="@mipmap/ic_launcher_private" />
<meta-data
android:name="org.mozilla.fenix.LAUNCH_PRIVATE_LINK"
android:value="true" />
</activity-alias>
<activity android:name=".widget.VoiceSearchActivity" /> <activity android:name=".widget.VoiceSearchActivity" />
<activity <activity

View File

@ -6,7 +6,6 @@ package org.mozilla.fenix
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting
import kotlinx.coroutines.MainScope import kotlinx.coroutines.MainScope
@ -38,22 +37,7 @@ class IntentReceiverActivity : Activity() {
} }
suspend fun processIntent(intent: Intent) { suspend fun processIntent(intent: Intent) {
val didLaunchPrivateLink = packageManager if (!Browsers.all(this).isDefaultBrowser) {
?.getActivityInfo(componentName, PackageManager.GET_META_DATA)
?.metaData
?.getBoolean(LAUNCH_PRIVATE_LINK) ?: false
/* If LAUNCH_PRIVATE_LINK is set AND we're the default browser they must have pressed "always."
This is because LAUNCH_PRIVATE_LINK is only accessible through the "launch browser intent" menu
Which only appears if the user doesn't have a default set. */
if (didLaunchPrivateLink && Browsers.all(this).isDefaultBrowser) {
this.settings().openLinksInAPrivateTab = true
components.analytics.metrics.track(Event.PreferenceToggled(
preferenceKey = getString(R.string.pref_key_open_links_in_a_private_tab),
enabled = true,
context = applicationContext
))
} else if (!Browsers.all(this).isDefaultBrowser) {
/* If the user has unset us as the default browser, unset openLinksInAPrivateTab */ /* If the user has unset us as the default browser, unset openLinksInAPrivateTab */
this.settings().openLinksInAPrivateTab = false this.settings().openLinksInAPrivateTab = false
components.analytics.metrics.track(Event.PreferenceToggled( components.analytics.metrics.track(Event.PreferenceToggled(
@ -63,7 +47,7 @@ class IntentReceiverActivity : Activity() {
)) ))
} }
val tabIntentProcessor = if (settings().openLinksInAPrivateTab || didLaunchPrivateLink) { val tabIntentProcessor = if (settings().openLinksInAPrivateTab) {
components.analytics.metrics.track(Event.OpenedLink(Event.OpenedLink.Mode.PRIVATE)) components.analytics.metrics.track(Event.OpenedLink(Event.OpenedLink.Mode.PRIVATE))
components.intentProcessors.privateIntentProcessor components.intentProcessors.privateIntentProcessor
} else { } else {
@ -108,9 +92,4 @@ class IntentReceiverActivity : Activity() {
intent.putExtra(HomeActivity.OPEN_TO_BROWSER, openToBrowser) intent.putExtra(HomeActivity.OPEN_TO_BROWSER, openToBrowser)
} }
companion object {
// This constant must match the metadata from the private activity-alias
const val LAUNCH_PRIVATE_LINK = "org.mozilla.fenix.LAUNCH_PRIVATE_LINK"
}
} }

View File

@ -307,8 +307,9 @@ class HomeFragment : Fragment() {
super.onDestroyView() super.onDestroyView()
} }
override fun onResume() { override fun onStart() {
super.onResume() super.onStart()
subscribeToTabCollections()
getAutoDisposeObservable<SessionControlAction>() getAutoDisposeObservable<SessionControlAction>()
.subscribe { .subscribe {
@ -351,11 +352,6 @@ class HomeFragment : Fragment() {
!PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(context)) { !PrivateShortcutCreateManager.doesPrivateBrowsingPinnedShortcutExist(context)) {
recommendPrivateBrowsingShortcut() recommendPrivateBrowsingShortcut()
} }
}
override fun onStart() {
super.onStart()
subscribeToTabCollections()
// We only want this observer live just before we navigate away to the collection creation screen // We only want this observer live just before we navigate away to the collection creation screen
requireComponents.core.tabCollectionStorage.unregister(collectionStorageObserver) requireComponents.core.tabCollectionStorage.unregister(collectionStorageObserver)
@ -598,9 +594,9 @@ class HomeFragment : Fragment() {
} }
} }
override fun onPause() { override fun onStop() {
invokePendingDeleteJobs() invokePendingDeleteJobs()
super.onPause() super.onStop()
val homeViewModel: HomeScreenViewModel by activityViewModels { val homeViewModel: HomeScreenViewModel by activityViewModels {
ViewModelProvider.NewInstanceFactory() // this is a workaround for #4652 ViewModelProvider.NewInstanceFactory() // this is a workaround for #4652
} }