mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-04 17:55:34 +08:00
更新 YukiHookAPI 版本
This commit is contained in:
@@ -64,8 +64,8 @@ dependencies {
|
|||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
|
||||||
compileOnly 'de.robv.android.xposed:api:82'
|
compileOnly 'de.robv.android.xposed:api:82'
|
||||||
implementation 'com.highcapable.yukihookapi:api:1.0.1'
|
implementation 'com.highcapable.yukihookapi:api:1.0.2'
|
||||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.1'
|
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.2'
|
||||||
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
||||||
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0'
|
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0'
|
||||||
implementation 'androidx.core:core-ktx:1.7.0'
|
implementation 'androidx.core:core-ktx:1.7.0'
|
||||||
|
@@ -108,8 +108,13 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
*/
|
*/
|
||||||
private fun PackageParam.isGrayscaleIcon(context: Context, drawable: Drawable) = safeOfFalse {
|
private fun PackageParam.isGrayscaleIcon(context: Context, drawable: Drawable) = safeOfFalse {
|
||||||
ContrastColorUtilClass.clazz.let {
|
ContrastColorUtilClass.clazz.let {
|
||||||
it.method(name = "isGrayscaleIcon", DrawableClass)
|
it.method {
|
||||||
?.call<Boolean>(it.method(name = "getInstance", ContextClass)?.callStatic(context), drawable) ?: false
|
name = "isGrayscaleIcon"
|
||||||
|
param(DrawableClass)
|
||||||
|
}.get(it.method {
|
||||||
|
name = "getInstance"
|
||||||
|
param(ContextClass)
|
||||||
|
}.get().invoke(context)).invoke<Boolean>(drawable) ?: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +123,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
* @return [Boolean]
|
* @return [Boolean]
|
||||||
*/
|
*/
|
||||||
private fun PackageParam.isShowMiuiStyle() = safeOfFalse {
|
private fun PackageParam.isShowMiuiStyle() = safeOfFalse {
|
||||||
NotificationUtilClass.clazz.method(name = "showMiuiStyle")?.callStatic() ?: false
|
NotificationUtilClass.clazz.method { name = "showMiuiStyle" }.get().invoke() ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,7 +142,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
* @return [String]
|
* @return [String]
|
||||||
*/
|
*/
|
||||||
private fun PackageParam.findAppName(instance: Any?) = safeOf(default = "<unknown>") {
|
private fun PackageParam.findAppName(instance: Any?) = safeOf(default = "<unknown>") {
|
||||||
ExpandedNotificationClass.clazz.method(name = "getAppName")?.call(instance) ?: "<empty>"
|
ExpandedNotificationClass.clazz.method { name = "getAppName" }.get(instance).invoke() ?: "<empty>"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,7 +202,9 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
*/
|
*/
|
||||||
private val PackageParam.globalContext
|
private val PackageParam.globalContext
|
||||||
get() = safeOfNull {
|
get() = safeOfNull {
|
||||||
SystemUIApplicationClass.clazz.method(name = "getContext")?.callStatic<Context>()
|
if (SystemUIApplicationClass.clazz.hasMethod(name = "getContext"))
|
||||||
|
SystemUIApplicationClass.clazz.method { name = "getContext" }.get().invoke<Context>()
|
||||||
|
else null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -471,7 +478,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
findClass(StatusBarIconViewClass).hook {
|
StatusBarIconViewClass.hook {
|
||||||
/** 修复通知图标为彩色 - MIPUSH 修复 */
|
/** 修复通知图标为彩色 - MIPUSH 修复 */
|
||||||
injectMember {
|
injectMember {
|
||||||
method { name = "updateIconColor" }
|
method { name = "updateIconColor" }
|
||||||
@@ -499,7 +506,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NotificationHeaderViewWrapperInjectorClass.hasClass)
|
if (NotificationHeaderViewWrapperInjectorClass.hasClass)
|
||||||
findClass(NotificationHeaderViewWrapperInjectorClass).hook {
|
NotificationHeaderViewWrapperInjectorClass.hook {
|
||||||
/** 修复下拉通知图标自动设置回 APP 图标的方法 */
|
/** 修复下拉通知图标自动设置回 APP 图标的方法 */
|
||||||
injectMember {
|
injectMember {
|
||||||
var isUseLegacy = false
|
var isUseLegacy = false
|
||||||
@@ -539,7 +546,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
findClass(NotificationHeaderViewWrapperClass).hook {
|
NotificationHeaderViewWrapperClass.hook {
|
||||||
/** 之前的版本解决方案 */
|
/** 之前的版本解决方案 */
|
||||||
injectMember {
|
injectMember {
|
||||||
method { name = "handleHeaderViews" }
|
method { name = "handleHeaderViews" }
|
||||||
@@ -547,19 +554,16 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
/** 对于之前没有通知图标色彩判断功能的版本判断是 MIUI 样式就停止 Hook */
|
/** 对于之前没有通知图标色彩判断功能的版本判断是 MIUI 样式就停止 Hook */
|
||||||
if (!hasIgnoreStatusBarIconColor() && isShowMiuiStyle()) return@afterHook
|
if (!hasIgnoreStatusBarIconColor() && isShowMiuiStyle()) return@afterHook
|
||||||
/** 获取小图标 */
|
/** 获取小图标 */
|
||||||
val iconImageView = field {
|
val iconImageView =
|
||||||
classSet = NotificationHeaderViewWrapperClass.clazz
|
NotificationHeaderViewWrapperClass.clazz
|
||||||
name = "mIcon"
|
.field { name = "mIcon" }.of<ImageView>(instance) ?: return@afterHook
|
||||||
}.of<ImageView>(instance) ?: return@afterHook
|
|
||||||
/** 从父类中得到 mRow 变量 - [ExpandableNotificationRowClass] */
|
/** 从父类中得到 mRow 变量 - [ExpandableNotificationRowClass] */
|
||||||
field {
|
NotificationViewWrapperClass.clazz.field { name = "mRow" }.get(instance).apply {
|
||||||
classSet = NotificationViewWrapperClass.clazz
|
|
||||||
name = "mRow"
|
|
||||||
}.get(instance).apply {
|
|
||||||
/** 获取其中的得到通知方法 */
|
/** 获取其中的得到通知方法 */
|
||||||
val expandedNf =
|
val expandedNf =
|
||||||
ExpandableNotificationRowClass.clazz.method(name = "getStatusBarNotification")
|
ExpandableNotificationRowClass.clazz
|
||||||
?.call<StatusBarNotification>(instance = self)
|
.method { name = "getStatusBarNotification" }
|
||||||
|
.get(self).invoke<StatusBarNotification>()
|
||||||
/** 执行 Hook */
|
/** 执行 Hook */
|
||||||
hookNotifyIconOnSet(iconImageView.context, expandedNf, iconImageView)
|
hookNotifyIconOnSet(iconImageView.context, expandedNf, iconImageView)
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,6 @@ import android.util.Base64
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.fankes.miui.notify.application.MNNApplication.Companion.appContext
|
import com.fankes.miui.notify.application.MNNApplication.Companion.appContext
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.highcapable.yukihookapi.hook.factory.callStatic
|
|
||||||
import com.highcapable.yukihookapi.hook.factory.classOf
|
import com.highcapable.yukihookapi.hook.factory.classOf
|
||||||
import com.highcapable.yukihookapi.hook.factory.hasClass
|
import com.highcapable.yukihookapi.hook.factory.hasClass
|
||||||
import com.highcapable.yukihookapi.hook.factory.method
|
import com.highcapable.yukihookapi.hook.factory.method
|
||||||
@@ -241,9 +240,10 @@ fun Bitmap.round(radius: Float): Bitmap =
|
|||||||
* @return [String]
|
* @return [String]
|
||||||
*/
|
*/
|
||||||
fun findPropString(key: String, default: String = "") = safeOf(default) {
|
fun findPropString(key: String, default: String = "") = safeOf(default) {
|
||||||
(classOf(name = "android.os.SystemProperties").method(
|
(classOf(name = "android.os.SystemProperties").method {
|
||||||
name = "get", StringType, StringType
|
name = "get"
|
||||||
)?.callStatic(key, default)) ?: default
|
param(StringType, StringType)
|
||||||
|
}.get().invoke(key, default)) ?: default
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -10,7 +10,8 @@ dependencyResolutionManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
maven { url "https://api.xposed.info/" }
|
maven { url "https://api.xposed.info/" }
|
||||||
maven { url 'https://www.jitpack.io' }
|
maven { url "https://www.jitpack.io" }
|
||||||
|
maven { url "https://s01.oss.sonatype.org/content/repositories/releases" }
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user