1
0
Fork 0

Fixes #262: Need full screen functionality and "Entering full screen"

master
Colin Lee 2019-03-04 04:42:35 -06:00 committed by Jeff Boek
parent 68a2513809
commit f5c3e0e35e
2 changed files with 27 additions and 0 deletions

View File

@ -17,6 +17,8 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.component_search.*
import kotlinx.android.synthetic.main.fragment_browser.view.*
import mozilla.components.browser.toolbar.behavior.BrowserToolbarBottomBehavior
import mozilla.components.feature.contextmenu.ContextMenuCandidate
@ -24,11 +26,14 @@ import mozilla.components.feature.contextmenu.ContextMenuFeature
import mozilla.components.feature.customtabs.CustomTabsToolbarFeature
import mozilla.components.feature.downloads.DownloadsFeature
import mozilla.components.feature.prompts.PromptFeature
import mozilla.components.feature.session.FullScreenFeature
import mozilla.components.feature.session.SessionFeature
import mozilla.components.feature.session.SessionUseCases
import mozilla.components.feature.sitepermissions.SitePermissionsFeature
import mozilla.components.support.base.feature.BackHandler
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import mozilla.components.support.ktx.android.view.enterToImmersiveMode
import mozilla.components.support.ktx.android.view.exitImmersiveModeIfNeeded
import org.mozilla.fenix.BrowsingModeManager
import org.mozilla.fenix.DefaultThemeManager
import org.mozilla.fenix.HomeActivity
@ -56,6 +61,7 @@ class BrowserFragment : Fragment(), BackHandler {
private val customTabsToolbarFeature = ViewBoundFeatureWrapper<CustomTabsToolbarFeature>()
private val toolbarIntegration = ViewBoundFeatureWrapper<ToolbarIntegration>()
private val sitePermissionsFeature = ViewBoundFeatureWrapper<SitePermissionsFeature>()
private val fullScreenFeature = ViewBoundFeatureWrapper<FullScreenFeature>()
var sessionId: String? = null
override fun onCreateView(
@ -178,6 +184,26 @@ class BrowserFragment : Fragment(), BackHandler {
owner = this,
view = view
)
fullScreenFeature.set(
feature = FullScreenFeature(
sessionManager,
SessionUseCases(sessionManager),
sessionId
) {
if (it) {
Snackbar.make(view.rootView, getString(R.string.full_screen_notification), Snackbar.LENGTH_LONG)
.show()
activity?.enterToImmersiveMode()
toolbar.visibility = View.GONE
} else {
activity?.exitImmersiveModeIfNeeded()
toolbar.visibility = View.VISIBLE
}
},
owner = this,
view = view
)
}
override fun onResume() {

View File

@ -200,4 +200,5 @@ people before profit. Our mission: keep the Internet open and accessible to all.
<!-- Text for the button to clear selected history items. The first parameter
is the number of items you have selected -->
<string name="history_delete_some">Delete %1$d Items</string>
<string name="full_screen_notification">Entering full screen mode</string>
</resources>