Skip to content

Commit b2b2585

Browse files
committed
Update for feature specific overlay
- Create separate full screen bottom sheet layout - Add strings - Update bottom sheet
1 parent 1cd0e9e commit b2b2585

5 files changed

Lines changed: 236 additions & 51 deletions

File tree

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

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
1313
import dagger.hilt.android.AndroidEntryPoint
1414
import org.wordpress.android.R
1515
import org.wordpress.android.databinding.JetpackPoweredBottomSheetBinding
16+
import org.wordpress.android.databinding.JetpackPoweredExpandedBottomSheetBinding
1617
import org.wordpress.android.ui.ActivityLauncherWrapper
1718
import org.wordpress.android.ui.ActivityLauncherWrapper.Companion.JETPACK_PACKAGE_NAME
1819
import org.wordpress.android.ui.main.WPMainNavigationView.PageType
@@ -28,38 +29,56 @@ import javax.inject.Inject
2829
class JetpackPoweredBottomSheetFragment : BottomSheetDialogFragment() {
2930
@Inject lateinit var activityLauncherWrapper: ActivityLauncherWrapper
3031
private val viewModel: JetpackPoweredDialogViewModel by viewModels()
32+
private var fullScreen: Boolean = false
33+
34+
override fun onCreate(savedInstanceState: Bundle?) {
35+
super.onCreate(savedInstanceState)
36+
fullScreen = arguments?.getBoolean(KEY_FULL_SCREEN, false) ?: false
37+
}
3138

3239
override fun onCreateView(
3340
inflater: LayoutInflater,
3441
container: ViewGroup?,
3542
savedInstanceState: Bundle?
3643
): View? {
37-
return inflater.inflate(R.layout.jetpack_powered_bottom_sheet, container)
44+
val layout = if (fullScreen) {
45+
R.layout.jetpack_powered_expanded_bottom_sheet
46+
} else {
47+
R.layout.jetpack_powered_bottom_sheet
48+
}
49+
50+
return inflater.inflate(layout, container)
3851
}
3952

4053
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
4154
super.onViewCreated(view, savedInstanceState)
4255

43-
with(JetpackPoweredBottomSheetBinding.bind(view)) {
44-
initializeViews()
45-
setupObservers()
46-
}
47-
}
48-
49-
private fun JetpackPoweredBottomSheetBinding.initializeViews() {
50-
primaryButton.setOnClickListener { viewModel.openJetpackAppDownloadLink() }
51-
52-
val fullScreen = arguments?.getBoolean(KEY_FULL_SCREEN, false) ?: false
53-
5456
if (fullScreen) {
55-
// secondaryButton.visibility = View.VISIBLE
56-
val pageType = arguments?.getSerializable(KEY_SITE_SCREEN) as? PageType ?: MY_SITE
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() }
57+
with(JetpackPoweredExpandedBottomSheetBinding.bind(view)) {
58+
when (arguments?.getSerializable(KEY_SITE_SCREEN) as? PageType ?: MY_SITE) {
59+
MY_SITE -> {
60+
title.text = getString(R.string.wp_jetpack_powered_stats_powered_by_jetpack)
61+
caption.text = getString(R.string.wp_jetpack_powered_stats_powered_by_jetpack_caption)
62+
secondaryButton.text = getString(R.string.wp_jetpack_continue_to_stats)
63+
}
64+
READER -> {
65+
title.text = getString(R.string.wp_jetpack_powered_reader_powered_by_jetpack)
66+
caption.text = getString(R.string.wp_jetpack_powered_reader_powered_by_jetpack_caption)
67+
secondaryButton.text = getString(R.string.wp_jetpack_continue_to_reader)
68+
}
69+
NOTIFS -> {
70+
title.text = getString(R.string.wp_jetpack_powered_notifications_powered_by_jetpack)
71+
caption.text = getString(R.string.wp_jetpack_powered_notifications_powered_by_jetpack_caption)
72+
secondaryButton.text = getString(R.string.wp_jetpack_continue_to_notifications)
73+
}
74+
}
75+
primaryButton.setOnClickListener { viewModel.openJetpackAppDownloadLink() }
76+
secondaryButton.setOnClickListener { viewModel.dismissBottomSheet() }
77+
}
78+
} else {
79+
with(JetpackPoweredBottomSheetBinding.bind(view)) {
80+
primaryButton.setOnClickListener { viewModel.openJetpackAppDownloadLink() }
81+
}
6382
}
6483

6584
(dialog as? BottomSheetDialog)?.apply {
@@ -74,15 +93,11 @@ class JetpackPoweredBottomSheetFragment : BottomSheetDialogFragment() {
7493
expandBottomSheet(bottomSheetBehavior)
7594
}
7695
}
77-
}
7896

79-
private fun JetpackPoweredBottomSheetBinding.setupObservers() {
80-
viewModel.start()
81-
//
82-
// viewModel.uiState.observe(this@JetpackPoweredBottomSheetFragment) { uiState ->
83-
// adapter.submitList(uiState?.uiItems ?: listOf())
84-
// }
97+
setupObservers()
98+
}
8599

100+
private fun setupObservers() {
86101
viewModel.action.observe(viewLifecycleOwner) { action ->
87102
when (action) {
88103
is OpenPlayStore -> {

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ import androidx.lifecycle.LiveData
44
import androidx.lifecycle.MutableLiveData
55
import dagger.hilt.android.lifecycle.HiltViewModel
66
import kotlinx.coroutines.CoroutineDispatcher
7-
import org.wordpress.android.R
8-
import org.wordpress.android.R.string
97
import org.wordpress.android.modules.UI_THREAD
10-
import org.wordpress.android.ui.mysite.jetpackbadge.JetpackPoweredItem.Caption
11-
import org.wordpress.android.ui.mysite.jetpackbadge.JetpackPoweredItem.Illustration
12-
import org.wordpress.android.ui.mysite.jetpackbadge.JetpackPoweredItem.Title
13-
import org.wordpress.android.ui.utils.UiString.UiStringRes
148
import org.wordpress.android.util.JetpackBrandingUtils
159
import org.wordpress.android.viewmodel.ScopedViewModel
1610
import javax.inject.Inject
@@ -21,34 +15,16 @@ class JetpackPoweredDialogViewModel @Inject constructor(
2115
@Named(UI_THREAD) mainDispatcher: CoroutineDispatcher,
2216
private val jetpackBrandingUtils: JetpackBrandingUtils
2317
) : ScopedViewModel(mainDispatcher) {
24-
private val _uiState = MutableLiveData<UiState>()
25-
val uiState: LiveData<UiState> = _uiState
26-
2718
private val _action = MutableLiveData<JetpackPoweredDialogAction>()
2819
val action: LiveData<JetpackPoweredDialogAction> = _action
2920

30-
@Suppress("ForbiddenComment")
31-
fun start() {
32-
_uiState.value = UiState(
33-
listOf(
34-
Illustration(R.raw.wp2jp),
35-
Title(UiStringRes(string.wp_jetpack_powered_better_with_jetpack)),
36-
Caption(UiStringRes(string.wp_jetpack_powered_features))
37-
)
38-
)
39-
}
40-
41-
@Suppress("ForbiddenComment")
4221
fun openJetpackAppDownloadLink() {
4322
jetpackBrandingUtils.trackGetJetpackAppTapped()
4423
_action.value = JetpackPoweredDialogAction.OpenPlayStore
4524
}
4625

47-
@Suppress("ForbiddenComment")
4826
fun dismissBottomSheet() {
4927
jetpackBrandingUtils.trackDismissTapped()
5028
_action.value = JetpackPoweredDialogAction.DismissDialog
5129
}
52-
53-
data class UiState(val uiItems: List<JetpackPoweredItem>)
5430
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
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">
10+
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"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:layout_marginTop="@dimen/margin_extra_medium_large"
26+
android:scaleType="centerCrop"
27+
app:layout_constraintTop_toBottomOf="@id/handle"
28+
app:layout_constraintStart_toStartOf="parent"
29+
app:layout_constraintBottom_toBottomOf="@id/title"
30+
app:lottie_rawRes="@raw/wp2jp"
31+
app:lottie_enableMergePathsForKitKatAndAbove="true"
32+
app:lottie_autoPlay="true"
33+
app:lottie_loop="false" />
34+
35+
<TextView
36+
android:id="@+id/title"
37+
style="@style/TextAppearance.Material3.HeadlineMedium"
38+
android:layout_width="match_parent"
39+
android:layout_height="wrap_content"
40+
android:layout_marginTop="@dimen/margin_extra_medium_large"
41+
android:text="@string/wp_jetpack_powered_reader_powered_by_jetpack"
42+
android:textFontWeight="700"
43+
app:layout_constraintTop_toBottomOf="@id/illustration_view"
44+
app:layout_constraintStart_toStartOf="parent"
45+
app:layout_constraintEnd_toEndOf="parent"
46+
tools:targetApi="p" />
47+
48+
<TextView
49+
android:id="@+id/caption"
50+
style="?attr/textAppearanceBody1"
51+
android:text="@string/wp_jetpack_powered_reader_powered_by_jetpack_caption"
52+
android:layout_width="match_parent"
53+
android:layout_height="wrap_content"
54+
android:layout_marginTop="@dimen/margin_extra_medium_large"
55+
app:layout_constraintTop_toBottomOf="@id/title"
56+
app:layout_constraintStart_toStartOf="parent"
57+
app:layout_constraintEnd_toEndOf="parent"/>
58+
59+
<com.google.android.material.button.MaterialButton
60+
android:id="@+id/primary_button"
61+
android:layout_width="match_parent"
62+
android:layout_height="wrap_content"
63+
android:layout_marginTop="@dimen/margin_64dp"
64+
android:backgroundTint="@color/jetpack_green_40"
65+
android:gravity="center"
66+
android:minHeight="@dimen/margin_64dp"
67+
app:cornerRadius="@dimen/margin_small_medium"
68+
android:text="@string/wp_jetpack_get_new_jetpack_app"
69+
android:textAppearance="?attr/textAppearanceSubtitle2"
70+
android:textColor="?attr/colorOnSecondary"
71+
app:layout_constraintTop_toBottomOf="@id/caption"
72+
app:layout_constraintEnd_toEndOf="parent"
73+
app:layout_constraintStart_toStartOf="parent"
74+
app:layout_constraintBottom_toTopOf="@id/secondary_button"/>
75+
76+
<com.google.android.material.button.MaterialButton
77+
android:id="@+id/secondary_button"
78+
style="@style/Widget.MaterialComponents.Button.TextButton"
79+
android:layout_width="match_parent"
80+
android:layout_height="wrap_content"
81+
android:layout_gravity="center"
82+
android:layout_marginBottom="@dimen/margin_64dp"
83+
android:gravity="center"
84+
android:minHeight="@dimen/margin_64dp"
85+
android:textAppearance="?attr/textAppearanceSubtitle2"
86+
android:textAllCaps="false"
87+
android:textColor="@color/jetpack_green"
88+
app:layout_constraintTop_toBottomOf="@id/primary_button"
89+
app:layout_constraintBottom_toBottomOf="parent"
90+
app:layout_constraintEnd_toEndOf="parent"
91+
app:layout_constraintStart_toStartOf="parent"
92+
tools:text="Continue to Reader" />
93+
94+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
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">
10+
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"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
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:layout_constraintBottom_toBottomOf="@id/title"
30+
app:lottie_rawRes="@raw/wp2jp"
31+
app:lottie_enableMergePathsForKitKatAndAbove="true"
32+
app:lottie_autoPlay="true"
33+
app:lottie_loop="false" />
34+
35+
<TextView
36+
android:id="@+id/title"
37+
style="@style/TextAppearance.Material3.HeadlineMedium"
38+
android:layout_width="match_parent"
39+
android:layout_height="wrap_content"
40+
android:layout_marginTop="@dimen/margin_extra_medium_large"
41+
android:text="@string/wp_jetpack_powered_reader_powered_by_jetpack"
42+
android:textFontWeight="700"
43+
app:layout_constraintTop_toBottomOf="@id/illustration_view"
44+
app:layout_constraintStart_toStartOf="parent"
45+
app:layout_constraintEnd_toEndOf="parent"
46+
tools:targetApi="p" />
47+
48+
<TextView
49+
android:id="@+id/caption"
50+
style="?attr/textAppearanceBody1"
51+
android:text="@string/wp_jetpack_powered_reader_powered_by_jetpack_caption"
52+
android:layout_width="match_parent"
53+
android:layout_height="wrap_content"
54+
android:layout_marginTop="@dimen/margin_extra_medium_large"
55+
app:layout_constraintTop_toBottomOf="@id/title"
56+
app:layout_constraintStart_toStartOf="parent"
57+
app:layout_constraintEnd_toEndOf="parent"/>
58+
59+
<com.google.android.material.button.MaterialButton
60+
android:id="@+id/primary_button"
61+
android:layout_width="match_parent"
62+
android:layout_height="wrap_content"
63+
android:layout_marginTop="@dimen/margin_200dp"
64+
android:backgroundTint="@color/jetpack_green_40"
65+
android:gravity="center"
66+
android:minHeight="@dimen/margin_64dp"
67+
app:cornerRadius="@dimen/margin_small_medium"
68+
android:text="@string/wp_jetpack_get_new_jetpack_app"
69+
android:textAppearance="?attr/textAppearanceSubtitle2"
70+
android:textColor="?attr/colorOnSecondary"
71+
app:layout_constraintTop_toBottomOf="@id/caption"
72+
app:layout_constraintEnd_toEndOf="parent"
73+
app:layout_constraintStart_toStartOf="parent"
74+
app:layout_constraintBottom_toTopOf="@id/secondary_button"/>
75+
76+
<com.google.android.material.button.MaterialButton
77+
android:id="@+id/secondary_button"
78+
style="@style/Widget.MaterialComponents.Button.TextButton"
79+
android:layout_width="match_parent"
80+
android:layout_height="wrap_content"
81+
android:layout_gravity="center"
82+
android:layout_marginBottom="@dimen/margin_64dp"
83+
android:gravity="center"
84+
android:minHeight="@dimen/margin_extra_extra_large"
85+
android:textAppearance="?attr/textAppearanceSubtitle2"
86+
android:textAllCaps="false"
87+
android:textColor="@color/jetpack_green"
88+
app:layout_constraintTop_toBottomOf="@id/primary_button"
89+
app:layout_constraintBottom_toBottomOf="parent"
90+
app:layout_constraintEnd_toEndOf="parent"
91+
app:layout_constraintStart_toStartOf="parent"
92+
tools:text="Continue to Reader" />
93+
94+
</androidx.constraintlayout.widget.ConstraintLayout>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4205,6 +4205,12 @@ translators: %s: Select control option value e.g: "Auto, 25%". -->
42054205
<string name="wp_jetpack_powered">Jetpack powered</string>
42064206
<string name="wp_jetpack_powered_better_with_jetpack">WordPress is better with Jetpack</string>
42074207
<string name="wp_jetpack_powered_features">The new Jetpack app has Stats, Reader, Notifications, and more that make your WordPress better.</string>
4208+
<string name="wp_jetpack_powered_reader_powered_by_jetpack">Reader is powered by Jetpack</string>
4209+
<string name="wp_jetpack_powered_reader_powered_by_jetpack_caption">Find, follow, and like all your favorite sites and posts with Reader, now available in the new Jetpack app.</string>
4210+
<string name="wp_jetpack_powered_stats_powered_by_jetpack">Stats are powered by Jetpack</string>
4211+
<string name="wp_jetpack_powered_stats_powered_by_jetpack_caption">Watch your traffic grow and learn about your audience with redesigned Stats and Insights, now available in the new Jetpack app.</string>
4212+
<string name="wp_jetpack_powered_notifications_powered_by_jetpack">Notifications are powered by Jetpack</string>
4213+
<string name="wp_jetpack_powered_notifications_powered_by_jetpack_caption">Stay informed with realtime updates for new comments, site traffic, security reports and more.</string>
42084214
<string name="wp_jetpack_get_new_jetpack_app">Get the new Jetpack app</string>
42094215
<string name="wp_jetpack_continue_to_reader">Continue to Reader</string>
42104216
<string name="wp_jetpack_continue_to_stats">Continue to Stats</string>

0 commit comments

Comments
 (0)