diff --git a/Habitica/res/drawable-hdpi/shop_locked.png b/Habitica/res/drawable-hdpi/shop_locked.png new file mode 100644 index 0000000000..21c480b88c Binary files /dev/null and b/Habitica/res/drawable-hdpi/shop_locked.png differ diff --git a/Habitica/res/drawable-xhdpi/shop_locked.png b/Habitica/res/drawable-xhdpi/shop_locked.png new file mode 100644 index 0000000000..29ed842892 Binary files /dev/null and b/Habitica/res/drawable-xhdpi/shop_locked.png differ diff --git a/Habitica/res/drawable-xxhdpi/shop_locked.png b/Habitica/res/drawable-xxhdpi/shop_locked.png new file mode 100644 index 0000000000..a3aab00062 Binary files /dev/null and b/Habitica/res/drawable-xxhdpi/shop_locked.png differ diff --git a/Habitica/res/layout/row_shopitem.xml b/Habitica/res/layout/row_shopitem.xml index 865c659471..73ee85d1a8 100644 --- a/Habitica/res/layout/row_shopitem.xml +++ b/Habitica/res/layout/row_shopitem.xml @@ -78,6 +78,8 @@ tools:visibility="visible" android:gravity="center" android:scaleType="center" + android:tintMode="multiply" + app:tint="@color/text_dimmed" android:textColor="@color/white" /> diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/adapter/inventory/ShopRecyclerAdapter.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/adapter/inventory/ShopRecyclerAdapter.kt index b689080914..868d0ca2be 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/adapter/inventory/ShopRecyclerAdapter.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/adapter/inventory/ShopRecyclerAdapter.kt @@ -14,7 +14,6 @@ import com.habitrpg.android.habitica.extensions.inflate import com.habitrpg.android.habitica.helpers.Analytics import com.habitrpg.android.habitica.helpers.EventCategory import com.habitrpg.android.habitica.helpers.HitType -import com.habitrpg.common.habitica.helpers.MainNavigationController import com.habitrpg.android.habitica.models.shops.Shop import com.habitrpg.android.habitica.models.shops.ShopCategory import com.habitrpg.android.habitica.models.shops.ShopItem @@ -27,9 +26,11 @@ import com.habitrpg.android.habitica.ui.views.getTranslatedClassName import com.habitrpg.android.habitica.ui.views.insufficientCurrency.InsufficientGemsDialog import com.habitrpg.common.habitica.extensions.fromHtml import com.habitrpg.common.habitica.extensions.loadImage +import com.habitrpg.common.habitica.helpers.MainNavigationController class ShopRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter() { + var completedQuests: List = emptyList() var armoireCount: Int = 0 var onNeedsRefresh: (() -> Unit)? = null var onShowPurchaseDialog: ((ShopItem, Boolean) -> Unit)? = null @@ -177,6 +178,7 @@ class ShopRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter (holder as? EmptyStateViewHolder)?.text = obj is Pair<*, *> -> (holder as? ArmoireGearViewHolder)?.bind(obj.first as? String ?: "", obj.second as? Int ?: 0) diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/inventory/shops/QuestShopFragment.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/inventory/shops/QuestShopFragment.kt index 40bcc734cd..5ed26abba9 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/inventory/shops/QuestShopFragment.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/inventory/shops/QuestShopFragment.kt @@ -4,7 +4,9 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.lifecycle.lifecycleScope import com.habitrpg.android.habitica.models.shops.Shop +import com.habitrpg.common.habitica.helpers.launchCatching import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint @@ -17,4 +19,14 @@ class QuestShopFragment : ShopFragment() { shopIdentifier = Shop.QUEST_SHOP return super.onCreateView(inflater, container, savedInstanceState) } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + lifecycleScope.launchCatching { + userRepository.getQuestAchievements().collect { + adapter?.completedQuests = it.map { it.questKey } + } + } + } } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/viewHolders/ShopItemViewHolder.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/viewHolders/ShopItemViewHolder.kt index 8725fdc930..4858aa9afc 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/viewHolders/ShopItemViewHolder.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/viewHolders/ShopItemViewHolder.kt @@ -11,7 +11,6 @@ import com.habitrpg.android.habitica.databinding.RowShopitemBinding import com.habitrpg.android.habitica.models.shops.ShopItem import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper import com.habitrpg.common.habitica.extensions.dpToPx -import com.habitrpg.common.habitica.extensions.isUsingNightModeResources import com.habitrpg.common.habitica.extensions.loadImage class ShopItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener { @@ -66,28 +65,28 @@ class ShopItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Vi binding.priceLabel.visibility = View.GONE binding.unlockLabel.visibility = View.VISIBLE } + val isLimited = item.isLimited || item.event?.end != null if (numberOwned > 0) { binding.itemDetailIndicator.text = numberOwned.toString() - binding.itemDetailIndicator.background = if (context.isUsingNightModeResources()) { - BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfItemIndicatorNumberDark(item.isLimited || item.event?.end != null)) - } else { - BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfItemIndicatorNumber(item.isLimited || item.event?.end != null)) - } + binding.itemDetailIndicator.background = + AppCompatResources.getDrawable(context, R.drawable.pill_bg_gray) + binding.itemDetailIndicator.visibility = View.VISIBLE + } + if (item.locked) { + binding.itemDetailIndicator.background = AppCompatResources.getDrawable(context, R.drawable.shop_locked) binding.itemDetailIndicator.visibility = View.VISIBLE - } else if (item.locked) { - binding.itemDetailIndicator.background = if (context.isUsingNightModeResources()) { - BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfItemIndicatorLockedDark(item.isLimited || item.event?.end != null)) + } else if (isLimited) { + if (numberOwned == 0) { + binding.itemDetailIndicator.background = BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfItemIndicatorLimited()) } else { - BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfItemIndicatorLocked(item.isLimited || item.event?.end != null)) + binding.itemDetailIndicator.background = AppCompatResources.getDrawable(context, R.drawable.pill_bg_purple_300) } binding.itemDetailIndicator.visibility = View.VISIBLE - } else if (item.isLimited || item.event?.end != null) { - binding.itemDetailIndicator.background = BitmapDrawable(context.resources, HabiticaIconsHelper.imageOfItemIndicatorLimited()) - binding.itemDetailIndicator.visibility = View.VISIBLE } if (item.key == "gem" && item.limitedNumberLeft == -1) { binding.itemDetailIndicator.background = AppCompatResources.getDrawable(context, R.drawable.item_indicator_subscribe) + binding.itemDetailIndicator.visibility = View.VISIBLE } if (binding.itemDetailIndicator.visibility == View.VISIBLE) { diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/HabiticaIconsHelper.java b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/HabiticaIconsHelper.java index c912f7d4f8..1fc3503529 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/HabiticaIconsHelper.java +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/HabiticaIconsHelper.java @@ -234,7 +234,7 @@ public static Bitmap imageOfPinnedItem() { if (imageOfPinnedItem != null) return imageOfPinnedItem; - int size = scaleSize(16); + int size = scaleSize(14); imageOfPinnedItem = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(imageOfPinnedItem); canvas.scale(displayDensity, displayDensity); diff --git a/version.properties b/version.properties index 071d764ba7..ad3e14c361 100644 --- a/version.properties +++ b/version.properties @@ -1,2 +1,2 @@ NAME=4.3 -CODE=6381 \ No newline at end of file +CODE=6391 \ No newline at end of file