Skip to content

Commit

Permalink
update subscription page
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Aug 16, 2024
1 parent 975b409 commit fd0fe17
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 104 deletions.
10 changes: 4 additions & 6 deletions Habitica/res/layout/fragment_bottomsheet_subscription.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,22 @@
android:id="@+id/subscription1month"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:gemCapText="@string/subscribe1month_gemcap"
app:gemCapText="25"
app:recurringText="@string/month" />

<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription3month"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:gemCapText="@string/subscribe3month_gemcap"
app:hourGlassCount="1"
app:gemCapText="25"
app:recurringText="@string/three_months" />

<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription12month"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:flagText="@string/save_20"
app:gemCapText="@string/subscribe12month_gemcap"
app:hourGlassCount="4"
app:flagText="@string/popular"
app:gemCapText="50"
app:recurringText="@string/twelve_months" />

<Button
Expand Down
17 changes: 5 additions & 12 deletions Habitica/res/layout/fragment_subscription.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,34 +205,27 @@
android:id="@+id/subscription1month"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:gemCapText="@string/subscribe1month_gemcap"
app:gemCapText="25"
app:recurringText="@string/month" />

<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription3month"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:gemCapText="@string/subscribe3month_gemcap"
app:hourGlassCount="1"
app:gemCapText="25"
app:recurringText="@string/three_months" />

<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription6month"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:gemCapText="@string/subscribe6month_gemcap"
app:hourGlassCount="2"
app:gemCapText="25"
app:recurringText="@string/six_months" />

<com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionOptionView
android:id="@+id/subscription12month"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:flagText="@string/save_20"
app:gemCapText="@string/subscribe12month_gemcap"
app:hourGlassCount="4"
app:flagText="@string/popular"
app:gemCapText="50"
app:recurringText="@string/twelve_months" />

<Button
android:id="@+id/subscribeButton"
style="@style/HabiticaButton.Purple.Small"
Expand Down
79 changes: 14 additions & 65 deletions Habitica/res/layout/subscription_benefits.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,32 @@
</LinearLayout>

<LinearLayout
android:id="@+id/benefit_armoire_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<com.habitrpg.common.habitica.views.PixelArtView
android:id="@+id/sub_benefits_mystery_item_icon"
android:layout_width="68dp"
android:layout_height="68dp"
android:scaleType="center"
android:src="@drawable/sub_benefits_armoire" />

android:scaleType="center" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:orientation="vertical">

<TextView
style="@style/Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe_listitemArmoire"
android:text="@string/subscribe_listitem3"
android:textColor="@color/text_primary" />

<TextView
android:id="@+id/sub_benefits_mystery_item_text"
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe_listitemArmoire_description"
android:text="@string/subscribe_listitem3_description"
android:textColor="@color/gray100_gray400" />
</LinearLayout>
</LinearLayout>
Expand All @@ -81,28 +77,24 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:layout_width="68dp"
android:layout_height="68dp"
android:scaleType="center"
android:src="@drawable/sub_benefits_hourglasses"
android:importantForAccessibility="no" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:orientation="vertical">

<TextView
style="@style/Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe_listitem2"
android:textColor="@color/text_primary" />

<TextView
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
Expand All @@ -113,107 +105,64 @@
</LinearLayout>

<LinearLayout
android:id="@+id/benefit_faint_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<com.habitrpg.common.habitica.views.PixelArtView
android:id="@+id/sub_benefits_mystery_item_icon"
android:layout_width="68dp"
android:layout_height="68dp"
android:scaleType="center" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:orientation="vertical">

<TextView
style="@style/Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe_listitem3"
android:textColor="@color/text_primary" />

<TextView
android:id="@+id/sub_benefits_mystery_item_text"
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe_listitem3_description"
android:textColor="@color/gray100_gray400" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:layout_width="68dp"
android:layout_height="68dp"
android:scaleType="center"
android:src="@drawable/sub_benefits_pet"
android:src="@drawable/sub_benefits_faint"
android:importantForAccessibility="no" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:orientation="vertical">

<TextView
style="@style/Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe_listitem4"
android:text="@string/subscribe_listitemFaint"
android:textColor="@color/text_primary" />

<TextView
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe_listitem4_description"
android:text="@string/subscribe_listitemFaint_description"
android:textColor="@color/gray100_gray400" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:id="@+id/benefit_faint_wrapper"
android:id="@+id/benefit_armoire_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
<com.habitrpg.common.habitica.views.PixelArtView
android:layout_width="68dp"
android:layout_height="68dp"
android:scaleType="center"
android:src="@drawable/sub_benefits_faint"
android:importantForAccessibility="no" />

android:src="@drawable/sub_benefits_armoire" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:orientation="vertical">

<TextView
style="@style/Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe_listitemFaint"
android:text="@string/subscribe_listitemArmoire"
android:textColor="@color/text_primary" />

<TextView
style="@style/Caption2.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe_listitemFaint_description"
android:text="@string/subscribe_listitemArmoire_description"
android:textColor="@color/gray100_gray400" />
</LinearLayout>
</LinearLayout>
Expand Down
2 changes: 1 addition & 1 deletion Habitica/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<declare-styleable name="SubscriptionOptionView">
<attr name="recurringText" format="string" />
<attr name="gemCapText" format="string" />
<attr name="gemCapText" format="integer" />
<attr name="isNonRecurring" format="boolean" />
<attr name="hourGlassCount" format="integer" />
<attr name="flagText" format="string" />
Expand Down
18 changes: 11 additions & 7 deletions Habitica/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -393,23 +393,23 @@
<string name="has_tag">Has Tag</string>
<string name="subscribe_title">Subscribing supports our small team and help keeps Habitica running, thank you!</string>
<string name="subscribe_prompt">Become a subscriber to receive these exclusive benefits!</string>
<string name="subscribe_listitem1">Gold for Gems</string>
<string name="subscribe_listitem2">Mystic Hourglasses</string>
<string name="subscribe_listitem3">Exclusive Monthly Gear Sets</string>
<string name="subscribe_listitem1">Free Monthly Gems</string>
<string name="subscribe_listitem2">Monthly Mystic Hourglass</string>
<string name="subscribe_listitem3">Never miss an item with 1 Mystic Hourglass a month to use in the Time Travelers Shop!</string>
<string name="subscribe_listitem4">Special Subscriber Pet</string>
<string name="subscribe_listitemFaint">Hang on with 1 HP!</string>
<string name="subscribe_listitem5">Double the Drops</string>
<string name="subscribe_listitem5">Special Pet &amp; More Drops</string>
<string name="subscriptions">Subscriptions</string>
<string name="subscription_duration">Recurring every %s</string>
<string name="subscription_duration_norenew">For %s</string>
<string name="subscribe">Subscribe</string>
<string name="subscribe_listitem1_description">You’ll be able to buy Gems from the Market for 20 gold each!</string>
<string name="subscribe_listitem2_description">Earn Mystic Hourglasses to purchase items in the Time Traveler’s Shop!</string>
<string name="subscribe_listitem1_description">Get up to 50 Gems in the Market to buy Quests, Customizations, Pets, and more!</string>
<string name="subscribe_listitem2_description">Never miss an item with 1 Mystic Hourglass a month to use in the Time Travelers Shop!</string>
<string name="subscribe_listitem3_description">Subscribe now to get an exclusive set now and receive new items every month!</string>
<string name="subscribe_listitem3_description_new">Subscribe now to get this %s and receive new items every month!</string>
<string name="subscribe_listitem4_description">Receive the Royal Purple Jackalope pet when you become a new subscriber.</string>
<string name="subscribe_listitemFaint_description">You’ll have the option of a second chance when you run out of HP.</string>
<string name="subscribe_listitem5_description">Discover even more items in Habitica with a 2x bonus daily drop cap.</string>
<string name="subscribe_listitem5_description">Get a Royal Purple Jackalope plus double the Eggs, Hatching Potions, and Food each day to grow your Pet collection!</string>
<string name="subscribe1month_gemcap">25 Gems a month</string>
<string name="subscribe3month_gemcap">30 Gems a month</string>
<string name="subscribe6month_gemcap">35 Gems a month</string>
Expand Down Expand Up @@ -1533,6 +1533,10 @@
<string name="error_loading_gems">There was an error loading gems</string>
<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">Unlocks %d Gold-purchasable Gems per month</string>
<string name="two_gems_per_month">+2 Gems each month</string>
<string name="popular">Popular</string>

<plurals name="you_x_others">
<item quantity="zero">You</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ open class SubscriptionPlan : RealmObject(), BaseObject {

val monthsUntilNextHourglass: Int
get() {
return if (subMonthCount > 1) {
(consecutive?.offset ?: 0) + 1
} else {
(3 - perkMonthCount)
}
return 1
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ class SubscriptionDetailsView : LinearLayout {
val now = LocalDate.now()
val nextHourglassDate =
LocalDate.now().plusMonths(plan.monthsUntilNextHourglass.toLong())
.withDayOfMonth(1)
val format =
if (now.year != nextHourglassDate.year) {
"MMM YYYY"
"dd MMM yyyy"
} else {
"MMMM"
"dd MMMM"
}
val nextHourglassMonth = nextHourglassDate.format(DateTimeFormatter.ofPattern(format))
nextHourglassMonth?.let { binding.nextHourglassTextview.text = it }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ class SubscriptionOptionView(context: Context, attrs: AttributeSet) : FrameLayou
)
}

binding.gemCapTextView.text = a.getText(R.styleable.SubscriptionOptionView_gemCapText)
val gemCap = a.getInteger(R.styleable.SubscriptionOptionView_gemCapText, 25)
binding.gemCapTextView.text = context.getString(R.string.unlocks_x_gems_per_month, gemCap)
setFlagText(a.getText(R.styleable.SubscriptionOptionView_flagText))
val hourGlassCount = a.getInteger(R.styleable.SubscriptionOptionView_hourGlassCount, 0)
binding.hourglassTextView.visibility = View.VISIBLE
if (hourGlassCount != 0) {
if (gemCap < 50) {
binding.hourglassTextView.visibility = View.VISIBLE
binding.hourglassTextView.text =
context.getString(R.string.subscription_hourglasses, hourGlassCount)
context.getString(R.string.two_gems_per_month)
} else {
binding.hourglassTextView.text =
context.getString(R.string.subscription_hourglasses_3month_timeframe)
binding.hourglassTextView.visibility = View.GONE
}
}

Expand Down

0 comments on commit fd0fe17

Please sign in to comment.