Fix color backgrounds

This commit is contained in:
h4h13 2019-12-16 10:36:08 +05:30
parent a334d88f7e
commit 9c580ad525
6 changed files with 34 additions and 33 deletions

View file

@ -9,6 +9,7 @@ import android.view.View
import androidx.core.app.ShareCompat import androidx.core.app.ShareCompat
import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.Constants.APP_INSTAGRAM_LINK import code.name.monkey.retromusic.Constants.APP_INSTAGRAM_LINK
import code.name.monkey.retromusic.Constants.APP_TELEGRAM_LINK import code.name.monkey.retromusic.Constants.APP_TELEGRAM_LINK
@ -22,7 +23,6 @@ import code.name.monkey.retromusic.Constants.TRANSLATE
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsBaseActivity import code.name.monkey.retromusic.activities.base.AbsBaseActivity
import code.name.monkey.retromusic.adapter.ContributorAdapter import code.name.monkey.retromusic.adapter.ContributorAdapter
import code.name.monkey.retromusic.extensions.surfaceColor
import code.name.monkey.retromusic.model.Contributor import code.name.monkey.retromusic.model.Contributor
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
@ -69,15 +69,13 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
setLightNavigationBar(true) setLightNavigationBar(true)
loadContributors() val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
setSupportActionBar(toolbar) toolbar.setBackgroundColor(toolbarColor)
toolbar.apply {
setBackgroundColor(surfaceColor(context))
setNavigationOnClickListener { onBackPressed() }
ToolbarContentTintHelper.colorBackButton(toolbar) ToolbarContentTintHelper.colorBackButton(toolbar)
} setSupportActionBar(toolbar)
version.setSummary(getAppVersion()) version.setSummary(getAppVersion())
setUpView() setUpView()
loadContributors()
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {

View file

@ -79,7 +79,7 @@ public class LicenseActivity extends AbsBaseActivity {
// Inject color values for WebView body background and links // Inject color values for WebView body background and links
final boolean isDark = INSTANCE.isWindowBackgroundDark(this); final boolean isDark = INSTANCE.isWindowBackgroundDark(this);
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, android.R.attr.windowBackground, Color.parseColor(isDark ? "#424242" : "#ffffff"))); final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff")));
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000")); final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
final String changeLog = buf.toString() final String changeLog = buf.toString()
.replace("{style-placeholder}", .replace("{style-placeholder}",

View file

@ -15,15 +15,11 @@ import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.*
import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.App import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.activities.tageditor.WriteTagsAsyncTask import code.name.monkey.retromusic.activities.tageditor.WriteTagsAsyncTask
import code.name.monkey.retromusic.extensions.applyToolbar
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
@ -52,7 +48,8 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
override fun onPageScrollStateChanged(state: Int) { override fun onPageScrollStateChanged(state: Int) {
when (state) { when (state) {
ViewPager.SCROLL_STATE_IDLE -> fab.show() ViewPager.SCROLL_STATE_IDLE -> fab.show()
ViewPager.SCROLL_STATE_DRAGGING, ViewPager.SCROLL_STATE_SETTLING -> fab.hide() ViewPager.SCROLL_STATE_DRAGGING,
ViewPager.SCROLL_STATE_SETTLING -> fab.hide()
} }
} }
@ -91,7 +88,6 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
setTaskDescriptionColorAuto() setTaskDescriptionColorAuto()
setNavigationbarColorAuto() setNavigationbarColorAuto()
applyToolbar(toolbar)
fab.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this)) fab.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this)))) ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this))))
.apply { .apply {
@ -106,33 +102,30 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
addOnPageChangeListener(this@LyricsActivity) addOnPageChangeListener(this@LyricsActivity)
} }
tabs.apply { val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
setupWithViewPager(viewPager) toolbar.setBackgroundColor(toolbarColor)
setSelectedTabIndicator( tabs.setBackgroundColor(toolbarColor)
TintHelper.createTintedDrawable( ToolbarContentTintHelper.colorBackButton(toolbar)
ContextCompat.getDrawable(
this@LyricsActivity, R.drawable.tab_indicator tabs.setupWithViewPager(viewPager)
), ThemeStore.accentColor(this@LyricsActivity) tabs.setSelectedTabIndicator(TintHelper.createTintedDrawable(ContextCompat.getDrawable(this, R.drawable.tab_indicator), ThemeStore.accentColor(this)))
) tabs.setTabTextColors(ATHUtil.resolveColor(this, android.R.attr.textColorSecondary), ThemeStore.accentColor(this))
) tabs.setSelectedTabIndicatorColor(ThemeStore.accentColor(this))
setTabTextColors(
ThemeStore.textColorSecondary(this@LyricsActivity),
ThemeStore.accentColor(this@LyricsActivity)
)
setSelectedTabIndicatorColor(ThemeStore.accentColor(context))
}
fab.setOnClickListener(this) fab.setOnClickListener(this)
} }
override fun onPlayingMetaChanged() { override fun onPlayingMetaChanged() {
super.onPlayingMetaChanged() super.onPlayingMetaChanged()
song = MusicPlayerRemote.currentSong updateTitleSong()
toolbar.title = song.title
toolbar.subtitle = song.artistName
} }
override fun onServiceConnected() { override fun onServiceConnected() {
super.onServiceConnected() super.onServiceConnected()
updateTitleSong()
}
private fun updateTitleSong() {
song = MusicPlayerRemote.currentSong song = MusicPlayerRemote.currentSong
toolbar.title = song.title toolbar.title = song.title
toolbar.subtitle = song.artistName toolbar.subtitle = song.artistName

View file

@ -15,7 +15,9 @@
package code.name.monkey.retromusic.extensions package code.name.monkey.retromusic.extensions
import android.content.Context import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -27,3 +29,9 @@ fun Int.ripAlpha(): Int {
fun Any.surfaceColor(context: Context): Int { fun Any.surfaceColor(context: Context): Int {
return ATHUtil.resolveColor(context, R.attr.colorSurface, Color.WHITE) return ATHUtil.resolveColor(context, R.attr.colorSurface, Color.WHITE)
} }
fun Toolbar.backgroundTintList() {
val surfaceColor = ATHUtil.resolveColor(context, R.attr.colorSurface, Color.BLACK)
val colorStateList = ColorStateList.valueOf(surfaceColor)
backgroundTintList = colorStateList
}

View file

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:fadingEdge="vertical" android:fadingEdge="vertical"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">

View file

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:orientation="vertical" android:orientation="vertical"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">