Skip to content
Snippets Groups Projects
Commit 2e5d5aed authored by Matthew Finkel's avatar Matthew Finkel
Browse files

fixup! Bug 40028: Implement new home screen

parent 091081a9
No related branches found
No related tags found
1 merge request!26Bug 40041 09
......@@ -27,6 +27,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
......@@ -42,6 +43,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.*
......@@ -270,6 +272,7 @@ class HomeFragment : Fragment() {
activity.themeManager.applyStatusBarTheme(activity)
adjustHomeFragmentView(currentMode.getCurrentMode(), view)
showSessionControlView(view)
return view
}
......@@ -341,16 +344,29 @@ class HomeFragment : Fragment() {
}
}
// This function should be paired with showSessionControlView()
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)
}
view?.sessionControlRecyclerView?.apply {
(getLayoutParams() as ViewGroup.MarginLayoutParams).setMargins(0, 0, 0, 0)
(layoutParams 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
......@@ -361,10 +377,26 @@ class HomeFragment : Fragment() {
setPadding(16, 16, 16, 16)
}
view?.sessionControlRecyclerView?.apply {
(getLayoutParams() as ViewGroup.MarginLayoutParams).setMargins(0, 0, 0, 120)
(layoutParams as ViewGroup.MarginLayoutParams).setMargins(0, 0, 0, 60)
}
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
}
}
}
// Hide the onion pattern during Onboarding, too.
view?.onion_pattern_image?.apply {
visibility = if (onboarding.userHasBeenOnboarded()) {
View.VISIBLE
} else {
View.GONE
}
}
view?.toolbarLayout?.apply {
visibility = View.VISIBLE
......@@ -372,6 +404,13 @@ class HomeFragment : Fragment() {
}
}
// 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)
......@@ -665,9 +704,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)
}
}
......@@ -781,6 +821,11 @@ class HomeFragment : Fragment() {
mode = currentMode.getCurrentMode()
)
)
adjustHomeFragmentView(
currentMode.getCurrentMode(),
view
)
showSessionControlView(view)
}
}
......
This diff is collapsed.
......@@ -62,14 +62,20 @@
android:id="@+id/app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
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:textColor="?primaryText"
android:textSize="14sp" />
android:fontFamily="Roboto-Medium"
android:textColor="#DEFFFFFF"
android:textSize="20sp"
android:lineSpacingMultiplier="1.2" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
......@@ -78,14 +84,18 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical"
android:width="199dp"
android:height="110dp"
android:clickable="false"
android:ellipsize="end"
android:focusable="false"
android:importantForAccessibility="no"
android:lines="2"
android:text="@string/tor_explore_privately"
android:textColor="?primaryText"
android:textSize="48sp" />
android:fontFamily="Roboto-Medium"
android:textColor="#DEFFFFFF"
android:textSize="40sp"
android:lineSpacingMultiplier="1.1"
app:layout_scrollFlags="scroll" />
</com.google.android.material.appbar.AppBarLayout>
......@@ -106,6 +116,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"
......
......@@ -31,6 +31,6 @@
<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.\nPrivately.</string>
<string name="tor_explore_privately">Explore. Privately.</string>
</resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment