Skip to content

Commit 1cd0e9e

Browse files
committed
Refactor layout
Replace Recyclerview with xml layout
1 parent 9292f9d commit 1cd0e9e

4 files changed

Lines changed: 113 additions & 130 deletions

File tree

WordPress/src/main/java/org/wordpress/android/ui/mysite/jetpackbadge/JetpackPoweredBottomSheetFragment.kt

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import android.view.View
77
import android.view.ViewGroup
88
import android.widget.FrameLayout
99
import androidx.fragment.app.viewModels
10-
import androidx.recyclerview.widget.LinearLayoutManager
1110
import com.google.android.material.bottomsheet.BottomSheetBehavior
1211
import com.google.android.material.bottomsheet.BottomSheetDialog
1312
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
@@ -22,13 +21,11 @@ import org.wordpress.android.ui.main.WPMainNavigationView.PageType.NOTIFS
2221
import org.wordpress.android.ui.main.WPMainNavigationView.PageType.READER
2322
import org.wordpress.android.ui.mysite.jetpackbadge.JetpackPoweredDialogAction.DismissDialog
2423
import org.wordpress.android.ui.mysite.jetpackbadge.JetpackPoweredDialogAction.OpenPlayStore
25-
import org.wordpress.android.util.extensions.disableAnimation
2624
import org.wordpress.android.util.extensions.exhaustive
2725
import javax.inject.Inject
2826

2927
@AndroidEntryPoint
3028
class JetpackPoweredBottomSheetFragment : BottomSheetDialogFragment() {
31-
@Inject lateinit var adapter: JetpackPoweredAdapter
3229
@Inject lateinit var activityLauncherWrapper: ActivityLauncherWrapper
3330
private val viewModel: JetpackPoweredDialogViewModel by viewModels()
3431

@@ -50,23 +47,19 @@ class JetpackPoweredBottomSheetFragment : BottomSheetDialogFragment() {
5047
}
5148

5249
private fun JetpackPoweredBottomSheetBinding.initializeViews() {
53-
contentRecyclerView.layoutManager = LinearLayoutManager(requireActivity())
54-
contentRecyclerView.adapter = adapter
55-
contentRecyclerView.disableAnimation()
56-
5750
primaryButton.setOnClickListener { viewModel.openJetpackAppDownloadLink() }
5851

5952
val fullScreen = arguments?.getBoolean(KEY_FULL_SCREEN, false) ?: false
6053

6154
if (fullScreen) {
62-
secondaryButton.visibility = View.VISIBLE
55+
// secondaryButton.visibility = View.VISIBLE
6356
val pageType = arguments?.getSerializable(KEY_SITE_SCREEN) as? PageType ?: MY_SITE
64-
secondaryButton.text = when (pageType) {
65-
MY_SITE -> getString(R.string.wp_jetpack_continue_to_stats)
66-
READER -> getString(R.string.wp_jetpack_continue_to_reader)
67-
NOTIFS -> getString(R.string.wp_jetpack_continue_to_notifications)
68-
}
69-
secondaryButton.setOnClickListener { viewModel.dismissBottomSheet() }
57+
// secondaryButton.text = when (pageType) {
58+
// MY_SITE -> getString(R.string.wp_jetpack_continue_to_stats)
59+
// READER -> getString(R.string.wp_jetpack_continue_to_reader)
60+
// NOTIFS -> getString(R.string.wp_jetpack_continue_to_notifications)
61+
// }
62+
// secondaryButton.setOnClickListener { viewModel.dismissBottomSheet() }
7063
}
7164

7265
(dialog as? BottomSheetDialog)?.apply {
@@ -85,10 +78,10 @@ class JetpackPoweredBottomSheetFragment : BottomSheetDialogFragment() {
8578

8679
private fun JetpackPoweredBottomSheetBinding.setupObservers() {
8780
viewModel.start()
88-
89-
viewModel.uiState.observe(this@JetpackPoweredBottomSheetFragment) { uiState ->
90-
adapter.submitList(uiState?.uiItems ?: listOf())
91-
}
81+
//
82+
// viewModel.uiState.observe(this@JetpackPoweredBottomSheetFragment) { uiState ->
83+
// adapter.submitList(uiState?.uiItems ?: listOf())
84+
// }
9285

9386
viewModel.action.observe(viewLifecycleOwner) { action ->
9487
when (action) {
Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,76 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
45
android:layout_width="match_parent"
56
android:layout_height="wrap_content"
6-
xmlns:tools="http://schemas.android.com/tools"
7-
android:animateLayoutChanges="true"
8-
android:background="@color/jetpack_powered_bottom_sheet_background"
9-
android:orientation="vertical">
7+
android:paddingStart="@dimen/margin_extra_extra_medium_large"
8+
android:paddingEnd="@dimen/margin_extra_extra_medium_large"
9+
android:background="@color/jetpack_powered_bottom_sheet_background">
1010

11-
<androidx.recyclerview.widget.RecyclerView
12-
android:id="@+id/content_recycler_view"
11+
<include
12+
android:id="@+id/handle"
13+
layout="@layout/bottom_sheet_handle_view"
1314
android:layout_width="match_parent"
1415
android:layout_height="wrap_content"
15-
android:layout_marginEnd="@dimen/margin_extra_extra_medium_large"
16-
android:layout_marginStart="@dimen/margin_extra_extra_medium_large"
17-
android:layout_marginTop="@dimen/margin_medium"
18-
android:clipToPadding="false"
19-
android:descendantFocusability="beforeDescendants"
20-
android:scrollbars="vertical"
21-
app:layout_constrainedHeight="true"
22-
app:layout_constraintBottom_toTopOf="@+id/primary_button"
16+
android:layout_marginBottom="@dimen/margin_small"
2317
app:layout_constraintEnd_toEndOf="parent"
2418
app:layout_constraintStart_toStartOf="parent"
25-
app:layout_constraintTop_toBottomOf="@+id/handle"
26-
app:layout_constraintVertical_bias="0.0" />
19+
app:layout_constraintTop_toTopOf="parent" />
2720

28-
<com.google.android.material.button.MaterialButton
29-
android:id="@+id/primary_button"
21+
<com.airbnb.lottie.LottieAnimationView
22+
android:id="@+id/illustration_view"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:layout_marginTop="@dimen/margin_extra_extra_medium_large"
26+
android:scaleType="centerCrop"
27+
app:layout_constraintTop_toBottomOf="@id/handle"
28+
app:layout_constraintStart_toStartOf="parent"
29+
app:lottie_rawRes="@raw/wp2jp"
30+
app:lottie_enableMergePathsForKitKatAndAbove="true"
31+
app:lottie_autoPlay="true"
32+
app:lottie_loop="false" />
33+
34+
<TextView
35+
android:id="@+id/title"
36+
style="@style/TextAppearance.Material3.HeadlineMedium"
3037
android:layout_width="match_parent"
3138
android:layout_height="wrap_content"
32-
android:layout_gravity="center"
33-
android:layout_marginEnd="@dimen/margin_extra_extra_medium_large"
34-
android:layout_marginStart="@dimen/margin_extra_extra_medium_large"
35-
android:backgroundTint="@color/jetpack_green_40"
36-
android:gravity="center"
37-
android:minHeight="@dimen/margin_extra_extra_large"
38-
android:text="@string/wp_jetpack_get_new_jetpack_app"
39-
android:textAppearance="?attr/textAppearanceSubtitle2"
40-
android:textColor="?attr/colorOnSecondary"
41-
app:layout_constraintTop_toBottomOf="@id/content_recycler_view"
42-
app:layout_constraintBottom_toTopOf="@id/secondary_button"
39+
android:layout_marginTop="@dimen/margin_extra_medium_large"
40+
android:text="@string/wp_jetpack_powered_better_with_jetpack"
41+
android:textFontWeight="700"
42+
app:layout_constraintTop_toBottomOf="@id/illustration_view"
43+
app:layout_constraintStart_toStartOf="parent"
4344
app:layout_constraintEnd_toEndOf="parent"
45+
tools:targetApi="p" />
46+
47+
<TextView
48+
android:id="@+id/caption"
49+
style="?attr/textAppearanceBody1"
50+
android:text="@string/wp_jetpack_powered_features"
51+
android:layout_width="match_parent"
52+
android:layout_height="wrap_content"
53+
android:layout_marginTop="@dimen/margin_extra_medium_large"
54+
app:layout_constraintTop_toBottomOf="@id/title"
4455
app:layout_constraintStart_toStartOf="parent"
45-
app:layout_goneMarginBottom="@dimen/margin_extra_extra_medium_large" />
56+
app:layout_constraintEnd_toEndOf="parent"/>
4657

4758
<com.google.android.material.button.MaterialButton
48-
android:id="@+id/secondary_button"
49-
android:visibility="gone"
50-
style="@style/Widget.MaterialComponents.Button.TextButton"
59+
android:id="@+id/primary_button"
5160
android:layout_width="match_parent"
5261
android:layout_height="wrap_content"
53-
android:layout_gravity="center"
54-
android:layout_marginBottom="@dimen/margin_extra_extra_medium_large"
55-
android:layout_marginEnd="@dimen/margin_extra_extra_medium_large"
56-
android:layout_marginStart="@dimen/margin_extra_extra_medium_large"
62+
android:layout_marginTop="@dimen/margin_extra_extra_large"
63+
android:layout_marginBottom="@dimen/margin_64dp"
64+
android:backgroundTint="@color/jetpack_green_40"
5765
android:gravity="center"
58-
android:minHeight="@dimen/margin_extra_extra_large"
66+
android:minHeight="@dimen/margin_64dp"
67+
app:cornerRadius="@dimen/margin_small_medium"
68+
android:text="@string/wp_jetpack_get_new_jetpack_app"
5969
android:textAppearance="?attr/textAppearanceSubtitle2"
60-
android:textAllCaps="false"
61-
android:textColor="@color/jetpack_green"
62-
app:layout_constraintTop_toBottomOf="@id/primary_button"
63-
app:layout_constraintBottom_toBottomOf="parent"
70+
android:textColor="?attr/colorOnSecondary"
71+
app:layout_constraintTop_toBottomOf="@id/caption"
6472
app:layout_constraintEnd_toEndOf="parent"
6573
app:layout_constraintStart_toStartOf="parent"
66-
tools:text="Continue to Reader"
67-
tools:visibility="visible"/>
74+
app:layout_constraintBottom_toBottomOf="parent"/>
6875

69-
<include
70-
android:id="@+id/handle"
71-
layout="@layout/bottom_sheet_handle_view"
72-
android:layout_width="match_parent"
73-
android:layout_height="wrap_content"
74-
android:layout_marginBottom="@dimen/margin_small"
75-
app:layout_constraintEnd_toEndOf="parent"
76-
app:layout_constraintStart_toStartOf="parent"
77-
app:layout_constraintTop_toTopOf="parent" />
7876
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 49 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,76 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
45
android:layout_width="match_parent"
56
android:layout_height="wrap_content"
6-
xmlns:tools="http://schemas.android.com/tools"
7-
android:animateLayoutChanges="true"
8-
android:background="@color/jetpack_powered_bottom_sheet_background"
9-
android:orientation="vertical">
7+
android:paddingStart="@dimen/margin_extra_extra_medium_large"
8+
android:paddingEnd="@dimen/margin_extra_extra_medium_large"
9+
android:background="@color/jetpack_powered_bottom_sheet_background">
1010

11-
<androidx.constraintlayout.widget.Guideline
12-
android:id="@+id/guideline3"
11+
<include
12+
android:id="@+id/handle"
13+
layout="@layout/bottom_sheet_handle_view"
14+
android:layout_width="match_parent"
15+
android:layout_height="wrap_content"
16+
android:layout_marginBottom="@dimen/margin_small"
17+
app:layout_constraintEnd_toEndOf="parent"
18+
app:layout_constraintStart_toStartOf="parent"
19+
app:layout_constraintTop_toTopOf="parent" />
20+
21+
<com.airbnb.lottie.LottieAnimationView
22+
android:id="@+id/illustration_view"
1323
android:layout_width="wrap_content"
1424
android:layout_height="wrap_content"
15-
android:orientation="horizontal"
16-
app:layout_constraintGuide_end="160dp"
17-
tools:ignore="InconsistentLayout"/>
25+
android:layout_marginTop="@dimen/margin_64dp"
26+
android:scaleType="centerCrop"
27+
app:layout_constraintTop_toBottomOf="@id/handle"
28+
app:layout_constraintStart_toStartOf="parent"
29+
app:lottie_rawRes="@raw/wp2jp"
30+
app:lottie_enableMergePathsForKitKatAndAbove="true"
31+
app:lottie_autoPlay="true"
32+
app:lottie_loop="false" />
1833

19-
<androidx.recyclerview.widget.RecyclerView
20-
android:id="@+id/content_recycler_view"
34+
<TextView
35+
android:id="@+id/title"
36+
style="@style/TextAppearance.Material3.HeadlineMedium"
2137
android:layout_width="match_parent"
2238
android:layout_height="wrap_content"
23-
android:layout_marginEnd="@dimen/margin_extra_extra_medium_large"
24-
android:layout_marginStart="@dimen/margin_extra_extra_medium_large"
25-
android:layout_marginTop="@dimen/my_site_bottom_spacing"
26-
android:clipToPadding="false"
27-
android:descendantFocusability="beforeDescendants"
28-
android:scrollbars="vertical"
29-
app:layout_constrainedHeight="true"
30-
app:layout_constraintBottom_toTopOf="@+id/guideline3"
39+
android:layout_marginTop="@dimen/margin_extra_medium_large"
40+
android:text="@string/wp_jetpack_powered_better_with_jetpack"
41+
android:textFontWeight="700"
42+
app:layout_constraintTop_toBottomOf="@id/illustration_view"
43+
app:layout_constraintStart_toStartOf="parent"
3144
app:layout_constraintEnd_toEndOf="parent"
45+
tools:targetApi="p" />
46+
47+
<TextView
48+
android:id="@+id/caption"
49+
style="?attr/textAppearanceBody1"
50+
android:text="@string/wp_jetpack_powered_features"
51+
android:layout_width="match_parent"
52+
android:layout_height="wrap_content"
53+
android:layout_marginTop="@dimen/margin_extra_medium_large"
54+
app:layout_constraintTop_toBottomOf="@id/title"
3255
app:layout_constraintStart_toStartOf="parent"
33-
app:layout_constraintTop_toBottomOf="@+id/handle"
34-
app:layout_constraintVertical_bias="0.0" />
56+
app:layout_constraintEnd_toEndOf="parent"/>
3557

3658
<com.google.android.material.button.MaterialButton
3759
android:id="@+id/primary_button"
3860
android:layout_width="match_parent"
3961
android:layout_height="wrap_content"
40-
android:layout_gravity="center"
41-
android:layout_marginEnd="@dimen/margin_extra_extra_medium_large"
42-
android:layout_marginStart="@dimen/margin_extra_extra_medium_large"
43-
android:layout_marginTop="@dimen/margin_extra_extra_medium_large"
62+
android:layout_marginTop="@dimen/margin_extra_extra_large"
63+
android:layout_marginBottom="@dimen/margin_64dp"
4464
android:backgroundTint="@color/jetpack_green_40"
4565
android:gravity="center"
46-
android:minHeight="@dimen/margin_extra_extra_large"
66+
android:minHeight="@dimen/margin_64dp"
67+
app:cornerRadius="@dimen/margin_small_medium"
4768
android:text="@string/wp_jetpack_get_new_jetpack_app"
4869
android:textAppearance="?attr/textAppearanceSubtitle2"
4970
android:textColor="?attr/colorOnSecondary"
50-
app:layout_constraintTop_toBottomOf="@id/guideline3"
51-
app:layout_constraintBottom_toTopOf="@id/secondary_button"
71+
app:layout_constraintTop_toBottomOf="@id/caption"
5272
app:layout_constraintEnd_toEndOf="parent"
5373
app:layout_constraintStart_toStartOf="parent"
54-
app:layout_goneMarginBottom="@dimen/margin_extra_extra_medium_large" />
74+
app:layout_constraintBottom_toBottomOf="parent"/>
5575

56-
<com.google.android.material.button.MaterialButton
57-
android:id="@+id/secondary_button"
58-
android:visibility="gone"
59-
style="@style/Widget.MaterialComponents.Button.TextButton"
60-
android:layout_width="match_parent"
61-
android:layout_height="wrap_content"
62-
android:layout_gravity="center"
63-
android:layout_marginBottom="@dimen/margin_extra_extra_medium_large"
64-
android:layout_marginEnd="@dimen/margin_extra_extra_medium_large"
65-
android:layout_marginStart="@dimen/margin_extra_extra_medium_large"
66-
android:gravity="center"
67-
android:minHeight="@dimen/margin_extra_extra_large"
68-
android:textAppearance="?attr/textAppearanceSubtitle2"
69-
android:textAllCaps="false"
70-
android:textColor="@color/jetpack_green"
71-
app:layout_constraintBottom_toBottomOf="parent"
72-
app:layout_constraintEnd_toEndOf="parent"
73-
app:layout_constraintStart_toStartOf="parent"
74-
tools:text="Continue to Reader"
75-
tools:visibility="visible"/>
76-
77-
<include
78-
android:id="@+id/handle"
79-
layout="@layout/bottom_sheet_handle_view"
80-
android:layout_width="match_parent"
81-
android:layout_height="wrap_content"
82-
android:layout_marginBottom="@dimen/margin_small"
83-
app:layout_constraintEnd_toEndOf="parent"
84-
app:layout_constraintStart_toStartOf="parent"
85-
app:layout_constraintTop_toTopOf="parent" />
8676
</androidx.constraintlayout.widget.ConstraintLayout>

WordPress/src/main/res/values/dimens.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@
114114
<dimen name="margin_extra_medium_large">24dp</dimen>
115115
<dimen name="margin_extra_extra_medium_large">32dp</dimen>
116116
<dimen name="margin_extra_extra_large">48dp</dimen>
117+
<dimen name="margin_64dp">64dp</dimen>
117118
<dimen name="margin_68dp">68dp</dimen>
119+
<dimen name="margin_200dp">200dp</dimen>
118120
<dimen name="margin_filter_spinner">16dp</dimen>
119121
<dimen name="margin_theme_browser_top">160dp</dimen>
120122
<dimen name="negative_margin_medium">-8dp</dimen>

0 commit comments

Comments
 (0)