unify tab layout theming on surface

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

View File

@ -24,6 +24,7 @@ package com.nextcloud.talk.remotefilebrowser.activities
import android.app.Activity
import android.content.Intent
import android.content.res.ColorStateList
import android.os.Bundle
import android.util.Log
import android.view.Menu
@ -74,14 +75,18 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
binding = ActivityRemoteFileBrowserBinding.inflate(layoutInflater)
setSupportActionBar(binding.remoteFileBrowserItemsToolbar)
viewThemeUtils.themeToolbar(binding.remoteFileBrowserItemsToolbar)
val scheme = viewThemeUtils.getScheme(binding.sortListButtonGroup.context)
binding.sortListButtonGroup.setBackgroundColor(scheme.surface)
binding.sortButton.iconTint = ColorStateList.valueOf(scheme.onSurface)
binding.sortButton.setTextColor(scheme.onSurface)
viewThemeUtils.colorMaterialTextButton(binding.sortButton)
binding.pathNavigationBackButton.iconTint = ColorStateList.valueOf(scheme.onSurface)
binding.pathNavigationBackButton.setTextColor(scheme.onSurface)
viewThemeUtils.colorMaterialTextButton(binding.pathNavigationBackButton)
viewThemeUtils.themeStatusBar(this, binding.remoteFileBrowserItemsToolbar)
setContentView(binding.root)
DisplayUtils.applyColorToStatusBar(
this,
ResourcesCompat.getColor(
resources, R.color.appbar, null
)
)
DisplayUtils.applyColorToNavigationBar(
this.window,
ResourcesCompat.getColor(resources, R.color.bg_default, null)

View File

@ -74,6 +74,8 @@ class SharedItemsActivity : AppCompatActivity() {
setContentView(binding.root)
viewThemeUtils.themeStatusBar(this, binding.sharedItemsToolbar)
viewThemeUtils.themeToolbar(binding.sharedItemsToolbar)
viewThemeUtils.themeTabLayoutOnSurface(binding.sharedItemsTabs)
DisplayUtils.applyColorToNavigationBar(
this.window,

View File

@ -148,9 +148,7 @@ class ShowReactionsDialog(
}
})
viewThemeUtils.colorTabLayout(binding.emojiReactionsTabs)
binding.emojiReactionsTabs.setBackgroundColor(
viewThemeUtils.getScheme(binding.emojiReactionsTabs .context).surface)
viewThemeUtils.themeTabLayoutOnSurface(binding.emojiReactionsTabs)
updateParticipantsForEmoji(chatMessage, tagAll)
}

View File

@ -585,27 +585,32 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
}
}
fun colorTabLayout(tabLayout: TabLayout) {
fun themeTabLayoutOnSurface(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)
)
)
tabLayout.setBackgroundColor(scheme.surface)
colorTabLayout(tabLayout, scheme)
}
}
fun colorTabLayout(tabLayout: TabLayout, scheme: 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)
)
)
}
fun getPlaceholderImage(context: Context, mimetype: String?): Drawable? {
val drawableResourceId = DrawableUtils.getDrawableResourceIdForMimeType(mimetype)
val drawable = AppCompatResources.getDrawable(