extend tab layout theming for text / states and ripple effect

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-08-02 13:28:28 +02:00
parent 37d88b7ea5
commit 9a2d7ee1ff
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
2 changed files with 26 additions and 1 deletions

View File

@ -52,12 +52,14 @@ import com.nextcloud.talk.models.json.conversations.Conversation
import com.nextcloud.talk.models.json.generic.GenericOverall import com.nextcloud.talk.models.json.generic.GenericOverall
import com.nextcloud.talk.models.json.reactions.ReactionsOverall import com.nextcloud.talk.models.json.reactions.ReactionsOverall
import com.nextcloud.talk.ui.theme.ServerTheme import com.nextcloud.talk.ui.theme.ServerTheme
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ApiUtils
import io.reactivex.Observer import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import java.util.Collections import java.util.Collections
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class) @AutoInjector(NextcloudTalkApplication::class)
class ShowReactionsDialog( class ShowReactionsDialog(
@ -70,12 +72,19 @@ class ShowReactionsDialog(
private val serverTheme: ServerTheme private val serverTheme: ServerTheme
) : BottomSheetDialog(activity), ReactionItemClickListener { ) : BottomSheetDialog(activity), ReactionItemClickListener {
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
private lateinit var binding: DialogMessageReactionsBinding private lateinit var binding: DialogMessageReactionsBinding
private var adapter: ReactionsAdapter? = null private var adapter: ReactionsAdapter? = null
private val tagAll: String? = null private val tagAll: String? = null
init {
NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this)
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = DialogMessageReactionsBinding.inflate(layoutInflater) binding = DialogMessageReactionsBinding.inflate(layoutInflater)
@ -98,7 +107,6 @@ class ShowReactionsDialog(
adapter?.list?.clear() adapter?.list?.clear()
if (chatMessage.reactions != null && chatMessage.reactions!!.isNotEmpty()) { if (chatMessage.reactions != null && chatMessage.reactions!!.isNotEmpty()) {
var reactionsTotal = 0 var reactionsTotal = 0
binding.emojiReactionsTabs.setSelectedTabIndicatorColor(serverTheme.primaryColor)
for ((emoji, amount) in chatMessage.reactions!!) { for ((emoji, amount) in chatMessage.reactions!!) {
reactionsTotal = reactionsTotal.plus(amount as Int) reactionsTotal = reactionsTotal.plus(amount as Int)
val tab: TabLayout.Tab = binding.emojiReactionsTabs.newTab() // Create a new Tab names "First Tab" val tab: TabLayout.Tab = binding.emojiReactionsTabs.newTab() // Create a new Tab names "First Tab"
@ -139,6 +147,8 @@ class ShowReactionsDialog(
} }
}) })
viewThemeUtils.colorTabLayout(binding.emojiReactionsTabs)
updateParticipantsForEmoji(chatMessage, tagAll) updateParticipantsForEmoji(chatMessage, tagAll)
} }
adapter?.notifyDataSetChanged() adapter?.notifyDataSetChanged()

View File

@ -581,6 +581,21 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
fun colorTabLayout(tabLayout: TabLayout) { fun colorTabLayout(tabLayout: TabLayout) {
withScheme(tabLayout) { scheme -> withScheme(tabLayout) { scheme ->
tabLayout.setSelectedTabIndicatorColor(scheme.primary) tabLayout.setSelectedTabIndicatorColor(scheme.primary)
tabLayout.tabTextColors = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_selected),
intArrayOf(-android.R.attr.state_selected)
),
intArrayOf(scheme.primary, ContextCompat.getColor(tabLayout.context, R.color.high_emphasis_text))
)
tabLayout.tabRippleColor = ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_pressed)
),
intArrayOf(
calculateDisabledColor(scheme.primary, SURFACE_OPACITY_BUTTON_DISABLED)
)
)
} }
} }