mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Fix displaying banner
This commit is contained in:
parent
2ecaf30e37
commit
6f5aa2d6f7
11 changed files with 47 additions and 31 deletions
|
|
@ -259,6 +259,7 @@
|
|||
android:gravity="center"
|
||||
android:paddingStart="30dp"
|
||||
android:paddingEnd="30dp"
|
||||
android:visibility="gone"
|
||||
android:text="@string/subscribers_mythic_hourglasses" />
|
||||
|
||||
<ImageView
|
||||
|
|
|
|||
|
|
@ -1331,6 +1331,7 @@
|
|||
<string name="see_more">See More</string>
|
||||
<string name="jubilant_gryphatrice_confirmation">You purchased the Jubilant Gryphatrice!</string>
|
||||
<string name="jubilant_gryphatrice_confirmation_gift">You gifted the Jubilant Gryphatrice!</string>
|
||||
<string name="open_settings">Open Settings</string>
|
||||
|
||||
<plurals name="you_x_others">
|
||||
<item quantity="zero">You</item>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ import kotlinx.coroutines.flow.Flow
|
|||
interface ContentRepository: BaseRepository {
|
||||
suspend fun retrieveContent(forced: Boolean = false): ContentResult?
|
||||
|
||||
suspend fun retrieveWorldState(): WorldState?
|
||||
suspend fun retrieveWorldState(forced: Boolean = false): WorldState?
|
||||
fun getWorldState(): Flow<WorldState>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ class ContentRepositoryImpl<T : ContentLocalRepository>(
|
|||
return null
|
||||
}
|
||||
|
||||
override suspend fun retrieveWorldState(): WorldState? {
|
||||
override suspend fun retrieveWorldState(forced: Boolean): WorldState? {
|
||||
val now = Date().time
|
||||
if (now - this.lastWorldStateSync > 3600000) {
|
||||
if (forced || now - this.lastWorldStateSync > 3600000) {
|
||||
val state = apiClient.getWorldState() ?: return null
|
||||
lastWorldStateSync = now
|
||||
localRepository.save(state)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.habitrpg.android.habitica.ui.activities
|
|||
|
||||
import android.app.Activity
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateFormat
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
|
|
@ -62,6 +61,7 @@ import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
|||
import com.habitrpg.android.habitica.ui.views.CurrencyText
|
||||
import com.habitrpg.common.habitica.extensions.DataBindingUtils
|
||||
import kotlinx.coroutines.flow.map
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ fun BirthdayTitle(text: String) {
|
|||
@Composable
|
||||
fun BirthdayActivityView(hasGryphatrice: Boolean, price: String, startDate: Date, endDate: Date, onPurchaseClick: () -> Unit, onGemPurchaseClick: () -> Unit, onEquipClick: () -> Unit) {
|
||||
val activity = LocalContext.current as? Activity
|
||||
val dateFormat = DateFormat.getDateFormat(activity)
|
||||
val dateFormat = SimpleDateFormat("MMM dd", java.util.Locale.getDefault())
|
||||
val textColor = Color.White
|
||||
val specialTextColor = colorResource(R.color.yellow_50)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ import android.graphics.drawable.ColorDrawable
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.text.SpannableString
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class ItemRecyclerAdapter(val context: Context) : BaseRecyclerViewAdapter<OwnedI
|
|||
menu.setSelectionRunnable { index ->
|
||||
item?.let { selectedItem ->
|
||||
if (!(selectedItem is QuestContent || selectedItem is SpecialItem || ownedItem?.itemType == "special") && index == 0) {
|
||||
ownedItem?.let { selectedOwnedItem -> sellItemEvents.onNext(selectedOwnedItem) }
|
||||
ownedItem?.let { selectedOwnedItem -> onSellItem?.invoke(selectedOwnedItem) }
|
||||
return@let
|
||||
}
|
||||
when (selectedItem) {
|
||||
|
|
|
|||
|
|
@ -140,15 +140,15 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
false
|
||||
initializeMenuItems()
|
||||
|
||||
adapter.itemSelectedEvents = {
|
||||
setSelection(it.transitionId, it.bundle, true)
|
||||
}
|
||||
adapter.promoClosedSubject = {
|
||||
sharedPreferences.edit {
|
||||
putBoolean("hide$it", true)
|
||||
}
|
||||
updatePromo()
|
||||
adapter.itemSelectedEvents = {
|
||||
setSelection(it.transitionId, it.bundle, true)
|
||||
}
|
||||
adapter.promoClosedSubject = {
|
||||
sharedPreferences.edit {
|
||||
putBoolean("hide$it", true)
|
||||
}
|
||||
updatePromo()
|
||||
}
|
||||
|
||||
lifecycleScope.launchCatching {
|
||||
contentRepository.getWorldState()
|
||||
|
|
@ -167,6 +167,21 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
}) {
|
||||
updateSeasonalMenuEntries(gearEvent, pair.second)
|
||||
}
|
||||
|
||||
val event = pair.first.events.firstOrNull { it.eventKey == "birthday10" }
|
||||
val item = getItemWithIdentifier(SIDEBAR_BIRTHDAY)
|
||||
if (event != null && item == null) {
|
||||
adapter.currentEvent = event
|
||||
val birthdayItem = HabiticaDrawerItem(R.id.birthdayActivity, SIDEBAR_BIRTHDAY)
|
||||
birthdayItem.itemViewType = 6
|
||||
val newItems = mutableListOf<HabiticaDrawerItem>()
|
||||
newItems.addAll(adapter.items)
|
||||
newItems.add(0, birthdayItem)
|
||||
adapter.updateItems(newItems)
|
||||
} else if (event == null && item != null) {
|
||||
item.isVisible = false
|
||||
adapter.updateItem(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -551,12 +566,6 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
item.itemViewType = 2
|
||||
items.add(item)
|
||||
}
|
||||
|
||||
configManager.getBirthdayEvent()?.let {
|
||||
val birthdayItem = HabiticaDrawerItem(R.id.birthdayActivity, SIDEBAR_BIRTHDAY)
|
||||
birthdayItem.itemViewType = 6
|
||||
items.add(0, birthdayItem)
|
||||
}
|
||||
adapter.updateItems(items)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import android.widget.ImageView
|
|||
import android.widget.TextView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.databinding.DialogPurchaseContentQuestBinding
|
||||
import com.habitrpg.android.habitica.extensions.fromHtml
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestDropItem
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
|
|
@ -26,7 +25,6 @@ class PurchaseDialogQuestContent(context: Context) : PurchaseDialogContent(conte
|
|||
|
||||
override fun setQuestContentItem(questContent: QuestContent) {
|
||||
super.setQuestContentItem(questContent)
|
||||
binding.notesTextView.setText(questContent.notes.fromHtml(), TextView.BufferType.SPANNABLE)
|
||||
binding.rageMeterView.visibility = View.GONE
|
||||
if (questContent.isBossQuest) {
|
||||
binding.questTypeTextView.setText(R.string.boss_quest)
|
||||
|
|
|
|||
|
|
@ -50,14 +50,19 @@ class SubscriptionDetailsView : LinearLayout {
|
|||
var duration: String? = null
|
||||
|
||||
if (plan.planId != null && plan.dateTerminated == null) {
|
||||
if (plan.planId == SubscriptionPlan.PLANID_BASIC || plan.planId == SubscriptionPlan.PLANID_BASICEARNED) {
|
||||
duration = resources.getString(R.string.month)
|
||||
} else if (plan.planId == SubscriptionPlan.PLANID_BASIC3MONTH) {
|
||||
duration = resources.getString(R.string.three_months)
|
||||
} else if (plan.planId == SubscriptionPlan.PLANID_BASIC6MONTH || plan.planId == SubscriptionPlan.PLANID_GOOGLE6MONTH) {
|
||||
duration = resources.getString(R.string.six_months)
|
||||
} else if (plan.planId == SubscriptionPlan.PLANID_BASIC12MONTH) {
|
||||
duration = resources.getString(R.string.twelve_months)
|
||||
when (plan.planId) {
|
||||
SubscriptionPlan.PLANID_BASIC, SubscriptionPlan.PLANID_BASICEARNED -> {
|
||||
duration = resources.getString(R.string.month)
|
||||
}
|
||||
SubscriptionPlan.PLANID_BASIC3MONTH -> {
|
||||
duration = resources.getString(R.string.three_months)
|
||||
}
|
||||
SubscriptionPlan.PLANID_BASIC6MONTH, SubscriptionPlan.PLANID_GOOGLE6MONTH -> {
|
||||
duration = resources.getString(R.string.six_months)
|
||||
}
|
||||
SubscriptionPlan.PLANID_BASIC12MONTH -> {
|
||||
duration = resources.getString(R.string.twelve_months)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.1
|
||||
CODE=4971
|
||||
CODE=4981
|
||||
Loading…
Reference in a new issue