From 413c3bbc7b94427a666e0b32e03618e5bf8c0b2a Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Thu, 6 Jun 2024 10:44:33 +0200 Subject: [PATCH] new shop headers --- .../res/drawable-hdpi/shop_header_sparkle.png | Bin 0 -> 318 bytes .../res/drawable-mdpi/shop_header_sparkle.png | Bin 0 -> 267 bytes .../shop_category_header_background.xml | 6 ++ .../drawable-xhdpi/shop_header_sparkle.png | Bin 0 -> 356 bytes .../drawable-xxhdpi/shop_header_sparkle.png | Bin 0 -> 420 bytes .../res/drawable/ic_arrow_drop_down_10dp.xml | 4 + .../shop_category_header_background.xml | 6 ++ .../drawable/shop_header_else_background.xml | 5 ++ .../shop_header_healer_background.xml | 5 ++ .../drawable/shop_header_rogue_background.xml | 5 ++ .../drawable/shop_header_time_background.xml | 5 ++ .../shop_header_warrior_background.xml | 5 ++ .../shop_header_wizard_background.xml | 5 ++ Habitica/res/layout/shop_section_header.xml | 83 ++++++++++++++---- Habitica/res/values/styles.xml | 2 +- .../models/shops/EmptyShopCategory.kt | 4 +- .../adapter/inventory/ShopRecyclerAdapter.kt | 19 +++- .../customization/AvatarOverviewFragment.kt | 70 +++++++++++---- .../ui/viewHolders/SectionViewHolder.kt | 41 ++++++++- .../ui/viewHolders/ShopItemViewHolder.kt | 2 +- version.properties | 2 +- 21 files changed, 230 insertions(+), 39 deletions(-) create mode 100644 Habitica/res/drawable-hdpi/shop_header_sparkle.png create mode 100644 Habitica/res/drawable-mdpi/shop_header_sparkle.png create mode 100644 Habitica/res/drawable-night/shop_category_header_background.xml create mode 100644 Habitica/res/drawable-xhdpi/shop_header_sparkle.png create mode 100644 Habitica/res/drawable-xxhdpi/shop_header_sparkle.png create mode 100644 Habitica/res/drawable/ic_arrow_drop_down_10dp.xml create mode 100644 Habitica/res/drawable/shop_category_header_background.xml create mode 100644 Habitica/res/drawable/shop_header_else_background.xml create mode 100644 Habitica/res/drawable/shop_header_healer_background.xml create mode 100644 Habitica/res/drawable/shop_header_rogue_background.xml create mode 100644 Habitica/res/drawable/shop_header_time_background.xml create mode 100644 Habitica/res/drawable/shop_header_warrior_background.xml create mode 100644 Habitica/res/drawable/shop_header_wizard_background.xml diff --git a/Habitica/res/drawable-hdpi/shop_header_sparkle.png b/Habitica/res/drawable-hdpi/shop_header_sparkle.png new file mode 100644 index 0000000000000000000000000000000000000000..b2c3dd5688ad090d3830b8bfe56b38d4a5568304 GIT binary patch literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xa&H|6fVg?3*IUvlacGk)SD9BhG zOV)oN0*;A+a# zlRJ2C!8)t2DpkUBORh+N;nMR{;^4}Aw7_Gb(Bv(>3q7+wwmW(MxHsRf!M=GJ^QL#_ z8yeXCo;>>+iQzP+4sG-&*mrODDG4?JbtrSrattxoKWyJHvL{y+JCvOto`lwkKKc z*_p*&lO%O*itFXWL4T6|6U literal 0 HcmV?d00001 diff --git a/Habitica/res/drawable-mdpi/shop_header_sparkle.png b/Habitica/res/drawable-mdpi/shop_header_sparkle.png new file mode 100644 index 0000000000000000000000000000000000000000..ad5159125769011adfe4efb5079d28150d718720 GIT binary patch literal 267 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4aTa()7Bet#3xhBt!>l*8o|0J>k`3pQ<978G?ThAGC9dZz0ytQ=?W@+i)SlsR(T@6oB8)Q;|6iN8;V&;B3{eIBHy3M z-11dX^T^RawbyYP3xDhi>gD?C?w~$l;`FO&ivt9hnhgccE!ntw!@?g$(|>>YKW%@* zBi + + + + + diff --git a/Habitica/res/drawable-xhdpi/shop_header_sparkle.png b/Habitica/res/drawable-xhdpi/shop_header_sparkle.png new file mode 100644 index 0000000000000000000000000000000000000000..209842b32522a25e9e3bb07d29b5452972c16411 GIT binary patch literal 356 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|&H|6fVg?2=RS;(M3{v?36l5$8 za(7}_cTVOdki(Mh=y>}>>qp5?{oZV57C2+B);O%Grw~ywZoN!$KzVZS4cD=Kb zU!#0uk2wfEiY(q^z*M`gM8eZWW2*b~e`#B;4&YrN2>C5@Y zu&zC0Uaqo&PIu;tsP6J-cMk`zViq-ah%jYTbT+zSH8DOosdZD*WQK=NTdYNwIW7s% y(rMFB)KzobGC?F*VP#ulN#fg;**ACHk$!!3+RfYEiu-|qz~JfX=d#Wzp$Pzs1co*M literal 0 HcmV?d00001 diff --git a/Habitica/res/drawable-xxhdpi/shop_header_sparkle.png b/Habitica/res/drawable-xxhdpi/shop_header_sparkle.png new file mode 100644 index 0000000000000000000000000000000000000000..ed6378d1dd476909b63b62f6baff7325f2083f97 GIT binary patch literal 420 zcmV;V0bBlwP)fiZ!YXr+mXVq@bg@CYSBN$Ucn7%KXedN@jm!EIVSQEAd z!3wG|0WyIqECQ*)D5iu|ARQ5kf^=jk2xdtT<-o-)0;yr*+S}(aOM)(+Jaz+AA7B9~ z2|7Dp^^JSL;1_``x0DWotY8W8r8>$BzfSpb{b;_Div(xv_2Aux_ zDZ_txGVTvSJg-A@vt}P$OxF&suzC+vt~ViGRS5D6q1UyVC4mNrn|lwn3anhse+(rg zVrtL;1+ipMfTEZg3_vPO4Mrd}76lcM2@^pjWX5(t1C$&FU8`QqVSQ%yuh%xmyx}nb O0000 + + + diff --git a/Habitica/res/drawable/shop_category_header_background.xml b/Habitica/res/drawable/shop_category_header_background.xml new file mode 100644 index 000000000..67c142ebe --- /dev/null +++ b/Habitica/res/drawable/shop_category_header_background.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/Habitica/res/drawable/shop_header_else_background.xml b/Habitica/res/drawable/shop_header_else_background.xml new file mode 100644 index 000000000..cb61299d7 --- /dev/null +++ b/Habitica/res/drawable/shop_header_else_background.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Habitica/res/drawable/shop_header_healer_background.xml b/Habitica/res/drawable/shop_header_healer_background.xml new file mode 100644 index 000000000..1333ee4d2 --- /dev/null +++ b/Habitica/res/drawable/shop_header_healer_background.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Habitica/res/drawable/shop_header_rogue_background.xml b/Habitica/res/drawable/shop_header_rogue_background.xml new file mode 100644 index 000000000..85fa9fc15 --- /dev/null +++ b/Habitica/res/drawable/shop_header_rogue_background.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Habitica/res/drawable/shop_header_time_background.xml b/Habitica/res/drawable/shop_header_time_background.xml new file mode 100644 index 000000000..e1519e027 --- /dev/null +++ b/Habitica/res/drawable/shop_header_time_background.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Habitica/res/drawable/shop_header_warrior_background.xml b/Habitica/res/drawable/shop_header_warrior_background.xml new file mode 100644 index 000000000..9ec917a50 --- /dev/null +++ b/Habitica/res/drawable/shop_header_warrior_background.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Habitica/res/drawable/shop_header_wizard_background.xml b/Habitica/res/drawable/shop_header_wizard_background.xml new file mode 100644 index 000000000..a6f29b100 --- /dev/null +++ b/Habitica/res/drawable/shop_header_wizard_background.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Habitica/res/layout/shop_section_header.xml b/Habitica/res/layout/shop_section_header.xml index fecc350b3..d085f9c36 100644 --- a/Habitica/res/layout/shop_section_header.xml +++ b/Habitica/res/layout/shop_section_header.xml @@ -4,46 +4,97 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical"> + android:orientation="vertical" + android:layout_marginHorizontal="12dp"> - + android:layout_height="match_parent" + android:orientation="vertical" + android:background="@drawable/shop_category_header_background" + android:layout_marginBottom="@dimen/spacing_large"> + + + android:gravity="center" + android:textColor="@color/white" /> + + + + + + + + + @style/PopupTheme @style/PopupTheme @style/PopupTheme - @color/brand_400 + @color/text_brand_neon @style/AlertDialogTheme false diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/EmptyShopCategory.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/EmptyShopCategory.kt index 550854888..c2e4706b6 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/EmptyShopCategory.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/EmptyShopCategory.kt @@ -7,12 +7,12 @@ import android.text.style.ForegroundColorSpan import androidx.core.content.ContextCompat import com.habitrpg.android.habitica.R -class EmptyShopCategory(val categoryIdentifier: String, context: Context?) { +class EmptyShopCategory(val categoryIdentifier: String, val shopIdentifier: String?, context: Context?) { val title: String = context?.getString(R.string.you_own_all_items) ?: "" val description: Spannable init { val stringId = when (categoryIdentifier) { - "backgrounds" -> R.string.try_on_next_month + "backgrounds" -> if (shopIdentifier == Shop.CUSTOMIZATIONS) R.string.try_on_next_month else R.string.try_on_customize "color" -> R.string.try_on_next_season "skin" -> R.string.try_on_next_season "mystery_sets" -> R.string.try_on_equipment 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 66adbbeca..1e1d6a822 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 @@ -5,7 +5,10 @@ import android.text.method.LinkMovementMethod import android.view.View import android.view.ViewGroup import android.widget.Button +import android.widget.LinearLayout import android.widget.TextView +import androidx.core.view.isVisible +import androidx.core.view.marginTop import androidx.recyclerview.widget.RecyclerView.ViewHolder import com.habitrpg.android.habitica.R import com.habitrpg.android.habitica.databinding.ShopArmoireGearBinding @@ -26,6 +29,7 @@ import com.habitrpg.android.habitica.ui.viewHolders.SectionViewHolder import com.habitrpg.android.habitica.ui.viewHolders.ShopItemViewHolder import com.habitrpg.android.habitica.ui.views.getTranslatedClassName import com.habitrpg.android.habitica.ui.views.insufficientCurrency.InsufficientGemsDialog +import com.habitrpg.common.habitica.extensions.dpToPx import com.habitrpg.common.habitica.extensions.fromHtml import com.habitrpg.common.habitica.extensions.loadImage import com.habitrpg.common.habitica.helpers.MainNavigationController @@ -93,7 +97,7 @@ class ShopRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter 1) { + 40.dpToPx(context) + } else { + 16.dpToPx(context) + } if (gearCategories.contains(obj)) { context?.let { context -> val adapter = @@ -160,6 +169,7 @@ class ShopRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter - displayCustomizationFragment(type, category) - }, - { type, category -> - displayAvatarEquipmentFragment(type, category) - }, - { type, equipped, isCostume -> - displayEquipmentFragment(type, equipped, isCostume) - }, - ) + val avatar by userViewModel.user.observeAsState() + Column { + + Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.background(colorResource(R.color.window_background))) { + ComposableAvatarView( + avatar = avatar, + configManager = appConfigManager, + modifier = + Modifier + .padding(vertical = 24.dp) + .size(140.dp, 147.dp), + ) + Box( + Modifier + .background(colorResource(R.color.content_background), RoundedCornerShape(topStart = 22.dp, topEnd = 22.dp)) + .fillMaxWidth() + .height(22.dp), + ) + } + AvatarOverviewView( + userViewModel, + showCustomization, + !showCustomization, + battleGearWeapon.value?.twoHanded == true, + costumeWeapon.value?.twoHanded == true, + { type, category -> + displayCustomizationFragment(type, category) + }, + { type, category -> + displayAvatarEquipmentFragment(type, category) + }, + { type, equipped, isCostume -> + displayEquipmentFragment(type, equipped, isCostume) + }, + ) + } } } } @@ -169,6 +201,12 @@ open class AvatarOverviewFragment : ) { super.onCreateOptionsMenu(menu, inflater) inflater.inflate(R.menu.menu_share_avatar, menu) + + mainActivity?.toolbar?.let { + val color = ContextCompat.getColor(requireContext(), R.color.window_background) + ToolbarColorHelper.colorizeToolbar(it, mainActivity, backgroundColor = color) + requireActivity().window.statusBarColor = color + } } override fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/viewHolders/SectionViewHolder.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/viewHolders/SectionViewHolder.kt index 71e739e3e..1ae223e04 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/viewHolders/SectionViewHolder.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/viewHolders/SectionViewHolder.kt @@ -6,9 +6,12 @@ import android.view.View import android.view.ViewGroup import android.widget.AdapterView import android.widget.ArrayAdapter +import android.widget.FrameLayout import android.widget.LinearLayout import android.widget.Spinner import android.widget.TextView +import androidx.appcompat.content.res.AppCompatResources +import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import com.habitrpg.android.habitica.R import com.habitrpg.android.habitica.extensions.getImpreciseRemainingString @@ -19,6 +22,7 @@ import com.habitrpg.android.habitica.ui.views.CurrencyView import java.util.Date class SectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val headerContainer: LinearLayout = itemView.findViewById(R.id.header_container) private val label: TextView = itemView.findViewById(R.id.label) private val switchesInLabel: TextView? = itemView.findViewById(R.id.switches_in_label) private val selectionSpinner: Spinner? = itemView.findViewById(R.id.class_selection_spinner) @@ -28,6 +32,9 @@ class SectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { val switchClassCurrency: CurrencyView? = itemView.findViewById(R.id.change_class_currency_view) internal val notesView: TextView? = itemView.findViewById(R.id.headerNotesView) private val countPill: TextView? = itemView.findViewById(R.id.count_pill) + val divider: View? = itemView.findViewById(R.id.divider) + val classSelectionButton: FrameLayout? = itemView.findViewById(R.id.class_selection_button) + val classSelectionLabel: TextView? = itemView.findViewById(R.id.class_name_label) var context: Context = itemView.context var spinnerSelectionChanged: (() -> Unit)? = null @@ -35,6 +42,9 @@ class SectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { constructor(parent: ViewGroup) : this(parent.inflate(R.layout.customization_section_header)) init { + classSelectionButton?.setOnClickListener { + selectionSpinner?.performClick() + } selectionSpinner?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onNothingSelected(parent: AdapterView<*>?) { @@ -99,11 +109,40 @@ class SectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { } } + fun setSelectedClass(selectedGearCategory: String) { + var textColor = R.color.white + when (selectedGearCategory) { + "warrior" -> { + classSelectionButton?.background = AppCompatResources.getDrawable(context, R.drawable.shop_header_warrior_background) + classSelectionLabel?.text = context.getString(R.string.warrior) + } + "wizard" -> { + classSelectionButton?.background = AppCompatResources.getDrawable(context, R.drawable.shop_header_wizard_background) + classSelectionLabel?.text = context.getString(R.string.mage) + } + "healer" -> { + classSelectionButton?.background = AppCompatResources.getDrawable(context, R.drawable.shop_header_healer_background) + classSelectionLabel?.text = context.getString(R.string.healer) + textColor = R.color.yellow_1 + } + "rogue" -> { + classSelectionButton?.background = AppCompatResources.getDrawable(context, R.drawable.shop_header_rogue_background) + classSelectionLabel?.text = context.getString(R.string.rogue) + } + else -> { + classSelectionButton?.background = AppCompatResources.getDrawable(context, R.drawable.shop_header_else_background) + classSelectionLabel?.text = context.getString(R.string.classless) + textColor = R.color.gray_100 + } + } + classSelectionLabel?.setTextColor(ContextCompat.getColor(context, textColor)) + } + var spinnerAdapter: ArrayAdapter? = null set(value) { field = value selectionSpinner?.adapter = field - selectionSpinner?.visibility = if (value != null) View.VISIBLE else View.GONE + classSelectionButton?.visibility = if (value != null) View.VISIBLE else View.GONE } var selectedItem: Int = 0 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 f101319d4..933a43b1b 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 @@ -120,7 +120,7 @@ class ShopItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Vi binding.itemDetailIndicator.layoutParams = layoutParams } - binding.priceLabel.isLocked = item.locked || !canBuy + binding.priceLabel.isLocked = item.locked || (!canBuy && item.currency == "gold") } override fun onClick(view: View) { diff --git a/version.properties b/version.properties index 3c5a3f96f..311d50402 100644 --- a/version.properties +++ b/version.properties @@ -1,2 +1,2 @@ NAME=4.3.7 -CODE=7841 \ No newline at end of file +CODE=7861 \ No newline at end of file