mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 10:45:20 +08:00
加入新安装应用的通知图标优化适配通知忽略 DEBUG 版本的 APP
This commit is contained in:
@@ -32,6 +32,7 @@ import android.content.ClipData
|
|||||||
import android.content.ClipboardManager
|
import android.content.ClipboardManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.ApplicationInfo
|
||||||
import android.content.pm.PackageInfo
|
import android.content.pm.PackageInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
@@ -57,6 +58,7 @@ import java.io.ByteArrayOutputStream
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统深色模式是否开启
|
* 系统深色模式是否开启
|
||||||
* @return [Boolean] 是否开启
|
* @return [Boolean] 是否开启
|
||||||
@@ -237,6 +239,14 @@ fun Context.findAppName(name: String) =
|
|||||||
fun Context.findAppIcon(name: String) =
|
fun Context.findAppIcon(name: String) =
|
||||||
safeOfNull { packageManager?.getPackageInfo(name, 0)?.applicationInfo?.loadIcon(packageManager) }
|
safeOfNull { packageManager?.getPackageInfo(name, 0)?.applicationInfo?.loadIcon(packageManager) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 APP 是否为 DEBUG 版本
|
||||||
|
* @param name APP 包名
|
||||||
|
* @return [Boolean]
|
||||||
|
*/
|
||||||
|
fun Context.isAppDebuggable(name: String) =
|
||||||
|
safeOfFalse { (packageManager?.getPackageInfo(name, 0)?.applicationInfo?.flags?.and(ApplicationInfo.FLAG_DEBUGGABLE) ?: 0) != 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对数值自动补零
|
* 对数值自动补零
|
||||||
* @return [String]
|
* @return [String]
|
||||||
|
@@ -116,6 +116,7 @@ object IconAdaptationTool {
|
|||||||
* @param packageName 安装的 APP 包名
|
* @param packageName 安装的 APP 包名
|
||||||
*/
|
*/
|
||||||
fun pushNewAppSupportNotify(context: Context, packageName: String) {
|
fun pushNewAppSupportNotify(context: Context, packageName: String) {
|
||||||
|
if (context.isAppDebuggable(packageName)) return
|
||||||
context.getSystemService(NotificationManager::class.java)?.apply {
|
context.getSystemService(NotificationManager::class.java)?.apply {
|
||||||
createNotificationChannel(
|
createNotificationChannel(
|
||||||
NotificationChannel(
|
NotificationChannel(
|
||||||
|
Reference in New Issue
Block a user