Skip to content

Commit

Permalink
Merge pull request #17124 from wordpress-mobile/hotfix/release-20.6.1…
Browse files Browse the repository at this point in the history
…-jetpack-powered-bottom-sheet-feature-config

[Hotfix] Show Jetpack Overlay only when the remote flag is enabled
  • Loading branch information
irfano authored Sep 6, 2022
2 parents 59cf73c + 4ec6991 commit fa6d3b4
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ class ActivityLogDetailFragment : Fragment(R.layout.activity_log_item_detail) {

if (jetpackBrandingUtils.shouldShowJetpackBranding()) {
jetpackBadge.root.isVisible = true
jetpackBadge.jetpackPoweredBadge.setOnClickListener {
jetpackBrandingUtils.trackBadgeTapped(ACTIVITY_LOG_DETAIL)
viewModel.showJetpackPoweredBottomSheet()
if (jetpackBrandingUtils.shouldShowJetpackPoweredBottomSheet()) {
jetpackBadge.jetpackPoweredBadge.setOnClickListener {
jetpackBrandingUtils.trackBadgeTapped(ACTIVITY_LOG_DETAIL)
viewModel.showJetpackPoweredBottomSheet()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ class MeFragment : Fragment(R.layout.me_fragment), OnScrollToTopListener {

if (jetpackBrandingUtils.shouldShowJetpackBranding()) {
jetpackBadge.root.isVisible = true
jetpackBadge.footerJetpackBadge.jetpackPoweredBadge.setOnClickListener {
jetpackBrandingUtils.trackBadgeTapped(ME)
viewModel.showJetpackPoweredBottomSheet()
if (jetpackBrandingUtils.shouldShowJetpackPoweredBottomSheet()) {
jetpackBadge.footerJetpackBadge.jetpackPoweredBadge.setOnClickListener {
jetpackBrandingUtils.trackBadgeTapped(ME)
viewModel.showJetpackPoweredBottomSheet()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,6 @@ sealed class MySiteCardAndItem(open val type: Type, open val activeQuickStartIte
}

data class JetpackBadge(
val onClick: ListItemInteraction
val onClick: ListItemInteraction? = null
) : MySiteCardAndItem(JETPACK_BADGE)
}
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,11 @@ class MySiteViewModel @Inject constructor(
)

val jetpackBadge = JetpackBadge(
ListItemInteraction.create(this::onJetpackBadgeClick)
if (jetpackBrandingUtils.shouldShowJetpackPoweredBottomSheet()) {
ListItemInteraction.create(this::onJetpackBadgeClick)
} else {
null
}
).takeIf { jetpackBrandingUtils.shouldShowJetpackBranding() }

return mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class MySiteJetpackBadgeViewHolder(
parent: ViewGroup,
) : MySiteCardAndItemViewHolder<JetpackBadgeBinding>(parent.viewBinding(JetpackBadgeBinding::inflate)) {
fun bind(item: JetpackBadge) = with(binding) {
jetpackPoweredBadge.setOnClickListener { item.onClick.click() }
item.onClick?.run {
jetpackPoweredBadge.setOnClickListener { click() }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,14 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
private void addJetpackBadgeAsFooterIfEnabled(LayoutInflater inflater, ListView listView) {
if (mJetpackBrandingUtils.shouldShowJetpackBranding()) {
final JetpackBadgeFooterBinding binding = JetpackBadgeFooterBinding.inflate(inflater);
binding.footerJetpackBadge.jetpackPoweredBadge.setOnClickListener(v -> {
if (mJetpackBrandingUtils.shouldShowJetpackPoweredBottomSheet()) {
binding.footerJetpackBadge.jetpackPoweredBadge.setOnClickListener(v -> {
mJetpackBrandingUtils.trackBadgeTapped(Screen.APP_SETTINGS);
new JetpackPoweredBottomSheetFragment().show(
((AppCompatActivity) getActivity()).getSupportFragmentManager(),
JetpackPoweredBottomSheetFragment.TAG);
});
});
}
listView.addFooterView(binding.getRoot(), null, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ private void addJetpackBadgeAsFooterIfEnabled(ListView listView) {
if (mJetpackBrandingUtils.shouldShowJetpackBranding()) {
LayoutInflater inflater = LayoutInflater.from(getContext());
final JetpackBadgeFooterBinding binding = JetpackBadgeFooterBinding.inflate(inflater);
binding.footerJetpackBadge.jetpackPoweredBadge.setOnClickListener(v -> {
mJetpackBrandingUtils.trackBadgeTapped(Screen.NOTIFICATIONS_SETTINGS);
new JetpackPoweredBottomSheetFragment().show(
((AppCompatActivity) getActivity()).getSupportFragmentManager(),
JetpackPoweredBottomSheetFragment.TAG);
});
if (mJetpackBrandingUtils.shouldShowJetpackPoweredBottomSheet()) {
binding.footerJetpackBadge.jetpackPoweredBadge.setOnClickListener(v -> {
mJetpackBrandingUtils.trackBadgeTapped(Screen.NOTIFICATIONS_SETTINGS);
new JetpackPoweredBottomSheetFragment().show(
((AppCompatActivity) getActivity()).getSupportFragmentManager(),
JetpackPoweredBottomSheetFragment.TAG);
});
}
listView.addFooterView(binding.getRoot(), null, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,11 @@ class ReaderPostDetailFragment : ViewPagerFragment(),

if (jetpackBrandingUtils.shouldShowJetpackBranding()) {
binding.jetpackBadge.root.isVisible = true
binding.jetpackBadge.jetpackPoweredBadge.setOnClickListener {
jetpackBrandingUtils.trackBadgeTapped(READER_POST_DETAIL)
viewModel.showJetpackPoweredBottomSheet()
if (jetpackBrandingUtils.shouldShowJetpackPoweredBottomSheet()) {
binding.jetpackBadge.jetpackPoweredBadge.setOnClickListener {
jetpackBrandingUtils.trackBadgeTapped(READER_POST_DETAIL)
viewModel.showJetpackPoweredBottomSheet()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
package org.wordpress.android.util.config

import org.wordpress.android.BuildConfig
import org.wordpress.android.annotation.FeatureInDevelopment
import org.wordpress.android.annotation.Feature
import javax.inject.Inject

/**
* Configuration for Jetpack Powered Bottom Sheet
*
* TODO: When it is ready to be rolled out uncomment the lines 12 and 19, remove line 13 and this to-do
*/
// @Feature(JetpackPoweredBottomSheetFeatureConfig.JETPACK_POWERED_BOTTOM_SHEET_REMOTE_FIELD, true)
@FeatureInDevelopment
@Suppress("ForbiddenComment")
@Feature(JetpackPoweredBottomSheetFeatureConfig.JETPACK_POWERED_BOTTOM_SHEET_REMOTE_FIELD, false)
class JetpackPoweredBottomSheetFeatureConfig @Inject constructor(
appConfig: AppConfig
) : FeatureConfig(
appConfig,
BuildConfig.JETPACK_POWERED,
// JETPACK_POWERED_BOTTOM_SHEET_REMOTE_FIELD
BuildConfig.JETPACK_POWERED_BOTTOM_SHEET,
JETPACK_POWERED_BOTTOM_SHEET_REMOTE_FIELD
) {
companion object {
const val JETPACK_POWERED_BOTTOM_SHEET_REMOTE_FIELD = "jetpack_powered_bottom_sheet_remote_field"
Expand Down

0 comments on commit fa6d3b4

Please sign in to comment.