Browse Source

theme toolbar icons including overflow icon and search field

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

+ 10 - 0
app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

@@ -2486,6 +2486,16 @@ class ChatController(args: Bundle) :
         super.onCreateOptionsMenu(menu, inflater)
         inflater.inflate(R.menu.menu_conversation, menu)
 
+        viewThemeUtils.colorToolbarMenuIcon(
+            binding.messageInputView.context,
+            menu.findItem(R.id.conversation_voice_call)
+        )
+
+        viewThemeUtils.colorToolbarMenuIcon(
+            binding.messageInputView.context,
+            menu.findItem(R.id.conversation_video_call)
+        )
+
         if (conversationUser?.userId == "?") {
             menu.removeItem(R.id.conversation_info)
         } else {

+ 9 - 0
app/src/main/java/com/nextcloud/talk/controllers/ContactsController.kt

@@ -334,6 +334,7 @@ class ContactsController(args: Bundle) :
             val searchManager: SearchManager? = activity?.getSystemService(Context.SEARCH_SERVICE) as SearchManager?
             if (searchItem != null) {
                 searchView = MenuItemCompat.getActionView(searchItem) as SearchView
+                viewThemeUtils.themeSearchView(searchView!!)
                 searchView!!.maxWidth = Int.MAX_VALUE
                 searchView!!.inputType = InputType.TYPE_TEXT_VARIATION_FILTER
                 var imeOptions: Int = EditorInfo.IME_ACTION_DONE or EditorInfo.IME_FLAG_NO_FULLSCREEN
@@ -377,6 +378,14 @@ class ContactsController(args: Bundle) :
 
     override fun onPrepareOptionsMenu(menu: Menu) {
         super.onPrepareOptionsMenu(menu)
+
+        if (searchItem != null) {
+            viewThemeUtils.colorToolbarMenuIcon(
+                binding.titleTextView.context,
+                searchItem!!
+            )
+        }
+
         checkAndHandleDoneMenuItem()
         if (adapter?.hasFilter() == true) {
             searchItem!!.expandActionView()

+ 1 - 0
app/src/main/java/com/nextcloud/talk/controllers/base/NewBaseController.kt

@@ -188,6 +188,7 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
         val layoutParams = binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
         binding.searchToolbar.visibility = View.GONE
         binding.toolbar.visibility = View.VISIBLE
+        viewThemeUtils.colorToolbarOverflowIcon(binding.toolbar)
         layoutParams.scrollFlags = 0
         binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
             binding.appBar.context,

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

@@ -30,6 +30,7 @@ import android.graphics.PorterDuff
 import android.graphics.drawable.Drawable
 import android.graphics.drawable.LayerDrawable
 import android.os.Build
+import android.view.MenuItem
 import android.view.View
 import android.view.ViewGroup
 import android.widget.CheckBox
@@ -120,6 +121,18 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
         }
     }
 
+    fun colorToolbarMenuIcon(context: Context, item: MenuItem) {
+        withScheme(context) { scheme ->
+            item.icon.setColorFilter(scheme.onSurface, PorterDuff.Mode.SRC_ATOP)
+        }
+    }
+
+    fun colorToolbarOverflowIcon(toolbar: MaterialToolbar) {
+        withScheme(toolbar) { scheme ->
+            toolbar.overflowIcon?.setColorFilter(scheme.onSurface, PorterDuff.Mode.SRC_ATOP)
+        }
+    }
+
     fun themeSearchView(searchView: SearchView) {
         withScheme(searchView) { scheme ->
             // hacky as no default way is provided
@@ -690,7 +703,8 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
                 .mutate()
             DrawableCompat.setTintList(
                 drawable,
-                ColorStateList.valueOf(scheme.primary))
+                ColorStateList.valueOf(scheme.primary)
+            )
             emoji.background = drawable
         }
     }