Browse Source

extend tab layout theming for text / states and ripple effect

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 years ago
parent
commit
9a2d7ee1ff

+ 11 - 1
app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt

@@ -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.reactions.ReactionsOverall
 import com.nextcloud.talk.ui.theme.ServerTheme
+import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.utils.ApiUtils
 import io.reactivex.Observer
 import io.reactivex.android.schedulers.AndroidSchedulers
 import io.reactivex.disposables.Disposable
 import io.reactivex.schedulers.Schedulers
 import java.util.Collections
+import javax.inject.Inject
 
 @AutoInjector(NextcloudTalkApplication::class)
 class ShowReactionsDialog(
@@ -70,12 +72,19 @@ class ShowReactionsDialog(
     private val serverTheme: ServerTheme
 ) : BottomSheetDialog(activity), ReactionItemClickListener {
 
+    @Inject
+    lateinit var viewThemeUtils: ViewThemeUtils
+
     private lateinit var binding: DialogMessageReactionsBinding
 
     private var adapter: ReactionsAdapter? = null
 
     private val tagAll: String? = null
 
+    init {
+        NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this)
+    }
+
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         binding = DialogMessageReactionsBinding.inflate(layoutInflater)
@@ -98,7 +107,6 @@ class ShowReactionsDialog(
         adapter?.list?.clear()
         if (chatMessage.reactions != null && chatMessage.reactions!!.isNotEmpty()) {
             var reactionsTotal = 0
-            binding.emojiReactionsTabs.setSelectedTabIndicatorColor(serverTheme.primaryColor)
             for ((emoji, amount) in chatMessage.reactions!!) {
                 reactionsTotal = reactionsTotal.plus(amount as Int)
                 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)
         }
         adapter?.notifyDataSetChanged()

+ 15 - 0
app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt

@@ -581,6 +581,21 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
     fun colorTabLayout(tabLayout: TabLayout) {
         withScheme(tabLayout) { scheme ->
             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)
+                )
+            )
         }
     }