mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-24 22:55:59 +00:00
Display back button on some pages
This commit is contained in:
parent
9bc66ac90b
commit
941f8b6a9d
11 changed files with 27 additions and 5 deletions
|
|
@ -313,6 +313,6 @@ class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiCli
|
|||
}
|
||||
|
||||
override fun getTasksForChallenge(challengeID: String?): Flowable<RealmResults<Task>> {
|
||||
return localRepository.getTasksForChallenge(challengeID)
|
||||
return localRepository.getTasksForChallenge(challengeID, userID)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,5 +35,5 @@ interface TaskLocalRepository : BaseLocalRepository {
|
|||
fun saveCompletedTodos(userId: String, tasks: MutableCollection<Task>)
|
||||
fun getErroredTasks(userID: String): Flowable<RealmResults<Task>>
|
||||
fun getUser(userID: String): Flowable<User>
|
||||
fun getTasksForChallenge(challengeID: String?): Flowable<RealmResults<Task>>
|
||||
fun getTasksForChallenge(challengeID: String?, userID: String?): Flowable<RealmResults<Task>>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,9 +237,10 @@ class RealmTaskLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
|
|||
.map { users -> users.first() }
|
||||
}
|
||||
|
||||
override fun getTasksForChallenge(challengeID: String?): Flowable<RealmResults<Task>> {
|
||||
override fun getTasksForChallenge(challengeID: String?, userID: String?): Flowable<RealmResults<Task>> {
|
||||
return realm.where(Task::class.java)
|
||||
.equalTo("challengeID", challengeID)
|
||||
.equalTo("userId", userID)
|
||||
.findAll()
|
||||
.asFlowable()
|
||||
.filter { it.isLoaded }
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
private var sideAvatarView: AvatarView? = null
|
||||
private var activeTutorialView: TutorialView? = null
|
||||
private var drawerFragment: NavigationDrawerFragment? = null
|
||||
private var drawerToggle: ActionBarDrawerToggle? = null
|
||||
var drawerToggle: ActionBarDrawerToggle? = null
|
||||
private var resumeFromActivity = false
|
||||
private var userIsOnQuest = false
|
||||
|
||||
|
|
@ -231,6 +231,11 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
|
||||
private fun setupNotifications() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channelId = "default"
|
||||
|
|
|
|||
|
|
@ -508,7 +508,7 @@ class TaskFormActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
private fun showChallengeDeleteTask() {
|
||||
compositeSubscription.add(taskRepository.getTasksForChallenge(task?.challengeID).subscribe(Consumer { tasks ->
|
||||
compositeSubscription.add(taskRepository.getTasksForChallenge(task?.challengeID).firstElement().subscribe(Consumer { tasks ->
|
||||
val taskCount = tasks.size
|
||||
val alert = HabiticaAlertDialog(this)
|
||||
alert.setTitle(getString(R.string.delete_challenge_task_title))
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
|
|
@ -28,6 +29,8 @@ abstract class BaseMainFragment : BaseFragment() {
|
|||
@Inject
|
||||
lateinit var soundManager: SoundManager
|
||||
|
||||
protected var showsBackButton: Boolean = false
|
||||
|
||||
open val activity get() = getActivity() as? MainActivity
|
||||
val tabLayout get() = activity?.binding?.detailTabs
|
||||
val collapsingToolbar get() = activity?.binding?.toolbar
|
||||
|
|
@ -72,6 +75,14 @@ abstract class BaseMainFragment : BaseFragment() {
|
|||
return null
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activity?.drawerToggle?.isDrawerIndicatorEnabled = !showsBackButton
|
||||
activity?.supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun updateTabLayoutVisibility() {
|
||||
if (this.usesTabLayout) {
|
||||
tabLayout?.removeAllTabs()
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ class AvatarEquipmentFragment : BaseMainFragment() {
|
|||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
showsBackButton = true
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
arguments?.let {
|
||||
val args = AvatarEquipmentFragmentArgs.fromBundle(it)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class AvatarOverviewFragment : BaseMainFragment(), AdapterView.OnItemSelectedLis
|
|||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
showsBackButton = true
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.avatarSizeSpinner.onItemSelectedListener = this
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ class EquipmentDetailFragment : BaseMainFragment() {
|
|||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
showsBackButton = true
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
arguments?.let {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class MountDetailRecyclerFragment : BaseMainFragment() {
|
|||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
showsBackButton = true
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
arguments?.let {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ class PetDetailRecyclerFragment : BaseMainFragment() {
|
|||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
showsBackButton = true
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
arguments?.let {
|
||||
|
|
|
|||
Loading…
Reference in a new issue