4 Commits
1.3 ... 1.35

7 changed files with 99 additions and 48 deletions

View File

@@ -2,7 +2,7 @@
![Eclipse Marketplace](https://img.shields.io/badge/build-passing-brightgreen) ![Eclipse Marketplace](https://img.shields.io/badge/build-passing-brightgreen)
![Eclipse Marketplace](https://img.shields.io/badge/license-AGPL3.0-blue) ![Eclipse Marketplace](https://img.shields.io/badge/license-AGPL3.0-blue)
![Eclipse Marketplace](https://img.shields.io/badge/version-v1.3-green) ![Eclipse Marketplace](https://img.shields.io/badge/version-v1.35-green)
<br/><br/> <br/><br/>
<img src="https://github.com/fankes/ColorOSNotifyIcon/blob/master/app/src/main/ic_launcher-playstore.png" width = "100" height = "100"/> <img src="https://github.com/fankes/ColorOSNotifyIcon/blob/master/app/src/main/ic_launcher-playstore.png" width = "100" height = "100"/>
<br/> <br/>
@@ -12,7 +12,7 @@ Optimize notification icons for ColorOS and adapt to native notification icon sp
# 开始使用 # 开始使用
点击下载最新版本 点击下载最新版本
<a href='https://github.com/fankes/ColorOSNotifyIcon/releases'>![Eclipse Marketplace](https://img.shields.io/badge/download-v1.3-green)</a> <a href='https://github.com/fankes/ColorOSNotifyIcon/releases'>![Eclipse Marketplace](https://img.shields.io/badge/download-v1.35-green)</a>
<br/><br/> <br/><br/>
⚠️ 适配说明<br/> ⚠️ 适配说明<br/>

View File

@@ -60,14 +60,12 @@ tasks.whenTaskAdded {
} }
dependencies { dependencies {
compileOnly 'de.robv.android.xposed:api:82'
implementation 'com.highcapable.yukihookapi:api:1.0.4'
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.4'
implementation 'com.github.tiann:FreeReflection:3.1.0' implementation 'com.github.tiann:FreeReflection:3.1.0'
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 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
compileOnly 'de.robv.android.xposed:api:82'
implementation 'com.highcapable.yukihookapi:api:1.0.3'
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.3'
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 'com.squareup.okhttp3:okhttp:4.9.3' implementation 'com.squareup.okhttp3:okhttp:4.9.3'

View File

@@ -267,11 +267,19 @@ class HookEntry : YukiHookXposedInitProxy {
} }
} }
override fun onHook() = encase { override fun onHook() {
configs { runConfig()
runHook()
}
/** 配置 Hook */
private fun runConfig() = configs {
debugTag = "ColorOSNotify" debugTag = "ColorOSNotify"
isDebug = false isDebug = false
} }
/** 开始 Hook */
private fun runHook() = encase {
loadApp(SYSTEMUI_PACKAGE_NAME) { loadApp(SYSTEMUI_PACKAGE_NAME) {
when { when {
/** 不是 ColorOS 系统停止 Hook */ /** 不是 ColorOS 系统停止 Hook */
@@ -301,7 +309,11 @@ class HookEntry : YukiHookXposedInitProxy {
} }
beforeHook { beforeHook {
/** 是否移除 */ /** 是否移除 */
if (firstArgs as Int == 7 && prefs.getBoolean(REMOVE_CHANGECP_NOTIFY, default = false)) resultNull() if (firstArgs as Int == 7 && prefs.getBoolean(
REMOVE_CHANGECP_NOTIFY,
default = false
)
) resultNull()
} }
} }
} }

View File

@@ -20,6 +20,8 @@
* *
* This file is Created by fankes on 2022/1/24. * This file is Created by fankes on 2022/1/24.
*/ */
@file:Suppress("MemberVisibilityCanBePrivate")
package com.fankes.coloros.notify.param package com.fankes.coloros.notify.param
import android.content.Context import android.content.Context
@@ -27,9 +29,7 @@ import android.graphics.Bitmap
import android.graphics.Color import android.graphics.Color
import com.fankes.coloros.notify.bean.IconDataBean import com.fankes.coloros.notify.bean.IconDataBean
import com.fankes.coloros.notify.hook.HookConst.NOTIFY_ICON_DATAS import com.fankes.coloros.notify.hook.HookConst.NOTIFY_ICON_DATAS
import com.fankes.coloros.notify.utils.bitmap import com.fankes.coloros.notify.utils.*
import com.fankes.coloros.notify.utils.safeOf
import com.fankes.coloros.notify.utils.safeOfNan
import com.highcapable.yukihookapi.hook.factory.modulePrefs import com.highcapable.yukihookapi.hook.factory.modulePrefs
import com.highcapable.yukihookapi.hook.param.PackageParam import com.highcapable.yukihookapi.hook.param.PackageParam
import org.json.JSONArray import org.json.JSONArray
@@ -101,7 +101,7 @@ class IconPackParams(private val context: Context? = null, private val param: Pa
* 已存储的 JSON 数据 * 已存储的 JSON 数据
* @return [String] * @return [String]
*/ */
private val storageDataJson get() = (context?.modulePrefs ?: param?.prefs)?.getString(NOTIFY_ICON_DATAS) internal val storageDataJson get() = (context?.modulePrefs ?: param?.prefs)?.getString(NOTIFY_ICON_DATAS)
/** /**
* 获取图标数据 * 获取图标数据
@@ -113,22 +113,29 @@ class IconPackParams(private val context: Context? = null, private val param: Pa
if (it.isNotBlank()) runCatching { if (it.isNotBlank()) runCatching {
JSONArray(it).also { array -> JSONArray(it).also { array ->
for (i in 0 until array.length()) runCatching { for (i in 0 until array.length()) runCatching {
(array.get(i) as JSONObject).apply { add(convertToBean(array.get(i) as JSONObject)!!)
add( }.onFailure { context?.snake(msg = "部分规则加载失败") }
}
}.onFailure { context?.snake(msg = "规则加载发生错误") }
}
}
/**
* 转换为 [IconDataBean]
* @param jsonObject Json 实例
* @return [IconDataBean] or null
*/
private fun convertToBean(jsonObject: JSONObject) = safeOfNull {
jsonObject.let {
IconDataBean( IconDataBean(
appName = getString("appName"), appName = it.getString("appName"),
packageName = getString("packageName"), packageName = it.getString("packageName"),
isEnabled = getBoolean("isEnabled"), isEnabled = it.getBoolean("isEnabled"),
isEnabledAll = getBoolean("isEnabledAll"), isEnabledAll = it.getBoolean("isEnabledAll"),
iconBitmap = getString("iconBitmap").bitmap, iconBitmap = it.getString("iconBitmap").bitmap,
iconColor = safeOfNan { Color.parseColor(getString("iconColor")) }, iconColor = safeOfNan { Color.parseColor(it.getString("iconColor")) },
contributorName = getString("contributorName") contributorName = it.getString("contributorName")
) )
)
}
}
}
}
} }
} }
@@ -147,7 +154,21 @@ class IconPackParams(private val context: Context? = null, private val param: Pa
* @param json 数据 * @param json 数据
* @return [Boolean] * @return [Boolean]
*/ */
fun isNotVaildJson(json: String) = json.trim().let { !it.startsWith("[") || !it.endsWith("]") } fun isNotVaildJson(json: String) = !isJsonArray(json) && !isJsonObject(json)
/**
* 是否为 JSON 数组
* @param json 数据
* @return [Boolean]
*/
fun isJsonArray(json: String) = json.trim().let { it.startsWith("[") && it.endsWith("]") }
/**
* 是否为 JSON 实例
* @param json 数据
* @return [Boolean]
*/
fun isJsonObject(json: String) = json.trim().let { it.startsWith("{") && it.endsWith("}") }
/** /**
* 是否为异常地址 * 是否为异常地址

View File

@@ -294,22 +294,42 @@ class ConfigureActivity : BaseActivity() {
invalidate() invalidate()
} }
} }
confirmButton {
IconPackParams(context = this@ConfigureActivity).also { params -> IconPackParams(context = this@ConfigureActivity).also { params ->
confirmButton(text = "合并") {
editText.text.toString().also { jsonString ->
when { when {
editText.text.toString().isNotBlank() && params.isNotVaildJson(editText.text.toString()) -> jsonString.isNotBlank() && params.isNotVaildJson(jsonString) -> snake(msg = "不是有效的 JSON 数据")
snake(msg = "不是有效的 JSON 数据") jsonString.isNotBlank() -> {
editText.text.toString().isNotBlank() -> { params.save(
params.save(editText.text.toString()) params.splicingJsonArray(
dataJson1 = params.storageDataJson ?: "[]",
dataJson2 = jsonString.takeIf { params.isJsonArray(it) } ?: "[$jsonString]"
)
)
filterText = "" filterText = ""
mockLocalData() mockLocalData()
SystemUITool.showNeedUpdateApplySnake(context = this@ConfigureActivity) SystemUITool.showNeedUpdateApplySnake(context = this@ConfigureActivity)
} }
else -> snake(msg = "规则数组内容为空") else -> snake(msg = "请输入有效内容")
} }
} }
} }
cancelButton() cancelButton(text = "覆盖") {
editText.text.toString().also { jsonString ->
when {
jsonString.isNotBlank() && params.isNotVaildJson(jsonString) -> snake(msg = "不是有效的 JSON 数据")
jsonString.isNotBlank() -> {
params.save(dataJson = jsonString.takeIf { params.isJsonArray(it) } ?: "[$jsonString]")
filterText = ""
mockLocalData()
SystemUITool.showNeedUpdateApplySnake(context = this@ConfigureActivity)
}
else -> snake(msg = "请输入有效内容")
}
}
}
}
neutralButton(text = "取消")
} }
} }
} }

View File

@@ -19,7 +19,7 @@
android:layout_height="150dp" android:layout_height="150dp"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center|start|top" android:gravity="center|start|top"
android:hint="请粘贴 JSON 规则数组到此处" android:hint="请粘贴 JSON 规则到此处"
android:textSize="14sp" /> android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
</LinearLayout> </LinearLayout>

View File

@@ -5,8 +5,8 @@ plugins {
} }
ext { ext {
appVersionName = "1.3" appVersionName = "1.35"
appVersionCode = 4 appVersionCode = 5
} }
task clean(type: Delete) { task clean(type: Delete) {