Skip to content

Commit

Permalink
update locked state for gear
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed May 16, 2024
1 parent 91dd28d commit 6da4f1a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 13 deletions.
16 changes: 15 additions & 1 deletion Habitica/res/layout/dialog_purchase_content_gear.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,18 @@
android:textColor="@color/text_ternary"
android:layout_marginTop="@dimen/spacing_medium"
android:gravity="center_horizontal"/>
</merge>


<TextView
android:id="@+id/class_disclaimer_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="22dp"
android:paddingVertical="9dp"
android:textColor="@color/text_secondary"
android:background="@drawable/layout_rounded_bg_window"
android:layout_marginTop="20dp"
android:gravity="center"
android:visibility="gone"
style="@style/Caption2"/>
</merge>
2 changes: 1 addition & 1 deletion Habitica/res/layout/dialog_purchase_content_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
android:layout_marginTop="20dp"
android:gravity="center"
style="@style/Caption2"/>
</merge>
</merge>
6 changes: 6 additions & 0 deletions Habitica/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@
<string name="equipment_empty">You already have all equipment! More will be released during the Grand Galas, near the solstices and equinoxes.</string>
<string name="classless">Classless</string>
<string name="class_equipment_shop_dialog">This item is only available to a specific class.\nYou can change your class from Settings.</string>
<string name="class_equipment_shop_dialog_new">This item is only available to %s.\nOpen Settings to change class.</string>
<string name="insufficient_level_equipment_dialog">This item is only available to a specific class.\nYou can select a class after level 10.</string>
<string name="insufficient_level_equipment_dialog_new">This item is only available to %s.\nYou can select a class after level 10.</string>
<string name="class_gear_disclaimer">You can only purchase gear for your current class</string>
<string name="check_into_inn">Check into Inn</string>
<string name="community_guidelines">Community Guidelines</string>
Expand Down Expand Up @@ -1520,6 +1522,10 @@
<string name="try_on_next_season">You can try them on by customizing your avatar. Be sure to check back later for next season’s options!</string>
<string name="try_on_customize">"You can try them on by customizing your avatar. "</string>
<string name="try_on_equipment">"You can try them on by Equipment. Be sure to check back later for next month’s options! "</string>
<string name="healers">Healers</string>
<string name="rogues">Rogues</string>
<string name="warriors">Warriors</string>
<string name="mages">Mages</string>

<plurals name="you_x_others">
<item quantity="zero">You</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ fun getTranslatedClassName(
}
}

fun getTranslatedClassNamePlural(
resources: Resources,
className: String?,
): String {
return when (className) {
Stats.HEALER -> resources.getString(R.string.healers)
Stats.ROGUE -> resources.getString(R.string.rogues)
Stats.WARRIOR -> resources.getString(R.string.warriors)
Stats.MAGE -> resources.getString(R.string.mages)
else -> resources.getString(R.string.warriors)
}
}

@Composable
fun AppHeaderView(
user: Avatar?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import com.habitrpg.android.habitica.ui.views.CurrencyViews
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.android.habitica.ui.views.SnackbarActivity
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
import com.habitrpg.android.habitica.ui.views.getTranslatedClassName
import com.habitrpg.android.habitica.ui.views.getTranslatedClassNamePlural
import com.habitrpg.android.habitica.ui.views.insufficientCurrency.InsufficientGemsDialog
import com.habitrpg.android.habitica.ui.views.insufficientCurrency.InsufficientGoldDialog
import com.habitrpg.android.habitica.ui.views.insufficientCurrency.InsufficientHourglassesDialog
Expand Down Expand Up @@ -151,6 +153,19 @@ class PurchaseDialog(
}
}

val userLvl = user?.stats?.lvl ?: 0
if (shopItem.habitClass != null && (shopItem.habitClass != "special" || shopItem.pinType == "marketGear") && shopItem.habitClass != "armoire" && user?.stats?.habitClass != shopItem.habitClass) {
val classDisclaimerView = contentView.findViewById<TextView>(R.id.class_disclaimer_view)
val className = getTranslatedClassNamePlural(context.resources, shopItem.habitClass ?: "")
classDisclaimerView.text =
if (userLvl >= 10) {
context.getString(R.string.class_equipment_shop_dialog_new, className)
} else {
context.getString(R.string.insufficient_level_equipment_dialog_new, className)
}
classDisclaimerView.visibility = View.VISIBLE
}

amountErrorLabel = contentView.findViewById(R.id.amount_error_label)

contentView.setItem(shopItem)
Expand Down Expand Up @@ -204,17 +219,7 @@ class PurchaseDialog(

private fun setLimitedTextView() {
if (user == null) return
val userLvl = user?.stats?.lvl ?: 0
if (shopItem.habitClass != null && shopItem.habitClass != "special" && shopItem.habitClass != "armoire" && user?.stats?.habitClass != shopItem.habitClass) {
limitedTextView.text =
if (userLvl >= 10) {
context.getString(R.string.class_equipment_shop_dialog)
} else {
context.getString(R.string.insufficient_level_equipment_dialog)
}
limitedTextView.visibility = View.VISIBLE
limitedTextView.setBackgroundColor(ContextCompat.getColor(context, R.color.inverted_background))
} else if (shopItem.availableUntil != null) {
if (shopItem.availableUntil != null) {
val endDate = shopItem.availableUntil
limitedTextViewJob?.cancel()
limitedTextViewJob =
Expand Down

0 comments on commit 6da4f1a

Please sign in to comment.