mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 21:29:00 +00:00
Fix multiple minor issues
This commit is contained in:
parent
01ce6ed39b
commit
75f6181cec
20 changed files with 109 additions and 50 deletions
|
|
@ -150,7 +150,7 @@ android {
|
|||
buildConfigField "String", "TESTING_LEVEL", "\"production\""
|
||||
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
|
||||
|
||||
versionCode 2614
|
||||
versionCode 2620
|
||||
versionName "3.1"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
<com.habitrpg.android.habitica.ui.helpers.RecyclerViewEmptySupport
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
<com.habitrpg.android.habitica.ui.views.social.ChatBarView
|
||||
android:id="@+id/chatBarView"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@
|
|||
<string name="quest_abort">Abort Quest</string>
|
||||
<string name="version_info">Version %1$s (%2$d)</string>
|
||||
|
||||
<string name="sidebar_help">Help & FAQ</string>
|
||||
<string name="sidebar_help">Support</string>
|
||||
<string name="complete_tutorial">Got it!</string>
|
||||
<string name="dismiss_tutorial">Remind me again</string>
|
||||
<string name="intro_1_subtitle">Welcome to</string>
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
|
|||
localRepository.executeTransaction {
|
||||
val liveItem = localRepository.getLiveObject(ownedItem)
|
||||
val liveUser = localRepository.getLiveObject(user)
|
||||
liveItem?.numberOwned = 1 + (liveItem?.numberOwned ?: 0)
|
||||
liveItem?.numberOwned = 1 - (liveItem?.numberOwned ?: 0)
|
||||
liveUser?.stats?.gp = (user.stats?.gp ?: 0.0) + item.value
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,8 +205,9 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
|
|||
}
|
||||
|
||||
override fun changeOwnedCount(item: OwnedItem, amountToAdd: Int?) {
|
||||
val liveItem = getLiveObject(item) ?: return
|
||||
amountToAdd?.let { amount ->
|
||||
executeTransaction { item.numberOwned = item.numberOwned + amount }
|
||||
executeTransaction { liveItem.numberOwned = liveItem.numberOwned + amount }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,10 +173,17 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
if (chatMessage.userLikesMessage(userId) == liked) {
|
||||
return
|
||||
}
|
||||
val liveMessage = getLiveObject(chatMessage)
|
||||
if (liked) {
|
||||
executeTransaction { chatMessage.likes?.add(ChatMessageLike(userId, chatMessage.id)) }
|
||||
executeTransaction {
|
||||
liveMessage?.likes?.add(ChatMessageLike(userId, chatMessage.id))
|
||||
}
|
||||
} else {
|
||||
chatMessage.likes?.filter { userId == it.id }?.forEach { like -> executeTransaction { like.deleteFromRealm() } }
|
||||
liveMessage?.likes?.filter { userId == it.id }?.forEach { like ->
|
||||
executeTransaction(Realm.Transaction {
|
||||
like.deleteFromRealm()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,8 +219,10 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
}
|
||||
|
||||
override fun setQuestActivity(party: Group?, active: Boolean) {
|
||||
if (party == null) return
|
||||
val liveParty = getLiveObject(party)
|
||||
executeTransaction {
|
||||
party?.quest?.active = active
|
||||
liveParty?.quest?.active = active
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
package com.habitrpg.android.habitica.models.social
|
||||
|
||||
import android.renderscript.BaseObj
|
||||
import com.habitrpg.android.habitica.models.BaseObject
|
||||
import com.habitrpg.android.habitica.models.user.Backer
|
||||
import com.habitrpg.android.habitica.models.user.ContributorInfo
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.Ignore
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class ChatMessage : RealmObject() {
|
||||
open class ChatMessage : RealmObject(), BaseObject {
|
||||
|
||||
override val realmClass: Class<ChatMessage>
|
||||
get() = ChatMessage::class.java
|
||||
override val primaryIdentifier: String?
|
||||
get() = id
|
||||
override val primaryIdentifierName: String
|
||||
get() = "id"
|
||||
|
||||
@PrimaryKey
|
||||
var id: String = ""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.habitrpg.android.habitica.models.social
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.habitrpg.android.habitica.models.BaseObject
|
||||
import com.habitrpg.android.habitica.models.inventory.Quest
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
|
||||
|
|
@ -8,7 +9,14 @@ import io.realm.RealmList
|
|||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Group : RealmObject() {
|
||||
open class Group : RealmObject(), BaseObject {
|
||||
|
||||
override val realmClass: Class<Group>
|
||||
get() = Group::class.java
|
||||
override val primaryIdentifier: String?
|
||||
get() = id
|
||||
override val primaryIdentifierName: String
|
||||
get() = "id"
|
||||
|
||||
@SerializedName("_id")
|
||||
@PrimaryKey
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.content.res.Resources
|
|||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
|
|
@ -102,6 +103,16 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
internal open fun loadTheme(sharedPreferences: SharedPreferences, forced: Boolean = false) {
|
||||
val theme = forcedTheme ?: sharedPreferences.getString("theme_name", "purple")
|
||||
val modernHeaderStyle = overrideModernHeader ?: sharedPreferences.getBoolean("modern_header_style", true)
|
||||
|
|
|
|||
|
|
@ -238,10 +238,6 @@ class TaskFormActivity : BaseActivity() {
|
|||
when (item.itemId) {
|
||||
R.id.action_save -> saveTask()
|
||||
R.id.action_delete -> deleteTask()
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ class NavigationDrawerAdapter(tintColor: Int, backgroundTintColor: Int): Recycle
|
|||
titleTextView?.text = drawerItem.text
|
||||
|
||||
if (isSelected) {
|
||||
itemView.setBackgroundColor(ContextCompat.getColor(itemView.context, R.color.offset_background))
|
||||
itemView.setBackgroundColor(ContextCompat.getColor(itemView.context, R.color.content_background_offset))
|
||||
itemView.background.alpha = 69
|
||||
titleTextView?.setTextColor(tintColor)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class PetDetailRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapt
|
|||
return equipEvents.toFlowable(BackpressureStrategy.DROP)
|
||||
}
|
||||
|
||||
var animalIngredientsRetriever: ((Animal) -> Pair<Egg?, HatchingPotion?>)? = null
|
||||
var animalIngredientsRetriever: ((Animal, ((Pair<Egg?, HatchingPotion?>) -> Unit)) -> Unit)? = null
|
||||
|
||||
private fun canRaiseToMount(pet: Pet): Boolean {
|
||||
for (mount in existingMounts ?: emptyList<Mount>()) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class StableRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
|
||||
var shopSpriteSuffix: String? = null
|
||||
private var eggs: Map<String, Egg> = mapOf()
|
||||
var animalIngredientsRetriever: ((Animal) -> Pair<Egg?, HatchingPotion?>)? = null
|
||||
var animalIngredientsRetriever: ((Animal, ((Pair<Egg?, HatchingPotion?>) -> Unit)) -> Unit)? = null
|
||||
var itemType: String? = null
|
||||
private val equipEvents = PublishSubject.create<String>()
|
||||
var ownedEggs: Map<String, OwnedItem>? = null
|
||||
|
|
|
|||
|
|
@ -474,11 +474,7 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
|
||||
val bg = binding?.notificationsBadge?.background as? GradientDrawable
|
||||
bg?.color = ColorStateList.valueOf(color)
|
||||
binding?.notificationsBadge?.setTextColor(if (allSeen) {
|
||||
ContextCompat.getColor(it, R.color.gray_10)
|
||||
} else {
|
||||
ContextCompat.getColor(it, R.color.white)
|
||||
})
|
||||
binding?.notificationsBadge?.setTextColor(ContextCompat.getColor(it, R.color.white))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
|||
import com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemRecyclerFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarginDecoration
|
||||
import com.habitrpg.android.habitica.ui.helpers.SafeDefaultItemAnimator
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.core.Maybe
|
||||
import io.reactivex.rxjava3.kotlin.Flowables
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import javax.inject.Inject
|
||||
|
|
@ -86,10 +88,15 @@ class PetDetailRecyclerFragment : BaseMainFragment<FragmentRecyclerviewBinding>(
|
|||
}
|
||||
binding?.recyclerView?.layoutManager = layoutManager
|
||||
binding?.recyclerView?.addItemDecoration(MarginDecoration(getActivity()))
|
||||
adapter.animalIngredientsRetriever = {
|
||||
val egg = inventoryRepository.getItems(Egg::class.java, arrayOf(it.animal)).firstElement().blockingGet().firstOrNull()
|
||||
val potion = inventoryRepository.getItems(HatchingPotion::class.java, arrayOf(it.color)).firstElement().blockingGet().firstOrNull()
|
||||
Pair(egg as? Egg, potion as? HatchingPotion)
|
||||
adapter.animalIngredientsRetriever = { animal, callback ->
|
||||
Maybe.zip(
|
||||
inventoryRepository.getItems(Egg::class.java, arrayOf(animal.animal)).firstElement(),
|
||||
inventoryRepository.getItems(HatchingPotion::class.java, arrayOf(animal.color)).firstElement(), { eggs, potions ->
|
||||
Pair(eggs.first() as? Egg, potions.first() as? HatchingPotion)
|
||||
}
|
||||
).subscribe({
|
||||
callback(it)
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
binding?.recyclerView?.adapter = adapter
|
||||
binding?.recyclerView?.itemAnimator = SafeDefaultItemAnimator()
|
||||
|
|
|
|||
|
|
@ -86,10 +86,15 @@ class StableRecyclerFragment : BaseFragment<FragmentRecyclerviewBinding>() {
|
|||
adapter = binding?.recyclerView?.adapter as? StableRecyclerAdapter
|
||||
if (adapter == null) {
|
||||
adapter = StableRecyclerAdapter()
|
||||
adapter?.animalIngredientsRetriever = {
|
||||
val egg = inventoryRepository.getItems(Egg::class.java, arrayOf(it.animal)).firstElement().blockingGet().firstOrNull()
|
||||
val potion = inventoryRepository.getItems(HatchingPotion::class.java, arrayOf(it.color)).firstElement().blockingGet().firstOrNull()
|
||||
Pair(egg as? Egg, potion as? HatchingPotion)
|
||||
adapter?.animalIngredientsRetriever = { animal, callback ->
|
||||
Maybe.zip(
|
||||
inventoryRepository.getItems(Egg::class.java, arrayOf(animal.animal)).firstElement(),
|
||||
inventoryRepository.getItems(HatchingPotion::class.java, arrayOf(animal.color)).firstElement(), { eggs, potions ->
|
||||
Pair(eggs.first() as? Egg, potions.first() as? HatchingPotion)
|
||||
}
|
||||
).subscribe({
|
||||
callback(it)
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
adapter?.itemType = this.itemType
|
||||
adapter?.shopSpriteSuffix = configManager.shopSpriteSuffix()
|
||||
|
|
|
|||
|
|
@ -78,9 +78,17 @@ class SkillsFragment : BaseMainFragment<FragmentSkillsBinding>() {
|
|||
adapter?.level = this.user?.stats?.lvl ?: 0
|
||||
adapter?.specialItems = this.user?.items?.special
|
||||
user?.let { user ->
|
||||
Observable.concat(userRepository.getSkills(user).toObservable().flatMap { Observable.fromIterable(it) },
|
||||
userRepository.getSpecialItems(user).toObservable().flatMap { Observable.fromIterable(it) })
|
||||
.toList()
|
||||
Flowable.combineLatest(userRepository.getSkills(user),
|
||||
userRepository.getSpecialItems(user), { skills, items ->
|
||||
val allEntries = mutableListOf<Skill>()
|
||||
for (skill in skills) {
|
||||
allEntries.add(skill)
|
||||
}
|
||||
for (item in items) {
|
||||
allEntries.add(item)
|
||||
}
|
||||
return@combineLatest allEntries
|
||||
})
|
||||
.subscribe({ skills -> adapter?.setSkillList(skills) }, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,13 @@ class InboxMessageListFragment : BaseMainFragment<FragmentInboxMessageListBindin
|
|||
layoutManager.reverseLayout = true
|
||||
layoutManager.stackFromEnd = false
|
||||
binding?.recyclerView?.layoutManager = layoutManager
|
||||
compositeSubscription.add(apiClient.getMember(replyToUserUUID!!).subscribe( { member ->
|
||||
val observable = if (replyToUserUUID?.isNotBlank() == true) {
|
||||
apiClient.getMember(replyToUserUUID!!)
|
||||
} else {
|
||||
apiClient.getMemberWithUsername(chatRoomUser ?: "")
|
||||
}
|
||||
compositeSubscription.add(observable.subscribe( { member ->
|
||||
setReceivingUser(member.username, member.id)
|
||||
chatAdapter = InboxAdapter(user, member)
|
||||
viewModel?.messages?.observe(this.viewLifecycleOwner, { chatAdapter?.submitList(it) })
|
||||
|
||||
|
|
@ -193,7 +199,7 @@ class InboxMessageListFragment : BaseMainFragment<FragmentInboxMessageListBindin
|
|||
}
|
||||
}
|
||||
|
||||
private fun setReceivingUser(chatRoomUser: String?, replyToUserUUID: String) {
|
||||
private fun setReceivingUser(chatRoomUser: String?, replyToUserUUID: String?) {
|
||||
this.chatRoomUser = chatRoomUser
|
||||
this.replyToUserUUID = replyToUserUUID
|
||||
activity?.title = chatRoomUser
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
|||
import io.reactivex.rxjava3.subjects.PublishSubject
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class PetViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject<String>, private val animalIngredientsRetriever: ((Animal) -> Pair<Egg?, HatchingPotion?>)?) : androidx.recyclerview.widget.RecyclerView.ViewHolder(parent.inflate(R.layout.pet_detail_item)), View.OnClickListener {
|
||||
class PetViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject<String>, private val animalIngredientsRetriever: ((Animal, ((Pair<Egg?, HatchingPotion?>) -> Unit)) -> Unit)?) : androidx.recyclerview.widget.RecyclerView.ViewHolder(parent.inflate(R.layout.pet_detail_item)), View.OnClickListener {
|
||||
private var hasMount: Boolean = false
|
||||
private var hasUnlockedPotion: Boolean = false
|
||||
private var hasUnlockedEgg: Boolean = false
|
||||
|
|
@ -147,16 +147,17 @@ class PetViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject<S
|
|||
val context = itemView.context
|
||||
val dialog = PetSuggestHatchDialog(context)
|
||||
animal?.let {
|
||||
val ingredients = animalIngredientsRetriever?.invoke(it)
|
||||
dialog.configure(it,
|
||||
ingredients?.first,
|
||||
ingredients?.second,
|
||||
eggCount,
|
||||
potionCount,
|
||||
hasUnlockedEgg,
|
||||
hasUnlockedPotion,
|
||||
hasMount)
|
||||
animalIngredientsRetriever?.invoke(it) { ingredients ->
|
||||
dialog.configure(it,
|
||||
ingredients.first,
|
||||
ingredients.second,
|
||||
eggCount,
|
||||
potionCount,
|
||||
hasUnlockedEgg,
|
||||
hasUnlockedPotion,
|
||||
hasMount)
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,10 +118,10 @@ private class MessagesDataSource(val socialRepository: SocialRepository, var rec
|
|||
if (it.isEmpty()) {
|
||||
if (recipientID?.isNotBlank() != true) { return@flatMapPublisher Flowable.just(it) }
|
||||
socialRepository.retrieveInboxMessages(recipientID ?: "", 0)
|
||||
.doOnNext {
|
||||
messages -> if (messages.size < 10) {
|
||||
lastFetchWasEnd = true
|
||||
}
|
||||
.doOnNext { messages ->
|
||||
if (messages.size < 10) {
|
||||
lastFetchWasEnd = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Flowable.just(it)
|
||||
|
|
|
|||
Loading…
Reference in a new issue