mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
improve leaving party flow
This commit is contained in:
parent
a8234e6b2a
commit
75bad46e09
7 changed files with 33 additions and 11 deletions
|
|
@ -551,9 +551,13 @@
|
|||
<string name="yesterdaililes_prompt">Check off any Dailies you did yesterday:</string>
|
||||
<string name="start_day">Start My Day</string>
|
||||
<string name="leave_party_confirmation">Are you sure you want to leave this party?</string>
|
||||
<string name="leave_party_confirmation_quest">Are you sure you want to leave this party?</string>
|
||||
<string name="leave_party_challenges_confirmation">Do you want to keep participating in the Challenge when leaving the Party?</string>
|
||||
<string name="discard_changes_to_task_message">Are you sure you want to discard changes to this task?</string>
|
||||
<string name="rejoin_party">You will not be able to rejoin this party unless invited.</string>
|
||||
<string name="rejoin_party_quest">You will not be able to rejoin this party unless invited.\n\nLeaving the party will also make you leave the quest you are currently on.</string>
|
||||
<string name="rejoin_party_quest_leader">You will not be able to rejoin this party unless invited.\n\nLeaving the party will also abort the current quest.</string>
|
||||
|
||||
<string name="pending">Pending</string>
|
||||
<string name="accepted">Accepted</string>
|
||||
<string name="declined">Declined</string>
|
||||
|
|
|
|||
|
|
@ -552,7 +552,7 @@ class TaskFormActivity : BaseActivity() {
|
|||
binding.tagsTitleView.visibility = if (isChallengeTask) View.GONE else View.VISIBLE
|
||||
binding.tagsWrapper.visibility = if (isChallengeTask) View.GONE else View.VISIBLE
|
||||
|
||||
binding.statWrapper.visibility = if (usesTaskAttributeStats) View.VISIBLE else View.GONE
|
||||
binding.statWrapper.visibility = if (usesTaskAttributeStats && taskType != TaskType.REWARD) View.VISIBLE else View.GONE
|
||||
if (isCreating) {
|
||||
binding.adjustStreakTitleView.visibility = View.GONE
|
||||
binding.adjustStreakWrapper.visibility = View.GONE
|
||||
|
|
|
|||
|
|
@ -165,14 +165,14 @@ class GuildDetailFragment : BaseFragment<FragmentGuildDetailBinding>() {
|
|||
alert.setTitle(R.string.guild_challenges)
|
||||
alert.setMessage(R.string.leave_guild_challenges_confirmation)
|
||||
alert.addButton(R.string.keep_challenges, true) { _, _ ->
|
||||
viewModel.leaveGroup(groupChallenges, true) { showLeaveSnackbar() }
|
||||
viewModel.leaveGroup(false, false, groupChallenges, true) { showLeaveSnackbar() }
|
||||
}
|
||||
alert.addButton(
|
||||
R.string.leave_challenges_delete_tasks,
|
||||
isPrimary = false,
|
||||
isDestructive = true,
|
||||
) { _, _ ->
|
||||
viewModel.leaveGroup(groupChallenges, false) { showLeaveSnackbar() }
|
||||
viewModel.leaveGroup(false, false, groupChallenges, false) { showLeaveSnackbar() }
|
||||
}
|
||||
alert.setExtraCloseButtonVisibility(View.VISIBLE)
|
||||
alert.show()
|
||||
|
|
@ -185,7 +185,7 @@ class GuildDetailFragment : BaseFragment<FragmentGuildDetailBinding>() {
|
|||
isPrimary = true,
|
||||
isDestructive = true,
|
||||
) { _, _ ->
|
||||
viewModel.leaveGroup(groupChallenges, false) {
|
||||
viewModel.leaveGroup(false, false, groupChallenges, false) {
|
||||
showLeaveSnackbar()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import com.habitrpg.android.habitica.data.InventoryRepository
|
|||
import com.habitrpg.android.habitica.data.SocialRepository
|
||||
import com.habitrpg.android.habitica.data.UserRepository
|
||||
import com.habitrpg.android.habitica.databinding.FragmentPartyDetailBinding
|
||||
import com.habitrpg.common.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.helpers.AppConfigManager
|
||||
import com.habitrpg.android.habitica.helpers.HapticFeedbackManager
|
||||
import com.habitrpg.android.habitica.models.inventory.QuestContent
|
||||
|
|
@ -42,6 +41,7 @@ import com.habitrpg.android.habitica.ui.views.dialogs.HabiticaBottomSheetDialog
|
|||
import com.habitrpg.android.habitica.ui.views.social.PartySeekingListItem
|
||||
import com.habitrpg.common.habitica.extensions.DataBindingUtils
|
||||
import com.habitrpg.common.habitica.extensions.dpToPx
|
||||
import com.habitrpg.common.habitica.extensions.inflate
|
||||
import com.habitrpg.common.habitica.extensions.loadImage
|
||||
import com.habitrpg.common.habitica.helpers.ExceptionHandler
|
||||
import com.habitrpg.common.habitica.helpers.MainNavigationController
|
||||
|
|
@ -507,7 +507,7 @@ class PartyDetailFragment : BaseFragment<FragmentPartyDetailBinding>() {
|
|||
alert.setTitle(R.string.party_challenges)
|
||||
alert.setMessage(R.string.leave_party_challenges_confirmation)
|
||||
alert.addButton(R.string.keep_challenges, true) { _, _ ->
|
||||
viewModel.leaveGroup(groupChallenges, true) {
|
||||
viewModel.leaveGroup(viewModel.isUserOnQuest, viewModel.isUserQuestLeader, groupChallenges, true) {
|
||||
parentFragmentManager.popBackStack()
|
||||
MainNavigationController.navigate(R.id.noPartyFragment)
|
||||
}
|
||||
|
|
@ -517,7 +517,7 @@ class PartyDetailFragment : BaseFragment<FragmentPartyDetailBinding>() {
|
|||
false,
|
||||
isDestructive = true,
|
||||
) { _, _ ->
|
||||
viewModel.leaveGroup(groupChallenges, false) {
|
||||
viewModel.leaveGroup(viewModel.isUserOnQuest, viewModel.isUserQuestLeader, groupChallenges, false) {
|
||||
parentFragmentManager.popBackStack()
|
||||
MainNavigationController.navigate(R.id.noPartyFragment)
|
||||
}
|
||||
|
|
@ -527,13 +527,21 @@ class PartyDetailFragment : BaseFragment<FragmentPartyDetailBinding>() {
|
|||
} else {
|
||||
val alert = HabiticaAlertDialog(context)
|
||||
alert.setTitle(R.string.leave_party_confirmation)
|
||||
alert.setMessage(R.string.rejoin_party)
|
||||
if (viewModel.isUserOnQuest) {
|
||||
if (viewModel.isUserQuestLeader) {
|
||||
alert.setMessage(R.string.rejoin_party_quest_leader)
|
||||
} else {
|
||||
alert.setMessage(R.string.rejoin_party_quest)
|
||||
}
|
||||
} else {
|
||||
alert.setMessage(R.string.rejoin_party)
|
||||
}
|
||||
alert.addButton(
|
||||
R.string.leave,
|
||||
isPrimary = true,
|
||||
isDestructive = true,
|
||||
) { _, _ ->
|
||||
viewModel.leaveGroup(groupChallenges, false) {
|
||||
viewModel.leaveGroup(viewModel.isUserOnQuest, viewModel.isUserQuestLeader, groupChallenges, false) {
|
||||
if (isAdded) {
|
||||
parentFragmentManager.popBackStack()
|
||||
MainNavigationController.navigate(R.id.noPartyFragment)
|
||||
|
|
|
|||
|
|
@ -179,6 +179,8 @@ open class GroupViewModel
|
|||
}
|
||||
|
||||
fun leaveGroup(
|
||||
leaveQuest: Boolean,
|
||||
abortQuest: Boolean,
|
||||
groupChallenges: List<Challenge>,
|
||||
keepChallenges: Boolean = true,
|
||||
function: (() -> Unit)? = null,
|
||||
|
|
@ -191,6 +193,11 @@ open class GroupViewModel
|
|||
}
|
||||
}
|
||||
viewModelScope.launch(ExceptionHandler.coroutine()) {
|
||||
if (abortQuest) {
|
||||
socialRepository.abortQuest(groupID ?: "")
|
||||
} else if (leaveQuest) {
|
||||
socialRepository.leaveQuest(groupID ?: "")
|
||||
}
|
||||
socialRepository.leaveGroup(groupID ?: "", keepChallenges)
|
||||
userRepository.retrieveUser(withTasks = false, forced = true)
|
||||
function?.invoke()
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ class PartyViewModel
|
|||
?: true
|
||||
)
|
||||
|
||||
internal val isUserQuestLeader: Boolean
|
||||
get() = user.value?.id == getGroupData().value?.quest?.leader
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private val membersFlow =
|
||||
groupIDFlow
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.5.0
|
||||
CODE=9261
|
||||
NAME=4.6.0
|
||||
CODE=9261
|
||||
|
|
|
|||
Loading…
Reference in a new issue