theme toolbar icons including overflow icon and search field

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-08-03 23:44:59 +02:00
parent 365a7502b4
commit fa82641f31
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
4 changed files with 35 additions and 1 deletions

View file

@ -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 {

View file

@ -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()

View file

@ -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,

View file

@ -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
}
}