Skip to content

Commit

Permalink
Revert "Merge pull request #953 from Automattic/task/patron-icons"
Browse files Browse the repository at this point in the history
This reverts commit 66e3d73, reversing
changes made to 68f19c9.
  • Loading branch information
ashiagr committed Jun 5, 2023
1 parent 5ff13f8 commit 91b1a42
Show file tree
Hide file tree
Showing 98 changed files with 47 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,6 @@ private fun Content(
is OnboardingFlow.PlusFlow -> defaultValue = flow.source
else -> Unit // Not a startDestination, default value should not be set.
}
},
navArgument(OnboardingNavRoute.PlusUpgrade.showPatronOnlyArgumentKey) {
type = NavType.BoolType
defaultValue = when (flow) {
is OnboardingFlow.PlusUpsell -> flow.showPatronOnly
else -> false
}
}
)
) { navBackStackEntry ->
Expand Down Expand Up @@ -265,13 +258,9 @@ private object OnboardingNavRoute {
private const val routeBase = "plus_upgrade"

const val sourceArgumentKey = "source"
const val showPatronOnlyArgumentKey = "show_patron_only"
// The route variable should only be used to navigate to the PlusUpgrade screens
// when they are the startDestination and the args for these startDestinations are set using default values.
// They are parsed based on this deep-link-like route by the navigation component.
// For more details check here: https://developer.android.com/jetpack/compose/navigation#nav-with-args
// In all other cases, use the routeWithSource function.
const val route = "$routeBase/{$sourceArgumentKey}?{$showPatronOnlyArgumentKey}={$showPatronOnlyArgumentKey}"
// when they are the startDestination. In all other cases, use the routeWithSource function.
const val route = "$routeBase/{$sourceArgumentKey}"
fun routeWithSource(source: OnboardingUpgradeSource) = "$routeBase/$source"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class OnboardingUpgradeFeaturesViewModel @Inject constructor(
val state: StateFlow<OnboardingUpgradeFeaturesState> = _state

private val source = savedStateHandle.get<OnboardingUpgradeSource>("source")
private val showPatronOnly = savedStateHandle.get<Boolean>("show_patron_only")

init {
if (BuildConfig.ADD_PATRON_ENABLED) {
Expand Down Expand Up @@ -90,7 +89,7 @@ class OnboardingUpgradeFeaturesViewModel @Inject constructor(
val lastSelectedTier = settings.getLastSelectedSubscriptionTier().takeIf { source in listOf(OnboardingUpgradeSource.LOGIN, OnboardingUpgradeSource.PROFILE) }
val lastSelectedFrequency = settings.getLastSelectedSubscriptionFrequency().takeIf { source in listOf(OnboardingUpgradeSource.LOGIN, OnboardingUpgradeSource.PROFILE) }

val showPatronOnly = source == OnboardingUpgradeSource.ACCOUNT_DETAILS || showPatronOnly == true
val showPatronOnly = source == OnboardingUpgradeSource.ACCOUNT_DETAILS
val updatedSubscriptions =
if (showPatronOnly) {
subscriptions.filter { it.tier == Subscription.SubscriptionTier.PATRON }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import androidx.appcompat.content.res.AppCompatResources
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.recyclerview.widget.RecyclerView
import au.com.shiftyjelly.pocketcasts.models.to.SignInState
import au.com.shiftyjelly.pocketcasts.models.type.SubscriptionType
import au.com.shiftyjelly.pocketcasts.settings.databinding.AdapterAppearanceAppiconItemBinding
import au.com.shiftyjelly.pocketcasts.ui.extensions.getThemeColor
import au.com.shiftyjelly.pocketcasts.ui.helper.AppIcon
Expand All @@ -20,7 +18,7 @@ import au.com.shiftyjelly.pocketcasts.ui.R as UR

class AppearanceIconSettingsAdapter(
private var mainWidth: Int?,
private var signInState: SignInState?,
private var isPlusSignedIn: Boolean,
private var selectedAppIcon: AppIcon.AppIconType,
private val list: List<AppIcon.AppIconType>,
private val clickListener: (AppIcon.AppIconType, AppIcon.AppIconType, Boolean) -> Unit
Expand Down Expand Up @@ -52,8 +50,8 @@ class AppearanceIconSettingsAdapter(

override fun getItemCount() = list.size

fun updatePlusSignedIn(signInState: SignInState?) {
this.signInState = signInState
fun updatePlusSignedIn(value: Boolean) {
isPlusSignedIn = value
notifyDataSetChanged()
}

Expand Down Expand Up @@ -84,25 +82,20 @@ class AppearanceIconSettingsAdapter(
}

fun bind(appIcon: AppIcon.AppIconType, selected: Boolean) {
val isValidIcon = isValidIcon(appIcon)
binding.appIconItem.alpha = if (isValidIcon) 1.0f else 0.65f
val showOption = !appIcon.isPlus || isPlusSignedIn
binding.appIconItem.alpha = if (showOption) 1.0f else 0.65f

val drawable = AppCompatResources.getDrawable(itemView.context, appIcon.settingsIcon)
binding.imgIcon.setImageDrawable(drawable)
var tickDrawable: Drawable? = null
if (isValidIcon && selected) {
if (showOption && selected) {
tickDrawable = AppCompatResources.getDrawable(itemView.context, R.drawable.ic_circle_tick)
} else if (!isValidIcon) {
val iconDrawable = when (appIcon.type) {
SubscriptionType.PLUS -> R.drawable.ic_locked_plus
SubscriptionType.PATRON -> R.drawable.ic_locked_patron
SubscriptionType.NONE -> throw IllegalStateException("Unknown type found for AppIcon")
}
tickDrawable = AppCompatResources.getDrawable(itemView.context, iconDrawable)
} else if (!showOption) {
tickDrawable = AppCompatResources.getDrawable(itemView.context, R.drawable.ic_plus_bubble)
}
binding.imgTick.setImageDrawable(tickDrawable)
binding.imgTick.contentDescription = binding.imgTick.resources.getString(if (selected) LR.string.on else LR.string.off)
binding.imgLock.isVisible = !isValidIcon
binding.imgLock.isVisible = !showOption
binding.txtTitle.setText(appIcon.labelId)

binding.outlinePanel1.setSelectedWithColors(selected, selectColor, deselectColor, strokeWidth)
Expand All @@ -114,16 +107,11 @@ class AppearanceIconSettingsAdapter(
}
val beforeAppIcon = selectedAppIcon
val afterAppIcon = list[bindingAdapterPosition]
val validAppIcon = isValidIcon(afterAppIcon)
val validAppIcon = !afterAppIcon.isPlus || isPlusSignedIn

selectedAppIcon = afterAppIcon
clickListener(beforeAppIcon, afterAppIcon, validAppIcon)
notifyDataSetChanged()
}

private fun isValidIcon(appIcon: AppIcon.AppIconType) =
(appIcon.type == SubscriptionType.NONE) ||
(appIcon.type == SubscriptionType.PLUS && signInState?.isSignedInAsPlus == true) ||
(appIcon.type == SubscriptionType.PATRON && signInState?.isSignedInAsPatron == true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import au.com.shiftyjelly.pocketcasts.models.type.SubscriptionType
import au.com.shiftyjelly.pocketcasts.preferences.Settings
import au.com.shiftyjelly.pocketcasts.repositories.subscription.SubscriptionManager
import au.com.shiftyjelly.pocketcasts.settings.databinding.FragmentSettingsAppearanceBinding
Expand Down Expand Up @@ -86,7 +85,7 @@ class AppearanceSettingsFragment : BaseFragment() {
binding.themeRecyclerView.setHasFixedSize(true)
scrollToCurrentTheme()

binding.appIconRecyclerView.adapter = AppearanceIconSettingsAdapter(mainWidth, viewModel.signInState.value, state.currentAppIcon, state.iconList) { beforeAppIconType, afterAppIconType, validIcon ->
binding.appIconRecyclerView.adapter = AppearanceIconSettingsAdapter(mainWidth, isSignedInAsPlus, state.currentAppIcon, state.iconList) { beforeAppIconType, afterAppIconType, validIcon ->
if (validIcon) {
viewModel.updateGlobalIcon(afterAppIconType)

Expand All @@ -97,7 +96,7 @@ class AppearanceSettingsFragment : BaseFragment() {
.show()
} else {
viewModel.updateChangeAppIconType(Pair(beforeAppIconType, afterAppIconType))
openOnboardingFlow(afterAppIconType.type)
openOnboardingFlow()
}
}
binding.appIconRecyclerView.setHasFixedSize(true)
Expand Down Expand Up @@ -149,7 +148,7 @@ class AppearanceSettingsFragment : BaseFragment() {
}

(binding.themeRecyclerView.adapter as? AppearanceThemeSettingsAdapter)?.updatePlusSignedIn(signInState.isSignedInAsPlus)
(binding.appIconRecyclerView.adapter as? AppearanceIconSettingsAdapter)?.updatePlusSignedIn(signInState)
(binding.appIconRecyclerView.adapter as? AppearanceIconSettingsAdapter)?.updatePlusSignedIn(signInState.isSignedInAsPlus)
binding.upgradeGroup.isVisible = !signInState.isSignedInAsPlus && !settings.getUpgradeClosedAppearSettings()
}

Expand Down Expand Up @@ -192,11 +191,8 @@ class AppearanceSettingsFragment : BaseFragment() {
viewModel.onShown()
}

private fun openOnboardingFlow(type: SubscriptionType? = null) {
val onboardingFlow = type?.takeIf { type == SubscriptionType.PATRON }?.let {
OnboardingFlow.PlusUpsell(source = OnboardingUpgradeSource.APPEARANCE, showPatronOnly = true)
} ?: OnboardingFlow.PlusUpsell(OnboardingUpgradeSource.APPEARANCE)
OnboardingLauncher.openOnboardingFlow(activity, onboardingFlow)
private fun openOnboardingFlow() {
OnboardingLauncher.openOnboardingFlow(activity, OnboardingFlow.PlusUpsell(OnboardingUpgradeSource.APPEARANCE))
}

private fun scrollToCurrentTheme() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class AppearanceThemeSettingsAdapter(
if (showOption && selected) {
tickDrawable = AppCompatResources.getDrawable(itemView.context, R.drawable.ic_circle_tick)
} else if (!showOption) {
tickDrawable = AppCompatResources.getDrawable(itemView.context, R.drawable.ic_locked_plus)
tickDrawable = AppCompatResources.getDrawable(itemView.context, R.drawable.ic_plus_bubble)
}
binding.imgTick.setImageDrawable(tickDrawable)
binding.imgTick.contentDescription = binding.imgTick.resources.getString(if (selected) LR.string.on else LR.string.off)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ sealed class OnboardingFlow(val analyticsValue: String) : Parcelable {
@Parcelize object InitialOnboarding : OnboardingFlow("initial_onboarding")
@Parcelize class PlusAccountUpgrade(override val source: OnboardingUpgradeSource) : PlusFlow, OnboardingFlow("plus_account_upgrade")
@Parcelize object PlusAccountUpgradeNeedsLogin : OnboardingFlow("plus_account_upgrade_needs_login")
@Parcelize class PlusUpsell(
override val source: OnboardingUpgradeSource,
val showPatronOnly: Boolean = false,
) : PlusFlow, OnboardingFlow(if (showPatronOnly) "patron_upsell" else "plus_upsell")
@Parcelize class PlusUpsell(override val source: OnboardingUpgradeSource) : PlusFlow, OnboardingFlow("plus_upsell")
@Parcelize class PatronAccountUpgrade(override val source: OnboardingUpgradeSource) : PlusFlow, OnboardingFlow("patron_account_upgrade")

sealed interface PlusFlow {
Expand Down
15 changes: 4 additions & 11 deletions modules/features/settings/src/main/res/drawable/ic_circle_tick.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="40"
android:viewportHeight="40">
<path
android:pathData="M20,33.75C12.406,33.75 6.25,27.594 6.25,20C6.25,12.406 12.406,6.25 20,6.25C27.594,6.25 33.75,12.406 33.75,20C33.75,27.594 27.594,33.75 20,33.75Z"
android:fillColor="#03A9F4"/>
<path
android:pathData="M24.046,15.443C24.492,14.916 25.28,14.85 25.807,15.296C26.334,15.742 26.4,16.53 25.954,17.058L18.202,26.219L13.491,21.509C13.003,21.021 13.003,20.229 13.491,19.741C13.979,19.253 14.771,19.253 15.259,19.741L18.048,22.531L24.046,15.443Z"
android:fillColor="#ffffff"/>
<vector android:height="24dp" android:viewportHeight="30"
android:viewportWidth="30" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#03A9F4" android:pathData="M15,28.75C7.4061,28.75 1.25,22.5939 1.25,15C1.25,7.4061 7.4061,1.25 15,1.25C22.5939,1.25 28.75,7.4061 28.75,15C28.75,22.5939 22.5939,28.75 15,28.75Z"/>
<path android:fillColor="#ffffff" android:pathData="M19.0458,10.4426C19.4917,9.9156 20.2804,9.8499 20.8074,10.2958C21.3344,10.7417 21.4002,11.5304 20.9542,12.0575L13.2017,21.2195L8.4911,16.5089C8.0029,16.0208 8.0029,15.2293 8.4911,14.7411C8.9793,14.253 9.7707,14.253 10.2589,14.7411L13.0483,17.5305L19.0458,10.4426Z"/>
</vector>

This file was deleted.

25 changes: 0 additions & 25 deletions modules/features/settings/src/main/res/drawable/ic_locked_plus.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/appIconItem"
android:layout_width="124dp"
android:layout_height="wrap_content"
Expand All @@ -27,9 +28,11 @@

<ImageView
android:id="@+id/imgTick"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_gravity="bottom|end"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:srcCompat="@drawable/ic_circle_tick" />

</androidx.cardview.widget.CardView>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/themeItem"
android:layout_width="124dp"
android:layout_height="wrap_content"
Expand All @@ -27,8 +28,8 @@

<ImageView
android:id="@+id/imgTick"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_gravity="bottom|end"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.

0 comments on commit 91b1a42

Please sign in to comment.