Improve menu display

This commit is contained in:
Phillip Thelen 2024-05-06 12:07:06 +02:00
parent 6656f304a2
commit bfd8764967
7 changed files with 33 additions and 8 deletions

View file

@ -1510,6 +1510,10 @@
<string name="switches_in_x">Switches in %s</string>
<string name="tap_to_reload">Refresh for new items</string>
<string name="monthly_backgrounds">Monthly Backgrounds</string>
<string name="winter">Winter</string>
<string name="spring">Spring</string>
<string name="summer">Summer</string>
<string name="fall">Fall</string>
<plurals name="you_x_others">
<item quantity="zero">You</item>

View file

@ -145,6 +145,7 @@ class AppConfigManager(contentRepository: ContentRepository?) :
return promo
}
fun knownIssues(): List<Map<String, String>> {
val type = object : TypeToken<List<Map<String, String>>>() {}.type
return Gson().fromJson(remoteConfig.getString("knownIssues"), type)

View file

@ -36,4 +36,8 @@ open class WorldState : RealmObject(), BaseObject {
}
return null
}
fun getCurrentSeason(): String? {
return events.firstOrNull { it?.season != null }?.season ?: currentEvent?.season
}
}

View file

@ -19,6 +19,7 @@ open class WorldStateEvent : RealmObject(), BaseMainObject {
var start: Date? = null
var end: Date? = null
var promo: String? = null
var season: String? = null
var npcImageSuffix: String? = null
var aprilFools: String? = null
var gear: Boolean = false

View file

@ -160,11 +160,11 @@ class NavigationDrawerFragment : DialogFragment() {
.combine(
inventoryRepository.getAvailableLimitedItems(),
) { state, items -> Pair(state, items) }
.collect { pair ->
val gearEvent = pair.first.events.firstOrNull { it.gear }
.collect { (worldState, items) ->
val gearEvent = worldState.events.firstOrNull { it.gear }
createUpdatingJob("seasonal", {
if (gearEvent?.isValid == false) return@createUpdatingJob false
gearEvent?.isCurrentlyActive == true || pair.second.isNotEmpty()
gearEvent?.isCurrentlyActive == true || items.isNotEmpty()
}, {
val diff = (gearEvent?.end?.time ?: 0) - Date().time
if (diff < (1.toDuration(DurationUnit.HOURS).inWholeMilliseconds)) {
@ -175,7 +175,7 @@ class NavigationDrawerFragment : DialogFragment() {
1.toDuration(DurationUnit.MINUTES)
}
}) {
updateSeasonalMenuEntries(gearEvent, pair.second)
updateSeasonalMenuEntries(gearEvent, items)
}
val event = configManager.getBirthdayEvent()
@ -194,6 +194,21 @@ class NavigationDrawerFragment : DialogFragment() {
adapter.updateItem(item)
(activity as? MainActivity)?.showBirthdayIcon = false
}
val season = worldState.getCurrentSeason()
if (season != null) {
getItemWithIdentifier(SIDEBAR_SHOPS_SEASONAL)?.let { seasonalItem ->
val seasonID = when (season) {
"winter" -> R.string.winter
"spring" -> R.string.spring
"summer" -> R.string.summer
"fall" -> R.string.fall
else -> R.string.open
}
seasonalItem.pillText = requireContext().getString(seasonID)
adapter.updateItem(seasonalItem)
}
}
}
}
@ -257,7 +272,7 @@ class NavigationDrawerFragment : DialogFragment() {
adapter.updateItem(market)
val shop = getItemWithIdentifier(SIDEBAR_SHOPS_SEASONAL) ?: return
shop.pillText = context?.getString(R.string.open)
shop.subtitle = gearEvent?.end?.getRemainingString(requireContext().resources)
adapter.updateItem(shop)
}

View file

@ -56,9 +56,9 @@ class SectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
try {
val stringID =
context.resources.getIdentifier("section$title", "string", context.packageName)
this.label.text = context.getString(stringID)
this.label.text = context.getString(stringID).uppercase()
} catch (e: Exception) {
this.label.text = title
this.label.text = title.uppercase()
}
}

View file

@ -129,7 +129,7 @@
<color name="yellow_00">#26221C</color>
<color name="orange_00">#26201C</color>
<color name="brand_sub_text">#B3432874</color>
<color name="brand_sub_text">@color/brand_300</color>
<color name="maroon_sub_text">#AB6565</color>
<color name="red_sub_text">#AB6570</color>
<color name="orange_sub_text">#AB8165</color>