2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

[fenix] Fixes https://github.com/mozilla-mobile/fenix/issues/5225 - Hide AuthCustomTabActivity

This commit is contained in:
Tiger Oakes 2019-09-26 10:15:12 -07:00
parent cecf51baab
commit d5c8f813d3
6 changed files with 61 additions and 26 deletions

View File

@ -75,14 +75,6 @@
android:taskAffinity=""
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity
android:name=".customtabs.AuthCustomTabActivity"
android:autoRemoveFromRecents="false"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize|locale|layoutDirection|smallestScreenSize|screenLayout"
android:exported="false"
android:taskAffinity=""
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity android:name=".IntentReceiverActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@ -185,6 +177,17 @@
android:enabled="${isRaptorEnabled}"
android:exported="${isRaptorEnabled}" />
<activity
android:name=".settings.account.AuthCustomTabActivity"
android:autoRemoveFromRecents="false"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize|locale|layoutDirection|smallestScreenSize|screenLayout"
android:exported="false"
android:taskAffinity=""
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity android:name=".settings.account.AuthIntentReceiverActivity"
android:exported="false" />
<activity android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"/>

View File

@ -13,8 +13,6 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import mozilla.components.feature.intent.processing.TabIntentProcessor
import mozilla.components.support.utils.Browsers
import org.mozilla.fenix.customtabs.AuthCustomTabActivity
import org.mozilla.fenix.customtabs.AuthCustomTabActivity.Companion.EXTRA_AUTH_CUSTOM_TAB
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
@ -77,13 +75,7 @@ class IntentReceiverActivity : Activity() {
private fun setIntentActivity(intent: Intent, tabIntentProcessor: TabIntentProcessor) {
val openToBrowser = when {
components.intentProcessors.externalAppIntentProcessors.any { it.matches(intent) } -> {
// TODO this needs to change: https://github.com/mozilla-mobile/fenix/issues/5225
val activityClass = if (intent.hasExtra(EXTRA_AUTH_CUSTOM_TAB)) {
AuthCustomTabActivity::class
} else {
ExternalAppBrowserActivity::class
}
intent.setClassName(applicationContext, activityClass.java.name)
intent.setClassName(applicationContext, ExternalAppBrowserActivity::class.java.name)
true
}
tabIntentProcessor.matches(intent) -> {

View File

@ -44,6 +44,10 @@ class IntentProcessors(
TabIntentProcessor(sessionManager, sessionUseCases.loadUrl, searchUseCases.newTabSearch, isPrivate = true)
}
val customTabIntentProcessor by lazy {
CustomTabIntentProcessor(sessionManager, sessionUseCases.loadUrl, context.resources)
}
val externalAppIntentProcessors by lazy {
listOf(
TrustedWebActivityIntentProcessor(
@ -55,7 +59,7 @@ class IntentProcessors(
store = customTabsStore
),
WebAppIntentProcessor(sessionManager, sessionUseCases.loadUrl, ManifestStorage(context)),
CustomTabIntentProcessor(sessionManager, sessionUseCases.loadUrl, context.resources)
customTabIntentProcessor
)
}
}

View File

@ -12,8 +12,8 @@ import mozilla.components.support.ktx.android.content.appVersionName
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.IntentReceiverActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.customtabs.AuthCustomTabActivity.Companion.EXTRA_AUTH_CUSTOM_TAB
import org.mozilla.fenix.ext.getColorFromAttr
import org.mozilla.fenix.settings.account.AuthIntentReceiverActivity
import java.io.UnsupportedEncodingException
import java.net.URLEncoder
import java.util.Locale
@ -68,11 +68,11 @@ object SupportUtils {
.build()
.intent
.setData(url.toUri())
.setClassName(context.applicationContext, IntentReceiverActivity::class.java.name)
.setClassName(context, IntentReceiverActivity::class.java.name)
.setPackage(context.packageName)
fun createAuthCustomTabIntent(context: Context, url: String): Intent =
createCustomTabIntent(context, url).putExtra(EXTRA_AUTH_CUSTOM_TAB, true)
createCustomTabIntent(context, url).setClassName(context, AuthIntentReceiverActivity::class.java.name)
private fun getEncodedTopicUTF8(topic: String): String {
try {

View File

@ -2,11 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.customtabs
package org.mozilla.fenix.settings.account
import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
import org.mozilla.fenix.ext.components
/**
@ -28,8 +29,4 @@ class AuthCustomTabActivity : ExternalAppBrowserActivity() {
val accountManager = components.backgroundServices.accountManager
accountManager.register(accountStateObserver, this, true)
}
companion object {
const val EXTRA_AUTH_CUSTOM_TAB = "support.customtabs.extra.AUTH"
}
}

View File

@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.settings.account
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import androidx.annotation.VisibleForTesting
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.ext.components
/**
* Processes incoming intents and sends them to the corresponding activity.
*/
class AuthIntentReceiverActivity : Activity() {
@VisibleForTesting
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
MainScope().launch {
// The intent property is nullable, but the rest of the code below
// assumes it is not. If it's null, then we make a new one and open
// the HomeActivity.
val intent = intent?.let { Intent(intent) } ?: Intent()
components.intentProcessors.customTabIntentProcessor.process(intent)
intent.setClassName(applicationContext, AuthCustomTabActivity::class.java.name)
intent.putExtra(HomeActivity.OPEN_TO_BROWSER, true)
startActivity(intent)
finish()
}
}
}