mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 02:35:32 +08:00
Update YukiHookAPI
This commit is contained in:
@@ -38,17 +38,17 @@ android {
|
|||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled false
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_11
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = '1.8'
|
jvmTarget = '11'
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding true
|
||||||
@@ -72,8 +72,8 @@ tasks.whenTaskAdded {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'de.robv.android.xposed:api:82'
|
compileOnly 'de.robv.android.xposed:api:82'
|
||||||
implementation 'com.highcapable.yukihookapi:api:1.0.67'
|
implementation 'com.highcapable.yukihookapi:api:1.0.68'
|
||||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.67'
|
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.68'
|
||||||
implementation "com.github.topjohnwu.libsu:core:3.1.2"
|
implementation "com.github.topjohnwu.libsu:core:3.1.2"
|
||||||
implementation 'androidx.annotation:annotation:1.3.0'
|
implementation 'androidx.annotation:annotation:1.3.0'
|
||||||
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
||||||
|
@@ -232,7 +232,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
}.get(it.method {
|
}.get(it.method {
|
||||||
name = "getInstance"
|
name = "getInstance"
|
||||||
param(ContextClass)
|
param(ContextClass)
|
||||||
}.get().invoke(context)).callBoolean(drawable)
|
}.get().invoke(context)).boolean(drawable)
|
||||||
}
|
}
|
||||||
} else BitmapCompatTool.isGrayscaleDrawable(drawable)
|
} else BitmapCompatTool.isGrayscaleDrawable(drawable)
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
StatusBarIconViewClass.clazz.field { name = "mNotification" }.also { result ->
|
StatusBarIconViewClass.clazz.field { name = "mNotification" }.also { result ->
|
||||||
statusBarIconViews.takeIf { it.isNotEmpty() }?.forEach {
|
statusBarIconViews.takeIf { it.isNotEmpty() }?.forEach {
|
||||||
/** 得到通知实例 */
|
/** 得到通知实例 */
|
||||||
val nf = result.of<StatusBarNotification>(it) ?: return
|
val nf = result.get(it).cast<StatusBarNotification>() ?: return
|
||||||
/** 刷新状态栏图标 */
|
/** 刷新状态栏图标 */
|
||||||
compatStatusIcon(it.context, nf, nf.notification.smallIcon.loadDrawable(it.context)).also { pair ->
|
compatStatusIcon(it.context, nf, nf.notification.smallIcon.loadDrawable(it.context)).also { pair ->
|
||||||
pair.first.let { e -> it.setImageDrawable(e) }
|
pair.first.let { e -> it.setImageDrawable(e) }
|
||||||
@@ -591,7 +591,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
isExpanded = ExpandableNotificationRowClass.clazz.method {
|
isExpanded = ExpandableNotificationRowClass.clazz.method {
|
||||||
name = "isExpanded"
|
name = "isExpanded"
|
||||||
returnType = BooleanType
|
returnType = BooleanType
|
||||||
}.get(it).callBoolean()
|
}.get(it).boolean()
|
||||||
}).call()?.let {
|
}).call()?.let {
|
||||||
it.javaClass.method {
|
it.javaClass.method {
|
||||||
name = "getSbn"
|
name = "getSbn"
|
||||||
@@ -662,7 +662,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
}
|
}
|
||||||
afterHook {
|
afterHook {
|
||||||
(globalContext ?: firstArgs())?.also { context ->
|
(globalContext ?: firstArgs())?.also { context ->
|
||||||
val expandedNf = args(if (isUseLegacy) 1 else 0).of<StatusBarNotification?>()
|
val expandedNf = args(if (isUseLegacy) 1 else 0).cast<StatusBarNotification?>()
|
||||||
/** Hook 状态栏小图标 */
|
/** Hook 状态栏小图标 */
|
||||||
compatStatusIcon(
|
compatStatusIcon(
|
||||||
context = context,
|
context = context,
|
||||||
@@ -681,7 +681,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
afterHook {
|
afterHook {
|
||||||
instance<ImageView>().also {
|
instance<ImageView>().also {
|
||||||
if (hasIgnoreStatusBarIconColor(it.context, field { name = "mNotification" }
|
if (hasIgnoreStatusBarIconColor(it.context, field { name = "mNotification" }
|
||||||
.of<StatusBarNotification>(instance))) it.apply {
|
.get(instance).cast<StatusBarNotification>())) it.apply {
|
||||||
alpha = 1f
|
alpha = 1f
|
||||||
colorFilter = null
|
colorFilter = null
|
||||||
} else it.apply {
|
} else it.apply {
|
||||||
@@ -690,7 +690,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
* 图标在任何场景下跟随状态栏其它图标保持半透明
|
* 图标在任何场景下跟随状态栏其它图标保持半透明
|
||||||
* MIUI 12 进行单独判断
|
* MIUI 12 进行单独判断
|
||||||
*/
|
*/
|
||||||
field { name = "mCurrentSetColor" }.ofInt(instance).also { color ->
|
field { name = "mCurrentSetColor" }.get(instance).int().also { color ->
|
||||||
if (hasIgnoreStatusBarIconColor) {
|
if (hasIgnoreStatusBarIconColor) {
|
||||||
alpha = if (color.isWhite) 0.95f else 0.8f
|
alpha = if (color.isWhite) 0.95f else 0.8f
|
||||||
setColorFilter(if (color.isWhite) color else Color.BLACK)
|
setColorFilter(if (color.isWhite) color else Color.BLACK)
|
||||||
@@ -769,7 +769,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
/** 获取小图标 */
|
/** 获取小图标 */
|
||||||
val iconImageView =
|
val iconImageView =
|
||||||
NotificationHeaderViewWrapperClass.clazz
|
NotificationHeaderViewWrapperClass.clazz
|
||||||
.field { name = "mIcon" }.of<ImageView>(instance) ?: return@afterHook
|
.field { name = "mIcon" }.get(instance).cast<ImageView>() ?: return@afterHook
|
||||||
|
|
||||||
/** 获取 [StatusBarNotification] */
|
/** 获取 [StatusBarNotification] */
|
||||||
val sbnPair = instance.getSbnPair()
|
val sbnPair = instance.getSbnPair()
|
||||||
@@ -799,7 +799,7 @@ class SystemUIHooker : YukiBaseHooker() {
|
|||||||
injectMember {
|
injectMember {
|
||||||
method { name = "handleAppIcon" }
|
method { name = "handleAppIcon" }
|
||||||
replaceUnit {
|
replaceUnit {
|
||||||
field { name = "mAppIcon" }.of<ImageView>(instance)?.apply {
|
field { name = "mAppIcon" }.get(instance).cast<ImageView>()?.apply {
|
||||||
compatNotifyIcon(context, instance.getSbnPair().second, iconImageView = this, isUseAndroid12Style = true)
|
compatNotifyIcon(context, instance.getSbnPair().second, iconImageView = this, isUseAndroid12Style = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user