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
The Tor Project
Applications
fenix
Commits
ac4efcfa
Commit
ac4efcfa
authored
Jul 26, 2020
by
Matthew Finkel
Browse files
Bug 34403: Disable Normal mode by default
parent
d0629988
Changes
14
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/mozilla/fenix/HomeActivity.kt
View file @
ac4efcfa
...
...
@@ -634,11 +634,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
}
}
/**
...
...
@@ -655,12 +661,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 @
ac4efcfa
...
...
@@ -827,7 +827,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 @
ac4efcfa
...
...
@@ -175,7 +175,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 @
ac4efcfa
...
...
@@ -28,6 +28,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
...
...
@@ -426,6 +427,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 @
ac4efcfa
...
...
@@ -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 @
ac4efcfa
...
...
@@ -182,6 +182,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 @
ac4efcfa
...
...
@@ -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
mozilla.components.support.ktx.android.util.dpToPx
import
org.mozilla.fenix.R
import
org.mozilla.fenix.components.metrics.Event
...
...
@@ -80,6 +82,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 @
ac4efcfa
...
...
@@ -155,7 +155,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
(
...
...
@@ -477,11 +477,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
)
{
...
...
@@ -823,7 +828,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 @
ac4efcfa
...
...
@@ -113,6 +113,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 @
ac4efcfa
...
...
@@ -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 @
ac4efcfa
<?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 @
ac4efcfa
...
...
@@ -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 @
ac4efcfa
...
...
@@ -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 @
ac4efcfa
...
...
@@ -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
Markdown
is supported
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