mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 02:35:32 +08:00
Merge code
This commit is contained in:
@@ -141,7 +141,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
private var notificationViewWrappers = HashSet<Any>()
|
||||
|
||||
/**
|
||||
* 是否启用忽略彩色图标和启用通知图标优化功能
|
||||
* 是否启用通知图标优化功能
|
||||
* @param isHooking 是否判断启用通知功能 - 默认:是
|
||||
* @return [Boolean]
|
||||
*/
|
||||
@@ -192,6 +192,13 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
NotificationUtilClass.clazz.method { name = "showMiuiStyle" }.get().invoke() ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理为圆角图标
|
||||
* @return [Drawable]
|
||||
*/
|
||||
private fun Drawable.rounded(context: Context) =
|
||||
safeOf(default = this) { BitmapDrawable(context.resources, toBitmap().round(10.dpFloat(context))) }
|
||||
|
||||
/**
|
||||
* 适配通知栏、状态栏图标
|
||||
*
|
||||
@@ -369,7 +376,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
/** 处理自定义通知图标优化 */
|
||||
customIcon != null -> it(BitmapDrawable(context.resources, customIcon), true)
|
||||
/** 若不是灰度图标自动处理为圆角 */
|
||||
isNotGrayscaleIcon -> it(notifyInstance.compatNotifyIcon(context, iconDrawable), true)
|
||||
isNotGrayscaleIcon -> it(notifyInstance.compatNotifyIcon(context, iconDrawable).rounded(context), true)
|
||||
/** 否则返回原始小图标 */
|
||||
else -> it(notifyInstance.notification.smallIcon.loadDrawable(context), false)
|
||||
}
|
||||
|
@@ -32,9 +32,7 @@ import android.content.Intent
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Color
|
||||
import android.graphics.*
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
@@ -321,6 +319,26 @@ val ByteArray.bitmap: Bitmap get() = BitmapFactory.decodeByteArray(this, 0, size
|
||||
*/
|
||||
val String.bitmap: Bitmap get() = unbase64.bitmap
|
||||
|
||||
/**
|
||||
* 圆角图片
|
||||
* @param radius 圆角度
|
||||
* @return [Bitmap] 圆角后的位图 - 失败会返回处理之前的位图
|
||||
*/
|
||||
fun Bitmap.round(radius: Float): Bitmap = safeOf(default = this) {
|
||||
Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888).also { out ->
|
||||
Canvas(out).also { canvas ->
|
||||
Paint().also { paint ->
|
||||
paint.isAntiAlias = true
|
||||
canvas.drawARGB(0, 0, 0, 0)
|
||||
paint.color = Color.WHITE
|
||||
canvas.drawRoundRect(RectF(Rect(0, 0, width, height)), radius, radius, paint)
|
||||
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)
|
||||
canvas.drawBitmap(this, Rect(0, 0, width, height), Rect(0, 0, width, height), paint)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统 Prop 值
|
||||
* @param key Key
|
||||
|
Reference in New Issue
Block a user