Skip to content

Commit

Permalink
Closes mozilla-mobile#804: Adds disable private browsing content desc…
Browse files Browse the repository at this point in the history
…ription
  • Loading branch information
sblatz committed Mar 5, 2019
1 parent fca5ed3 commit ba779c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 21 additions & 9 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,7 @@ class HomeFragment : Fragment() {
override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) { }
})

view.toolbar_wrapper.isPrivateModeEnabled = (activity as HomeActivity).browsingModeManager.isPrivate

privateBrowsingButton.setOnClickListener {
val browsingModeManager = (activity as HomeActivity).browsingModeManager
browsingModeManager.mode = when (browsingModeManager.mode) {
BrowsingModeManager.Mode.Normal -> BrowsingModeManager.Mode.Private
BrowsingModeManager.Mode.Private -> BrowsingModeManager.Mode.Normal
}
}
adaptToPrivateMode()
}

override fun onDestroyView() {
Expand Down Expand Up @@ -236,6 +228,26 @@ class HomeFragment : Fragment() {
}
}

private fun adaptToPrivateMode() {
view!!.toolbar_wrapper.isPrivateModeEnabled = (activity as HomeActivity).browsingModeManager.isPrivate

if ((activity as HomeActivity).browsingModeManager.isPrivate) {
privateBrowsingButton.contentDescription =
getString(R.string.content_description_disable_private_browsing_button)
} else {
privateBrowsingButton.contentDescription =
getString(R.string.content_description_private_browsing_button)
}

privateBrowsingButton.setOnClickListener {
val browsingModeManager = (activity as HomeActivity).browsingModeManager
browsingModeManager.mode = when (browsingModeManager.mode) {
BrowsingModeManager.Mode.Normal -> BrowsingModeManager.Mode.Private
BrowsingModeManager.Mode.Private -> BrowsingModeManager.Mode.Normal
}
}
}

private fun setupHomeMenu() {
homeMenu = HomeMenu(requireContext()) {
val directions = when (it) {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<string name="content_description_menu">More options</string>
<!-- Content description (not visible, for screen readers etc.): "Private Browsing" menu button. -->
<string name="content_description_private_browsing_button">Enable private browsing</string>
<!-- Content description (not visible, for screen readers etc.): "Private Browsing" menu button. -->
<string name="content_description_disable_private_browsing_button">Disable private browsing</string>
<!-- Explanation for how sessions work -->
<string name="sessions_intro_description">Sessions help you return to the sites you visit often and those you\'ve just discovered. Start browsing and they\'ll begin to appear here. </string>
<!-- Placeholder text shown in the search bar before a user enters text -->
Expand Down

0 comments on commit ba779c6

Please sign in to comment.