Skip to content

Commit 29b14a8

Browse files
committed
refactor: migrate and update to YukiHookAPI 1.3.0
1 parent 9b9eda8 commit 29b14a8

10 files changed

Lines changed: 222 additions & 207 deletions

File tree

app/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ dependencies {
8181
compileOnly(de.robv.android.xposed.api)
8282
implementation(com.highcapable.yukihookapi.api)
8383
ksp(com.highcapable.yukihookapi.ksp.xposed)
84+
implementation(com.highcapable.kavaref.kavaref.core)
85+
implementation(com.highcapable.kavaref.kavaref.extension)
8486
implementation(com.fankes.projectpromote.project.promote)
8587
implementation(com.github.topjohnwu.libsu.core)
8688
implementation(com.github.duanhong169.drawabletoolbox)

app/src/main/java/com/fankes/coloros/notify/hook/entity/FrameworkHooker.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
*/
2323
package com.fankes.coloros.notify.hook.entity
2424

25+
import android.app.Notification
26+
import com.highcapable.kavaref.KavaRef.Companion.resolve
2527
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
26-
import com.highcapable.yukihookapi.hook.factory.method
27-
import com.highcapable.yukihookapi.hook.type.android.NotificationClass
28-
import com.highcapable.yukihookapi.hook.type.java.BooleanType
29-
import com.highcapable.yukihookapi.hook.type.java.StringClass
3028

3129
/**
3230
* 系统框架核心 Hook 类
@@ -38,9 +36,9 @@ object FrameworkHooker : YukiBaseHooker() {
3836

3937
override fun onHook() {
4038
/** 拦截 ColorOS 覆盖应用通知图标 */
41-
OplusNotificationFixHelperClass?.method {
39+
OplusNotificationFixHelperClass?.resolve()?.optional()?.firstMethodOrNull {
4240
name = "fixSmallIcon"
43-
param(NotificationClass, StringClass, StringClass, BooleanType)
44-
}?.ignored()?.hook()?.intercept()
41+
parameters(Notification::class, String::class, String::class, Boolean::class)
42+
}?.hook()?.intercept()
4543
}
4644
}

app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt

Lines changed: 160 additions & 183 deletions
Large diffs are not rendered by default.

app/src/main/java/com/fankes/coloros/notify/ui/activity/base/BaseActivity.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,20 @@
2020
*
2121
* This file is created by fankes on 2022/1/30.
2222
*/
23-
@file:Suppress("DEPRECATION")
24-
2523
package com.fankes.coloros.notify.ui.activity.base
2624

2725
import android.os.Build
2826
import android.os.Bundle
27+
import android.view.LayoutInflater
2928
import androidx.appcompat.app.AppCompatActivity
3029
import androidx.core.content.res.ResourcesCompat
3130
import androidx.core.view.WindowCompat
3231
import androidx.viewbinding.ViewBinding
3332
import com.fankes.coloros.notify.R
3433
import com.fankes.coloros.notify.utils.factory.isNotSystemInDarkMode
35-
import com.highcapable.yukihookapi.hook.factory.current
36-
import com.highcapable.yukihookapi.hook.factory.method
37-
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
34+
import com.highcapable.kavaref.KavaRef.Companion.resolve
35+
import com.highcapable.kavaref.extension.genericSuperclassTypeArguments
36+
import com.highcapable.kavaref.extension.toClassOrNull
3837

3938
abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
4039

@@ -50,10 +49,11 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
5049
override fun onCreate(savedInstanceState: Bundle?) {
5150
super.onCreate(savedInstanceState)
5251
isMainThreadRunning = true
53-
binding = current().generic()?.argument()?.method {
52+
val bindingClass = javaClass.genericSuperclassTypeArguments().firstOrNull()?.toClassOrNull()
53+
binding = bindingClass?.resolve()?.optional()?.firstMethodOrNull {
5454
name = "inflate"
55-
param(LayoutInflaterClass)
56-
}?.get()?.invoke<VB>(layoutInflater) ?: error("binding failed")
55+
parameters(LayoutInflater::class)
56+
}?.invoke<VB>(layoutInflater) ?: error("binding failed")
5757
if (Build.VERSION.SDK_INT >= 35) binding.root.fitsSystemWindows = true
5858
setContentView(binding.root)
5959
/** 隐藏系统的标题栏 */
@@ -63,6 +63,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
6363
isAppearanceLightStatusBars = isNotSystemInDarkMode
6464
isAppearanceLightNavigationBars = isNotSystemInDarkMode
6565
}
66+
@Suppress("DEPRECATION")
6667
ResourcesCompat.getColor(resources, R.color.colorThemeBackground, null).also {
6768
window?.statusBarColor = it
6869
window?.navigationBarColor = it

app/src/main/java/com/fankes/coloros/notify/utils/factory/BaseAdapterFactory.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*
2121
* This file is created by fankes on 2022/6/3.
2222
*/
23+
@file:Suppress("DEPRECATION")
24+
2325
package com.fankes.coloros.notify.utils.factory
2426

2527
import android.content.Context

app/src/main/java/com/fankes/coloros/notify/utils/factory/DialogBuilderFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* This file is created by fankes on 2022/1/7.
2222
*/
23-
@file:Suppress("unused")
23+
@file:Suppress("unused", "DEPRECATION")
2424

2525
package com.fankes.coloros.notify.utils.factory
2626

app/src/main/java/com/fankes/coloros/notify/utils/factory/FunctionFactory.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* This file is created by fankes on 2022/1/7.
2222
*/
23-
@file:Suppress("unused", "ObsoleteSdkInt")
23+
@file:Suppress("unused", "ObsoleteSdkInt", "DEPRECATION")
2424

2525
package com.fankes.coloros.notify.utils.factory
2626

@@ -56,6 +56,7 @@ import androidx.core.app.NotificationManagerCompat
5656
import androidx.core.content.getSystemService
5757
import androidx.core.content.pm.PackageInfoCompat
5858
import androidx.core.content.res.ResourcesCompat
59+
import androidx.core.net.toUri
5960
import com.fankes.coloros.notify.wrapper.BuildConfigWrapper
6061
import com.google.android.material.snackbar.Snackbar
6162
import com.highcapable.yukihookapi.hook.factory.field
@@ -133,7 +134,7 @@ inline val isNotColorOS get() = !isColorOS
133134
val isRealmeUI
134135
get() = safeOfFalse {
135136
val query = appContext.contentResolver.query(
136-
Uri.parse("content://com.oplus.customize.coreapp.configmanager.configprovider.AppFeatureProvider")
137+
"content://com.oplus.customize.coreapp.configmanager.configprovider.AppFeatureProvider".toUri()
137138
.buildUpon()
138139
.appendPath("app_feature")
139140
.build(), null, "featurename=?", arrayOf("com.android.launcher.device_rm"), null
@@ -485,7 +486,7 @@ fun Context.openBrowser(url: String, packageName: String = "") = runCatching {
485486
startActivity(Intent().apply {
486487
if (packageName.isNotBlank()) setPackage(packageName)
487488
action = Intent.ACTION_VIEW
488-
data = Uri.parse(url)
489+
data = url.toUri()
489490
/** 防止顶栈一样重叠在自己的 APP 中 */
490491
flags = Intent.FLAG_ACTIVITY_NEW_TASK
491492
})

app/src/main/res/layout/activity_main.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,35 @@
13061306
android:textColor="@color/colorTextGray"
13071307
android:textSize="11sp" />
13081308
</LinearLayout>
1309+
1310+
<LinearLayout
1311+
android:layout_width="match_parent"
1312+
android:layout_height="wrap_content"
1313+
android:layout_marginLeft="15dp"
1314+
android:layout_marginRight="15dp"
1315+
android:layout_marginBottom="10dp"
1316+
android:background="@drawable/bg_permotion_round"
1317+
android:gravity="center|start"
1318+
android:orientation="horizontal"
1319+
android:padding="10dp">
1320+
1321+
<ImageView
1322+
android:layout_width="35dp"
1323+
android:layout_height="35dp"
1324+
android:layout_marginEnd="10dp"
1325+
android:src="@mipmap/ic_kavaref" />
1326+
1327+
<TextView
1328+
android:layout_width="match_parent"
1329+
android:layout_height="wrap_content"
1330+
android:autoLink="web"
1331+
android:ellipsize="end"
1332+
android:lineSpacingExtra="6dp"
1333+
android:maxLines="2"
1334+
android:text="此模块使用 KavaRef 强力驱动。\n了解更多 https://github.com/HighCapable/KavaRef"
1335+
android:textColor="@color/colorTextGray"
1336+
android:textSize="11sp" />
1337+
</LinearLayout>
13091338
</LinearLayout>
13101339
</androidx.core.widget.NestedScrollView>
13111340
</LinearLayout>
17 KB
Loading

gradle/sweet-dependency/sweet-dependency-config.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repositories:
2222
plugins:
2323
com.android.application:
2424
alias: android-application
25-
version: 8.9.0
25+
version: 8.9.3
2626
org.jetbrains.kotlin.android:
2727
alias: kotlin-android
2828
version: 2.1.10
@@ -43,9 +43,14 @@ libraries:
4343
rovo89-xposed-api
4444
com.highcapable.yukihookapi:
4545
api:
46-
version: 1.2.1
46+
version: 1.3.0
4747
ksp-xposed:
4848
version-ref: <this>::api
49+
com.highcapable.kavaref:
50+
kavaref-core:
51+
version: 1.0.0
52+
kavaref-extension:
53+
version: 1.0.0
4954
com.github.topjohnwu.libsu:
5055
core:
5156
version: 5.2.2
@@ -55,13 +60,13 @@ libraries:
5560
version: 1.0.7
5661
com.squareup.okhttp3:
5762
okhttp:
58-
version: 5.0.0-alpha.14
63+
version: 5.0.0-alpha.16
5964
androidx.core:
6065
core-ktx:
61-
version: 1.15.0
66+
version: 1.16.0
6267
androidx.appcompat:
6368
appcompat:
64-
version: 1.7.0
69+
version: 1.7.1
6570
com.google.android.material:
6671
material:
6772
version: 1.12.0

0 commit comments

Comments
 (0)