From fa82641f31e048a29b6e01bc4cc876f26dfcd55b Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 3 Aug 2022 23:44:59 +0200 Subject: [PATCH] theme toolbar icons including overflow icon and search field Signed-off-by: Andy Scherzinger --- .../nextcloud/talk/controllers/ChatController.kt | 10 ++++++++++ .../talk/controllers/ContactsController.kt | 9 +++++++++ .../talk/controllers/base/NewBaseController.kt | 1 + .../nextcloud/talk/ui/theme/ViewThemeUtils.kt | 16 +++++++++++++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index a587c5f0f..852369bf7 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/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 { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.kt index 703926253..2bafd3486 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.kt +++ b/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() diff --git a/app/src/main/java/com/nextcloud/talk/controllers/base/NewBaseController.kt b/app/src/main/java/com/nextcloud/talk/controllers/base/NewBaseController.kt index 2bfd5f869..065c3b078 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/base/NewBaseController.kt +++ b/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, diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt index 6139777fd..29a5065eb 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt +++ b/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 } }