Skip to content

Commit fc77566

Browse files
authored
(Very) explicitly bounce Event namespace to external browser. (#5845)
1 parent 2bc329b commit fc77566

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

app/src/main/java/org/wikipedia/page/PageFragment.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
2424
import androidx.core.animation.doOnEnd
2525
import androidx.core.app.ActivityCompat
2626
import androidx.core.app.ActivityOptionsCompat
27+
import androidx.core.net.toUri
2728
import androidx.core.view.forEach
2829
import androidx.core.widget.TextViewCompat
2930
import androidx.fragment.app.Fragment
@@ -415,6 +416,21 @@ class PageFragment : Fragment(), BackPressedHandler, CommunicationBridge.Communi
415416
bridge.onPcsReady()
416417
bridge.execute(JavaScriptActionHandler.mobileWebChromeShim(DimenUtil.roundedPxToDp(((requireActivity() as AppCompatActivity).supportActionBar?.height ?: 0).toFloat()),
417418
DimenUtil.roundedPxToDp(binding.pageActionsTabLayout.height.toFloat())))
419+
420+
// In the case of certain types of namespaces, especially pages with a lot of interactivity
421+
// that we can't control, we need to bounce them out explicitly to an external
422+
// browser, even after the page is fully loaded into our WebView. This is because
423+
// we can determine the namespace only after the loading sequence is in progress.
424+
if (model.page?.pageProperties?.namespace == Namespace.EVENT) {
425+
model.title?.let {
426+
UriUtil.visitInExternalBrowser(requireActivity(), it.uri.toUri())
427+
binding.root.post {
428+
if (isAdded) {
429+
requireActivity().onBackPressed()
430+
}
431+
}
432+
}
433+
}
418434
}
419435
}
420436
}

0 commit comments

Comments
 (0)