mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
[fenix] Issue https://github.com/mozilla-mobile/fenix/issues/1340: Forward Activity results to the fragment
This commit is contained in:
parent
e4ff93f889
commit
fb997764ca
@ -52,6 +52,7 @@ import mozilla.components.feature.privatemode.notification.PrivateNotificationFe
|
||||
import mozilla.components.feature.search.BrowserStoreSearchAdapter
|
||||
import mozilla.components.feature.search.ext.legacy
|
||||
import mozilla.components.service.fxa.sync.SyncReason
|
||||
import mozilla.components.support.base.feature.ActivityResultHandler
|
||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||
import mozilla.components.support.ktx.android.arch.lifecycle.addObservers
|
||||
import mozilla.components.support.ktx.android.content.call
|
||||
@ -536,6 +537,15 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
final override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
supportFragmentManager.primaryNavigationFragment?.childFragmentManager?.fragments?.forEach {
|
||||
if (it is ActivityResultHandler && it.onActivityResult(requestCode, data, resultCode)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
|
||||
private fun shouldUseCustomBackLongPress(): Boolean {
|
||||
val isAndroidN =
|
||||
Build.VERSION.SDK_INT == Build.VERSION_CODES.N || Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1
|
||||
|
@ -128,6 +128,7 @@ import org.mozilla.fenix.wifi.SitePermissionsWifiIntegration
|
||||
import java.lang.ref.WeakReference
|
||||
import mozilla.components.feature.media.fullscreen.MediaFullscreenOrientationFeature
|
||||
import mozilla.components.feature.webauthn.WebAuthnFeature
|
||||
import mozilla.components.support.base.feature.ActivityResultHandler
|
||||
import org.mozilla.fenix.FeatureFlags.newMediaSessionApi
|
||||
|
||||
/**
|
||||
@ -137,7 +138,7 @@ import org.mozilla.fenix.FeatureFlags.newMediaSessionApi
|
||||
*/
|
||||
@ExperimentalCoroutinesApi
|
||||
@Suppress("TooManyFunctions", "LargeClass")
|
||||
abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
||||
abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, ActivityResultHandler,
|
||||
OnBackLongPressedListener, AccessibilityManager.AccessibilityStateChangeListener {
|
||||
|
||||
private lateinit var browserFragmentStore: BrowserFragmentStore
|
||||
@ -1037,10 +1038,10 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler,
|
||||
}
|
||||
|
||||
/**
|
||||
* Forwards activity results to the prompt feature.
|
||||
* Forwards activity results to the [ActivityResultHandler] features.
|
||||
*/
|
||||
final override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
listOf(
|
||||
override fun onActivityResult(requestCode: Int, data: Intent?, resultCode: Int): Boolean {
|
||||
return listOf(
|
||||
promptsFeature,
|
||||
webAuthnFeature
|
||||
).any { it.onActivityResult(requestCode, data, resultCode) }
|
||||
|
Loading…
Reference in New Issue
Block a user