parent
1ece88762e
commit
b758beaf09
@ -1,27 +1,42 @@ |
||||
package io.legado.app.utils |
||||
|
||||
import android.graphics.ColorFilter |
||||
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 |
||||
|
||||
@Suppress("unused") |
||||
object UIUtils { |
||||
|
||||
/** 设置更多工具条图标和颜色 */ |
||||
fun setToolbarMoreIconCustomColor(toolbar: Toolbar, colorId: Int? = null) { |
||||
fun setToolbarMoreIconCustomColor(toolbar: Toolbar, color: Int? = null) { |
||||
if (toolbar == null) |
||||
return |
||||
val moreIcon = ContextCompat.getDrawable(toolbar.context, R.drawable.ic_more) |
||||
if(moreIcon != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
||||
if (colorId != null ) { |
||||
moreIcon.colorFilter = PorterDuffColorFilter(ContextCompat.getColor(toolbar.context, colorId), PorterDuff.Mode.SRC_ATOP) |
||||
if (color != null ) { |
||||
moreIcon.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) |
||||
} |
||||
toolbar.overflowIcon = moreIcon |
||||
} |
||||
} |
||||
|
||||
|
||||
fun getMenuColor(context: Context, theme: Theme = Theme.Auto, requiresOverflow: Boolean = false): Int { |
||||
val defaultTextColor = context.getCompatColor(R.color.tv_text_default) |
||||
if (requiresOverflow) |
||||
return defaultTextColor |
||||
val primaryTextColor = context.primaryTextColor |
||||
return when (theme) { |
||||
Theme.Dark -> context.getCompatColor(R.color.md_white_1000) |
||||
Theme.Light -> context.getCompatColor(R.color.md_black_1000) |
||||
else -> primaryTextColor |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,9 +1,9 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="48dp" |
||||
android:height="24dp" |
||||
android:viewportWidth="48" |
||||
android:viewportHeight="24"> |
||||
android:width="16dp" |
||||
android:height="16dp" |
||||
android:viewportWidth="16" |
||||
android:viewportHeight="16"> |
||||
<path |
||||
android:pathData="M32,9L32,5a1,1 0,0 0,-1 -1L22.15,4a1,1 0,0 0,-1 1L21.15,6.25L17,6.25a1,1 0,0 0,-1 1v9.5a1,1 0,0 0,1 1h4.19L21.19,19a1,1 0,0 0,1 1L31,20a1,1 0,0 0,1 -1L32,15a1,1 0,0 0,-1 -1L22.15,14a1,1 0,0 0,-1 1v1.25L17.48,16.25L17.48,7.75h3.69L21.17,9a1,1 0,0 0,1 1L31,10A1,1 0,0 0,32 9ZM22.65,5.5h7.87v3L22.65,8.5ZM22.65,15.5h7.87v3L22.65,18.5Z" |
||||
android:fillColor="#3f3f3f"/> |
||||
android:fillColor="#FF000000" |
||||
android:pathData="M15,0L6.15,0a1,1 0,0 0,-1 1L5.15,2.25L1,2.25a1,1 0,0 0,-1 1v9.5a1,1 0,0 0,1 1L5.17,13.75L5.17,15a1,1 0,0 0,1 1L15,16a1,1 0,0 0,1 -1L16,11a1,1 0,0 0,-1 -1L6.15,10a1,1 0,0 0,-1 1v1.25L1.48,12.25L1.48,3.75L5.17,3.75L5.17,5a1,1 0,0 0,1 1L15,6a1,1 0,0 0,1 -1L16,1a1,1 0,0 0,-1 -1ZM6.65,4.5v-3h7.87v3ZM6.65,14.5v-3h7.87v3Z"/> |
||||
</vector> |
||||
|
@ -0,0 +1,9 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="48dp" |
||||
android:height="24dp" |
||||
android:viewportWidth="48" |
||||
android:viewportHeight="24"> |
||||
<path |
||||
android:pathData="M32,9L32,5a1,1 0,0 0,-1 -1L22.15,4a1,1 0,0 0,-1 1L21.15,6.25L17,6.25a1,1 0,0 0,-1 1v9.5a1,1 0,0 0,1 1h4.19L21.19,19a1,1 0,0 0,1 1L31,20a1,1 0,0 0,1 -1L32,15a1,1 0,0 0,-1 -1L22.15,14a1,1 0,0 0,-1 1v1.25L17.48,16.25L17.48,7.75h3.69L21.17,9a1,1 0,0 0,1 1L31,10A1,1 0,0 0,32 9ZM22.65,5.5h7.87v3L22.65,8.5ZM22.65,15.5h7.87v3L22.65,18.5Z" |
||||
android:fillColor="#3f3f3f"/> |
||||
</vector> |
Loading…
Reference in new issue