fix bugs and crashes

This commit is contained in:
Phillip Thelen 2023-01-11 10:43:03 +01:00
parent c06a2e2d07
commit 1b81f0ce2f
12 changed files with 66 additions and 21 deletions

View file

@ -75,5 +75,10 @@
style="@style/HabiticaButton.Purple"
android:layout_marginTop="@dimen/spacing_medium"
android:text="@string/send_gift" />
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -747,7 +747,7 @@
<string name="gift_confirmation_title">Your gift was sent!</string>
<string name="gift_confirmation_text_sub_g1g1">You sent %1$s a %2$s-month Habitica subscription and the same subscription was applied to your account for our Gift One Get One promotion!</string>
<string name="gift_confirmation_text_sub">You sent @%1$s a %2$s-month Habitica subscription.</string>
<string name="gift_confirmation_text_gems_new">You sent @%s %s gems.</string>
<string name="gift_confirmation_text_gems_new">You sent @%1$s %2$s gems.</string>
<string name="subscription_confirmation">You are now subscribed for 1 month</string>
<string name="subscription_confirmation_multiple">You are now subscribed for %s months</string>
<string name="gem_purchase_confirmation">You gained %s gems.</string>

View file

@ -89,11 +89,10 @@ class SocialRepositoryImpl(
return null
}
val liked = chatMessage.userLikesMessage(userID)
if (chatMessage.isManaged) {
localRepository.likeMessage(chatMessage, userID, !liked)
}
localRepository.likeMessage(chatMessage, userID, !liked)
val message = apiClient.likeMessage(chatMessage.groupId ?: "", chatMessage.id)
message?.groupId = chatMessage.groupId
message?.let { localRepository.save(it) }
return null
}

View file

@ -211,7 +211,9 @@ class PurchaseHandler(
}
val flowParams = BillingFlowParams.newBuilder()
.setProductDetailsParamsList(listOf(skuDetails).map {
BillingFlowParams.ProductDetailsParams.newBuilder().setProductDetails(skuDetails)
BillingFlowParams.ProductDetailsParams.newBuilder()
.setProductDetails(skuDetails)
.setOfferToken(skuDetails.subscriptionOfferDetails?.first()?.offerToken ?: "")
.build()
})
.build()

View file

@ -11,6 +11,7 @@ import com.habitrpg.android.habitica.helpers.AmplitudeManager
import com.habitrpg.android.habitica.helpers.launchCatching
import com.habitrpg.android.habitica.models.user.User
import kotlinx.coroutines.MainScope
import java.io.IOException
class PushNotificationManager(
var apiClient: ApiClient,
@ -52,8 +53,12 @@ class PushNotificationManager(
addRefreshToken()
} else {
FirebaseMessaging.getInstance().token.addOnCompleteListener {
refreshedToken = it.result
addRefreshToken()
try {
refreshedToken = it.result
addRefreshToken()
} catch (_: IOException) {
// This can happen during google test runs
}
}
}
}

View file

@ -126,7 +126,6 @@ class LoginActivity : BaseActivity() {
}
override fun getLayoutResId(): Int {
window.requestFeature(Window.FEATURE_ACTION_BAR)
return R.layout.activity_login
}
@ -136,6 +135,7 @@ class LoginActivity : BaseActivity() {
}
override fun onCreate(savedInstanceState: Bundle?) {
window.requestFeature(Window.FEATURE_ACTION_BAR)
super.onCreate(savedInstanceState)
viewModel = AuthenticationViewModel()
supportActionBar?.hide()

View file

@ -111,7 +111,7 @@ class CustomizationEquipmentRecyclerViewAdapter : androidx.recyclerview.widget.R
imageView.loadImage("shop_" + this.equipment?.key)
val priceLabel = dialogContent.findViewById<TextView>(R.id.priceLabel)
priceLabel.text = if (equipment?.gearSet == "animal") {
priceLabel?.text = if (equipment?.gearSet == "animal") {
2.0
} else {
equipment?.value ?: 0

View file

@ -335,7 +335,7 @@ class AvatarCustomizationFragment :
button.setOnCheckedChangeListener { _, isChecked ->
val newFilter = filter.copy()
newFilter.months = mutableListOf()
newFilter.months.addAll(filter.months)
newFilter.months.addAll(currentFilter.value.months)
if (!isChecked && newFilter.months.contains(identifier)) {
button.typeface = Typeface.create("sans-serif", Typeface.NORMAL)
newFilter.months.remove(identifier)

View file

@ -5,28 +5,41 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.components.UserComponent
import com.habitrpg.android.habitica.data.SocialRepository
import com.habitrpg.android.habitica.data.UserRepository
import com.habitrpg.android.habitica.databinding.FragmentGiftGemBalanceBinding
import com.habitrpg.android.habitica.extensions.addCloseButton
import com.habitrpg.android.habitica.helpers.launchCatching
import com.habitrpg.android.habitica.models.members.Member
import com.habitrpg.android.habitica.ui.fragments.BaseFragment
import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaAlertDialog
import javax.inject.Inject
class GiftBalanceGemsFragment : BaseFragment<FragmentGiftGemBalanceBinding>() {
@Inject
lateinit var socialRepository: SocialRepository
@Inject
lateinit var userRepository: UserRepository
override var binding: FragmentGiftGemBalanceBinding? = null
private var isGifting = false
set(value) {
field = value
binding?.giftButton?.isVisible = !isGifting
binding?.progressBar?.isVisible = isGifting
}
override fun createBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentGiftGemBalanceBinding {
override fun createBinding(
inflater: LayoutInflater,
container: ViewGroup?
): FragmentGiftGemBalanceBinding {
return FragmentGiftGemBalanceBinding.inflate(inflater, container, false)
}
@ -61,15 +74,29 @@ class GiftBalanceGemsFragment : BaseFragment<FragmentGiftGemBalanceBinding>() {
if (isGifting) return
isGifting = true
try {
val amount = binding?.giftEditText?.text.toString().toInt()
val amount = binding?.giftEditText?.text.toString().strip().toInt()
giftedMember?.id?.let {
lifecycleScope.launchCatching({
activity?.lifecycleScope?.launchCatching({
isGifting = false
}) {
socialRepository.transferGems(it, amount)
userRepository.retrieveUser(false)
val dialog = context?.let { it1 -> HabiticaAlertDialog(it1) }
dialog?.setTitle(R.string.gift_confirmation_title)
dialog?.setMessage(
getString(
R.string.gift_confirmation_text_gems_new,
giftedMember?.username,
amount.toString()
)
)
dialog?.addCloseButton { _, _ ->
activity?.finish()
}
dialog?.show()
}
}
} catch (ignored: NumberFormatException) {}
} catch (ignored: NumberFormatException) {
}
}
}

View file

@ -91,8 +91,12 @@ object MarkdownParser {
return SpannableString("")
}
val hashCode = input.hashCode()
if (cache.containsKey(hashCode)) {
return cache[hashCode] ?: SpannableString(input)
try {
if (cache.containsKey(hashCode)) {
return cache[hashCode] ?: SpannableString(input)
}
} catch (_: NullPointerException) {
// Sometimes happens
}
val text = EmojiParser.parseEmojis(input) ?: input
// Adding this space here bc for some reason some markdown is not rendered correctly when the whole string is supposed to be formatted

View file

@ -1,9 +1,12 @@
New in 4.1:
-You can view, complete, assign, and add tasks to your Group Plans shared task board!
-You can view, complete, assign, and add tasks to your Group Plan's shared task board!
-Tap your name on a task screen to switch to different task boards
-Subscription details will show extra months and when youll get your next Hourglass
-More intuitive system notification settings
-Audio will be controlled by media volume now
-Task details are now tinted based on task health
-New Avatar Customization interface
-Audio will be controlled by media volume now
-Fixed a bug that caused tasks to shuffle around
-Monthly Dailies should recur more consistently now
-More intuitive system notification settings
-Improved link support
-More special event support

View file

@ -1,2 +1,2 @@
NAME=4.1
CODE=4981
CODE=4991