mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
various fixes
This commit is contained in:
parent
651148f56f
commit
61bfeb6862
7 changed files with 34 additions and 11 deletions
|
|
@ -70,6 +70,7 @@ open class ShopItem : RealmObject(), BaseObject {
|
|||
|
||||
fun canAfford(user: User?, quantity: Int): Boolean = when (currency) {
|
||||
"gold" -> (value * quantity) <= (user?.stats?.gp ?: 0.0)
|
||||
"gems" -> (value * quantity) <= (user?.gemCount ?: 0)
|
||||
else -> true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ import com.habitrpg.android.habitica.ui.viewmodels.MainUserViewModel
|
|||
import com.habitrpg.android.habitica.ui.views.CurrencyText
|
||||
import com.habitrpg.android.habitica.ui.views.PixelArtView
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
|
||||
import com.habitrpg.android.habitica.ui.views.insufficientCurrency.InsufficientGemsDialog
|
||||
import com.habitrpg.common.habitica.extensions.DataBindingUtils
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.delay
|
||||
|
|
@ -127,6 +128,11 @@ class BirthdayActivity : BaseActivity() {
|
|||
lifecycleScope.launchCatching({
|
||||
isPurchasing.value = false
|
||||
}) {
|
||||
if ((userViewModel.user.value?.gemCount ?: 0) < 60) {
|
||||
val dialog = InsufficientGemsDialog(this@BirthdayActivity, 3)
|
||||
dialog.show()
|
||||
return@launchCatching
|
||||
}
|
||||
isPurchasing.value = true
|
||||
val dialog = HabiticaAlertDialog(this@BirthdayActivity)
|
||||
dialog.setTitle(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import android.content.res.Configuration
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
|
@ -18,7 +17,6 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||
import androidx.activity.viewModels
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
|
|
@ -124,6 +122,21 @@ open class MainActivity : BaseActivity(), SnackbarActivity {
|
|||
private var sideAvatarView: AvatarView? = null
|
||||
private var drawerFragment: NavigationDrawerFragment? = null
|
||||
var drawerToggle: ActionBarDrawerToggle? = null
|
||||
var showBirthdayIcon = false
|
||||
var showBackButton: Boolean? = null
|
||||
set(value) {
|
||||
if (field == value) return
|
||||
if (value == true && showBirthdayIcon) {
|
||||
drawerToggle?.isDrawerIndicatorEnabled = false
|
||||
drawerToggle?.setHomeAsUpIndicator(R.drawable.arrow_back)
|
||||
} else if (value == false && showBirthdayIcon) {
|
||||
drawerToggle?.isDrawerIndicatorEnabled = false
|
||||
drawerToggle?.setHomeAsUpIndicator(R.drawable.icon_birthday)
|
||||
} else {
|
||||
drawerToggle?.isDrawerIndicatorEnabled = value != true
|
||||
}
|
||||
field = value
|
||||
}
|
||||
private var resumeFromActivity = false
|
||||
private var userQuestStatus = UserQuestStatus.NO_QUEST
|
||||
private var lastNotificationOpen: Long? = null
|
||||
|
|
@ -335,7 +348,7 @@ open class MainActivity : BaseActivity(), SnackbarActivity {
|
|||
return if (binding.root.parent is DrawerLayout && drawerToggle?.onOptionsItemSelected(item) == true) {
|
||||
true
|
||||
} else if (item.itemId == android.R.id.home) {
|
||||
if (drawerToggle?.isDrawerIndicatorEnabled == true) {
|
||||
if (showBackButton != true) {
|
||||
drawerFragment?.toggleDrawer()
|
||||
} else {
|
||||
MainNavigationController.navigateBack()
|
||||
|
|
|
|||
|
|
@ -110,18 +110,18 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
var lastSet = CustomizationSet()
|
||||
val today = Date()
|
||||
for (customization in newCustomizationList) {
|
||||
val isUsable = customization.isUsable(ownedCustomizations.contains(customization.id))
|
||||
if (customization.availableFrom != null || customization.availableUntil != null) {
|
||||
if (((customization.availableFrom?.compareTo(today)
|
||||
?: 0) > 0 || (customization.availableUntil?.compareTo(today)
|
||||
?: 0) < 0) && !customization.isUsable(
|
||||
ownedCustomizations.contains(
|
||||
customization.id
|
||||
)
|
||||
)
|
||||
?: 0) < 0) && !isUsable
|
||||
) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if ((customization.identifier?.contains("HabitversaryBash") == true || customization.identifier?.contains("birthday") == true) && !isUsable) {
|
||||
continue
|
||||
}
|
||||
if (customization.customizationSet != null && customization.customizationSet != lastSet.identifier) {
|
||||
if (lastSet.hasPurchasable && lastSet.price > 0) {
|
||||
customizationList.add(lastSet)
|
||||
|
|
@ -136,7 +136,7 @@ class CustomizationRecyclerViewAdapter() : androidx.recyclerview.widget.Recycler
|
|||
}
|
||||
customizationList.add(customization)
|
||||
lastSet.customizations.add(customization)
|
||||
if (customization.isUsable(ownedCustomizations.contains(customization.id)) && lastSet.hasPurchasable) {
|
||||
if (isUsable && lastSet.hasPurchasable) {
|
||||
lastSet.ownedCustomizations.add(customization)
|
||||
if (!lastSet.isSetDeal()) {
|
||||
lastSet.hasPurchasable = false
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ abstract class BaseMainFragment<VB : ViewBinding> : BaseFragment<VB>() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.drawerToggle?.isDrawerIndicatorEnabled = !showsBackButton
|
||||
activity?.showBackButton = showsBackButton
|
||||
activity?.supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -178,9 +178,11 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
newItems.addAll(adapter.items)
|
||||
newItems.add(0, birthdayItem)
|
||||
adapter.updateItems(newItems)
|
||||
(activity as? MainActivity)?.showBirthdayIcon = true
|
||||
} else if (event == null && item != null) {
|
||||
item.isVisible = false
|
||||
adapter.updateItem(item)
|
||||
(activity as? MainActivity)?.showBirthdayIcon = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ abstract class TaskListFactory internal constructor(
|
|||
return
|
||||
}
|
||||
CoroutineScope(Dispatchers.Main + job).launch(ExceptionHandler.coroutine()) {
|
||||
val tasks = taskRepository.getTasks(taskType, null, emptyArray()).firstOrNull()?.filter { task ->
|
||||
val mirroredTasks = userRepository.getUser().firstOrNull()?.preferences?.tasks?.mirrorGroupTasks?.toTypedArray()
|
||||
val tasks = taskRepository.getTasks(taskType, null, mirroredTasks ?: emptyArray()).firstOrNull()?.filter { task ->
|
||||
task.type == TaskType.TODO && !task.completed || task.isDisplayedActive
|
||||
} ?: return@launch
|
||||
taskList = taskRepository.getTaskCopies(tasks)
|
||||
|
|
|
|||
Loading…
Reference in a new issue