Code Cleanup
This commit is contained in:
parent
aca697f6ff
commit
db01ce6ee8
15 changed files with 32 additions and 115 deletions
|
@ -20,10 +20,8 @@ import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.Constants.PRO_VERSION_PRODUCT_ID
|
import code.name.monkey.retromusic.Constants.PRO_VERSION_PRODUCT_ID
|
||||||
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.anjlab.android.iab.v3.BillingProcessor
|
import com.anjlab.android.iab.v3.BillingProcessor
|
||||||
import com.anjlab.android.iab.v3.TransactionDetails
|
import com.anjlab.android.iab.v3.TransactionDetails
|
||||||
import com.google.android.material.color.DynamicColors
|
|
||||||
import org.koin.android.ext.koin.androidContext
|
import org.koin.android.ext.koin.androidContext
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
|
|
||||||
|
@ -47,10 +45,6 @@ class App : Application() {
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PreferenceUtil.materialYou) {
|
|
||||||
DynamicColors.applyToActivitiesIfAvailable(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VersionUtils.hasNougatMR())
|
if (VersionUtils.hasNougatMR())
|
||||||
DynamicShortcutManager(this).initDynamicShortcuts()
|
DynamicShortcutManager(this).initDynamicShortcuts()
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ import androidx.annotation.StringDef
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
|
||||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
@ -89,8 +88,6 @@ open class BugReportActivity : AbsThemeActivity() {
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
val accentColor = ThemeStore.accentColor(this)
|
val accentColor = ThemeStore.accentColor(this)
|
||||||
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
|
|
||||||
binding.toolbar.setBackgroundColor(primaryColor)
|
|
||||||
setSupportActionBar(binding.toolbar)
|
setSupportActionBar(binding.toolbar)
|
||||||
ToolbarContentTintHelper.colorBackButton(binding.toolbar)
|
ToolbarContentTintHelper.colorBackButton(binding.toolbar)
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
|
|
@ -21,7 +21,6 @@ import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.AppCompatTextView
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.findFragment
|
import androidx.fragment.app.findFragment
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
|
@ -31,7 +30,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
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.ColorUtil
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
|
||||||
import code.name.monkey.retromusic.*
|
import code.name.monkey.retromusic.*
|
||||||
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
||||||
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
||||||
|
@ -192,11 +190,7 @@ class HomeAdapter(
|
||||||
)
|
)
|
||||||
|
|
||||||
fun bindView(home: Home) {
|
fun bindView(home: Home) {
|
||||||
val color = if (PreferenceUtil.materialYou && VersionUtils.hasS()) {
|
val color = ThemeStore.accentColor(activity)
|
||||||
ContextCompat.getColor(App.getContext(), R.color.m3_accent_color)
|
|
||||||
} else {
|
|
||||||
ThemeStore.accentColor(activity)
|
|
||||||
}
|
|
||||||
itemView.findViewById<TextView>(R.id.message).apply {
|
itemView.findViewById<TextView>(R.id.message).apply {
|
||||||
setTextColor(color)
|
setTextColor(color)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import android.view.ViewGroup.MarginLayoutParams
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.FrameLayout
|
|
||||||
import androidx.annotation.LayoutRes
|
import androidx.annotation.LayoutRes
|
||||||
import androidx.core.animation.doOnEnd
|
import androidx.core.animation.doOnEnd
|
||||||
import androidx.core.animation.doOnStart
|
import androidx.core.animation.doOnStart
|
||||||
|
@ -34,7 +33,6 @@ import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.afollestad.materialdialogs.utils.MDUtil.updatePadding
|
import com.afollestad.materialdialogs.utils.MDUtil.updatePadding
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.imageview.ShapeableImageView
|
import com.google.android.material.imageview.ShapeableImageView
|
||||||
import com.google.android.material.shape.ShapeAppearanceModel
|
import com.google.android.material.shape.ShapeAppearanceModel
|
||||||
|
|
|
@ -20,30 +20,27 @@ import android.view.MenuInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM
|
import android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
import androidx.core.view.doOnPreDraw
|
import androidx.core.view.doOnPreDraw
|
||||||
import androidx.navigation.fragment.FragmentNavigatorExtras
|
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
|
||||||
import code.name.monkey.retromusic.*
|
import code.name.monkey.retromusic.*
|
||||||
import code.name.monkey.retromusic.adapter.HomeAdapter
|
import code.name.monkey.retromusic.adapter.HomeAdapter
|
||||||
import code.name.monkey.retromusic.databinding.FragmentBannerHomeBinding
|
import code.name.monkey.retromusic.databinding.FragmentBannerHomeBinding
|
||||||
import code.name.monkey.retromusic.databinding.FragmentHomeBinding
|
import code.name.monkey.retromusic.databinding.FragmentHomeBinding
|
||||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
||||||
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import code.name.monkey.retromusic.extensions.drawNextToNavbar
|
import code.name.monkey.retromusic.extensions.drawNextToNavbar
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||||
import code.name.monkey.retromusic.glide.GlideApp
|
import code.name.monkey.retromusic.glide.GlideApp
|
||||||
import code.name.monkey.retromusic.glide.RetroGlideExtension
|
import code.name.monkey.retromusic.glide.RetroGlideExtension
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import com.google.android.gms.cast.framework.CastButtonFactory
|
import com.google.android.gms.cast.framework.CastButtonFactory
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
|
||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import com.google.android.material.transition.MaterialSharedAxis
|
import com.google.android.material.transition.MaterialSharedAxis
|
||||||
|
|
||||||
|
@ -144,12 +141,7 @@ class HomeFragment :
|
||||||
MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
||||||
findNavController().navigate(R.id.searchFragment, null, navOptions)
|
findNavController().navigate(R.id.searchFragment, null, navOptions)
|
||||||
}
|
}
|
||||||
val color = if (PreferenceUtil.materialYou && VersionUtils.hasS()) {
|
val hexColor = String.format("#%06X", 0xFFFFFF and accentColor())
|
||||||
ContextCompat.getColor(App.getContext(), R.color.m3_accent_color)
|
|
||||||
} else {
|
|
||||||
ThemeStore.accentColor(requireContext())
|
|
||||||
}
|
|
||||||
val hexColor = String.format("#%06X", 0xFFFFFF and color)
|
|
||||||
val appName = HtmlCompat.fromHtml(
|
val appName = HtmlCompat.fromHtml(
|
||||||
"Retro <span style='color:$hexColor';>Music</span>",
|
"Retro <span style='color:$hexColor';>Music</span>",
|
||||||
HtmlCompat.FROM_HTML_MODE_COMPACT
|
HtmlCompat.FROM_HTML_MODE_COMPACT
|
||||||
|
|
|
@ -23,7 +23,6 @@ import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.transition.Fade
|
import androidx.transition.Fade
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.MainActivity
|
import code.name.monkey.retromusic.activities.MainActivity
|
||||||
|
@ -118,7 +117,7 @@ class LyricsFragment : AbsMusicServiceFragment(R.layout.fragment_lyrics) {
|
||||||
}.attach()
|
}.attach()
|
||||||
// lyricsPager.isUserInputEnabled = false
|
// lyricsPager.isUserInputEnabled = false
|
||||||
|
|
||||||
binding.tabLyrics.setSelectedTabIndicatorColor(ThemeStore.accentColor(requireContext()))
|
binding.tabLyrics.setSelectedTabIndicatorColor(accentColor())
|
||||||
binding.tabLyrics.setTabTextColors(textColorSecondary(), accentColor())
|
binding.tabLyrics.setTabTextColors(textColorSecondary(), accentColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,10 +325,10 @@ class LyricsFragment : AbsMusicServiceFragment(R.layout.fragment_lyrics) {
|
||||||
|
|
||||||
private fun setupLyricsView() {
|
private fun setupLyricsView() {
|
||||||
binding.lyricsView.apply {
|
binding.lyricsView.apply {
|
||||||
setCurrentColor(ThemeStore.accentColor(context))
|
setCurrentColor(accentColor())
|
||||||
setTimeTextColor(ThemeStore.accentColor(context))
|
setTimeTextColor(accentColor())
|
||||||
setTimelineColor(ThemeStore.accentColor(context))
|
setTimelineColor(accentColor())
|
||||||
setTimelineTextColor(ThemeStore.accentColor(context))
|
setTimelineTextColor(accentColor())
|
||||||
setDraggable(true, LrcView.OnPlayClickListener {
|
setDraggable(true, LrcView.OnPlayClickListener {
|
||||||
MusicPlayerRemote.seekTo(it.toInt())
|
MusicPlayerRemote.seekTo(it.toInt())
|
||||||
return@OnPlayClickListener true
|
return@OnPlayClickListener true
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package code.name.monkey.retromusic.glide
|
package code.name.monkey.retromusic.glide
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
|
import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
|
||||||
import code.name.monkey.retromusic.App.Companion.getContext
|
import code.name.monkey.retromusic.App.Companion.getContext
|
||||||
import code.name.monkey.retromusic.Constants.USER_BANNER
|
import code.name.monkey.retromusic.Constants.USER_BANNER
|
||||||
import code.name.monkey.retromusic.Constants.USER_PROFILE
|
import code.name.monkey.retromusic.Constants.USER_PROFILE
|
||||||
|
@ -19,7 +17,6 @@ import code.name.monkey.retromusic.util.CustomArtistImageUtil.Companion.getFile
|
||||||
import code.name.monkey.retromusic.util.CustomArtistImageUtil.Companion.getInstance
|
import code.name.monkey.retromusic.util.CustomArtistImageUtil.Companion.getInstance
|
||||||
import code.name.monkey.retromusic.util.MusicUtil.getMediaStoreAlbumCoverUri
|
import code.name.monkey.retromusic.util.MusicUtil.getMediaStoreAlbumCoverUri
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil.materialYou
|
|
||||||
import com.bumptech.glide.GenericTransitionOptions
|
import com.bumptech.glide.GenericTransitionOptions
|
||||||
import com.bumptech.glide.Priority
|
import com.bumptech.glide.Priority
|
||||||
import com.bumptech.glide.RequestBuilder
|
import com.bumptech.glide.RequestBuilder
|
||||||
|
@ -185,11 +182,7 @@ object RetroGlideExtension {
|
||||||
return TintHelper.createTintedDrawable(
|
return TintHelper.createTintedDrawable(
|
||||||
getContext(),
|
getContext(),
|
||||||
R.drawable.ic_account,
|
R.drawable.ic_account,
|
||||||
if (materialYou && VersionUtils.hasS()) {
|
|
||||||
ContextCompat.getColor(getContext(), R.color.m3_accent_color)
|
|
||||||
} else {
|
|
||||||
accentColor(getContext())
|
accentColor(getContext())
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil.isColorLight
|
import code.name.monkey.appthemehelper.util.ColorUtil.isColorLight
|
||||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper.getPrimaryTextColor
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper.getPrimaryTextColor
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
|
||||||
import code.name.monkey.retromusic.views.PopupBackground
|
import code.name.monkey.retromusic.views.PopupBackground
|
||||||
import me.zhanghai.android.fastscroll.FastScroller
|
import me.zhanghai.android.fastscroll.FastScroller
|
||||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||||
|
@ -28,11 +27,7 @@ import me.zhanghai.android.fastscroll.R
|
||||||
object ThemedFastScroller {
|
object ThemedFastScroller {
|
||||||
fun create(view: ViewGroup): FastScroller {
|
fun create(view: ViewGroup): FastScroller {
|
||||||
val context = view.context
|
val context = view.context
|
||||||
val color = if (PreferenceUtil.materialYou && VersionUtils.hasS()) {
|
val color = accentColor(context)
|
||||||
context.getColor(code.name.monkey.retromusic.R.color.m3_accent_color)
|
|
||||||
} else {
|
|
||||||
accentColor(context)
|
|
||||||
}
|
|
||||||
val textColor = getPrimaryTextColor(context, isColorLight(color))
|
val textColor = getPrimaryTextColor(context, isColorLight(color))
|
||||||
val fastScrollerBuilder = FastScrollerBuilder(view)
|
val fastScrollerBuilder = FastScrollerBuilder(view)
|
||||||
fastScrollerBuilder.useMd2Style()
|
fastScrollerBuilder.useMd2Style()
|
||||||
|
|
|
@ -4,13 +4,7 @@ import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.appcompat.widget.AppCompatImageView
|
import androidx.appcompat.widget.AppCompatImageView
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
|
||||||
import code.name.monkey.retromusic.App
|
|
||||||
import code.name.monkey.retromusic.R
|
|
||||||
import code.name.monkey.retromusic.extensions.accentColor
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
|
||||||
class AccentIcon @JvmOverloads constructor(
|
class AccentIcon @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -18,11 +12,6 @@ class AccentIcon @JvmOverloads constructor(
|
||||||
defStyleAttr: Int = -1
|
defStyleAttr: Int = -1
|
||||||
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
) : AppCompatImageView(context, attrs, defStyleAttr) {
|
||||||
init {
|
init {
|
||||||
val color = if (PreferenceUtil.materialYou && VersionUtils.hasS()) {
|
imageTintList = ColorStateList.valueOf(ThemeStore.accentColor(context))
|
||||||
ContextCompat.getColor(context, R.color.m3_accent_color)
|
|
||||||
} else {
|
|
||||||
ThemeStore.accentColor(context)
|
|
||||||
}
|
|
||||||
imageTintList = ColorStateList.valueOf(color)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
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:background="?attr/colorSurface"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -122,22 +123,9 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/mainContent" />
|
app:layout_constraintTop_toBottomOf="@id/mainContent" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<code.name.monkey.retromusic.views.StatusBarView
|
|
||||||
android:id="@+id/status_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:background="?attr/colorSurface"
|
|
||||||
tools:ignore="UnusedAttribute" />
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/transparent"
|
|
||||||
android:elevation="0dp"
|
android:elevation="0dp"
|
||||||
app:elevation="0dp">
|
app:elevation="0dp">
|
||||||
|
|
||||||
|
@ -149,5 +137,4 @@
|
||||||
app:title="@string/social_stories"
|
app:title="@string/social_stories"
|
||||||
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal" />
|
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal" />
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
</LinearLayout>
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import androidx.preference.PreferenceManager
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil.isWindowBackgroundDark
|
import code.name.monkey.appthemehelper.util.ATHUtil.isWindowBackgroundDark
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,6 +206,10 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
||||||
@CheckResult
|
@CheckResult
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun accentColor(context: Context): Int {
|
fun accentColor(context: Context): Int {
|
||||||
|
// Set MD3 accent if MD3 is enabled or in-app accent otherwise
|
||||||
|
if (isMD3Enabled(context) && VersionUtils.hasS()) {
|
||||||
|
return ContextCompat.getColor(context, R.color.m3_accent_color)
|
||||||
|
}
|
||||||
val desaturatedColor = prefs(context).getBoolean("desaturated_color", false)
|
val desaturatedColor = prefs(context).getBoolean("desaturated_color", false)
|
||||||
val color = prefs(context).getInt(
|
val color = prefs(context).getInt(
|
||||||
ThemeStorePrefKeys.KEY_ACCENT_COLOR,
|
ThemeStorePrefKeys.KEY_ACCENT_COLOR,
|
||||||
|
@ -301,7 +306,7 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isMD3Enabled(context: Context): Boolean {
|
private fun isMD3Enabled(context: Context): Boolean {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ThemeStorePrefKeys.KEY_MATERIAL_YOU, false)
|
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ThemeStorePrefKeys.KEY_MATERIAL_YOU, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,9 @@ package code.name.monkey.appthemehelper.common.prefs.supportv7
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.preference.PreferenceCategory
|
import androidx.preference.PreferenceCategory
|
||||||
import androidx.preference.PreferenceViewHolder
|
import androidx.preference.PreferenceViewHolder
|
||||||
import code.name.monkey.appthemehelper.R
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
|
||||||
|
|
||||||
class ATEPreferenceCategory @JvmOverloads constructor(
|
class ATEPreferenceCategory @JvmOverloads constructor(
|
||||||
context: Context?,
|
context: Context?,
|
||||||
|
@ -35,12 +32,7 @@ class ATEPreferenceCategory @JvmOverloads constructor(
|
||||||
super.onBindViewHolder(holder)
|
super.onBindViewHolder(holder)
|
||||||
val title = holder.itemView.findViewById<TextView>(android.R.id.title)
|
val title = holder.itemView.findViewById<TextView>(android.R.id.title)
|
||||||
title.setTextColor(
|
title.setTextColor(
|
||||||
// Set MD3 accent if MD3 is enabled or in-app accent otherwise
|
|
||||||
if (ThemeStore.isMD3Enabled(context) && VersionUtils.hasS()) {
|
|
||||||
ContextCompat.getColor(context, R.color.m3_accent_color)
|
|
||||||
} else {
|
|
||||||
ThemeStore.accentColor(context)
|
ThemeStore.accentColor(context)
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,11 +47,7 @@ class ATESeekBarPreference @JvmOverloads constructor(
|
||||||
val seekBar = view.findViewById(R.id.seekbar) as SeekBar
|
val seekBar = view.findViewById(R.id.seekbar) as SeekBar
|
||||||
TintHelper.setTintAuto(
|
TintHelper.setTintAuto(
|
||||||
seekBar, // Set MD3 accent if MD3 is enabled or in-app accent otherwise
|
seekBar, // Set MD3 accent if MD3 is enabled or in-app accent otherwise
|
||||||
if (ThemeStore.isMD3Enabled(context) && VersionUtils.hasS()) {
|
ThemeStore.accentColor(context), false
|
||||||
ContextCompat.getColor(context, R.color.m3_accent_color)
|
|
||||||
} else {
|
|
||||||
ThemeStore.accentColor(context)
|
|
||||||
}, false
|
|
||||||
)
|
)
|
||||||
(view.findViewById(R.id.seekbar_value) as TextView).apply {
|
(view.findViewById(R.id.seekbar_value) as TextView).apply {
|
||||||
appendUnit(editableText)
|
appendUnit(editableText)
|
||||||
|
|
|
@ -17,10 +17,7 @@ package code.name.monkey.appthemehelper.common.views
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.appcompat.widget.AppCompatTextView
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import code.name.monkey.appthemehelper.R
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
|
||||||
|
|
||||||
class ATEAccentTextView @JvmOverloads constructor(
|
class ATEAccentTextView @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -31,11 +28,7 @@ class ATEAccentTextView @JvmOverloads constructor(
|
||||||
init {
|
init {
|
||||||
setTextColor(
|
setTextColor(
|
||||||
// Set MD3 accent if MD3 is enabled or in-app accent otherwise
|
// Set MD3 accent if MD3 is enabled or in-app accent otherwise
|
||||||
if (ThemeStore.isMD3Enabled(context) && VersionUtils.hasS()) {
|
|
||||||
ContextCompat.getColor(context, R.color.m3_accent_color)
|
|
||||||
} else {
|
|
||||||
ThemeStore.accentColor(context)
|
ThemeStore.accentColor(context)
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,9 @@ package code.name.monkey.appthemehelper.common.views
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
import androidx.appcompat.widget.SwitchCompat
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import code.name.monkey.appthemehelper.ATH
|
import code.name.monkey.appthemehelper.ATH
|
||||||
import code.name.monkey.appthemehelper.R
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Aidan Follestad (afollestad)
|
* @author Aidan Follestad (afollestad)
|
||||||
|
@ -32,12 +29,8 @@ class ATESwitch : SwitchCompat {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun init(context: Context) {
|
private fun init(context: Context) {
|
||||||
if (ThemeStore.isMD3Enabled(context) && VersionUtils.hasS()) {
|
|
||||||
ATH.setTint(this, ContextCompat.getColor(context, R.color.m3_accent_color))
|
|
||||||
} else {
|
|
||||||
ATH.setTint(this, ThemeStore.accentColor(context))
|
ATH.setTint(this, ThemeStore.accentColor(context))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun isShown(): Boolean {
|
override fun isShown(): Boolean {
|
||||||
return parent != null && isVisible
|
return parent != null && isVisible
|
||||||
|
|
Loading…
Reference in a new issue