Subscription page tweaks

This commit is contained in:
Phillip Thelen 2024-09-30 15:00:10 +02:00
parent c61d43be8d
commit c7468969c2
32 changed files with 399 additions and 113 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,018 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@id/background"
android:gravity="center_vertical|fill_horizontal">
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<size android:height="8dp" />
<solid android:color="@color/brand_100" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress"
android:gravity="center_vertical|fill_horizontal">
<scale android:scaleWidth="100%">
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<size android:height="8dp" />
<solid android:color="@color/yellow_100" />
</shape>
</scale>
</item>
<item android:id="@android:id/progress"
android:gravity="center_vertical|fill_horizontal">
<scale android:scaleWidth="100%">
<shape android:shape="rectangle"
android:tint="?attr/colorControlActivated">
<corners android:radius="4dp" />
<size android:height="8dp" />
<solid android:color="@color/white" />
</shape>
</scale>
</item>
</layer-list>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="12dp" />
<solid android:color="@color/teal_1" />
</shape>

View file

@ -82,29 +82,27 @@
android:layout_marginStart="@dimen/spacing_large"
android:layout_marginEnd="@dimen/spacing_large"
android:layout_marginBottom="@dimen/spacing_large">
<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription1MonthView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:recurringText="@string/one_month_one_time"
app:isNonRecurring="true"
app:isGifted="true" />
<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription3MonthView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:recurringText="@string/three_months_one_time"
app:isNonRecurring="true" />
app:isNonRecurring="true"
app:isGifted="true" />
<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription6MonthView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:recurringText="@string/six_months_one_time"
app:isNonRecurring="true" >
<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription1MonthView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:recurringText="@string/one_month_one_time"
app:isNonRecurring="true" />
</com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView>
app:isNonRecurring="true"
app:isGifted="true" />
<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription12MonthView"
android:layout_width="match_parent"
@ -112,23 +110,49 @@
app:recurringText="@string/twelve_months_one_time"
app:gemCapText="50"
app:isNonRecurring="true"
app:flagText="@string/popular">
app:flagText="@string/popular"
app:isGifted="true" />
</com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView>
<Button
android:text="@string/send_gift"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/subscription_button"
style="@style/HabiticaButton.Purple.Small"
android:textAllCaps="false"
android:layout_marginTop="8dp" />
android:layout_marginTop="8dp">
<com.facebook.shimmer.ShimmerFrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:shimmer_auto_start="true"
app:shimmer_repeat_delay="6000"
app:shimmer_duration="100"
app:shimmer_base_color="@color/yellow_100"
app:shimmer_base_alpha="1.0"
app:shimmer_highlight_alpha="1.0"
app:shimmer_colored="true"
app:shimmer_highlight_color="@color/yellow_400">
<View
style="@style/HabiticaButton"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/button_background" />
</com.facebook.shimmer.ShimmerFrameLayout>
<Button
android:id="@+id/subscription_button"
style="@style/HabiticaButton.Borderless"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="@string/send_gift"
android:textColor="@color/brand_100"
android:textAllCaps="false" />
</FrameLayout>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/subscription_bg" />
<LinearLayout
android:id="@+id/gift_subscription_container"
android:layout_width="match_parent"

View file

@ -9,11 +9,54 @@
android:scrollbarThumbVertical="@color/scrollbarThumb"
android:background="@color/brand_300"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/gems_for_gold_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:background="@drawable/layout_extra_rounded_teal_1"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gem_gold_left" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="18sp"
android:fontFamily="@string/font_family_medium"
android:text="@string/buy_gems_with_gold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:text="@string/subscriber_benefit"
android:textSize="10sp"
android:textColor="@color/white"
android:letterSpacing="0.15"
/>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gem_gold_right" />
</LinearLayout>
<androidx.compose.ui.platform.ComposeView
android:id="@+id/promo_compose_view"
android:layout_width="match_parent"
@ -103,7 +146,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="24dp">
android:padding="18dp">
<ImageView
android:id="@+id/header_image_view"
@ -130,9 +173,9 @@
<TextView
android:id="@+id/subscribeBenefitsTitle"
style="@style/SubHeader1"
android:layout_width="250dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginHorizontal="30dp"
android:layout_marginTop="8dp"
android:gravity="center"
android:lineSpacingExtra="4dp"
@ -141,10 +184,66 @@
<include layout="@layout/separator_fancy" />
<LinearLayout
android:id="@+id/existing_gem_cap_bonus_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="6dp"
android:paddingVertical="@dimen/spacing_large"
android:gravity="center"
android:visibility="gone">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/extra_gem_cap_left" />
<TextView
android:id="@+id/gem_cap_extra_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:fontFamily="@string/font_family_medium"
android:textColor="@color/white"
android:paddingHorizontal="8dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/extra_gem_cap_right" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/rescrubscribe_to_pick_up"
android:textSize="15sp"
android:textColor="@color/white"
android:gravity="center"
android:layout_marginBottom="6dp"
android:layout_marginTop="2dp"/>
<ProgressBar
android:id="@+id/extra_gems_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:progressDrawable="@drawable/gem_extra_progress"
android:progress="40"
android:max="50"
android:indeterminate="false"
android:progressTint="@color/green_100"/>
</LinearLayout>
<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriberBenefitView
android:id="@+id/subscriber_benefits"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:paddingHorizontal="6dp" />
<TextView
android:id="@+id/subscribeBenefitsFooter"
@ -222,27 +321,52 @@
app:gemCapText="50"
app:recurringText="@string/twelve_months" />
<Button
android:id="@+id/subscribeButton"
style="@style/HabiticaButton"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/subscribe"
android:textColor="@color/brand_100"
android:backgroundTint="@color/yellow_100"
android:textAllCaps="false" />
android:layout_marginTop="8dp">
<com.facebook.shimmer.ShimmerFrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:shimmer_auto_start="true"
app:shimmer_repeat_delay="6000"
app:shimmer_duration="100"
app:shimmer_base_color="@color/yellow_100"
app:shimmer_base_alpha="1.0"
app:shimmer_highlight_alpha="1.0"
app:shimmer_colored="true"
app:shimmer_highlight_color="@color/yellow_400">
<View
style="@style/HabiticaButton"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/button_background" />
</com.facebook.shimmer.ShimmerFrameLayout>
<Button
android:id="@+id/subscribeButton"
style="@style/HabiticaButton.Borderless"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="@string/subscribe"
android:textColor="@color/brand_100"
android:textAllCaps="false" />
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="13sp"
android:textSize="14sp"
android:textStyle="italic"
android:gravity="center"
android:text="@string/subscribe_title"
android:layout_marginTop="6dp"
android:layout_marginBottom="32dp" />
android:layout_marginBottom="32dp"
android:layout_marginHorizontal="14dp"/>
</LinearLayout>
<include
@ -256,8 +380,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/subscription_bg"
android:scaleType="centerCrop"
/>
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -266,14 +390,25 @@
android:paddingTop="6dp"
android:paddingBottom="32dp"
android:paddingHorizontal="24dp">
<TextView
android:id="@+id/subscription_disclaimer_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textColorLink="@color/yellow_100"
android:textSize="13sp"
android:textStyle="italic"/>
android:textSize="14sp"
android:textStyle="italic" />
<Button
android:id="@+id/see_more_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/see_more_subscription_options"
style="@style/HabiticaButton.Borderless"
android:textColor="@color/yellow_100"
android:visibility="gone"
/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -13,15 +13,18 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="12dp"
android:minHeight="126dp"
android:paddingStart="38dp"
android:paddingEnd="0dp"
android:paddingEnd="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:minHeight="126dp">
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
@ -76,7 +79,7 @@
android:layout_height="wrap_content"
android:id="@+id/descriptionTextView"
android:textColor="@color/brand_600"
android:textSize="13sp"
android:textSize="14sp"
android:textStyle="bold"
tools:text="recurring every month" />
@ -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" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<TextView
android:id="@+id/hourglass_promo_view"
android:layout_width="match_parent"
@ -131,6 +134,5 @@
android:id="@+id/selected_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/subscription_selected_indicator"
android:visibility="gone" />
android:src="@drawable/subscription_selected_indicator" />
</FrameLayout>

View file

@ -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" />
</LinearLayout>
@ -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" />
</LinearLayout>
@ -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" />
</LinearLayout>
@ -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" />
</LinearLayout>
@ -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" />
</LinearLayout>
@ -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" />
<LinearLayout
@ -242,7 +242,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_listitem5_description"
android:textColor="@color/white" />
</LinearLayout>

View file

@ -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"

View file

@ -47,6 +47,7 @@
<attr name="recurringText" format="string" />
<attr name="gemCapText" format="integer" />
<attr name="isNonRecurring" format="boolean" />
<attr name="isGifted" format="boolean" />
<attr name="hourGlassCount" format="integer" />
<attr name="flagText" format="string" />
</declare-styleable>

View file

@ -928,7 +928,8 @@
<string name="preference_push_party_activity">Party Activity</string>
<string name="promo_subscription_buy_gems_prompt">Need Gems?</string>
<string name="promo_subscription_buy_gems_description">Become a Subscriber to buy Gems with gold, get monthly mystery items, increased drop caps and more!</string>
<string name="see_other_options">See Other Options</string>
<string name="see_other_options">See other options</string>
<string name="see_other_sub_options">See other subscription options</string>
<string name="gift_gems">Gift Gems</string>
<string name="profile_send_message">Send\nMessage</string>
<string name="profile_gift_gems">Gift\nGems</string>
@ -1170,10 +1171,10 @@
<string name="g1g1_promo_info_instructions">Tap Gift a Subscription and type in the username of the account youd like to gift to. From there, pick the sub length youd like to gift and check out. Your account will automatically be rewarded with the same level of subscription you just gifted.</string>
<string name="g1g1_promo_info_limitations_fixed">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.</string>
<string name="gift_one_get_one_purchase_banner">Gift a sub and get a sub for free until %s</string>
<string name="one_month_one_time">1 month one-time subscription</string>
<string name="three_months_one_time">3 month one-time subscription</string>
<string name="six_months_one_time">6 month one-time subscription</string>
<string name="twelve_months_one_time">12 month one-time subscription</string>
<string name="one_month_one_time">1 month</string>
<string name="three_months_one_time">3 months</string>
<string name="six_months_one_time">6 months</string>
<string name="twelve_months_one_time">12 months</string>
<string name="sidebar_teams">Teams</string>
<string name="team_information">Team Information</string>
<string name="mystery_item_title">You open the Mystery Box and find…</string>
@ -1537,9 +1538,11 @@
<string name="clear_database">Clear Database</string>
<string name="clear_cache_settings">Clear Cache</string>
<string name="best_deal">Best Deal</string>
<string name="unlocks_x_gems_per_month">Unlock %d Gems per month instantly</string>
<string name="unlock_x_gems_per_month">Unlock %d Gems per month instantly</string>
<string name="unlocks_x_gems_per_month">Unlocks %d Gems per month instantly</string>
<string name="x_gems">%d Gems</string>
<string name="two_gems_per_month">Earn +2 Gems every month you\'re subscribed</string>
<string name="two_gems_per_month_gift">Earns +2 Gems every month they\'re subscribed</string>
<string name="plus_two_gems">+2 Gems</string>
<string name="popular">Popular</string>
<string name="choose_member">Choose Member</string>
@ -1553,6 +1556,8 @@
<string name="twelve_mystic_hourglasses">12 Mystic Hourglasses</string>
<string name="thanks_for_subscribing">Thanks for subscribing</string>
<string name="set">Set</string>
<string name="rescrubscribe_to_pick_up">Resubscribe to pick up where you left off!</string>
<string name="gem_cap_extra">%d/%d Gem Cap</string>
<plurals name="you_x_others">
<item quantity="zero">You</item>

View file

@ -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() {

View file

@ -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) }
}
}
}
}

View file

@ -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() {

View file

@ -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
}
}
}

View file

@ -189,10 +189,12 @@ class SubscriptionFragment : BaseFragment<FragmentSubscriptionBinding>() {
?: "",
)
}
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<FragmentSubscriptionBinding>() {
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<FragmentSubscriptionBinding>() {
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)
}

View file

@ -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,

View file

@ -1,2 +1,2 @@
NAME=4.4.3
CODE=8171
CODE=8201