Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed May 9, 2024
1 parent fccd8ca commit 74c283e
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class AppConfigManager(contentRepository: ContentRepository?) :
}

fun enableCustomizationShop(): Boolean {
if (BuildConfig.DEBUG) return true
if (BuildConfig.DEBUG) return false
return remoteConfig.getBoolean("enableCustomizationShop")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.inventory.Customization
import com.habitrpg.android.habitica.models.inventory.CustomizationSet
import com.habitrpg.android.habitica.models.inventory.Equipment
import com.habitrpg.android.habitica.models.inventory.ItemEvent
import com.habitrpg.android.habitica.models.user.User
import io.realm.RealmList
Expand Down Expand Up @@ -234,5 +235,16 @@ open class ShopItem : RealmObject(), BaseObject {
}
return item
}

fun fromAnimalEquipment(equipment: Equipment?): ShopItem {
val item = ShopItem()
item.key = equipment?.key ?: ""
item.text = equipment?.text
item.currency = "gems"
item.value = 2
item.purchaseType = "gear"
item.imageName = equipment?.key
return item
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import com.habitrpg.android.habitica.databinding.CustomizationGridItemBinding
import com.habitrpg.android.habitica.databinding.DialogPurchaseCustomizationBinding
import com.habitrpg.android.habitica.models.inventory.CustomizationSet
import com.habitrpg.android.habitica.models.inventory.Equipment
import com.habitrpg.android.habitica.models.shops.ShopItem
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
import com.habitrpg.android.habitica.ui.views.shops.PurchaseDialog
import com.habitrpg.common.habitica.extensions.loadImage
import com.habitrpg.common.habitica.helpers.MainNavigationController
import com.habitrpg.common.habitica.views.AvatarView
import com.habitrpg.common.habitica.views.PixelArtView

class CustomizationEquipmentRecyclerViewAdapter :
Expand All @@ -36,6 +39,7 @@ class CustomizationEquipmentRecyclerViewAdapter :

var onSelect: ((Equipment) -> Unit)? = null
var onUnlock: ((Equipment) -> Unit)? = null
var onShowPurchaseDialog: ((ShopItem) -> Unit)? = null

override fun onCreateViewHolder(
parent: ViewGroup,
Expand Down Expand Up @@ -125,42 +129,11 @@ class CustomizationEquipmentRecyclerViewAdapter :
equipment?.value
}
if (equipment?.owned != true && (itemValue ?: 0.0) > 0.0) {
val dialogContent = LinearLayout(itemView.context)
DialogPurchaseCustomizationBinding.inflate(
LayoutInflater.from(itemView.context),
dialogContent,
onShowPurchaseDialog?.invoke(
ShopItem.fromAnimalEquipment(
equipment
),
)

val imageView = dialogContent.findViewById<PixelArtView>(R.id.imageView)
imageView.loadImage("shop_" + this.equipment?.key)

val priceLabel = dialogContent.findViewById<TextView>(R.id.priceLabel)
priceLabel?.text = itemValue.toString()

(dialogContent.findViewById<View>(R.id.gem_icon) as? ImageView)?.setImageBitmap(
HabiticaIconsHelper.imageOfGem(),
)

val dialog = HabiticaAlertDialog(itemView.context)
dialog.addButton(R.string.purchase_button, true) { _, _ ->
gemBalance?.let {
if ((itemValue ?: 0.0) > it) {
MainNavigationController.navigate(
R.id.gemPurchaseActivity,
bundleOf(Pair("openSubscription", false)),
)
return@addButton
}
}

equipment?.let {
onUnlock?.invoke(it)
}
}
dialog.setTitle(R.string.purchase_customization)
dialog.setAdditionalContentView(dialogContent)
dialog.addButton(R.string.reward_dialog_dismiss, false)
dialog.show()
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
import com.habitrpg.android.habitica.ui.helpers.MarginDecoration
import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
import com.habitrpg.android.habitica.ui.views.shops.PurchaseDialog
import com.habitrpg.common.habitica.helpers.ExceptionHandler
import com.habitrpg.common.habitica.helpers.launchCatching
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -72,6 +73,10 @@ class AvatarEquipmentFragment :
userRepository.retrieveUser(forced = true)
}
}
adapter.onShowPurchaseDialog = { item ->
val dialog = PurchaseDialog(requireContext(), userRepository, inventoryRepository, item)
dialog.show()
}
return super.onCreateView(inflater, container, savedInstanceState)
}

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ buildscript {
ext {
min_sdk = 21
target_sdk = 34
wearos_target_sdk = 33
app_version_name = ''
app_version_code = 0

Expand Down
8 changes: 8 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ Submit a new Beta Build to Google Play

Deploy a new version to the Google Play

### android upload_to_slack

```sh
[bundle exec] fastlane android upload_to_slack
```

Upload the latest output APK to slack

----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
Expand Down
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NAME=4.3.7
CODE=7631
CODE=7671
4 changes: 2 additions & 2 deletions wearos/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
defaultConfig {
applicationId "com.habitrpg.android.habitica"
minSdk 26
targetSdk target_sdk
compileSdk 34
targetSdk wearos_target_sdk
compileSdk target_sdk
versionCode app_version_code + 1
versionName "${app_version_name}w"
buildConfigField "String", "TESTING_LEVEL", "\"production\""
Expand Down

0 comments on commit 74c283e

Please sign in to comment.