Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthew Finkel
fenix
Commits
45924165
Commit
45924165
authored
Sep 10, 2020
by
Matthew Finkel
Browse files
Bug 40028: Implement new home screen
parent
cf3e1c5b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
View file @
45924165
...
...
@@ -28,6 +28,7 @@ import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import
androidx.constraintlayout.widget.ConstraintSet.TOP
import
androidx.coordinatorlayout.widget.CoordinatorLayout
import
androidx.core.content.ContextCompat
import
androidx.core.view.children
import
androidx.core.view.doOnLayout
import
androidx.core.view.isGone
import
androidx.core.view.isVisible
...
...
@@ -43,6 +44,7 @@ import androidx.navigation.fragment.navArgs
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE
import
com.google.android.material.appbar.AppBarLayout
import
com.google.android.material.snackbar.Snackbar
import
kotlinx.android.synthetic.main.fragment_home.*
import
kotlinx.android.synthetic.main.fragment_home.view.*
...
...
@@ -191,6 +193,15 @@ class HomeFragment : Fragment() {
val
activity
=
activity
as
HomeActivity
val
components
=
requireComponents
// Splits by full stops or commas and puts the parts in different lines.
// Ignoring separators at the end of the string, it is expected
// that there are at most two parts (e.g. "Explore. Privately.").
view
.
exploreprivately
.
text
=
view
.
exploreprivately
.
text
?.
replace
(
" *([.,。।]) *"
.
toRegex
(),
"$1\n"
)
?.
trim
()
currentMode
=
CurrentMode
(
view
.
context
,
onboarding
,
...
...
@@ -271,6 +282,7 @@ class HomeFragment : Fragment() {
activity
.
themeManager
.
applyStatusBarTheme
(
activity
)
adjustHomeFragmentView
(
currentMode
.
getCurrentMode
(),
view
)
showSessionControlView
(
view
)
return
view
}
...
...
@@ -343,14 +355,29 @@ class HomeFragment : Fragment() {
}
}
// This function should be paired with showSessionControlView()
@SuppressWarnings
(
"ComplexMethod"
,
"NestedBlockDepth"
,
"LongMethod"
)
private
fun
adjustHomeFragmentView
(
mode
:
Mode
,
view
:
View
?)
{
view
?.
sessionControlRecyclerView
?.
apply
{
visibility
=
View
.
INVISIBLE
}
if
(
mode
==
Mode
.
Bootstrap
)
{
view
?.
sessionControlRecyclerView
?.
apply
{
setPadding
(
0
,
0
,
0
,
0
)
(
getL
ayoutParams
()
as
ViewGroup
.
MarginLayoutParams
).
setMargins
(
0
,
0
,
0
,
0
)
(
l
ayoutParams
as
ViewGroup
.
MarginLayoutParams
).
setMargins
(
0
,
0
,
0
,
0
)
}
view
?.
homeAppBar
?.
apply
{
visibility
=
View
.
GONE
// Reset this as SCROLL in case it was previously set as NO_SCROLL after bootstrap
children
.
forEach
{
(
it
.
layoutParams
as
AppBarLayout
.
LayoutParams
).
scrollFlags
=
AppBarLayout
.
LayoutParams
.
SCROLL_FLAG_SCROLL
}
}
view
?.
onion_pattern_image
?.
apply
{
visibility
=
View
.
GONE
}
view
?.
toolbarLayout
?.
apply
{
visibility
=
View
.
GONE
...
...
@@ -365,22 +392,71 @@ class HomeFragment : Fragment() {
SESSION_CONTROL_VIEW_PADDING
)
// Default margin until it is re-set below (either set immediately or after Layout)
(
getL
ayoutParams
()
as
ViewGroup
.
MarginLayoutParams
).
setMargins
(
(
l
ayoutParams
as
ViewGroup
.
MarginLayoutParams
).
setMargins
(
0
,
0
,
0
,
DEFAULT_ONBOARDING_FINISH_MARGIN
)
}
view
?.
homeAppBar
?.
apply
{
view
?.
toolbarLayout
?.
apply
{
visibility
=
View
.
VISIBLE
// If the Layout rendering pass was completed, then we have a |height| value,
// if it wasn't completed then we have 0.
if
(
height
==
0
)
{
// Set the bottom margin after the toolbar height is defined during Layout
doOnLayout
{
val
toolbarLayoutHeight
=
view
.
toolbarLayout
.
height
view
.
sessionControlRecyclerView
?.
apply
{
(
layoutParams
as
ViewGroup
.
MarginLayoutParams
).
setMargins
(
0
,
0
,
0
,
toolbarLayoutHeight
-
SESSION_CONTROL_VIEW_PADDING
)
}
}
}
else
{
view
.
sessionControlRecyclerView
?.
apply
{
(
layoutParams
as
ViewGroup
.
MarginLayoutParams
).
setMargins
(
0
,
0
,
0
,
height
-
SESSION_CONTROL_VIEW_PADDING
)
}
}
}
view
?.
toolbarLayout
?.
apply
{
// Hide the onion pattern during Onboarding, too.
view
?.
onion_pattern_image
?.
apply
{
visibility
=
if
(
onboarding
.
userHasBeenOnboarded
())
{
View
.
VISIBLE
}
else
{
View
.
GONE
}
}
view
?.
homeAppBar
?.
apply
{
visibility
=
View
.
VISIBLE
children
.
forEach
{
(
it
.
layoutParams
as
AppBarLayout
.
LayoutParams
).
scrollFlags
=
if
(
onboarding
.
userHasBeenOnboarded
())
{
AppBarLayout
.
LayoutParams
.
SCROLL_FLAG_NO_SCROLL
}
else
{
AppBarLayout
.
LayoutParams
.
SCROLL_FLAG_SCROLL
}
}
}
}
}
// This function should be paired with adjustHomeFragmentView()
private
fun
showSessionControlView
(
view
:
View
?)
{
view
?.
sessionControlRecyclerView
?.
apply
{
visibility
=
View
.
VISIBLE
}
}
@Suppress
(
"LongMethod"
,
"ComplexMethod"
)
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
...
...
@@ -675,9 +751,10 @@ class HomeFragment : Fragment() {
homeFragmentStore
.
dispatch
(
HomeFragmentAction
.
ModeChange
(
mode
))
val
localView
=
view
adjustHomeFragmentView
(
mode
,
view
)
if
(
localView
!=
null
)
{
adjustHomeFragmentView
(
mode
,
localView
)
updateSessionControlView
(
localView
)
showSessionControlView
(
localView
)
}
}
...
...
@@ -790,6 +867,11 @@ class HomeFragment : Fragment() {
mode
=
currentMode
.
getCurrentMode
()
)
)
adjustHomeFragmentView
(
currentMode
.
getCurrentMode
(),
view
)
showSessionControlView
(
view
)
}
}
...
...
app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/PrivateBrowsingDescriptionViewHolder.kt
View file @
45924165
...
...
@@ -4,12 +4,10 @@
package
org.mozilla.fenix.home.sessioncontrol.viewholders
import
android.text.method.LinkMovementMethod
import
android.view.View
import
androidx.recyclerview.widget.RecyclerView
import
kotlinx.android.synthetic.main.private_browsing_description.view.*
import
org.mozilla.fenix.R
import
org.mozilla.fenix.ext.addUnderline
import
org.mozilla.fenix.home.sessioncontrol.TabSessionInteractor
class
PrivateBrowsingDescriptionViewHolder
(
...
...
@@ -18,18 +16,18 @@ class PrivateBrowsingDescriptionViewHolder(
)
:
RecyclerView
.
ViewHolder
(
view
)
{
init
{
val
resources
=
view
.
resources
val
appName
=
resources
.
getString
(
R
.
string
.
app_name
)
view
.
private_session_description
.
text
=
resources
.
getString
(
R
.
string
.
private_browsing_placeholder_description_2
,
appName
)
with
(
view
.
private_session_common_myths
)
{
movementMethod
=
LinkMovementMethod
.
getInstance
()
addUnderline
()
setOnClickListener
{
interactor
.
onPrivateBrowsingLearnMoreClicked
()
}
}
//
val resources = view.resources
//
val appName = resources.getString(R.string.app_name)
//
view.private_session_description.text = resources.getString(
//
R.string.private_browsing_placeholder_description_2, appName
//
)
//
with(view.private_session_common_myths) {
//
movementMethod = LinkMovementMethod.getInstance()
//
addUnderline()
//
setOnClickListener {
//
interactor.onPrivateBrowsingLearnMoreClicked()
//
}
//
}
}
companion
object
{
...
...
app/src/main/res/drawable/ic_onion_pattern.xml
0 → 100644
View file @
45924165
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/fragment_home.xml
View file @
45924165
...
...
@@ -54,12 +54,48 @@
android:contentDescription=
"@string/app_name"
android:focusable=
"false"
android:importantForAccessibility=
"no"
app:srcCompat=
"
?fenixLogo
"
app:srcCompat=
"
@mipmap/ic_launcher
"
app:layout_collapseMode=
"parallax"
app:layout_collapseParallaxMultiplier=
".1"
/>
<TextView
android:id=
"@+id/app_name"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"80dp"
android:layout_marginTop=
"9dp"
android:gravity=
"center_vertical"
android:width=
"130dp"
android:height=
"60dp"
android:clickable=
"false"
android:focusable=
"false"
android:importantForAccessibility=
"no"
android:lines=
"2"
android:text=
"@string/app_name"
android:fontFamily=
"Roboto-Medium"
android:textColor=
"#DEFFFFFF"
android:textSize=
"20sp"
android:lineSpacingMultiplier=
"1.2"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<TextView
android:id=
"@+id/exploreprivately"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center|center_vertical"
android:gravity=
"center_horizontal"
android:clickable=
"false"
android:ellipsize=
"end"
android:focusable=
"false"
android:importantForAccessibility=
"no"
android:text=
"@string/tor_explore_privately"
android:fontFamily=
"Roboto-Medium"
android:textColor=
"#DEFFFFFF"
android:textSize=
"40sp"
android:lineSpacingMultiplier=
"1.1"
app:layout_scrollFlags=
"scroll"
/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
...
...
@@ -79,6 +115,17 @@
tools:itemCount=
"3"
app:layout_behavior=
"com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
/>
<ImageView
android:id=
"@+id/onion_pattern_image"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
app:srcCompat=
"@drawable/ic_onion_pattern"
tools:ignore=
"ContentDescription"
app:layout_constraintBottom_toTopOf=
"@id/toolbarLayout"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/toolbarLayout"
android:elevation=
"5dp"
...
...
app/src/main/res/layout/private_browsing_description.xml
View file @
45924165
...
...
@@ -24,7 +24,7 @@
android:textColor=
"?primaryText"
android:textDirection=
"locale"
android:textSize=
"14sp"
tools:text=
"
@string/private_browsing_placeholder_description_2
"
/>
tools:text=
""
/>
<org.mozilla.fenix.utils.LinkTextView
android:id=
"@+id/private_session_common_myths"
...
...
@@ -37,7 +37,7 @@
android:paddingTop=
"10dp"
android:paddingBottom=
"19dp"
android:scrollHorizontally=
"false"
android:text=
"
@string/private_browsing_common_myths
"
android:text=
""
android:textColor=
"?primaryText"
android:textSize=
"14sp"
/>
</LinearLayout>
app/src/main/res/values/torbrowser_strings.xml
View file @
45924165
...
...
@@ -25,7 +25,7 @@
<string
name=
"tor_onboarding_donate_description"
>
Tor is free to use because of donations from people like you.
</string>
<string
name=
"tor_onboarding_donate_button"
>
Donate Now
</string>
<string
name=
"tor_explore_privately"
>
Explore.
\n
Privately.
</string>
<string
name=
"tor_explore_privately"
>
Explore.
Privately.
</string>
<!-- Description of security levels -->
<string
name=
"tor_security_level_standard_option"
>
Standard
</string>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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