subscription display fixes

This commit is contained in:
Phillip Thelen 2024-10-31 13:16:07 +01:00
parent f46b1f8a4f
commit e4bf648095
15 changed files with 48 additions and 20 deletions

View file

@ -76,7 +76,7 @@
android:layout_marginEnd="84dp" android:layout_marginEnd="84dp"
android:gravity="center" android:gravity="center"
android:textColor="@color/white" android:textColor="@color/white"
android:layout_marginBottom="6dp" /> android:layout_marginBottom="4dp" />
<TextView <TextView
android:id="@+id/promo_banner_subtitle_text" android:id="@+id/promo_banner_subtitle_text"
@ -84,7 +84,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold" android:fontFamily="@string/font_family_medium"
android:layout_marginStart="84dp" android:layout_marginStart="84dp"
android:layout_marginEnd="84dp" android:layout_marginEnd="84dp"
android:gravity="center" android:gravity="center"

View file

@ -2,7 +2,8 @@
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools"
android:background="?colorContentBackground">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -120,7 +120,7 @@
android:textStyle="bold" android:textStyle="bold"
android:gravity="center" android:gravity="center"
android:textColor="@color/white" android:textColor="@color/white"
android:layout_marginBottom="6dp" /> android:layout_marginBottom="4dp" />
<TextView <TextView
android:id="@+id/promo_banner_subtitle_text" android:id="@+id/promo_banner_subtitle_text"
@ -128,7 +128,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold" android:fontFamily="@string/font_family_medium"
android:gravity="center" android:gravity="center"
android:textColor="@color/white" android:textColor="@color/white"
android:layout_marginBottom="6dp" /> android:layout_marginBottom="6dp" />

View file

@ -33,6 +33,7 @@ open class RealmContentLocalRepository(realm: Realm) :
realm1.insertOrUpdate(contentResult.appearances) realm1.insertOrUpdate(contentResult.appearances)
realm1.insertOrUpdate(contentResult.backgrounds) realm1.insertOrUpdate(contentResult.backgrounds)
realm1.insertOrUpdate(contentResult.faq) realm1.insertOrUpdate(contentResult.faq)
realm1.insertOrUpdate(contentResult.mystery)
} }
} }

View file

@ -464,7 +464,6 @@ class RealmInventoryLocalRepository(realm: Realm) :
private fun getLatestMysterySet(): Flow<EquipmentSet?> { private fun getLatestMysterySet(): Flow<EquipmentSet?> {
return realm.where(EquipmentSet::class.java) return realm.where(EquipmentSet::class.java)
.equalTo("pinType", "mystery_set")
.sort("key", Sort.DESCENDING) .sort("key", Sort.DESCENDING)
.findAll() .findAll()
.toFlow() .toFlow()

View file

@ -57,6 +57,7 @@ class PurchaseHandler(
private val context: Context, private val context: Context,
private val apiClient: ApiClient, private val apiClient: ApiClient,
private val userViewModel: MainUserViewModel, private val userViewModel: MainUserViewModel,
private val configManager: AppConfigManager
) : PurchasesUpdatedListener, PurchasesResponseListener { ) : PurchasesUpdatedListener, PurchasesResponseListener {
private var billingClient = private var billingClient =
BillingClient.newBuilder(context).setListener(this).enablePendingPurchases().build() BillingClient.newBuilder(context).setListener(this).enablePendingPurchases().build()
@ -383,7 +384,7 @@ class PurchaseHandler(
consume(purchase) consume(purchase)
} }
if (response != null) { if (response != null) {
displayConfirmationDialog(purchase, gift?.third) displayConfirmationDialog(purchase, gift?.second, gift?.third)
} }
} catch (throwable: Throwable) { } catch (throwable: Throwable) {
handleError(throwable, purchase) handleError(throwable, purchase)
@ -402,7 +403,7 @@ class PurchaseHandler(
consume(purchase) consume(purchase)
} }
if (response != null) { if (response != null) {
displayConfirmationDialog(purchase, gift?.third) displayConfirmationDialog(purchase, gift?.second, gift?.third)
} }
} catch (throwable: Throwable) { } catch (throwable: Throwable) {
handleError(throwable, purchase) handleError(throwable, purchase)
@ -574,6 +575,7 @@ class PurchaseHandler(
private fun displayConfirmationDialog( private fun displayConfirmationDialog(
purchase: Purchase, purchase: Purchase,
giftedToID: String? = null,
giftedTo: String? = null, giftedTo: String? = null,
) { ) {
if (displayedConfirmations.contains(purchase.orderId)) { if (displayedConfirmations.contains(purchase.orderId)) {
@ -591,7 +593,11 @@ class PurchaseHandler(
PurchaseTypes.allSubscriptionNoRenewTypes.contains(sku) -> { PurchaseTypes.allSubscriptionNoRenewTypes.contains(sku) -> {
title = context.getString(R.string.gift_confirmation_title) title = context.getString(R.string.gift_confirmation_title)
context.getString( context.getString(
R.string.gift_confirmation_text_sub, if (configManager.activePromo()?.identifier == "g1g1" && giftedToID != userViewModel.user.value?.id) {
R.string.gift_confirmation_text_sub_g1g1
} else {
R.string.gift_confirmation_text_sub
},
giftedTo, giftedTo,
durationString(sku), durationString(sku),
) )
@ -629,6 +635,11 @@ class PurchaseHandler(
message?.let { alert.setMessage(it) } message?.let { alert.setMessage(it) }
alert.addOkButton { dialog, _ -> alert.addOkButton { dialog, _ ->
dialog.dismiss() dialog.dismiss()
if (giftedTo != null) {
if (activity is PurchaseActivity) {
activity.finish()
}
}
} }
alert.enqueue() alert.enqueue()
} }

View file

@ -3,6 +3,7 @@ package com.habitrpg.android.habitica.models
import com.habitrpg.android.habitica.models.inventory.Customization import com.habitrpg.android.habitica.models.inventory.Customization
import com.habitrpg.android.habitica.models.inventory.Egg import com.habitrpg.android.habitica.models.inventory.Egg
import com.habitrpg.android.habitica.models.inventory.Equipment import com.habitrpg.android.habitica.models.inventory.Equipment
import com.habitrpg.android.habitica.models.inventory.EquipmentSet
import com.habitrpg.android.habitica.models.inventory.Food import com.habitrpg.android.habitica.models.inventory.Food
import com.habitrpg.android.habitica.models.inventory.HatchingPotion import com.habitrpg.android.habitica.models.inventory.HatchingPotion
import com.habitrpg.android.habitica.models.inventory.Mount import com.habitrpg.android.habitica.models.inventory.Mount
@ -29,4 +30,5 @@ class ContentResult {
var backgrounds = RealmList<Customization>() var backgrounds = RealmList<Customization>()
var faq = RealmList<FAQArticle>() var faq = RealmList<FAQArticle>()
var special = RealmList<SpecialItem>() var special = RealmList<SpecialItem>()
var mystery = RealmList<EquipmentSet>()
} }

View file

@ -81,13 +81,13 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
binding.promoBannerLeftImage.setImageDrawable( binding.promoBannerLeftImage.setImageDrawable(
ContextCompat.getDrawable( ContextCompat.getDrawable(
context, context,
R.drawable.g1g1_promo_left_small, R.drawable.g1g1_promo_left,
), ),
) )
binding.promoBannerRightImage.setImageDrawable( binding.promoBannerRightImage.setImageDrawable(
ContextCompat.getDrawable( ContextCompat.getDrawable(
context, context,
R.drawable.g1g1_promo_right_small, R.drawable.g1g1_promo_right,
), ),
) )
binding.promoBannerTitleImage.visibility = View.GONE binding.promoBannerTitleImage.visibility = View.GONE
@ -107,13 +107,13 @@ class GiftOneGetOneHabiticaPromotion(startDate: Date?, endDate: Date?) : Habitic
binding.content.promoBannerLeftImage.setImageDrawable( binding.content.promoBannerLeftImage.setImageDrawable(
ContextCompat.getDrawable( ContextCompat.getDrawable(
context, context,
R.drawable.g1g1_promo_left_small, R.drawable.g1g1_promo_left,
), ),
) )
binding.content.promoBannerRightImage.setImageDrawable( binding.content.promoBannerRightImage.setImageDrawable(
ContextCompat.getDrawable( ContextCompat.getDrawable(
context, context,
R.drawable.g1g1_promo_right_small, R.drawable.g1g1_promo_right,
), ),
) )
binding.content.promoBannerTitleImage.visibility = View.GONE binding.content.promoBannerTitleImage.visibility = View.GONE

View file

@ -215,7 +215,8 @@ class UserRepositoryModule {
@ApplicationContext context: Context, @ApplicationContext context: Context,
apiClient: ApiClient, apiClient: ApiClient,
userViewModel: MainUserViewModel, userViewModel: MainUserViewModel,
appConfigManager: AppConfigManager
): PurchaseHandler { ): PurchaseHandler {
return PurchaseHandler(context, apiClient, userViewModel) return PurchaseHandler(context, apiClient, userViewModel, appConfigManager)
} }
} }

View file

@ -7,6 +7,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.habitrpg.android.habitica.R import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.extensions.hideKeyboard
import com.habitrpg.android.habitica.extensions.updateStatusBarColor import com.habitrpg.android.habitica.extensions.updateStatusBarColor
import com.habitrpg.android.habitica.ui.fragments.purchases.GemsPurchaseFragment import com.habitrpg.android.habitica.ui.fragments.purchases.GemsPurchaseFragment
import com.habitrpg.android.habitica.ui.fragments.purchases.SubscriptionFragment import com.habitrpg.android.habitica.ui.fragments.purchases.SubscriptionFragment

View file

@ -211,16 +211,17 @@ class TaskFormActivity : BaseActivity() {
setSupportActionBar(binding.toolbar) setSupportActionBar(binding.toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true) supportActionBar?.setDisplayShowHomeEnabled(true)
tintColor = getThemeColor(R.attr.taskFormTint)
val upperTintColor =
if (forcedTheme == "taskform") getThemeColor(R.attr.taskFormTint) else getThemeColor(R.attr.colorAccent)
if (forcedTheme == "taskform" || forcedTheme == "maroon") { if (forcedTheme == "taskform" || forcedTheme == "maroon") {
ToolbarColorHelper.colorizeToolbar( ToolbarColorHelper.colorizeToolbar(
binding.toolbar, binding.toolbar,
this, this,
ContextCompat.getColor(this, R.color.white), ContextCompat.getColor(this, R.color.white),
upperTintColor
) )
} }
tintColor = getThemeColor(R.attr.taskFormTint)
val upperTintColor =
if (forcedTheme == "taskform") getThemeColor(R.attr.taskFormTint) else getThemeColor(R.attr.colorAccent)
supportActionBar?.setBackgroundDrawable(ColorDrawable(upperTintColor)) supportActionBar?.setBackgroundDrawable(ColorDrawable(upperTintColor))
binding.upperTextWrapper.setBackgroundColor(upperTintColor) binding.upperTextWrapper.setBackgroundColor(upperTintColor)

View file

@ -12,6 +12,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.replace
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.android.billingclient.api.ProductDetails import com.android.billingclient.api.ProductDetails
import com.habitrpg.android.habitica.R import com.habitrpg.android.habitica.R
@ -98,7 +99,8 @@ class GemsPurchaseFragment : BaseFragment<FragmentGemPurchaseBinding>() {
val fragment = PromoInfoFragment() val fragment = PromoInfoFragment()
parentFragmentManager parentFragmentManager
.beginTransaction() .beginTransaction()
.add(R.id.fragment_container, fragment as Fragment) .replace(R.id.fragment_container, fragment as Fragment)
.addToBackStack(null)
.commit() .commit()
} }
} else { } else {

View file

@ -14,6 +14,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.replace
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.android.billingclient.api.ProductDetails import com.android.billingclient.api.ProductDetails
import com.habitrpg.android.habitica.R import com.habitrpg.android.habitica.R
@ -121,7 +122,8 @@ class SubscriptionFragment : BaseFragment<FragmentSubscriptionBinding>() {
val fragment = PromoInfoFragment() val fragment = PromoInfoFragment()
parentFragmentManager parentFragmentManager
.beginTransaction() .beginTransaction()
.add(R.id.fragment_container, fragment as Fragment) .replace(R.id.fragment_container, fragment as Fragment)
.addToBackStack(null)
.commit() .commit()
} }
} else { } else {

View file

@ -14,6 +14,7 @@ import com.habitrpg.android.habitica.models.Skill
import com.habitrpg.android.habitica.models.inventory.Customization import com.habitrpg.android.habitica.models.inventory.Customization
import com.habitrpg.android.habitica.models.inventory.Egg import com.habitrpg.android.habitica.models.inventory.Egg
import com.habitrpg.android.habitica.models.inventory.Equipment import com.habitrpg.android.habitica.models.inventory.Equipment
import com.habitrpg.android.habitica.models.inventory.EquipmentSet
import com.habitrpg.android.habitica.models.inventory.Food import com.habitrpg.android.habitica.models.inventory.Food
import com.habitrpg.android.habitica.models.inventory.HatchingPotion import com.habitrpg.android.habitica.models.inventory.HatchingPotion
import com.habitrpg.android.habitica.models.inventory.Mount import com.habitrpg.android.habitica.models.inventory.Mount
@ -112,6 +113,12 @@ class ContentDeserializer : JsonDeserializer<ContentResult> {
} }
} }
if (obj.has("mystery")) {
for (entry in obj.get("mystery").asJsonObject.entrySet()) {
result.mystery.add(context.deserialize(entry.value, EquipmentSet::class.java))
}
}
result.appearances = result.appearances =
context.deserialize( context.deserialize(
obj.get("appearances"), obj.get("appearances"),

View file

@ -1,2 +1,2 @@
NAME=4.5.0 NAME=4.5.0
CODE=8711 CODE=8771