mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +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
|
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"
|
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"
|
versionName "2.4.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,5 +68,9 @@
|
||||||
<key>useNewMysteryBenefits</key>
|
<key>useNewMysteryBenefits</key>
|
||||||
<value>false</value>
|
<value>false</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>insufficientGemPurchaseAdjust</key>
|
||||||
|
<value>false</value>
|
||||||
|
</entry>
|
||||||
</defaultsMap>
|
</defaultsMap>
|
||||||
<!-- END xml_defaults -->
|
<!-- END xml_defaults -->
|
||||||
|
|
@ -67,6 +67,10 @@ class AppConfigManager {
|
||||||
return remoteConfig.getBoolean("insufficientGemPurchase")
|
return remoteConfig.getBoolean("insufficientGemPurchase")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun insufficientGemPurchaseAdjust(): Boolean {
|
||||||
|
return remoteConfig.getBoolean("insufficientGemPurchaseAdjust")
|
||||||
|
}
|
||||||
|
|
||||||
fun showSubscriptionBanner(): Boolean {
|
fun showSubscriptionBanner(): Boolean {
|
||||||
return remoteConfig.getBoolean("showSubscriptionBanner")
|
return remoteConfig.getBoolean("showSubscriptionBanner")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,6 @@ public class Customization extends RealmObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImageName(String userSize, String hairColor) {
|
public String getImageName(String userSize, String hairColor) {
|
||||||
|
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case "skin":
|
case "skin":
|
||||||
return "skin_" + this.identifier;
|
return "skin_" + this.identifier;
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,11 @@ class CustomizationRecyclerViewAdapter : androidx.recyclerview.widget.RecyclerVi
|
||||||
fun bind(customization: Customization) {
|
fun bind(customization: Customization) {
|
||||||
this.customization = customization
|
this.customization = customization
|
||||||
|
|
||||||
|
if (customization.customizationSet?.contains("timeTravel") == true) {
|
||||||
DataBindingUtils.loadImage(this.imageView, customization.getImageName(userSize, hairColor))
|
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))
|
cardView.setCardBackgroundColor(ContextCompat.getColor(itemView.context, android.R.color.white))
|
||||||
if (customization.isUsable) {
|
if (customization.isUsable) {
|
||||||
imageView.alpha = 1.0f
|
imageView.alpha = 1.0f
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import android.widget.Button
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||||
import com.habitrpg.android.habitica.R
|
import com.habitrpg.android.habitica.R
|
||||||
import com.habitrpg.android.habitica.events.ConsumablePurchasedEvent
|
import com.habitrpg.android.habitica.events.ConsumablePurchasedEvent
|
||||||
|
|
@ -24,7 +25,7 @@ import javax.inject.Inject
|
||||||
* Created by phillip on 27.09.17.
|
* 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
|
private var purchaseButton: Button? = null
|
||||||
@Inject
|
@Inject
|
||||||
|
|
@ -38,6 +39,8 @@ class InsufficientGemsDialog(context: Context) : InsufficientCurrencyDialog(cont
|
||||||
return R.layout.dialog_insufficient_gems
|
return R.layout.dialog_insufficient_gems
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sku: String? = ""
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
HabiticaBaseApplication.userComponent?.inject(this)
|
HabiticaBaseApplication.userComponent?.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
@ -54,6 +57,15 @@ class InsufficientGemsDialog(context: Context) : InsufficientCurrencyDialog(cont
|
||||||
purchaseHandler = PurchaseHandler(it, crashlyticsProxy)
|
purchaseHandler = PurchaseHandler(it, crashlyticsProxy)
|
||||||
purchaseHandler?.startListening()
|
purchaseHandler?.startListening()
|
||||||
purchaseHandler?.whenCheckoutReady = {
|
purchaseHandler?.whenCheckoutReady = {
|
||||||
|
sku = if (configManager.insufficientGemPurchaseAdjust()) {
|
||||||
|
if (gemPrice > 4) {
|
||||||
|
PurchaseTypes.Purchase21Gems
|
||||||
|
} else {
|
||||||
|
PurchaseTypes.Purchase4Gems
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PurchaseTypes.Purchase4Gems
|
||||||
|
}
|
||||||
purchaseHandler?.getInAppPurchaseSKU(PurchaseTypes.Purchase4Gems) { sku ->
|
purchaseHandler?.getInAppPurchaseSKU(PurchaseTypes.Purchase4Gems) { sku ->
|
||||||
val purchaseTextView = contentView.findViewById<TextView>(R.id.purchase_textview)
|
val purchaseTextView = contentView.findViewById<TextView>(R.id.purchase_textview)
|
||||||
purchaseTextView.text = sku.displayTitle
|
purchaseTextView.text = sku.displayTitle
|
||||||
|
|
@ -62,6 +74,7 @@ class InsufficientGemsDialog(context: Context) : InsufficientCurrencyDialog(cont
|
||||||
}
|
}
|
||||||
|
|
||||||
purchaseButton?.setOnClickListener {
|
purchaseButton?.setOnClickListener {
|
||||||
|
FirebaseAnalytics.getInstance(context).logEvent("purchased_gems_from_insufficient", bundleOf(Pair("gemPrice", gemPrice), Pair("sku", "")))
|
||||||
purchaseHandler?.purchaseGems(PurchaseTypes.Purchase4Gems)
|
purchaseHandler?.purchaseGems(PurchaseTypes.Purchase4Gems)
|
||||||
}
|
}
|
||||||
addButton(R.string.see_other_options, false) { _, _ -> MainNavigationController.navigate(R.id.gemPurchaseActivity, bundleOf(Pair("openSubscription", false))) }
|
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 {
|
when {
|
||||||
"gems" == shopItem.purchaseType -> InsufficientSubscriberGemsDialog(context)
|
"gems" == shopItem.purchaseType -> InsufficientSubscriberGemsDialog(context)
|
||||||
"gold" == shopItem.currency -> InsufficientGoldDialog(context)
|
"gold" == shopItem.currency -> InsufficientGoldDialog(context)
|
||||||
"gems" == shopItem.currency -> InsufficientGemsDialog(context)
|
"gems" == shopItem.currency -> InsufficientGemsDialog(context, shopItem.value)
|
||||||
"hourglasses" == shopItem.currency -> InsufficientHourglassesDialog(context)
|
"hourglasses" == shopItem.currency -> InsufficientHourglassesDialog(context)
|
||||||
else -> null
|
else -> null
|
||||||
}?.show()
|
}?.show()
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import android.util.AttributeSet
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import com.facebook.drawee.backends.pipeline.Fresco
|
||||||
import com.facebook.drawee.view.SimpleDraweeView
|
import com.facebook.drawee.view.SimpleDraweeView
|
||||||
import com.habitrpg.android.habitica.R
|
import com.habitrpg.android.habitica.R
|
||||||
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
||||||
|
|
@ -36,7 +37,15 @@ abstract class PurchaseDialogContent : LinearLayout {
|
||||||
|
|
||||||
|
|
||||||
open fun setItem(item: ShopItem) {
|
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
|
titleTextView.text = item.text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ class CustomizationDeserializer : JsonDeserializer<List<Customization>> {
|
||||||
customization.isBuyable = false
|
customization.isBuyable = false
|
||||||
} else if ("timeTravelBackgrounds" == setName) {
|
} else if ("timeTravelBackgrounds" == setName) {
|
||||||
customization.customizationSetName = "Time Travel Backgrounds"
|
customization.customizationSetName = "Time Travel Backgrounds"
|
||||||
customization.price = 0
|
customization.price = 1
|
||||||
customization.setPrice = 0
|
customization.setPrice = 0
|
||||||
customization.isBuyable = false
|
customization.isBuyable = false
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue