diff --git a/Habitica/res/drawable-hdpi/extra_gem_cap_left.png b/Habitica/res/drawable-hdpi/extra_gem_cap_left.png
new file mode 100644
index 000000000..77687431c
Binary files /dev/null and b/Habitica/res/drawable-hdpi/extra_gem_cap_left.png differ
diff --git a/Habitica/res/drawable-hdpi/extra_gem_cap_right.png b/Habitica/res/drawable-hdpi/extra_gem_cap_right.png
new file mode 100644
index 000000000..8339d0c60
Binary files /dev/null and b/Habitica/res/drawable-hdpi/extra_gem_cap_right.png differ
diff --git a/Habitica/res/drawable-hdpi/gem_gold_left.png b/Habitica/res/drawable-hdpi/gem_gold_left.png
new file mode 100644
index 000000000..1ddd560c5
Binary files /dev/null and b/Habitica/res/drawable-hdpi/gem_gold_left.png differ
diff --git a/Habitica/res/drawable-hdpi/gem_gold_right.png b/Habitica/res/drawable-hdpi/gem_gold_right.png
new file mode 100644
index 000000000..bd25070bc
Binary files /dev/null and b/Habitica/res/drawable-hdpi/gem_gold_right.png differ
diff --git a/Habitica/res/drawable-mdpi/extra_gem_cap_left.png b/Habitica/res/drawable-mdpi/extra_gem_cap_left.png
new file mode 100644
index 000000000..062a3996c
Binary files /dev/null and b/Habitica/res/drawable-mdpi/extra_gem_cap_left.png differ
diff --git a/Habitica/res/drawable-mdpi/extra_gem_cap_right.png b/Habitica/res/drawable-mdpi/extra_gem_cap_right.png
new file mode 100644
index 000000000..132499cad
Binary files /dev/null and b/Habitica/res/drawable-mdpi/extra_gem_cap_right.png differ
diff --git a/Habitica/res/drawable-mdpi/gem_gold_left.png b/Habitica/res/drawable-mdpi/gem_gold_left.png
new file mode 100644
index 000000000..a24dd4b00
Binary files /dev/null and b/Habitica/res/drawable-mdpi/gem_gold_left.png differ
diff --git a/Habitica/res/drawable-mdpi/gem_gold_right.png b/Habitica/res/drawable-mdpi/gem_gold_right.png
new file mode 100644
index 000000000..bb9383d4f
Binary files /dev/null and b/Habitica/res/drawable-mdpi/gem_gold_right.png differ
diff --git a/Habitica/res/drawable-xhdpi/extra_gem_cap_left.png b/Habitica/res/drawable-xhdpi/extra_gem_cap_left.png
new file mode 100644
index 000000000..597a47570
Binary files /dev/null and b/Habitica/res/drawable-xhdpi/extra_gem_cap_left.png differ
diff --git a/Habitica/res/drawable-xhdpi/extra_gem_cap_right.png b/Habitica/res/drawable-xhdpi/extra_gem_cap_right.png
new file mode 100644
index 000000000..baf951bae
Binary files /dev/null and b/Habitica/res/drawable-xhdpi/extra_gem_cap_right.png differ
diff --git a/Habitica/res/drawable-xhdpi/gem_gold_left.png b/Habitica/res/drawable-xhdpi/gem_gold_left.png
new file mode 100644
index 000000000..cb8a9643b
Binary files /dev/null and b/Habitica/res/drawable-xhdpi/gem_gold_left.png differ
diff --git a/Habitica/res/drawable-xhdpi/gem_gold_right.png b/Habitica/res/drawable-xhdpi/gem_gold_right.png
new file mode 100644
index 000000000..a992da7ab
Binary files /dev/null and b/Habitica/res/drawable-xhdpi/gem_gold_right.png differ
diff --git a/Habitica/res/drawable-xxhdpi/extra_gem_cap_left.png b/Habitica/res/drawable-xxhdpi/extra_gem_cap_left.png
new file mode 100644
index 000000000..74b2e70ef
Binary files /dev/null and b/Habitica/res/drawable-xxhdpi/extra_gem_cap_left.png differ
diff --git a/Habitica/res/drawable-xxhdpi/extra_gem_cap_right.png b/Habitica/res/drawable-xxhdpi/extra_gem_cap_right.png
new file mode 100644
index 000000000..e19371219
Binary files /dev/null and b/Habitica/res/drawable-xxhdpi/extra_gem_cap_right.png differ
diff --git a/Habitica/res/drawable-xxhdpi/gem_gold_left.png b/Habitica/res/drawable-xxhdpi/gem_gold_left.png
new file mode 100644
index 000000000..4321b394b
Binary files /dev/null and b/Habitica/res/drawable-xxhdpi/gem_gold_left.png differ
diff --git a/Habitica/res/drawable-xxhdpi/gem_gold_right.png b/Habitica/res/drawable-xxhdpi/gem_gold_right.png
new file mode 100644
index 000000000..6bd13abf9
Binary files /dev/null and b/Habitica/res/drawable-xxhdpi/gem_gold_right.png differ
diff --git a/Habitica/res/drawable/gem_extra_progress.xml b/Habitica/res/drawable/gem_extra_progress.xml
new file mode 100644
index 000000000..d56a7122a
--- /dev/null
+++ b/Habitica/res/drawable/gem_extra_progress.xml
@@ -0,0 +1,47 @@
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
diff --git a/Habitica/res/drawable/layout_extra_rounded_teal_1.xml b/Habitica/res/drawable/layout_extra_rounded_teal_1.xml
new file mode 100644
index 000000000..2db80cfe8
--- /dev/null
+++ b/Habitica/res/drawable/layout_extra_rounded_teal_1.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/Habitica/res/layout/activity_gift_subscription.xml b/Habitica/res/layout/activity_gift_subscription.xml
index e76d416da..8336bb328 100644
--- a/Habitica/res/layout/activity_gift_subscription.xml
+++ b/Habitica/res/layout/activity_gift_subscription.xml
@@ -82,29 +82,27 @@
android:layout_marginStart="@dimen/spacing_large"
android:layout_marginEnd="@dimen/spacing_large"
android:layout_marginBottom="@dimen/spacing_large">
-
+
-
+ app:isNonRecurring="true"
+ app:isGifted="true" />
-
-
-
-
+ app:isNonRecurring="true"
+ app:isGifted="true" />
-
-
+ app:flagText="@string/popular"
+ app:isGifted="true" />
-
+ android:layout_marginTop="8dp">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:padding="18dp">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_height="wrap_content"
+ android:paddingHorizontal="6dp" />
-
+ android:layout_marginTop="8dp">
+
+
+
+
+
+
+
+
+
+ android:layout_marginBottom="32dp"
+ android:layout_marginHorizontal="14dp"/>
+ android:scaleType="centerCrop" />
+
+
+ android:textSize="14sp"
+ android:textStyle="italic" />
+
+
diff --git a/Habitica/res/layout/purchase_subscription_view.xml b/Habitica/res/layout/purchase_subscription_view.xml
index 517537663..6acaaee91 100644
--- a/Habitica/res/layout/purchase_subscription_view.xml
+++ b/Habitica/res/layout/purchase_subscription_view.xml
@@ -13,15 +13,18 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
-
-
+
+ android:layout_gravity="center">
@@ -90,7 +93,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="@string/subscribe1month_gemcap"
- android:textSize="12sp"
+ android:textSize="14sp"
android:textColor="@color/brand_600"
android:layout_marginTop="4dp"
android:drawableStart="@drawable/sub_plus"
@@ -103,14 +106,14 @@
android:layout_height="wrap_content"
tools:text="+1 Mystic Hourglass"
android:textColor="@color/brand_600"
- android:textSize="12sp"
+ android:textSize="14sp"
android:layout_marginTop="4dp"
android:drawableStart="@drawable/sub_plus"
android:drawableTint="@color/brand_400"
android:drawablePadding="8dp" />
-
+
+ android:src="@drawable/subscription_selected_indicator" />
diff --git a/Habitica/res/layout/subscription_benefits.xml b/Habitica/res/layout/subscription_benefits.xml
index c4b9074f1..0fa696195 100644
--- a/Habitica/res/layout/subscription_benefits.xml
+++ b/Habitica/res/layout/subscription_benefits.xml
@@ -41,7 +41,7 @@
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textSize="13sp"
+ android:textSize="14sp"
android:text="@string/subscribe_listitem1_description"
android:textColor="@color/white" />
@@ -81,7 +81,7 @@
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textSize="13sp"
+ android:textSize="14sp"
android:text="@string/subscribe_listitem3_description"
android:textColor="@color/white" />
@@ -122,7 +122,7 @@
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textSize="13sp"
+ android:textSize="14sp"
android:text="@string/subscribe_listitem2_description"
android:textColor="@color/white" />
@@ -163,7 +163,7 @@
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textSize="13sp"
+ android:textSize="14sp"
android:text="@string/subscribe_listitemFaint_description"
android:textColor="@color/white" />
@@ -203,7 +203,7 @@
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textSize="13sp"
+ android:textSize="14sp"
android:text="@string/subscribe_listitemArmoire_description"
android:textColor="@color/white" />
@@ -220,7 +220,7 @@
android:layout_height="72dp"
android:background="@drawable/subscription_box_bg"
android:scaleType="center"
- android:src="@drawable/sub_benefits_drops"
+ android:src="@drawable/sub_benefits_pet"
android:importantForAccessibility="no" />
diff --git a/Habitica/res/layout/subscription_details.xml b/Habitica/res/layout/subscription_details.xml
index 650178657..2d9baecb9 100644
--- a/Habitica/res/layout/subscription_details.xml
+++ b/Habitica/res/layout/subscription_details.xml
@@ -20,7 +20,7 @@
android:text="@string/thanks_for_subscribing"
android:textColor="@color/white"
android:textSize="17sp"
- android:layout_gravity="center_horizontal"
+ android:gravity="center_horizontal"
android:fontFamily="@string/font_family_medium"
android:layout_marginBottom="14dp"/>
@@ -319,7 +319,7 @@
android:layout_height="wrap_content"
android:text="@string/subscription_details_footer"
android:textColor="@color/white"
- android:textSize="13sp"
+ android:textSize="14sp"
android:textStyle="italic"
android:layout_marginTop="4dp"
android:layout_marginHorizontal="16dp"
diff --git a/Habitica/res/values/attrs.xml b/Habitica/res/values/attrs.xml
index 40752e049..59e802ebc 100644
--- a/Habitica/res/values/attrs.xml
+++ b/Habitica/res/values/attrs.xml
@@ -47,6 +47,7 @@
+
diff --git a/Habitica/res/values/strings.xml b/Habitica/res/values/strings.xml
index d4586e1ac..a51d64d54 100644
--- a/Habitica/res/values/strings.xml
+++ b/Habitica/res/values/strings.xml
@@ -928,7 +928,8 @@
Party Activity
Need Gems?
Become a Subscriber to buy Gems with gold, get monthly mystery items, increased drop caps and more!
- See Other Options
+ See other options
+ See other subscription options
Gift Gems
Send\nMessage
Gift\nGems
@@ -1170,10 +1171,10 @@
Tap ‘Gift a Subscription’ and type in the username of the account you’d like to gift to. From there, pick the sub length you’d like to gift and check out. Your account will automatically be rewarded with the same level of subscription you just gifted.
This is a limited time event that starts on %1$s (%2$s) and will end %3$s (%4$s). This promotion only applies when you gift to another Habitican. If you or your gift recipient already have a subscription, the gifted subscription will add months of credit that will only be used after the current subscription is cancelled or expires.
Gift a sub and get a sub for free until %s
- 1 month one-time subscription
- 3 month one-time subscription
- 6 month one-time subscription
- 12 month one-time subscription
+ 1 month
+ 3 months
+ 6 months
+ 12 months
Teams
Team Information
You open the Mystery Box and find…
@@ -1537,9 +1538,11 @@
Clear Database
Clear Cache
Best Deal
- Unlock %d Gems per month instantly
+ Unlock %d Gems per month instantly
+ Unlocks %d Gems per month instantly
%d Gems
Earn +2 Gems every month you\'re subscribed
+ Earns +2 Gems every month they\'re subscribed
+2 Gems
Popular
Choose Member
@@ -1553,6 +1556,8 @@
12 Mystic Hourglasses
Thanks for subscribing
Set
+ Resubscribe to pick up where you left off!
+ %d/%d Gem Cap
- You
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/models/user/SubscriptionPlan.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/models/user/SubscriptionPlan.kt
index 80bae9fa2..39ffbec4e 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/models/user/SubscriptionPlan.kt
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/models/user/SubscriptionPlan.kt
@@ -41,11 +41,7 @@ open class SubscriptionPlan : RealmObject(), BaseObject {
val totalNumberOfGems: Int
get() {
- return if (isActive) {
- 24 + (consecutive?.gemCapExtra ?: 0)
- } else {
- 0
- }
+ return 24 + (consecutive?.gemCapExtra ?: 0)
}
val numberOfGemsLeft: Int
@@ -53,23 +49,6 @@ open class SubscriptionPlan : RealmObject(), BaseObject {
return totalNumberOfGems - (gemsBought ?: 0)
}
- /*
- If user has a initial basic monthly subscription, receive hourglasses on fourth month,
- else receive on third month (subtract 1 from total consecutive count)
- */
-
- val subMonthCount: Int
- get() {
- return when (planId) {
- "basic_earned" -> 1
- "basic_3mo" -> 3
- "basic_6mo" -> 6
- "google_6mo" -> 6
- "basic_12mo" -> 12
- "group_plan_auto" -> 1
- else -> 0
- }
- }
val monthsUntilNextHourglass: Int
get() {
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/GiftSubscriptionActivity.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/GiftSubscriptionActivity.kt
index eb619f4ef..685defc9e 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/GiftSubscriptionActivity.kt
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/GiftSubscriptionActivity.kt
@@ -1,8 +1,10 @@
package com.habitrpg.android.habitica.ui.activities
import android.annotation.SuppressLint
+import android.graphics.Color
import android.os.Bundle
import android.view.View
+import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import androidx.navigation.navArgs
import com.android.billingclient.api.ProductDetails
@@ -10,6 +12,7 @@ import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.data.SocialRepository
import com.habitrpg.android.habitica.databinding.ActivityGiftSubscriptionBinding
import com.habitrpg.android.habitica.extensions.addCloseButton
+import com.habitrpg.android.habitica.extensions.updateStatusBarColor
import com.habitrpg.android.habitica.helpers.AppConfigManager
import com.habitrpg.android.habitica.helpers.PurchaseHandler
import com.habitrpg.android.habitica.helpers.PurchaseTypes
@@ -57,7 +60,7 @@ class GiftSubscriptionActivity : PurchaseActivity() {
super.onCreate(savedInstanceState)
setTitle(R.string.gift_subscription)
- setSupportActionBar(binding.toolbar)
+ setupToolbar(binding.toolbar, Color.WHITE, ContextCompat.getColor(this, R.color.brand_300))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
@@ -114,6 +117,11 @@ class GiftSubscriptionActivity : PurchaseActivity() {
}
}
+ override fun onResume() {
+ super.onResume()
+ window.updateStatusBarColor(ContextCompat.getColor(this, R.color.brand_300), false)
+ }
+
private fun showMemberLoadingErrorDialog() {
val dialog = HabiticaAlertDialog(this@GiftSubscriptionActivity)
dialog.setTitle(R.string.error_loading_member)
@@ -131,8 +139,10 @@ class GiftSubscriptionActivity : PurchaseActivity() {
for (sku in skus) {
updateButtonLabel(sku)
}
- skus.minByOrNull { it.oneTimePurchaseOfferDetails?.priceAmountMicros ?: 0 }
- ?.let { selectSubscription(it) }
+ if (selectedSubscriptionSku == null) {
+ skus.maxByOrNull { it.oneTimePurchaseOfferDetails?.priceAmountMicros ?: 0 }
+ ?.let { selectSubscription(it) }
+ }
}
}
}
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/EventOutcomeSubscriptionBottomSheetFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/EventOutcomeSubscriptionBottomSheetFragment.kt
index fd63050d1..2c5971916 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/EventOutcomeSubscriptionBottomSheetFragment.kt
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/EventOutcomeSubscriptionBottomSheetFragment.kt
@@ -37,6 +37,7 @@ class EventOutcomeSubscriptionBottomSheetFragment : SubscriptionBottomSheetFragm
binding.content.subscribeBenefitsTitle.text = getString(R.string.subscribe_gems_for_gold_incentive_text)
binding.content.subscriberBenefits.hideGemsForGoldBenefit()
binding.content.subscription3month.visibility = View.GONE
+ binding.content.gemsForGoldBanner.isVisible = true
}
private fun setHourglassShopEventSubscriptionViews() {
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/SubscriptionBottomSheetFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/SubscriptionBottomSheetFragment.kt
index 544f537bd..284bcf1f2 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/SubscriptionBottomSheetFragment.kt
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/SubscriptionBottomSheetFragment.kt
@@ -6,6 +6,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import com.android.billingclient.api.ProductDetails
@@ -83,8 +84,16 @@ open class SubscriptionBottomSheetFragment : BottomSheetDialogFragment() {
binding.content.subscriptionDetails.visibility = View.GONE
binding.content.subscribeBenefitsFooter.visibility = View.GONE
binding.content.giftSegmentSubscribed.root.visibility = View.GONE
- binding.content.giftSegmentUnsubscribed.root.visibility = View.VISIBLE
+ binding.content.giftSegmentUnsubscribed.root.visibility = View.GONE
+ binding.content.headerImageView.visibility = View.GONE
binding.content.subscriptionDisclaimerView.visibility = View.VISIBLE
+ binding.content.seeMoreButton.visibility = View.VISIBLE
+
+ binding.content.seeMoreButton.setOnClickListener {
+ MainNavigationController.navigate(R.id.gemPurchaseActivity,
+ bundleOf(Pair("openSubscription", true))
+ )
+ }
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@@ -124,12 +133,14 @@ open class SubscriptionBottomSheetFragment : BottomSheetDialogFragment() {
?: "",
)
}
- subscriptions
- .filter { buttonForSku(it)?.isVisible == true }
- .minByOrNull {
- it.subscriptionOfferDetails?.firstOrNull()?.pricingPhases?.pricingPhaseList?.firstOrNull()?.priceAmountMicros
- ?: 0
- }?.let { selectSubscription(it) }
+ if (selectedSubscriptionSku == null) {
+ subscriptions
+ .filter { buttonForSku(it)?.isVisible == true }
+ .maxByOrNull {
+ it.subscriptionOfferDetails?.firstOrNull()?.pricingPhases?.pricingPhaseList?.firstOrNull()?.priceAmountMicros
+ ?: 0
+ }?.let { selectSubscription(it) }
+ }
hasLoadedSubscriptionOptions = true
updateSubscriptionInfo()
}
@@ -197,6 +208,18 @@ open class SubscriptionBottomSheetFragment : BottomSheetDialogFragment() {
if (user != null) {
binding.content.loadingIndicator.visibility = View.GONE
binding.content.subscription12month.showHourglassPromo(user?.purchased?.plan?.isEligableForHourglassPromo == true)
+ val totalGemCap = user?.purchased?.plan?.totalNumberOfGems ?: 24
+ binding.content.subscription1month.gemCap = totalGemCap
+ binding.content.subscription3month.gemCap = totalGemCap
+ binding.content.subscription6month.gemCap = totalGemCap
+
+ if (totalGemCap > 24) {
+ binding.content.existingGemCapBonusView.visibility = View.VISIBLE
+ binding.content.gemCapExtraLabel.text = getString(R.string.gem_cap_extra, totalGemCap - 24, 50)
+ binding.content.extraGemsProgress.progress = totalGemCap
+ } else {
+ binding.content.existingGemCapBonusView.visibility = View.GONE
+ }
}
}
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/SubscriptionFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/SubscriptionFragment.kt
index 232a112a6..6ac30884d 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/SubscriptionFragment.kt
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/purchases/SubscriptionFragment.kt
@@ -189,10 +189,12 @@ class SubscriptionFragment : BaseFragment() {
?: "",
)
}
- subscriptions.maxByOrNull {
- it.subscriptionOfferDetails?.firstOrNull()?.pricingPhases?.pricingPhaseList?.firstOrNull()?.priceAmountMicros
- ?: 0
- }?.let { selectSubscription(it) }
+ if (selectedSubscriptionSku == null) {
+ subscriptions.maxByOrNull {
+ it.subscriptionOfferDetails?.firstOrNull()?.pricingPhases?.pricingPhaseList?.firstOrNull()?.priceAmountMicros
+ ?: 0
+ }?.let { selectSubscription(it) }
+ }
hasLoadedSubscriptionOptions = true
updateSubscriptionInfo()
}
@@ -275,7 +277,9 @@ class SubscriptionFragment : BaseFragment() {
binding?.content?.giftSegmentUnsubscribed?.root?.visibility = View.GONE
binding?.content?.giftSegmentSubscribed?.root?.visibility = View.VISIBLE
binding?.content?.subscribeBenefitsTitle?.visibility = View.GONE
+ binding?.content?.subscribeBenefitsFooter?.visibility = View.VISIBLE
binding?.content?.subscriptionDisclaimerView?.visibility = View.GONE
+ binding?.content?.existingGemCapBonusView?.visibility = View.GONE
} else {
binding?.content?.headerImageView?.setImageResource(R.drawable.subscribe_header_dark)
if (!hasLoadedSubscriptionOptions) {
@@ -289,6 +293,19 @@ class SubscriptionFragment : BaseFragment() {
binding?.content?.giftSegmentUnsubscribed?.root?.visibility = View.VISIBLE
binding?.content?.subscriptionDisclaimerView?.visibility = View.VISIBLE
+ val totalGemCap = user?.purchased?.plan?.totalNumberOfGems ?: 24
+ binding?.content?.subscription1month?.gemCap = totalGemCap
+ binding?.content?.subscription3month?.gemCap = totalGemCap
+ binding?.content?.subscription6month?.gemCap = totalGemCap
+
+ if (totalGemCap > 24) {
+ binding?.content?.existingGemCapBonusView?.visibility = View.VISIBLE
+ binding?.content?.gemCapExtraLabel?.text = getString(R.string.gem_cap_extra, totalGemCap, 50)
+ binding?.content?.extraGemsProgress?.progress = totalGemCap
+ } else {
+ binding?.content?.existingGemCapBonusView?.visibility = View.GONE
+ }
+
binding?.content?.subscription12month?.showHourglassPromo(user?.purchased?.plan?.isEligableForHourglassPromo == true)
}
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/subscriptions/SubscriptionOptionView.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/subscriptions/SubscriptionOptionView.kt
index 2a8e16f13..3d067812a 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/subscriptions/SubscriptionOptionView.kt
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/subscriptions/SubscriptionOptionView.kt
@@ -1,6 +1,9 @@
package com.habitrpg.android.habitica.ui.views.subscriptions
+import android.animation.ArgbEvaluator
+import android.animation.ValueAnimator
import android.content.Context
+import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.LinearGradient
import android.graphics.Shader
@@ -26,7 +29,17 @@ class SubscriptionOptionView(context: Context, attrs: AttributeSet) : FrameLayou
var sku: String? = null
private var isPromoted: Boolean = false
- private var gemCap: Int = 24
+ private var isGifted: Boolean = false
+ var gemCap: Int = 24
+ set(value) {
+ field = value
+ updateGemCapText()
+ }
+ private var isSubscriptionSelected = false
+ set(value) {
+ field = value
+ updateGemCapText()
+ }
init {
val a = context.theme.obtainStyledAttributes(
@@ -36,6 +49,8 @@ class SubscriptionOptionView(context: Context, attrs: AttributeSet) : FrameLayou
0,
)
+ isGifted = a.getBoolean(R.styleable.SubscriptionOptionView_isGifted, false)
+
if (a.getBoolean(R.styleable.SubscriptionOptionView_isNonRecurring, false)) {
binding.descriptionTextView.text = context.getString(
R.string.subscription_duration_norenew,
@@ -49,15 +64,17 @@ class SubscriptionOptionView(context: Context, attrs: AttributeSet) : FrameLayou
}
gemCap = a.getInteger(R.styleable.SubscriptionOptionView_gemCapText, 24)
- setGemCapText(false)
+ updateGemCapText()
setAddtlGemText(false)
setFlagText(a.getText(R.styleable.SubscriptionOptionView_flagText))
+
+ binding.selectedIndicator.translationX = -binding.selectedIndicator.drawable.intrinsicWidth.toFloat()
}
- private fun setGemCapText(isSelected: Boolean) {
- binding.gemCapTextView.text = highlightText(context.getString(R.string.unlocks_x_gems_per_month, gemCap),
+ private fun updateGemCapText() {
+ binding.gemCapTextView.text = highlightText(context.getString(if (isGifted) R.string.unlock_x_gems_per_month else R.string.unlock_x_gems_per_month, gemCap),
context.getString(R.string.x_gems, gemCap),
- ContextCompat.getColor(context, if (isSelected) R.color.yellow_5 else R.color.white))
+ ContextCompat.getColor(context, if (isSubscriptionSelected) R.color.yellow_5 else R.color.white))
}
private fun setAddtlGemText(isSelected: Boolean) {
@@ -69,7 +86,7 @@ class SubscriptionOptionView(context: Context, attrs: AttributeSet) : FrameLayou
)
} else {
binding.hourglassTextView.text = highlightText(
- context.getString(R.string.two_gems_per_month),
+ context.getString(if (isGifted) R.string.two_gems_per_month_gift else R.string.two_gems_per_month),
context.getString(R.string.plus_two_gems),
ContextCompat.getColor(context, if (isSelected) R.color.yellow_5 else R.color.white)
)
@@ -124,9 +141,24 @@ class SubscriptionOptionView(context: Context, attrs: AttributeSet) : FrameLayou
return spannable
}
+ fun animateBackgroundColor(colorFrom: Int, colorTo: Int) {
+ val colorAnimation = ValueAnimator.ofObject(ArgbEvaluator(), colorFrom, colorTo)
+ colorAnimation.setDuration(350) // milliseconds
+ colorAnimation.addUpdateListener { animator -> binding.root.backgroundTintList = ColorStateList.valueOf(animator.animatedValue as Int) }
+ colorAnimation.start()
+ }
+
fun setIsSelected(purchased: Boolean) {
+ if (isSubscriptionSelected == purchased) return
+ isSubscriptionSelected = purchased
if (purchased) {
- binding.selectedIndicator.visibility = View.VISIBLE
+ binding.selectedIndicator.animate()
+ .withStartAction { binding.selectedIndicator.alpha = 1f }
+ .translationX(0f)
+ .setDuration(250)
+ .setStartDelay(400)
+ .start()
+ animateBackgroundColor(ContextCompat.getColor(context, R.color.brand_200), ContextCompat.getColor(context, R.color.white))
binding.root.setBackgroundResource(R.drawable.subscription_box_bg_selected)
val textColor = if (isPromoted) {
ContextCompat.getColor(context, R.color.teal_1)
@@ -134,7 +166,6 @@ class SubscriptionOptionView(context: Context, attrs: AttributeSet) : FrameLayou
ContextCompat.getColor(context, R.color.brand_300)
}
binding.gemCapTextView.setTextColor(textColor)
- setGemCapText(true)
binding.hourglassTextView.setTextColor(textColor)
setAddtlGemText(true)
if (!isPromoted) {
@@ -146,15 +177,21 @@ class SubscriptionOptionView(context: Context, attrs: AttributeSet) : FrameLayou
TextViewCompat.setCompoundDrawableTintList(binding.hourglassTextView, ContextCompat.getColorStateList(context, R.color.yellow_100))
}
} else {
- binding.selectedIndicator.visibility = View.GONE
- binding.root.setBackgroundResource(R.drawable.subscription_type_box_bg)
+ binding.selectedIndicator.animate()
+ .alpha(0f)
+ .setStartDelay(0)
+ .setDuration(200)
+ .withEndAction {
+ binding.selectedIndicator.translationX = -binding.selectedIndicator.drawable.intrinsicWidth.toFloat()
+ }
+ .start()
+ animateBackgroundColor(ContextCompat.getColor(context, R.color.white), ContextCompat.getColor(context, R.color.brand_200))
binding.gemCapTextView.setTextColor(
ContextCompat.getColor(
context,
R.color.brand_600,
),
)
- setGemCapText(false)
binding.hourglassTextView.setTextColor(
ContextCompat.getColor(
context,
diff --git a/version.properties b/version.properties
index b45fd4f2c..68460da1c 100644
--- a/version.properties
+++ b/version.properties
@@ -1,2 +1,2 @@
NAME=4.4.3
-CODE=8171
\ No newline at end of file
+CODE=8201
\ No newline at end of file