Code refactor

main
h4h13 2020-01-28 23:17:48 +05:30
parent fdb2ab300e
commit 08033d6a16
31 changed files with 196 additions and 147 deletions

View File

@ -151,7 +151,7 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:3.8.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:1.5.0'
debugImplementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar') {
transitive = true

View File

@ -145,7 +145,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
}
private fun setupToolbar() {
toolbar.apply {
backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
setNavigationIcon(R.drawable.ic_menu_white_24dp)

View File

@ -32,7 +32,7 @@ import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.list.listItems
import java.io.File
import java.util.*
import java.util.ArrayList
class BlacklistPreference : ATEDialogPreference {
constructor(context: Context) : super(context)
@ -67,7 +67,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
dismiss()
}
neutralButton(text = getString(R.string.clear_action)) {
MaterialDialog(context, BottomSheet(LayoutMode.WRAP_CONTENT)).show {
MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
title(code.name.monkey.retromusic.R.string.clear_blacklist)
message(code.name.monkey.retromusic.R.string.do_you_want_to_clear_the_blacklist)
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)

View File

@ -47,8 +47,10 @@
android:id="@+id/toolbarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="?colorSurface"
app:cardCornerRadius="8dp"
app:cardUseCompatPadding="true"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways">
<FrameLayout

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2019 Hemanth Savarala.
~
~ Licensed under the GNU General Public License v3
~
~ This is free software: you can redistribute it and/or modify it under
~ the terms of the GNU General Public License as published by
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details.
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/rectSelector"
android:minHeight="72dp"
android:orientation="horizontal"
android:padding="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:ignore="PrivateResource">
<androidx.appcompat.widget.AppCompatImageView
android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="?attr/colorControlNormal"
tools:srcCompat="@drawable/ic_telegram_white" />
<com.google.android.material.textview.MaterialTextView
android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="@style/TextViewSubtitle1"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="@android:id/widget_frame"
app:layout_constraintStart_toStartOf="@+id/guideline_front_margin"
app:layout_constraintTop_toTopOf="parent"
tools:maxLines="@string/grid_size_1"
tools:text="@tools:sample/lorem" />
<code.name.monkey.retromusic.views.BaselineGridTextView
android:id="@android:id/summary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textColor="?android:attr/textColorSecondary"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="@android:id/widget_frame"
app:layout_constraintStart_toStartOf="@+id/guideline_front_margin"
app:layout_constraintTop_toBottomOf="@android:id/title"
app:lineHeightHint="20sp"
tools:maxLines="2"
tools:text="@tools:sample/lorem/random" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_front_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="52dp" />
<LinearLayout
android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end|center_vertical"
android:gravity="center_vertical"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -21,7 +21,7 @@
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="72dp"
android:paddingStart="70dp"
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewOverline"

View File

@ -27,7 +27,7 @@
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
android:key="accent_color"
android:layout="@layout/list_item_view"
android:layout="@layout/list_item_color_view"
android:persistent="false"
android:summary="@string/accent_color_desc"
android:title="@string/accent_color"

View File

@ -23,8 +23,6 @@
android:summary="@string/pref_summary_home_banner"
android:title="@string/pref_title_home_banner" />
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory

View File

@ -21,10 +21,10 @@ import android.view.View
import code.name.monkey.appthemehelper.R
class ATEColorPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
) : Preference(context, attrs, defStyleAttr, defStyleRes) {
private var mView: View? = null

View File

@ -7,14 +7,17 @@ import android.graphics.Paint
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.graphics.drawable.Drawable
import androidx.core.content.ContextCompat
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import androidx.core.content.ContextCompat
import code.name.monkey.appthemehelper.R
import kotlin.math.min
class BorderCircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : FrameLayout(context, attrs, defStyleAttr) {
class BorderCircleView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {
private val mCheck: Drawable? = ContextCompat.getDrawable(context, R.drawable.ate_check)
private val paint: Paint = Paint()
@ -49,14 +52,14 @@ class BorderCircleView @JvmOverloads constructor(context: Context, attrs: Attrib
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val widthMode = View.MeasureSpec.getMode(widthMeasureSpec)
val heightMode = View.MeasureSpec.getMode(heightMeasureSpec)
if (widthMode == View.MeasureSpec.EXACTLY && heightMode != View.MeasureSpec.EXACTLY) {
val width = View.MeasureSpec.getSize(widthMeasureSpec)
val widthMode = MeasureSpec.getMode(widthMeasureSpec)
val heightMode = MeasureSpec.getMode(heightMeasureSpec)
if (widthMode == MeasureSpec.EXACTLY && heightMode != MeasureSpec.EXACTLY) {
val width = MeasureSpec.getSize(widthMeasureSpec)
var height = width
if (heightMode == View.MeasureSpec.AT_MOST) {
height = Math.min(height, View.MeasureSpec.getSize(heightMeasureSpec))
if (heightMode == MeasureSpec.AT_MOST) {
height = min(height, MeasureSpec.getSize(heightMeasureSpec))
}
setMeasuredDimension(width, height)
} else {
@ -73,8 +76,18 @@ class BorderCircleView @JvmOverloads constructor(context: Context, attrs: Attrib
}
val circleCenter = (canvasSize - borderWidth * 2) / 2
canvas.drawCircle((circleCenter + borderWidth).toFloat(), (circleCenter + borderWidth).toFloat(), (canvasSize - borderWidth * 2) / 2 + borderWidth - 4.0f, paintBorder)
canvas.drawCircle((circleCenter + borderWidth).toFloat(), (circleCenter + borderWidth).toFloat(), (canvasSize - borderWidth * 2) / 2 - 4.0f, paint)
canvas.drawCircle(
(circleCenter + borderWidth).toFloat(),
(circleCenter + borderWidth).toFloat(),
(canvasSize - borderWidth * 2) / 2 + borderWidth - 4.0f,
paintBorder
)
canvas.drawCircle(
(circleCenter + borderWidth).toFloat(),
(circleCenter + borderWidth).toFloat(),
(canvasSize - borderWidth * 2) / 2 - 4.0f,
paint
)
if (isActivated) {
val offset = canvasSize / 2 - mCheck!!.intrinsicWidth / 2

View File

@ -25,9 +25,9 @@ import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.common.prefs.BorderCircleView
class ATEColorPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : Preference(context, attrs, defStyleAttr) {
private var mView: View? = null

View File

@ -19,12 +19,7 @@ import android.util.AttributeSet
import androidx.preference.DialogPreference
open class ATEDialogPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0, defStyleRes: Int = 0
) : DialogPreference(context, attrs, defStyleAttr, defStyleRes) {
init {
}
}
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0, defStyleRes: Int = 0
) : DialogPreference(context, attrs, defStyleAttr, defStyleRes)

View File

@ -20,10 +20,10 @@ import androidx.preference.EditTextPreference
import code.name.monkey.appthemehelper.R
class ATEEditTextPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
) : EditTextPreference(context, attrs, defStyleAttr, defStyleRes) {
init {

View File

@ -16,9 +16,7 @@ package code.name.monkey.appthemehelper.common.prefs.supportv7;
import android.content.Context;
import android.util.AttributeSet;
import androidx.preference.ListPreference;
import code.name.monkey.appthemehelper.R;
public class ATEListPreference extends ListPreference {
@ -45,7 +43,8 @@ public class ATEListPreference extends ListPreference {
private void init(Context context, AttributeSet attrs) {
setLayoutResource(R.layout.ate_preference_custom_support);
if (getSummary() == null || getSummary().toString().trim().isEmpty())
if (getSummary() == null || getSummary().toString().trim().isEmpty()) {
setSummary("%s");
}
}
}

View File

@ -21,14 +21,13 @@ import androidx.preference.Preference
import code.name.monkey.appthemehelper.ThemeStore
class ATEPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
) : Preference(context, attrs, defStyleAttr, defStyleRes) {
init {
icon?.setColorFilter(ThemeStore.textColorSecondary(context), PorterDuff.Mode.SRC_IN)
}
}

View File

@ -22,11 +22,12 @@ import androidx.preference.PreferenceViewHolder
import code.name.monkey.appthemehelper.ThemeStore
class ATEPreferenceCategory @JvmOverloads constructor(
context: Context?,
attrs: AttributeSet?,
defStyleAttr: Int = -1,
defStyleRes: Int = -1
context: Context?,
attrs: AttributeSet?,
defStyleAttr: Int = -1,
defStyleRes: Int = -1
) : PreferenceCategory(context, attrs, defStyleAttr, defStyleRes) {
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val title = holder.itemView.findViewById<TextView>(android.R.id.title)

View File

@ -14,18 +14,17 @@
package code.name.monkey.appthemehelper.common.prefs.supportv7
import androidx.fragment.app.DialogFragment
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs.ATEListPreferenceDialogFragmentCompat
import code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs.ATEPreferenceDialogFragment
/**
* @author Karim Abou Zeid (kabouzeid)
*/
abstract class ATEPreferenceFragmentCompat : PreferenceFragmentCompat() {
override fun onDisplayPreferenceDialog(preference: Preference) {
if (callbackFragment is OnPreferenceDisplayDialogCallback) {
(callbackFragment as OnPreferenceDisplayDialogCallback).onPreferenceDisplayDialog(this, preference)

View File

@ -23,7 +23,12 @@ class ATESeekBarPreference : SeekBarPreference {
init()
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(
context,
attrs,
defStyleAttr,
defStyleRes
) {
init()
}

View File

@ -21,9 +21,9 @@ import androidx.appcompat.widget.AppCompatTextView
import code.name.monkey.appthemehelper.ThemeStore
class ATEAccentTextView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AppCompatTextView(context, attrs, defStyleAttr) {
init {

View File

@ -1,32 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.appthemehelper.common.views
import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatCheckBox
import code.name.monkey.appthemehelper.ATH
import code.name.monkey.appthemehelper.ThemeStore
class ATECheckBox @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AppCompatCheckBox(context, attrs, defStyleAttr) {
init {
ATH.setTint(this, ThemeStore.accentColor(context))
}
}

View File

@ -16,14 +16,13 @@ package code.name.monkey.appthemehelper.common.views
import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
import code.name.monkey.appthemehelper.ThemeStore
import com.google.android.material.textview.MaterialTextView
class ATEPrimaryTextView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : MaterialTextView(context, attrs, defStyleAttr) {
init {

View File

@ -20,9 +20,9 @@ import code.name.monkey.appthemehelper.ThemeStore
import com.google.android.material.textview.MaterialTextView
class ATESecondaryTextView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : MaterialTextView(context, attrs, defStyleAttr) {
init {

View File

@ -7,7 +7,6 @@ import androidx.appcompat.widget.SwitchCompat
import code.name.monkey.appthemehelper.ATH
import code.name.monkey.appthemehelper.ThemeStore
/**
* @author Aidan Follestad (afollestad)
*/

View File

@ -26,8 +26,12 @@ object ATHUtil {
try {
return Class.forName(clsName)
} catch (t: Throwable) {
throw IllegalStateException(String.format("%s is not in your class path! You must include the associated library.", clsName))
throw IllegalStateException(
String.format(
"%s is not in your class path! You must include the associated library.",
clsName
)
)
}
}
}

View File

@ -4,7 +4,6 @@ import android.graphics.Color
import androidx.annotation.ColorInt
import androidx.annotation.FloatRange
object ColorUtil {
fun desaturateColor(color: Int, ratio: Float): Int {
val hsv = FloatArray(3)
@ -14,6 +13,7 @@ object ColorUtil {
return Color.HSVToColor(hsv)
}
fun stripAlpha(@ColorInt color: Int): Int {
return -0x1000000 or color
}
@ -79,7 +79,6 @@ object ColorUtil {
return Color.argb(a.toInt(), r.toInt(), g.toInt(), b.toInt())
}
private fun getColorDarkness(@ColorInt color: Int): Double {
return if (color == Color.BLACK)
1.0
@ -104,9 +103,9 @@ object ColorUtil {
@ColorInt
fun getMixedColor(@ColorInt color1: Int, @ColorInt color2: Int): Int {
return Color.rgb(
(Color.red(color1) + Color.red(color2)) / 2,
(Color.green(color1) + Color.green(color2)) / 2,
(Color.blue(color1) + Color.blue(color2)) / 2
(Color.red(color1) + Color.red(color2)) / 2,
(Color.green(color1) + Color.green(color2)) / 2,
(Color.blue(color1) + Color.blue(color2)) / 2
)
}

View File

@ -5,7 +5,6 @@ import android.graphics.drawable.Drawable
import android.graphics.drawable.TransitionDrawable
import androidx.annotation.ColorInt
object DrawableUtil {
fun createTransitionDrawable(@ColorInt startColor: Int, @ColorInt endColor: Int): TransitionDrawable {

View File

@ -7,17 +7,19 @@ import com.afollestad.materialdialogs.internal.button.DialogActionButton
import com.google.android.material.button.MaterialButton
import com.google.android.material.textfield.TextInputLayout
object MaterialUtil {
@JvmOverloads
fun setTint(button: MaterialButton, background: Boolean = true,
color: Int = ThemeStore.accentColor(button.context)) {
fun setTint(
button: MaterialButton, background: Boolean = true,
color: Int = ThemeStore.accentColor(button.context)
) {
button.isAllCaps = false
val context = button.context
val colorState = ColorStateList.valueOf(color)
val textColor = ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(color)))
val textColor =
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(color)))
if (background) {
@ -28,7 +30,6 @@ object MaterialUtil {
button.setTextColor(colorState)
button.iconTint = colorState
}
}
fun setTint(textInputLayout: TextInputLayout, background: Boolean = true) {
@ -44,14 +45,18 @@ object MaterialUtil {
textInputLayout.defaultHintTextColor = colorState
textInputLayout.isHintAnimationEnabled = true
}
}
fun setTint(button: DialogActionButton, color: Int = ThemeStore.accentColor(button.context), background: Boolean = true) {
fun setTint(
button: DialogActionButton,
color: Int = ThemeStore.accentColor(button.context),
background: Boolean = true
) {
val temp = button as AppCompatButton
val context = temp.context
val colorState = ColorStateList.valueOf(color)
val textColor = ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(color)))
val textColor =
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(color)))
if (background) {
temp.backgroundTintList = colorState

View File

@ -7,7 +7,6 @@ import androidx.core.content.ContextCompat
import code.name.monkey.appthemehelper.R
object MaterialValueHelper {
@SuppressLint("PrivateResource")

View File

@ -12,30 +12,41 @@ import com.google.android.material.navigation.NavigationView
object NavigationViewUtil {
fun setItemIconColors(navigationView: NavigationView, @ColorInt normalColor: Int, @ColorInt selectedColor: Int) {
val iconSl = ColorStateList(arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)), intArrayOf(normalColor, selectedColor))
val iconSl = ColorStateList(
arrayOf(
intArrayOf(-android.R.attr.state_checked),
intArrayOf(android.R.attr.state_checked)
), intArrayOf(normalColor, selectedColor)
)
navigationView.itemIconTintList = iconSl
val drawable = navigationView.itemBackground
navigationView.itemBackground = TintHelper.createTintedDrawable(drawable, ColorUtil.withAlpha(ThemeStore.accentColor(navigationView.context), 0.2f))
navigationView.itemBackground = TintHelper.createTintedDrawable(
drawable,
ColorUtil.withAlpha(ThemeStore.accentColor(navigationView.context), 0.2f)
)
}
fun setItemTextColors(navigationView: NavigationView, @ColorInt normalColor: Int, @ColorInt selectedColor: Int) {
val textSl = ColorStateList(
arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)),
intArrayOf(normalColor, selectedColor))
arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)),
intArrayOf(normalColor, selectedColor)
)
navigationView.itemTextColor = textSl
}
fun setItemIconColors(bottomNavigationView: BottomNavigationView, @ColorInt normalColor: Int, @ColorInt selectedColor: Int) {
val iconSl = ColorStateList(
arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)),
intArrayOf(normalColor, selectedColor))
arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)),
intArrayOf(normalColor, selectedColor)
)
bottomNavigationView.itemIconTintList = iconSl
}
fun setItemTextColors(bottomNavigationView: BottomNavigationView, @ColorInt normalColor: Int, @ColorInt selectedColor: Int) {
val textSl = ColorStateList(
arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)),
intArrayOf(normalColor, selectedColor))
arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)),
intArrayOf(normalColor, selectedColor)
)
bottomNavigationView.itemTextColor = textSl
}
}

View File

@ -1,23 +0,0 @@
package code.name.monkey.appthemehelper.util
import android.content.res.ColorStateList
import androidx.annotation.ColorInt
import com.google.android.material.tabs.TabLayout
object TabLayoutUtil {
fun setTabIconColors(tabLayout: TabLayout?, @ColorInt normalColor: Int, @ColorInt selectedColor: Int) {
if (tabLayout == null)
return
val sl = ColorStateList(arrayOf(intArrayOf(-android.R.attr.state_selected), intArrayOf(android.R.attr.state_selected)),
intArrayOf(normalColor, selectedColor))
for (i in 0 until tabLayout.tabCount) {
val tab = tabLayout.getTabAt(i)
if (tab != null && tab.icon != null) {
tab.icon = TintHelper.createTintedDrawable(tab.icon, sl)
}
}
}
}

View File

@ -4,7 +4,6 @@ import android.graphics.drawable.Drawable
import android.view.View
import android.view.ViewTreeObserver
object ViewUtil {
fun removeOnGlobalLayoutListener(v: View, listener: ViewTreeObserver.OnGlobalLayoutListener) {
v.viewTreeObserver.removeOnGlobalLayoutListener(listener)