mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
fix opening challenge creation screen
This commit is contained in:
parent
97841e5cac
commit
def26be822
10 changed files with 62 additions and 48 deletions
BIN
Habitica/res/drawable-hdpi/ic_add_white_18dp.png
Normal file
BIN
Habitica/res/drawable-hdpi/ic_add_white_18dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 138 B |
BIN
Habitica/res/drawable-mdpi/ic_add_white_18dp.png
Normal file
BIN
Habitica/res/drawable-mdpi/ic_add_white_18dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 108 B |
BIN
Habitica/res/drawable-xhdpi/ic_add_white_18dp.png
Normal file
BIN
Habitica/res/drawable-xhdpi/ic_add_white_18dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 156 B |
BIN
Habitica/res/drawable-xxhdpi/ic_add_white_18dp.png
Normal file
BIN
Habitica/res/drawable-xxhdpi/ic_add_white_18dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 176 B |
BIN
Habitica/res/drawable-xxxhdpi/ic_add_white_18dp.png
Normal file
BIN
Habitica/res/drawable-xxxhdpi/ic_add_white_18dp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 180 B |
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/challenge_gem_add_button_disabled" android:state_enabled="false"></item>
|
||||
<item android:drawable="@drawable/challenge_gem_add_button_enabled" android:state_enabled="true"></item>
|
||||
<item android:drawable="@drawable/challenge_gem_add_button_disabled" android:state_enabled="false" />
|
||||
<item android:drawable="@drawable/challenge_gem_add_button_enabled" android:state_enabled="true" />
|
||||
</selector>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item >
|
||||
<bitmap
|
||||
android:src="@drawable/plus"
|
||||
android:src="@drawable/ic_add_white_18dp"
|
||||
android:tint="#e1e0e3" />
|
||||
</item>
|
||||
</layer-list>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item >
|
||||
<bitmap
|
||||
android:src="@drawable/plus"
|
||||
android:src="@drawable/ic_add_white_18dp"
|
||||
android:tint="@color/brand_400" />
|
||||
</item>
|
||||
</layer-list>
|
||||
|
|
@ -142,7 +142,7 @@ class ChallengeListFragment : BaseFragment(), androidx.swiperefreshlayout.widget
|
|||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
private fun retrieveChallengesPage(forced: Boolean = false) {
|
||||
internal fun retrieveChallengesPage(forced: Boolean = false) {
|
||||
if ((!forced && swipeRefreshLayout?.isRefreshing == true) || loadedAllData) {
|
||||
return
|
||||
}
|
||||
|
|
@ -157,20 +157,7 @@ class ChallengeListFragment : BaseFragment(), androidx.swiperefreshlayout.widget
|
|||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
|
||||
inflater?.inflate(R.menu.menu_list_challenges, menu)
|
||||
|
||||
@Suppress("Deprecation")
|
||||
val badgeLayout = MenuItemCompat.getActionView(menu?.findItem(R.id.action_search)) as? RelativeLayout
|
||||
if (badgeLayout != null) {
|
||||
val filterCountTextView = badgeLayout.findViewById<TextView>(R.id.badge_textview)
|
||||
filterCountTextView.text = null
|
||||
filterCountTextView.visibility = View.GONE
|
||||
badgeLayout.setOnClickListener { showFilterDialog() }
|
||||
}
|
||||
}
|
||||
|
||||
private fun showFilterDialog() {
|
||||
internal fun showFilterDialog() {
|
||||
activity.notNull {
|
||||
ChallengeFilterDialogHolder.showDialog(it,
|
||||
challenges ?: emptyList(),
|
||||
|
|
@ -186,30 +173,4 @@ class ChallengeListFragment : BaseFragment(), androidx.swiperefreshlayout.widget
|
|||
filterOptions = challengeFilterOptions
|
||||
challengeAdapter?.filter(challengeFilterOptions)
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
val id = item?.itemId
|
||||
|
||||
when (id) {
|
||||
R.id.action_create_challenge -> {
|
||||
val intent = Intent(getActivity(), ChallengeFormActivity::class.java)
|
||||
startActivity(intent)
|
||||
return true
|
||||
}
|
||||
R.id.action_reload -> {
|
||||
retrieveChallengesPage()
|
||||
return true
|
||||
}
|
||||
R.id.action_search -> {
|
||||
showFilterDialog()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,23 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments.social.challenges
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.MenuItemCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.data.ChallengeRepository
|
||||
import com.habitrpg.android.habitica.extensions.notNull
|
||||
import com.habitrpg.android.habitica.ui.activities.ChallengeFormActivity
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import com.habitrpg.android.habitica.ui.helpers.resetViews
|
||||
import com.habitrpg.android.habitica.utils.Action1
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -55,6 +60,54 @@ class ChallengesOverviewFragment : BaseMainFragment() {
|
|||
component.inject(this)
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
|
||||
inflater?.inflate(R.menu.menu_list_challenges, menu)
|
||||
|
||||
@Suppress("Deprecation")
|
||||
val badgeLayout = MenuItemCompat.getActionView(menu?.findItem(R.id.action_search)) as? RelativeLayout
|
||||
if (badgeLayout != null) {
|
||||
val filterCountTextView = badgeLayout.findViewById<TextView>(R.id.badge_textview)
|
||||
filterCountTextView.text = null
|
||||
filterCountTextView.visibility = View.GONE
|
||||
badgeLayout.setOnClickListener { getActiveFragment()?.showFilterDialog() }
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
val id = item?.itemId
|
||||
|
||||
when (id) {
|
||||
R.id.action_create_challenge -> {
|
||||
val intent = Intent(getActivity(), ChallengeFormActivity::class.java)
|
||||
startActivity(intent)
|
||||
return true
|
||||
}
|
||||
R.id.action_reload -> {
|
||||
getActiveFragment()?.retrieveChallengesPage()
|
||||
return true
|
||||
}
|
||||
R.id.action_search -> {
|
||||
getActiveFragment()?.showFilterDialog()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun getActiveFragment(): ChallengeListFragment? {
|
||||
return if (viewPager?.currentItem == 0) {
|
||||
userChallengesFragment
|
||||
} else {
|
||||
availableChallengesFragment
|
||||
}
|
||||
}
|
||||
|
||||
private fun setViewPagerAdapter() {
|
||||
val fragmentManager = childFragmentManager
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue