Loading app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +87 −5 Changes for app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt: 87 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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.* Loading Loading @@ -190,6 +192,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, Loading Loading @@ -270,6 +281,7 @@ class HomeFragment : Fragment() { activity.themeManager.applyStatusBarTheme(activity) adjustHomeFragmentView(currentMode.getCurrentMode(), view) showSessionControlView(view) return view } Loading Loading @@ -342,14 +354,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) (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 Loading @@ -364,22 +391,71 @@ class HomeFragment : Fragment() { SESSION_CONTROL_VIEW_PADDING ) // Default margin until it is re-set below (either set immediately or after Layout) (getLayoutParams() as ViewGroup.MarginLayoutParams).setMargins( (layoutParams 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 ) } view?.toolbarLayout?.apply { } } else { view.sessionControlRecyclerView?.apply { (layoutParams as ViewGroup.MarginLayoutParams).setMargins( 0, 0, 0, height - SESSION_CONTROL_VIEW_PADDING ) } } } // 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) Loading Loading @@ -659,9 +735,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) } } Loading Loading @@ -775,6 +852,11 @@ class HomeFragment : Fragment() { mode = currentMode.getCurrentMode() ) ) adjustHomeFragmentView( currentMode.getCurrentMode(), view ) showSessionControlView(view) } } Loading app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/PrivateBrowsingDescriptionViewHolder.kt +12 −14 Changes for app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/PrivateBrowsingDescriptionViewHolder.kt: 12 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -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( Loading @@ -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 { Loading app/src/main/res/drawable/ic_onion_pattern.xml 0 → 100644 +806 −0 File added.Preview size limit exceeded, changes collapsed. Show changes app/src/main/res/layout/fragment_home.xml +48 −1 Changes for app/src/main/res/layout/fragment_home.xml: 48 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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" Loading app/src/main/res/layout/private_browsing_description.xml +2 −2 Changes for app/src/main/res/layout/private_browsing_description.xml: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -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" Loading @@ -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> Loading
app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +87 −5 Changes for app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt: 87 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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.* Loading Loading @@ -190,6 +192,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, Loading Loading @@ -270,6 +281,7 @@ class HomeFragment : Fragment() { activity.themeManager.applyStatusBarTheme(activity) adjustHomeFragmentView(currentMode.getCurrentMode(), view) showSessionControlView(view) return view } Loading Loading @@ -342,14 +354,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) (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 Loading @@ -364,22 +391,71 @@ class HomeFragment : Fragment() { SESSION_CONTROL_VIEW_PADDING ) // Default margin until it is re-set below (either set immediately or after Layout) (getLayoutParams() as ViewGroup.MarginLayoutParams).setMargins( (layoutParams 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 ) } view?.toolbarLayout?.apply { } } else { view.sessionControlRecyclerView?.apply { (layoutParams as ViewGroup.MarginLayoutParams).setMargins( 0, 0, 0, height - SESSION_CONTROL_VIEW_PADDING ) } } } // 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) Loading Loading @@ -659,9 +735,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) } } Loading Loading @@ -775,6 +852,11 @@ class HomeFragment : Fragment() { mode = currentMode.getCurrentMode() ) ) adjustHomeFragmentView( currentMode.getCurrentMode(), view ) showSessionControlView(view) } } Loading
app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/PrivateBrowsingDescriptionViewHolder.kt +12 −14 Changes for app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/PrivateBrowsingDescriptionViewHolder.kt: 12 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -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( Loading @@ -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 { Loading
app/src/main/res/drawable/ic_onion_pattern.xml 0 → 100644 +806 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
app/src/main/res/layout/fragment_home.xml +48 −1 Changes for app/src/main/res/layout/fragment_home.xml: 48 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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" Loading
app/src/main/res/layout/private_browsing_description.xml +2 −2 Changes for app/src/main/res/layout/private_browsing_description.xml: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -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" Loading @@ -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>