mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-18 19:59:00 +00:00
Fix background handling
This commit is contained in:
parent
aad726ecf5
commit
9bac0372b5
9 changed files with 40 additions and 8 deletions
|
|
@ -151,7 +151,7 @@ android {
|
|||
multiDexEnabled true
|
||||
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
|
||||
|
||||
versionCode 2336
|
||||
versionCode 2338
|
||||
versionName "2.4.1"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,5 +68,9 @@
|
|||
<key>useNewMysteryBenefits</key>
|
||||
<value>false</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>insufficientGemPurchaseAdjust</key>
|
||||
<value>false</value>
|
||||
</entry>
|
||||
</defaultsMap>
|
||||
<!-- END xml_defaults -->
|
||||
|
|
@ -67,6 +67,10 @@ class AppConfigManager {
|
|||
return remoteConfig.getBoolean("insufficientGemPurchase")
|
||||
}
|
||||
|
||||
fun insufficientGemPurchaseAdjust(): Boolean {
|
||||
return remoteConfig.getBoolean("insufficientGemPurchaseAdjust")
|
||||
}
|
||||
|
||||
fun showSubscriptionBanner(): Boolean {
|
||||
return remoteConfig.getBoolean("showSubscriptionBanner")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,6 @@ public class Customization extends RealmObject {
|
|||
}
|
||||
|
||||
public String getImageName(String userSize, String hairColor) {
|
||||
|
||||
switch (this.type) {
|
||||
case "skin":
|
||||
return "skin_" + this.identifier;
|
||||
|
|
|
|||
|
|
@ -139,8 +139,11 @@ class CustomizationRecyclerViewAdapter : androidx.recyclerview.widget.RecyclerVi
|
|||
fun bind(customization: Customization) {
|
||||
this.customization = customization
|
||||
|
||||
|
||||
DataBindingUtils.loadImage(this.imageView, customization.getImageName(userSize, hairColor))
|
||||
if (customization.customizationSet?.contains("timeTravel") == true) {
|
||||
DataBindingUtils.loadImage(this.imageView, customization.getImageName(userSize, hairColor), imageFormat = "gif")
|
||||
} else {
|
||||
DataBindingUtils.loadImage(this.imageView, customization.getImageName(userSize, hairColor))
|
||||
}
|
||||
cardView.setCardBackgroundColor(ContextCompat.getColor(itemView.context, android.R.color.white))
|
||||
if (customization.isUsable) {
|
||||
imageView.alpha = 1.0f
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.widget.Button
|
|||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.os.bundleOf
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.events.ConsumablePurchasedEvent
|
||||
|
|
@ -24,7 +25,7 @@ import javax.inject.Inject
|
|||
* Created by phillip on 27.09.17.
|
||||
*/
|
||||
|
||||
class InsufficientGemsDialog(context: Context) : InsufficientCurrencyDialog(context) {
|
||||
class InsufficientGemsDialog(context: Context, var gemPrice: Int) : InsufficientCurrencyDialog(context) {
|
||||
|
||||
private var purchaseButton: Button? = null
|
||||
@Inject
|
||||
|
|
@ -38,6 +39,8 @@ class InsufficientGemsDialog(context: Context) : InsufficientCurrencyDialog(cont
|
|||
return R.layout.dialog_insufficient_gems
|
||||
}
|
||||
|
||||
var sku: String? = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
HabiticaBaseApplication.userComponent?.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
@ -54,6 +57,15 @@ class InsufficientGemsDialog(context: Context) : InsufficientCurrencyDialog(cont
|
|||
purchaseHandler = PurchaseHandler(it, crashlyticsProxy)
|
||||
purchaseHandler?.startListening()
|
||||
purchaseHandler?.whenCheckoutReady = {
|
||||
sku = if (configManager.insufficientGemPurchaseAdjust()) {
|
||||
if (gemPrice > 4) {
|
||||
PurchaseTypes.Purchase21Gems
|
||||
} else {
|
||||
PurchaseTypes.Purchase4Gems
|
||||
}
|
||||
} else {
|
||||
PurchaseTypes.Purchase4Gems
|
||||
}
|
||||
purchaseHandler?.getInAppPurchaseSKU(PurchaseTypes.Purchase4Gems) { sku ->
|
||||
val purchaseTextView = contentView.findViewById<TextView>(R.id.purchase_textview)
|
||||
purchaseTextView.text = sku.displayTitle
|
||||
|
|
@ -62,6 +74,7 @@ class InsufficientGemsDialog(context: Context) : InsufficientCurrencyDialog(cont
|
|||
}
|
||||
|
||||
purchaseButton?.setOnClickListener {
|
||||
FirebaseAnalytics.getInstance(context).logEvent("purchased_gems_from_insufficient", bundleOf(Pair("gemPrice", gemPrice), Pair("sku", "")))
|
||||
purchaseHandler?.purchaseGems(PurchaseTypes.Purchase4Gems)
|
||||
}
|
||||
addButton(R.string.see_other_options, false) { _, _ -> MainNavigationController.navigate(R.id.gemPurchaseActivity, bundleOf(Pair("openSubscription", false))) }
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
when {
|
||||
"gems" == shopItem.purchaseType -> InsufficientSubscriberGemsDialog(context)
|
||||
"gold" == shopItem.currency -> InsufficientGoldDialog(context)
|
||||
"gems" == shopItem.currency -> InsufficientGemsDialog(context)
|
||||
"gems" == shopItem.currency -> InsufficientGemsDialog(context, shopItem.value)
|
||||
"hourglasses" == shopItem.currency -> InsufficientHourglassesDialog(context)
|
||||
else -> null
|
||||
}?.show()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.util.AttributeSet
|
|||
import android.view.Gravity
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.facebook.drawee.backends.pipeline.Fresco
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
||||
|
|
@ -36,7 +37,15 @@ abstract class PurchaseDialogContent : LinearLayout {
|
|||
|
||||
|
||||
open fun setItem(item: ShopItem) {
|
||||
DataBindingUtils.loadImage(imageView, item.imageName)
|
||||
if (item.path?.contains("timeTravelBackgrounds") == true) {
|
||||
val controller = Fresco.newDraweeControllerBuilder()
|
||||
.setUri("https://habitica-assets.s3.amazonaws.com/mobileApp/images/${item.imageName?.replace("icon_", "")}.gif")
|
||||
.setAutoPlayAnimations(true)
|
||||
.build()
|
||||
imageView.controller = controller
|
||||
} else {
|
||||
DataBindingUtils.loadImage(imageView, item.imageName)
|
||||
}
|
||||
titleTextView.text = item.text
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class CustomizationDeserializer : JsonDeserializer<List<Customization>> {
|
|||
customization.isBuyable = false
|
||||
} else if ("timeTravelBackgrounds" == setName) {
|
||||
customization.customizationSetName = "Time Travel Backgrounds"
|
||||
customization.price = 0
|
||||
customization.price = 1
|
||||
customization.setPrice = 0
|
||||
customization.isBuyable = false
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue