Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alex Catarineu
fenix
Commits
b2b8b0a3
Commit
b2b8b0a3
authored
Jul 26, 2020
by
Matthew Finkel
Browse files
Bug 34403: Disable Normal mode by default
parent
a1b004b7
Changes
14
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/mozilla/fenix/HomeActivity.kt
View file @
b2b8b0a3
...
...
@@ -638,11 +638,17 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
internal
fun
getModeFromIntentOrLastKnown
(
intent
:
Intent
?):
BrowsingMode
{
intent
?.
toSafeIntent
()
?.
let
{
if
(
it
.
hasExtra
(
PRIVATE_BROWSING_MODE
))
{
val
startPrivateMode
=
it
.
getBooleanExtra
(
PRIVATE_BROWSING_MODE
,
false
)
val
startPrivateMode
=
settings
().
shouldDisableNormalMode
||
it
.
getBooleanExtra
(
PRIVATE_BROWSING_MODE
,
settings
().
openLinksInAPrivateTab
)
return
BrowsingMode
.
fromBoolean
(
isPrivate
=
startPrivateMode
)
}
}
return
settings
().
lastKnownMode
return
when
{
settings
().
shouldDisableNormalMode
->
BrowsingMode
.
Private
settings
().
openLinksInAPrivateTab
->
BrowsingMode
.
Private
else
->
settings
().
lastKnownMode
}
}
/**
...
...
@@ -659,12 +665,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
}
private
fun
checkPrivateShortcutEntryPoint
(
intent
:
Intent
)
{
if
(
intent
.
hasExtra
(
OPEN_TO_SEARCH
)
&&
(
intent
.
getStringExtra
(
OPEN_TO_SEARCH
)
==
val
shouldStartPrivate
=
settings
().
shouldDisableNormalMode
||
intent
.
getStringExtra
(
OPEN_TO_SEARCH
)
==
StartSearchIntentProcessor
.
STATIC_SHORTCUT_NEW_PRIVATE_TAB
||
intent
.
getStringExtra
(
OPEN_TO_SEARCH
)
==
StartSearchIntentProcessor
.
PRIVATE_BROWSING_PINNED_SHORTCUT
)
)
{
StartSearchIntentProcessor
.
PRIVATE_BROWSING_PINNED_SHORTCUT
if
(
intent
.
hasExtra
(
OPEN_TO_SEARCH
)
&&
shouldStartPrivate
)
{
PrivateNotificationService
.
isStartedFromPrivateShortcut
=
true
}
}
...
...
app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt
View file @
b2b8b0a3
...
...
@@ -842,7 +842,17 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
}
hideToolbar
()
getSessionById
()
?.
let
{
updateThemeForSession
(
it
)
}
getSessionById
()
?.
let
{
// If the most-recent session was a tab in Normal mode, and now Normal mode is disabled,
// then load the Private Mode home screen, instead.
if
(!
it
.
private
&&
requireContext
().
settings
().
shouldDisableNormalMode
)
{
findNavController
().
nav
(
R
.
id
.
browserFragment
,
BrowserFragmentDirections
.
actionGlobalHomeFragment
()
)
}
updateThemeForSession
(
it
)
}
}
@CallSuper
...
...
app/src/main/java/org/mozilla/fenix/components/toolbar/DefaultToolbarMenu.kt
View file @
b2b8b0a3
...
...
@@ -176,7 +176,8 @@ class DefaultToolbarMenu(
val
shouldShowSaveToCollection
=
(
context
.
asActivity
()
as
?
HomeActivity
)
?.
browsingModeManager
?.
mode
==
BrowsingMode
.
Normal
val
shouldDeleteDataOnQuit
=
context
.
components
.
settings
.
shouldDeleteBrowsingDataOnQuit
.
shouldDeleteBrowsingDataOnQuit
&&
!
context
.
components
.
settings
.
shouldDisableNormalMode
val
syncedTabsInTabsTray
=
context
.
components
.
settings
.
syncedTabsInTabsTray
...
...
app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
View file @
b2b8b0a3
...
...
@@ -29,6 +29,7 @@ import androidx.constraintlayout.widget.ConstraintSet.TOP
import
androidx.coordinatorlayout.widget.CoordinatorLayout
import
androidx.core.content.ContextCompat
import
androidx.core.view.doOnLayout
import
androidx.core.view.isGone
import
androidx.core.view.isVisible
import
androidx.core.view.updateLayoutParams
import
androidx.fragment.app.Fragment
...
...
@@ -428,6 +429,8 @@ class HomeFragment : Fragment() {
}
}
privateBrowsingButton
.
isGone
=
view
.
context
.
settings
().
shouldDisableNormalMode
// We call this onLayout so that the bottom bar width is correctly set for us to center
// the CFR in.
view
.
toolbar_wrapper
.
doOnLayout
{
...
...
app/src/main/java/org/mozilla/fenix/home/HomeMenu.kt
View file @
b2b8b0a3
...
...
@@ -161,9 +161,11 @@ class HomeMenu(
}
val
settings
=
context
.
components
.
settings
val
shouldDeleteBrowsingDataOnQuit
=
settings
.
shouldDeleteBrowsingDataOnQuit
&&
!
settings
.
shouldDisableNormalMode
val
menuItems
=
listOfNotNull
(
if
(
settings
.
shouldDeleteBrowsingDataOnQuit
)
quitItem
else
null
,
if
(
shouldDeleteBrowsingDataOnQuit
)
quitItem
else
null
,
settingsItem
,
BrowserMenuDivider
(),
if
(
settings
.
syncedTabsInTabsTray
)
null
else
syncedTabsItem
,
...
...
app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt
View file @
b2b8b0a3
...
...
@@ -183,6 +183,10 @@ class SettingsFragment : PreferenceFragmentCompat() {
requirePreference
<
Preference
>(
R
.
string
.
pref_key_close_tabs
)
tabSettingsPreference
.
summary
=
context
?.
settings
()
?.
getTabTimeoutString
()
// Hide "Delete browsing data on quit" when in Private Browsing-only mode
deleteBrowsingDataPreference
.
isVisible
=
!
deleteBrowsingDataPreference
.
context
.
settings
().
shouldDisableNormalMode
setupPreferences
()
if
(
shouldUpdateAccountUIState
)
{
...
...
app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt
View file @
b2b8b0a3
...
...
@@ -16,6 +16,7 @@ import androidx.cardview.widget.CardView
import
androidx.constraintlayout.widget.ConstraintLayout
import
androidx.constraintlayout.widget.ConstraintSet
import
androidx.core.content.ContextCompat
import
androidx.core.view.isGone
import
androidx.core.view.isVisible
import
androidx.core.view.updateLayoutParams
import
androidx.core.view.updatePadding
...
...
@@ -42,6 +43,7 @@ import mozilla.components.browser.state.state.BrowserState
import
mozilla.components.browser.tabstray.TabViewHolder
import
mozilla.components.feature.syncedtabs.SyncedTabsFeature
import
mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import
mozilla.components.support.base.log.logger.Logger
import
org.mozilla.fenix.R
import
org.mozilla.fenix.components.metrics.Event
import
org.mozilla.fenix.components.toolbar.TabCounter.Companion.INFINITE_CHAR_PADDING_BOTTOM
...
...
@@ -79,6 +81,8 @@ class TabTrayView(
private
val
isPrivateModeSelected
:
Boolean
get
()
=
view
.
tab_layout
.
selectedTabPosition
==
PRIVATE_TAB_ID
private
val
isNormalModeDisabled
=
container
.
context
.
settings
().
shouldDisableNormalMode
private
val
behavior
=
BottomSheetBehavior
.
from
(
view
.
tab_wrapper
)
private
val
concatAdapter
=
ConcatAdapter
(
tabsAdapter
)
...
...
@@ -94,6 +98,8 @@ class TabTrayView(
private
var
hasLoaded
=
false
private
val
logger
=
Logger
(
"TabTrayView"
)
override
val
containerView
:
View
?
get
()
=
container
...
...
@@ -102,6 +108,10 @@ class TabTrayView(
init
{
components
.
analytics
.
metrics
.
track
(
Event
.
TabsTrayOpened
)
if
(!
isPrivate
&&
isNormalModeDisabled
)
{
logger
.
debug
(
"TabTrayView: isNormalModeDisabled but not Private tabs"
)
}
toggleFabText
(
isPrivate
)
behavior
.
addBottomSheetCallback
(
object
:
BottomSheetBehavior
.
BottomSheetCallback
()
{
...
...
@@ -129,6 +139,15 @@ class TabTrayView(
PRIVATE_TAB_ID
}
// Find non-private mode tab and set visibility
view
.
tab_layout
.
getTabAt
(
DEFAULT_TAB_ID
)
?.
getCustomView
()
?.
apply
{
// The View we get from getCustomView() is only a sub-component
// of the actual tab (for example, the tab-count box). We need
// the "Custom View"'s parent for controlling the visibility
// of the entire tab.
(
getParent
()
as
?
View
)
?.
isGone
=
isNormalModeDisabled
}
view
.
tab_layout
.
getTabAt
(
selectedTabIndex
)
?.
also
{
view
.
tab_layout
.
selectTab
(
it
,
true
)
}
...
...
app/src/main/java/org/mozilla/fenix/utils/Settings.kt
View file @
b2b8b0a3
...
...
@@ -163,7 +163,7 @@ class Settings(private val appContext: Context) : PreferencesHolder {
var
openLinksInAPrivateTab
by
booleanPreference
(
appContext
.
getPreferenceKey
(
R
.
string
.
pref_key_open_links_in_a_private_tab
),
default
=
fals
e
default
=
tru
e
)
var
allowScreenshotsInPrivateMode
by
booleanPreference
(
...
...
@@ -489,11 +489,16 @@ class Settings(private val appContext: Context) : PreferencesHolder {
return
touchExplorationIsEnabled
||
switchServiceIsEnabled
}
var
lastKnownMode
:
BrowsingMode
=
BrowsingMode
.
Normal
val
shouldDisableNormalMode
by
booleanPreference
(
appContext
.
getPreferenceKey
(
R
.
string
.
pref_key_disable_normal_mode
),
true
)
var
lastKnownMode
:
BrowsingMode
=
BrowsingMode
.
Private
get
()
{
val
lastKnownModeWasPrivate
=
preferences
.
getBoolean
(
appContext
.
getPreferenceKey
(
R
.
string
.
pref_key_last_known_mode_private
),
fals
e
shouldDisableNormalMod
e
)
return
if
(
lastKnownModeWasPrivate
)
{
...
...
@@ -858,7 +863,8 @@ class Settings(private val appContext: Context) : PreferencesHolder {
numTimesPrivateModeOpened
.
value
==
CFR_COUNT_CONDITION_FOCUS_NOT_INSTALLED
}
if
(
showCondition
&&
!
showedPrivateModeContextualFeatureRecommender
)
{
if
(!
shouldDisableNormalMode
&&
showCondition
&&
!
showedPrivateModeContextualFeatureRecommender
)
{
showedPrivateModeContextualFeatureRecommender
=
true
return
true
}
...
...
app/src/main/res/navigation/nav_graph.xml
View file @
b2b8b0a3
...
...
@@ -117,6 +117,9 @@
<action
android:id=
"@+id/action_global_closeTabSettingsFragment"
app:destination=
"@id/closeTabsSettingsFragment"
/>
<action
android:id=
"@+id/action_global_homeFragment"
app:destination=
"@id/homeFragment"
/>
<dialog
android:id=
"@+id/tabTrayDialogFragment"
...
...
app/src/main/res/values/preference_keys.xml
View file @
b2b8b0a3
...
...
@@ -33,6 +33,7 @@
<string
name=
"pref_key_delete_caches_now"
translatable=
"false"
>
pref_key_delete_caches_now
</string>
<string
name=
"pref_key_delete_permissions_now"
translatable=
"false"
>
pref_key_delete_permissions_now
</string>
<string
name=
"pref_key_delete_browsing_data_on_quit_categories"
translatable=
"false"
>
pref_key_delete_browsing_data_on_quit_categories
</string>
<string
name=
"pref_key_disable_normal_mode"
translatable=
"false"
>
pref_key_disable_normal_mode
</string>
<string
name=
"pref_key_last_known_mode_private"
translatable=
"false"
>
pref_key_last_known_mode_private
</string>
<string
name=
"pref_key_addons"
translatable=
"false"
>
pref_key_addons
</string>
<string
name=
"pref_key_last_maintenance"
translatable=
"false"
>
pref_key_last_maintenance
</string>
...
...
app/src/main/res/values/torbrowser_strings.xml
0 → 100644
View file @
b2b8b0a3
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- 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/. -->
<resources>
<!-- Preference for enabling non-Private Browsing Mode-->
<string
name=
"preferences_disable_normal_mode"
>
Allow Only Private Browsing Mode
</string>
</resources>
app/src/main/res/xml/preferences.xml
View file @
b2b8b0a3
...
...
@@ -92,6 +92,7 @@
<androidx.preference.Preference
android:icon=
"@drawable/ic_private_browsing"
android:key=
"@string/pref_key_private_browsing"
app:isPreferenceVisible=
"false"
android:title=
"@string/preferences_private_browsing_options"
/>
<androidx.preference.Preference
...
...
app/src/main/res/xml/private_browsing_preferences.xml
View file @
b2b8b0a3
...
...
@@ -4,6 +4,7 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<PreferenceScreen
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<Preference
android:defaultValue=
"false"
android:key=
"@string/pref_key_add_private_browsing_shortcut"
android:title=
"@string/preferences_add_private_browsing_shortcut"
/>
<SwitchPreference
...
...
app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt
View file @
b2b8b0a3
...
...
@@ -44,13 +44,13 @@ class SettingsTest {
fun
launchLinksInPrivateTab
()
{
// When just created
// Then
assert
Fals
e
(
settings
.
openLinksInAPrivateTab
)
assert
Tru
e
(
settings
.
openLinksInAPrivateTab
)
// When
settings
.
openLinksInAPrivateTab
=
tru
e
settings
.
openLinksInAPrivateTab
=
fals
e
// Then
assert
Tru
e
(
settings
.
openLinksInAPrivateTab
)
assert
Fals
e
(
settings
.
openLinksInAPrivateTab
)
}
@Test
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment