Code refactor
This commit is contained in:
parent
0b16b1f5c4
commit
e26310dbc7
5 changed files with 28 additions and 17 deletions
|
@ -9,8 +9,6 @@ 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.retromusic.App
|
import code.name.monkey.retromusic.App
|
||||||
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
|
||||||
|
@ -24,6 +22,7 @@ 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.applyToolbar
|
||||||
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
|
||||||
|
@ -67,10 +66,7 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
||||||
setNavigationbarColorAuto()
|
setNavigationbarColorAuto()
|
||||||
setLightNavigationBar(true)
|
setLightNavigationBar(true)
|
||||||
|
|
||||||
val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
|
applyToolbar(toolbar)
|
||||||
toolbar.setBackgroundColor(toolbarColor)
|
|
||||||
ToolbarContentTintHelper.colorBackButton(toolbar)
|
|
||||||
setSupportActionBar(toolbar)
|
|
||||||
version.setSummary(getAppVersion())
|
version.setSummary(getAppVersion())
|
||||||
setUpView()
|
setUpView()
|
||||||
loadContributors()
|
loadContributors()
|
||||||
|
|
|
@ -12,6 +12,7 @@ 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.AbsSlidingMusicPanelActivity
|
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||||
import code.name.monkey.retromusic.adapter.song.ShuffleButtonSongAdapter
|
import code.name.monkey.retromusic.adapter.song.ShuffleButtonSongAdapter
|
||||||
|
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||||
import code.name.monkey.retromusic.helper.menu.GenreMenuHelper
|
import code.name.monkey.retromusic.helper.menu.GenreMenuHelper
|
||||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||||
import code.name.monkey.retromusic.model.Genre
|
import code.name.monkey.retromusic.model.Genre
|
||||||
|
@ -75,8 +76,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpToolBar() {
|
private fun setUpToolBar() {
|
||||||
toolbar.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
applyToolbar(toolbar)
|
||||||
setSupportActionBar(toolbar)
|
|
||||||
title = genre.name
|
title = genre.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
||||||
private var fragment: LockScreenPlayerControlsFragment? = null
|
private var fragment: LockScreenPlayerControlsFragment? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
setDrawUnderStatusBar()
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||||
setShowWhenLocked(true)
|
setShowWhenLocked(true)
|
||||||
|
@ -36,7 +37,6 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
||||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
setDrawUnderStatusBar()
|
|
||||||
setContentView(R.layout.activity_lock_screen)
|
setContentView(R.layout.activity_lock_screen)
|
||||||
hideStatusBar()
|
hideStatusBar()
|
||||||
setStatusbarColorAuto()
|
setStatusbarColorAuto()
|
||||||
|
|
|
@ -14,3 +14,13 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.extensions
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
|
|
||||||
|
fun AppCompatActivity.applyToolbar(toolbar: MaterialToolbar) {
|
||||||
|
toolbar.setBackgroundColor(surfaceColor())
|
||||||
|
ToolbarContentTintHelper.colorBackButton(toolbar)
|
||||||
|
setSupportActionBar(toolbar)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
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
|
||||||
|
@ -26,8 +27,12 @@ fun Int.ripAlpha(): Int {
|
||||||
return ColorUtil.stripAlpha(this)
|
return ColorUtil.stripAlpha(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Any.surfaceColor(context: Context): Int {
|
fun Context.accentColor(): Int {
|
||||||
return ATHUtil.resolveColor(context, R.attr.colorSurface, Color.WHITE)
|
return ThemeStore.accentColor(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.surfaceColor(): Int {
|
||||||
|
return ATHUtil.resolveColor(this, R.attr.colorSurface, Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Toolbar.backgroundTintList() {
|
fun Toolbar.backgroundTintList() {
|
||||||
|
@ -36,14 +41,14 @@ fun Toolbar.backgroundTintList() {
|
||||||
backgroundTintList = colorStateList
|
backgroundTintList = colorStateList
|
||||||
}
|
}
|
||||||
|
|
||||||
fun textColorSecondary(context: Context): Int {
|
fun Context.textColorSecondary(): Int {
|
||||||
return ATHUtil.resolveColor(context, android.R.attr.textColorSecondary)
|
return ATHUtil.resolveColor(this, android.R.attr.textColorSecondary)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun colorControlNormal(context: Context): Int {
|
fun Context.colorControlNormal(): Int {
|
||||||
return ATHUtil.resolveColor(context, android.R.attr.colorControlNormal)
|
return ATHUtil.resolveColor(this, android.R.attr.colorControlNormal)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun textColorPrimary(context: Context): Int {
|
fun Context.textColorPrimary(): Int {
|
||||||
return ATHUtil.resolveColor(context, android.R.attr.textColorPrimary)
|
return ATHUtil.resolveColor(this, android.R.attr.textColorPrimary)
|
||||||
}
|
}
|
Loading…
Reference in a new issue