From 08033d6a160759a51bf0f39c4bf5d920a6f3bed4 Mon Sep 17 00:00:00 2001 From: h4h13 Date: Tue, 28 Jan 2020 23:17:48 +0530 Subject: [PATCH] Code refactor --- app/build.gradle | 2 +- .../mainactivity/home/BannerHomeFragment.kt | 1 - .../preferences/BlacklistPreferenceDialog.kt | 4 +- app/src/main/res/layout/fragment_library.xml | 2 + .../main/res/layout/list_item_color_view.xml | 80 +++++++++++++++++++ .../res/layout/preference_category_title.xml | 2 +- app/src/main/res/xml/pref_general.xml | 2 +- app/src/main/res/xml/pref_ui.xml | 2 - .../common/prefs/ATEColorPreference.kt | 8 +- .../common/prefs/BorderCircleView.kt | 37 ++++++--- .../prefs/supportv7/ATEColorPreference.kt | 6 +- .../prefs/supportv7/ATEDialogPreference.kt | 13 +-- .../prefs/supportv7/ATEEditTextPreference.kt | 8 +- .../prefs/supportv7/ATEListPreference.java | 5 +- .../common/prefs/supportv7/ATEPreference.kt | 9 +-- .../prefs/supportv7/ATEPreferenceCategory.kt | 9 ++- .../supportv7/ATEPreferenceFragmentCompat.kt | 3 +- .../prefs/supportv7/ATESeekBarPreference.kt | 7 +- .../common/views/ATEAccentTextView.kt | 6 +- .../common/views/ATECheckBox.kt | 32 -------- .../common/views/ATEPrimaryTextView.kt | 7 +- .../common/views/ATESecondaryTextView.kt | 6 +- .../appthemehelper/common/views/ATESwitch.kt | 1 - .../monkey/appthemehelper/util/ATHUtil.kt | 8 +- .../monkey/appthemehelper/util/ColorUtil.kt | 9 +-- .../appthemehelper/util/DrawableUtil.kt | 1 - .../appthemehelper/util/MaterialUtil.kt | 21 +++-- .../util/MaterialValueHelper.kt | 1 - .../appthemehelper/util/NavigationViewUtil.kt | 27 +++++-- .../appthemehelper/util/TabLayoutUtil.kt | 23 ------ .../monkey/appthemehelper/util/ViewUtil.kt | 1 - 31 files changed, 196 insertions(+), 147 deletions(-) create mode 100644 app/src/main/res/layout/list_item_color_view.xml delete mode 100755 appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATECheckBox.kt delete mode 100755 appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/TabLayoutUtil.kt diff --git a/app/build.gradle b/app/build.gradle index 1597466e..4e2ed67e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt index e8714864..8eb55f76 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt @@ -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) diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt index ab856a40..8271e715 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt @@ -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) diff --git a/app/src/main/res/layout/fragment_library.xml b/app/src/main/res/layout/fragment_library.xml index 88e3adb8..d0eaa8f5 100644 --- a/app/src/main/res/layout/fragment_library.xml +++ b/app/src/main/res/layout/fragment_library.xml @@ -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"> + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/preference_category_title.xml b/app/src/main/res/layout/preference_category_title.xml index 13e95047..53db041d 100644 --- a/app/src/main/res/layout/preference_category_title.xml +++ b/app/src/main/res/layout/preference_category_title.xml @@ -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" diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index d742391d..4de7ba2c 100755 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -27,7 +27,7 @@ - - (android.R.id.title) diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceFragmentCompat.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceFragmentCompat.kt index e6c8ff62..b0c21558 100644 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceFragmentCompat.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceFragmentCompat.kt @@ -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) diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATESeekBarPreference.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATESeekBarPreference.kt index 3cd3db72..72dad5b9 100644 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATESeekBarPreference.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATESeekBarPreference.kt @@ -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() } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEAccentTextView.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEAccentTextView.kt index 1ac734ef..56b40c92 100644 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEAccentTextView.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEAccentTextView.kt @@ -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 { diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATECheckBox.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATECheckBox.kt deleted file mode 100755 index a95eddb2..00000000 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATECheckBox.kt +++ /dev/null @@ -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)) - } -} diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEPrimaryTextView.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEPrimaryTextView.kt index 23d5ef5e..483beee4 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEPrimaryTextView.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEPrimaryTextView.kt @@ -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 { diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESecondaryTextView.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESecondaryTextView.kt index 568d65e8..0aa51fe0 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESecondaryTextView.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESecondaryTextView.kt @@ -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 { diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESwitch.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESwitch.kt index 89284b9c..6bdff1f7 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESwitch.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESwitch.kt @@ -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) */ diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ATHUtil.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ATHUtil.kt index 2d9d301c..be81103d 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ATHUtil.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ATHUtil.kt @@ -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 + ) + ) } - } } \ No newline at end of file diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ColorUtil.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ColorUtil.kt index ae66d149..57eaf4d6 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ColorUtil.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ColorUtil.kt @@ -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 ) } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/DrawableUtil.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/DrawableUtil.kt index 1997533e..5dd3f1ff 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/DrawableUtil.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/DrawableUtil.kt @@ -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 { diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialUtil.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialUtil.kt index e1709893..2fd17295 100644 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialUtil.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialUtil.kt @@ -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 diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialValueHelper.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialValueHelper.kt index 6a57e56b..ef7ec71e 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialValueHelper.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/MaterialValueHelper.kt @@ -7,7 +7,6 @@ import androidx.core.content.ContextCompat import code.name.monkey.appthemehelper.R - object MaterialValueHelper { @SuppressLint("PrivateResource") diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/NavigationViewUtil.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/NavigationViewUtil.kt index 05782028..ae29dd81 100644 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/NavigationViewUtil.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/NavigationViewUtil.kt @@ -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 } } \ No newline at end of file diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/TabLayoutUtil.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/TabLayoutUtil.kt deleted file mode 100755 index 06cbaba8..00000000 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/TabLayoutUtil.kt +++ /dev/null @@ -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) - } - } - } -} diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ViewUtil.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ViewUtil.kt index 40ca8ebf..7620f31c 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ViewUtil.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/util/ViewUtil.kt @@ -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)