final fixes

This commit is contained in:
Phillip Thelen 2024-01-05 16:05:40 +01:00
parent 23dd2d6fd1
commit 55a9da2be3
13 changed files with 100 additions and 37 deletions

View file

@ -37,6 +37,7 @@
app:showPet="false"
app:showMount="false"
app:showSleeping="false"
android:clipChildren="false"
android:layout_gravity="center_horizontal"/>
<com.habitrpg.android.habitica.ui.views.UsernameLabel
android:id="@+id/display_name_text_view"

View file

@ -24,7 +24,9 @@
android:layout_height="110dp"
android:src="@mipmap/ic_launcher"
android:layout_marginEnd="4dp"
android:scaleType="centerInside"
android:scaleType="fitCenter"
android:background="@drawable/layout_rounded_bg_window"
android:clipToOutline="true"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="match_parent"

View file

@ -1472,8 +1472,8 @@
<string name="subscriber_benefit">SUBSCRIBER BENEFIT</string>
<string name="no_saddles">You don\'t have any Saddles</string>
<string name="purchase_saddles_in_market">Saddles instantly raise a Pet to a Mount. You can purchase one from the Market.</string>
<string name="error_loading_member">Error Loading Member</string>
<string name="error_loading_member_body">There was an error when loading this members data. Please try again later.</string>
<string name="error_loading_member">Unable to find player</string>
<string name="error_loading_member_body">There was an error when loading this player's data. Please make sure you typed their @username correctly.</string>
<plurals name="you_x_others">

View file

@ -197,7 +197,7 @@ class UserRepositoryImpl(
override suspend fun getNewsNotification(): Notification {
val baileyNews = apiClient.getNews()
val baileyAnnouncement = (baileyNews?.first() as Map<*, *>)["title"] as String
val baileyAnnouncement = (baileyNews?.first() as? Map<*, *>)?.get("title") as? String
val notification = Notification()
notification.id = "custom-new-stuff-notification"
notification.type = Notification.Type.NEW_STUFF.type

View file

@ -397,7 +397,7 @@ open class Task : RealmObject, BaseMainObject, Parcelable, BaseTask {
}
// Calculate weeks since start and adjust for the correct interval
val weeksSinceStart = ChronoUnit.WEEKS.between(startDate.toLocalDate(), nextDueDate.toLocalDate())
if (weeksSinceStart % everyX != 0L) {
if (everyX > 0 && weeksSinceStart % everyX != 0L) {
val weeksToNextValidInterval = everyX - (weeksSinceStart % everyX)
nextDueDate = nextDueDate.plusWeeks(weeksToNextValidInterval)
// Find the exact next due day within the valid interval

View file

@ -10,16 +10,19 @@ import com.google.android.material.tabs.TabLayoutMediator
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.data.SocialRepository
import com.habitrpg.android.habitica.databinding.ActivityGiftGemsBinding
import com.habitrpg.android.habitica.extensions.addCloseButton
import com.habitrpg.android.habitica.helpers.AppConfigManager
import com.habitrpg.android.habitica.helpers.PurchaseHandler
import com.habitrpg.android.habitica.models.members.Member
import com.habitrpg.android.habitica.ui.fragments.purchases.GiftBalanceGemsFragment
import com.habitrpg.android.habitica.ui.fragments.purchases.GiftPurchaseGemsFragment
import com.habitrpg.android.habitica.ui.views.CurrencyView
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
import com.habitrpg.common.habitica.helpers.ExceptionHandler
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.launch
import java.lang.reflect.InvocationTargetException
import javax.inject.Inject
@AndroidEntryPoint
@ -69,15 +72,35 @@ class GiftGemsActivity : PurchaseActivity() {
giftedUserID = intent.getStringExtra("userID")
giftedUsername = intent.getStringExtra("username")
if (giftedUserID == null && giftedUsername == null) {
giftedUserID = navArgs<GiftGemsActivityArgs>().value.userID
giftedUsername = navArgs<GiftGemsActivityArgs>().value.username
if (giftedUserID.isNullOrBlank()) {
try {
giftedUserID = navArgs<GiftSubscriptionActivityArgs>().value.userID
} catch (_: InvocationTargetException) {
// user ID wasn't passed as nav arg
}
}
if (giftedUsername.isNullOrBlank()) {
try {
giftedUsername = navArgs<GiftSubscriptionActivityArgs>().value.username
} catch (_: InvocationTargetException) {
// username wasn't passed as nav arg
}
}
if (giftedUsername.isNullOrBlank() && giftedUserID.isNullOrBlank()) {
showMemberLoadingErrorDialog()
}
setViewPagerAdapter()
lifecycleScope.launch(ExceptionHandler.coroutine()) {
val member = socialRepository.retrieveMember(giftedUsername ?: giftedUserID) ?: return@launch
lifecycleScope.launch(ExceptionHandler.coroutine {
showMemberLoadingErrorDialog()
}) {
val member = socialRepository.retrieveMember(giftedUsername ?: giftedUserID)
if (member == null) {
showMemberLoadingErrorDialog()
return@launch
}
giftedMember = member
giftedUserID = member.id
giftedUsername = member.username
@ -89,6 +112,14 @@ class GiftGemsActivity : PurchaseActivity() {
}
}
private fun showMemberLoadingErrorDialog() {
val dialog = HabiticaAlertDialog(this)
dialog.setTitle(R.string.error_loading_member)
dialog.setMessage(R.string.error_loading_member_body)
dialog.addCloseButton(isPrimary = true) { _, _ -> finish() }
dialog.show()
}
private fun setViewPagerAdapter() {
val statePagerAdapter = object : FragmentStateAdapter(supportFragmentManager, lifecycle) {
override fun createFragment(position: Int): Fragment {

View file

@ -21,6 +21,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.lang.reflect.InvocationTargetException
import javax.inject.Inject
@AndroidEntryPoint
@ -65,23 +66,37 @@ class GiftSubscriptionActivity : PurchaseActivity() {
giftedUserID = intent.getStringExtra("userID")
giftedUsername = intent.getStringExtra("username")
if (giftedUserID.isNullOrBlank()) {
giftedUserID = navArgs<GiftSubscriptionActivityArgs>().value.userID
try {
giftedUserID = navArgs<GiftSubscriptionActivityArgs>().value.userID
} catch (_: InvocationTargetException) {
// user ID wasn't passed as nav arg
}
}
if (giftedUsername.isNullOrBlank()) {
giftedUsername = navArgs<GiftSubscriptionActivityArgs>().value.username
try {
giftedUsername = navArgs<GiftSubscriptionActivityArgs>().value.username
} catch (_: InvocationTargetException) {
// username wasn't passed as nav arg
}
}
if (giftedUsername.isNullOrBlank() && giftedUserID.isNullOrBlank()) {
showMemberLoadingErrorDialog()
}
if (giftedUsername?.isNotBlank() == true) {
binding.usernameTextView.text = "@${giftedUsername}"
}
binding.subscriptionButton.setOnClickListener {
selectedSubscriptionSku?.let { sku -> purchaseSubscription(sku) }
}
lifecycleScope.launch(ExceptionHandler.coroutine()) {
lifecycleScope.launch(ExceptionHandler.coroutine {
showMemberLoadingErrorDialog()
}) {
val member = socialRepository.retrieveMember(giftedUsername ?: giftedUserID)
if (member == null) {
val dialog = HabiticaAlertDialog(this@GiftSubscriptionActivity)
dialog.setTitle(R.string.error_loading_member)
dialog.setMessage(R.string.error_loading_member_body)
dialog.addCloseButton { _, _ -> finish() }
dialog.show()
showMemberLoadingErrorDialog()
return@launch
}
binding.avatarView.setAvatar(member)
@ -99,6 +114,14 @@ class GiftSubscriptionActivity : PurchaseActivity() {
}
}
private fun showMemberLoadingErrorDialog() {
val dialog = HabiticaAlertDialog(this@GiftSubscriptionActivity)
dialog.setTitle(R.string.error_loading_member)
dialog.setMessage(R.string.error_loading_member_body)
dialog.addCloseButton(isPrimary = true) { _, _ -> finish() }
dialog.show()
}
override fun onStart() {
super.onStart()
CoroutineScope(Dispatchers.IO).launch(ExceptionHandler.coroutine()) {

View file

@ -59,11 +59,13 @@ class EquipmentDetailFragment :
lifecycleScope.launchCatching {
inventoryRepository.equipGear(it, isCostume ?: false)
userViewModel.user.observeOnce(viewLifecycleOwner) { user ->
val parentActivity = mainActivity
val totalCheckIns = user?.loginIncentives
if (totalCheckIns != null && parentActivity != null) {
reviewManager.requestReview(parentActivity, totalCheckIns)
if (this@EquipmentDetailFragment.isAdded) {
userViewModel.user.observeOnce(viewLifecycleOwner) { user ->
val parentActivity = mainActivity
val totalCheckIns = user?.loginIncentives
if (totalCheckIns != null && parentActivity != null) {
reviewManager.requestReview(parentActivity, totalCheckIns)
}
}
}
}

View file

@ -133,11 +133,13 @@ class PetDetailRecyclerFragment :
val items = inventoryRepository.equip("pet", it)
adapter.currentPet = items?.currentPet
userViewModel.user.observeOnce(viewLifecycleOwner) { user ->
val parentActivity = mainActivity
val totalCheckIns = user?.loginIncentives
if (totalCheckIns != null && parentActivity != null) {
reviewManager.requestReview(parentActivity, totalCheckIns)
if (isAdded) {
userViewModel.user.observeOnce(viewLifecycleOwner) { user ->
val parentActivity = mainActivity
val totalCheckIns = user?.loginIncentives
if (totalCheckIns != null && parentActivity != null) {
reviewManager.requestReview(parentActivity, totalCheckIns)
}
}
}
}

View file

@ -169,6 +169,9 @@ class PreferencesFragment :
isPrimary = true,
isDestructive = true
) { _, _ ->
lifecycleScope.launch {
userRepository.changeClass()
}
classSelectionResult.launch(
intent
)

View file

@ -266,6 +266,7 @@ fun PetBottomSheet(
MainNavigationController.navigate(R.id.marketFragment)
}
dialog.addCloseButton()
dialog.show()
}
onDismiss()
}, modifier = Modifier

View file

@ -1,10 +1,8 @@
New in 4.3:
New in 4.3.2:
- Reminders should show more reliably now
- Remaining Armoire equipment no longer counts unreleased items
- Better error handling when gifting
- Avatar widget now displays correctly
- Pets just got cuter! Tap a Pet or Mount to see them in an environment that changes each month.
- Pets bounce when fed
- New Subscriber benefit: Buy one Armoire, get another free!
- New Subscriber benefit: Get a second chance at life once a day when you run out of HP!
- Tap your avatar to share your latest looks at any time
- New Subscriber benefits: Buy one Armoire, get another free! Also, get a second chance at life once a day when you run out of HP!
- See answers to common Quest mechanic questions under your active Quest
- Updated Quest interface
- The Quest shop now shows a check by completed Quests

View file

@ -1,2 +1,2 @@
NAME=4.3.2
CODE=6801
CODE=6811