From 95f2f1f9a4218f8b2d0320e1d40b7914d22fa55b Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 1 Jan 2021 20:38:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/utils/ToolBarExtensions.kt | 19 +++++++++++++++++++ .../main/java/io/legado/app/utils/UIUtils.kt | 18 ------------------ 2 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 app/src/main/java/io/legado/app/utils/ToolBarExtensions.kt diff --git a/app/src/main/java/io/legado/app/utils/ToolBarExtensions.kt b/app/src/main/java/io/legado/app/utils/ToolBarExtensions.kt new file mode 100644 index 000000000..325923f15 --- /dev/null +++ b/app/src/main/java/io/legado/app/utils/ToolBarExtensions.kt @@ -0,0 +1,19 @@ +package io.legado.app.utils + +import android.graphics.PorterDuff +import android.graphics.PorterDuffColorFilter +import android.os.Build +import android.widget.Toolbar +import androidx.core.content.ContextCompat +import io.legado.app.R + +/** + * 设置toolBar更多图标颜色 + */ +fun Toolbar.setMoreIconColor(color: Int) { + val moreIcon = ContextCompat.getDrawable(context, R.drawable.ic_more) + if (moreIcon != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + moreIcon.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) + overflowIcon = moreIcon + } +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/utils/UIUtils.kt b/app/src/main/java/io/legado/app/utils/UIUtils.kt index b50a4c493..059f94a07 100644 --- a/app/src/main/java/io/legado/app/utils/UIUtils.kt +++ b/app/src/main/java/io/legado/app/utils/UIUtils.kt @@ -1,11 +1,6 @@ package io.legado.app.utils import android.content.Context -import android.graphics.PorterDuff -import android.graphics.PorterDuffColorFilter -import android.os.Build -import androidx.appcompat.widget.Toolbar -import androidx.core.content.ContextCompat import io.legado.app.R import io.legado.app.constant.Theme import io.legado.app.lib.theme.primaryTextColor @@ -13,19 +8,6 @@ import io.legado.app.lib.theme.primaryTextColor @Suppress("unused") object UIUtils { - /** 设置更多工具条图标和颜色 */ - fun setToolbarMoreIconCustomColor(toolbar: Toolbar?, color: Int? = null) { - toolbar ?: return - val moreIcon = ContextCompat.getDrawable(toolbar.context, R.drawable.ic_more) - if (moreIcon != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (color != null) { - moreIcon.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) - } - toolbar.overflowIcon = moreIcon - } - } - - fun getMenuColor( context: Context, theme: Theme = Theme.Auto,