mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 02:35:32 +08:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
83c98b2ad3 | |||
0d7f323232 | |||
0d63b0a14d | |||
6684d7f376 | |||
89321af1ce |
@@ -2,7 +2,7 @@
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
<br/><br/>
|
||||
<img src="https://github.com/fankes/MIUINativeNotifyIcon/blob/master/app/src/main/ic_launcher-playstore.png" width = "100" height = "100"/>
|
||||
<br/>
|
||||
@@ -12,7 +12,7 @@ Fix the native notification bar icon function abandoned by the MIUI development
|
||||
# 开始使用
|
||||
|
||||
点击下载最新版本
|
||||
<a href='https://github.com/fankes/MIUINativeNotifyIcon/releases'></a>
|
||||
<a href='https://github.com/fankes/MIUINativeNotifyIcon/releases'></a>
|
||||
<br/><br/>
|
||||
⚠️ 适配说明<br/>
|
||||
|
||||
|
@@ -68,8 +68,8 @@ dependencies {
|
||||
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.2'
|
||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.2'
|
||||
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-ktx:3.2.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||
|
@@ -261,9 +261,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
*/
|
||||
private val PackageParam.globalContext
|
||||
get() = safeOfNull {
|
||||
if (SystemUIApplicationClass.clazz.hasMethod(name = "getContext"))
|
||||
SystemUIApplicationClass.clazz.method { name = "getContext" }.get().invoke<Context>()
|
||||
else null
|
||||
SystemUIApplicationClass.clazz.method { name = "getContext" }.ignoredError().get().invoke<Context>()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,7 +503,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
replaceAny {
|
||||
hookIgnoreStatusBarIconColor(
|
||||
context = globalContext ?: error("GlobalContext got null"),
|
||||
expandedNf = args[0] as? StatusBarNotification?
|
||||
expandedNf = firstArgs as? StatusBarNotification?
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -526,7 +524,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
}.onFind { isUseLegacy = true }
|
||||
}
|
||||
afterHook {
|
||||
(globalContext ?: args[0] as Context).also { context ->
|
||||
(globalContext ?: firstArgs as Context).also { context ->
|
||||
hookSmallIconOnSet(
|
||||
context = context,
|
||||
args[if (isUseLegacy) 1 else 0] as? StatusBarNotification?,
|
||||
@@ -597,15 +595,15 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
}
|
||||
}
|
||||
intercept()
|
||||
}.ignoredAllFailure()
|
||||
}.ignoredHookingFailure()
|
||||
injectMember {
|
||||
method {
|
||||
name = "resetIconBgAndPaddings"
|
||||
param(ImageViewClass, ExpandedNotificationClass.clazz)
|
||||
}
|
||||
intercept()
|
||||
}.ignoredAllFailure()
|
||||
}
|
||||
}.ignoredHookingFailure()
|
||||
}.ignoredHookClassNotFoundFailure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,8 +25,6 @@
|
||||
package com.fankes.miui.notify.ui
|
||||
|
||||
import android.app.ProgressDialog
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -51,6 +49,9 @@ import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
||||
|
||||
class ConfigureActivity : BaseActivity() {
|
||||
|
||||
/** 访问请求链接 */
|
||||
private var rawGithubUrl = "https://raw.githubusercontent.com/fankes/AndroidNotifyIconAdapt/main"
|
||||
|
||||
/** 当前筛选条件 */
|
||||
private var filterText = ""
|
||||
|
||||
@@ -192,16 +193,7 @@ class ConfigureActivity : BaseActivity() {
|
||||
}
|
||||
/** 设置点击事件 */
|
||||
findViewById<View>(R.id.config_cbr_button).setOnClickListener {
|
||||
runCatching {
|
||||
startActivity(Intent().apply {
|
||||
action = "android.intent.action.VIEW"
|
||||
data = Uri.parse("https://github.com/fankes/AndroidNotifyIconAdapt/blob/main/CONTRIBUTING.md")
|
||||
/** 防止顶栈一样重叠在自己的 APP 中 */
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
})
|
||||
}.onFailure {
|
||||
toast(msg = "无法启动系统默认浏览器")
|
||||
}
|
||||
openBrowser(url = "https://github.com/fankes/AndroidNotifyIconAdapt/blob/main/CONTRIBUTING.md")
|
||||
}
|
||||
/** 装载数据 */
|
||||
mockLocalData()
|
||||
@@ -227,7 +219,7 @@ class ConfigureActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
/** 开始更新数据 */
|
||||
private fun onRefreshing() {
|
||||
private fun onRefreshing() = ClientRequestTool.checkingInternetConnect(context = this) {
|
||||
ProgressDialog(this).apply {
|
||||
setDefaultStyle(context = this@ConfigureActivity)
|
||||
setCancelable(false)
|
||||
@@ -237,12 +229,12 @@ class ConfigureActivity : BaseActivity() {
|
||||
}.also {
|
||||
ClientRequestTool.wait(
|
||||
context = this,
|
||||
url = "https://raw.githubusercontent.com/fankes/AndroidNotifyIconAdapt/main/OS/MIUI/NotifyIconsSupportConfig.json"
|
||||
url = "$rawGithubUrl/OS/MIUI/NotifyIconsSupportConfig.json"
|
||||
) { isDone1, ctOS ->
|
||||
it.setMessage("正在同步 APP 数据")
|
||||
ClientRequestTool.wait(
|
||||
context = this,
|
||||
url = "https://raw.githubusercontent.com/fankes/AndroidNotifyIconAdapt/main/APP/NotifyIconsSupportConfig.json"
|
||||
url = "$rawGithubUrl/APP/NotifyIconsSupportConfig.json"
|
||||
) { isDone2, ctAPP ->
|
||||
it.cancel()
|
||||
IconPackParams(context = this).also { params ->
|
||||
@@ -253,12 +245,14 @@ class ConfigureActivity : BaseActivity() {
|
||||
mockLocalData()
|
||||
SystemUITool.showNeedUpdateApplySnake(context = this)
|
||||
} else snake(msg = "列表数据已是最新")
|
||||
} else
|
||||
showDialog {
|
||||
title = "连接失败"
|
||||
msg = "连接失败,错误如下:\n${if (!isDone1) ctOS else ctAPP}"
|
||||
confirmButton(text = "我知道了")
|
||||
} else showDialog {
|
||||
title = "连接失败"
|
||||
msg = "连接失败,错误如下:\n${if (!isDone1) ctOS else ctAPP}"
|
||||
confirmButton(text = "解决方案") {
|
||||
openBrowser(url = "https://www.baidu.com/s?wd=github%2Braw%2B%E6%97%A0%E6%B3%95%E8%AE%BF%E9%97%AE")
|
||||
}
|
||||
cancelButton()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@ package com.fankes.miui.notify.ui
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
@@ -177,30 +176,11 @@ class MainActivity : BaseActivity() {
|
||||
findViewById<View>(R.id.title_restart_icon).setOnClickListener { SystemUITool.restartSystemUI(context = this) }
|
||||
/** 恰饭! */
|
||||
findViewById<View>(R.id.link_with_follow_me).setOnClickListener {
|
||||
runCatching {
|
||||
startActivity(Intent().apply {
|
||||
setPackage("com.coolapk.market")
|
||||
action = "android.intent.action.VIEW"
|
||||
data = Uri.parse("https://www.coolapk.com/u/876977")
|
||||
/** 防止顶栈一样重叠在自己的 APP 中 */
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
})
|
||||
}.onFailure {
|
||||
toast(msg = "你可能没有安装酷安")
|
||||
}
|
||||
openBrowser(url = "https://www.coolapk.com/u/876977", packageName = "com.coolapk.market")
|
||||
}
|
||||
/** 项目地址点击事件 */
|
||||
findViewById<View>(R.id.link_with_project_address).setOnClickListener {
|
||||
runCatching {
|
||||
startActivity(Intent().apply {
|
||||
action = "android.intent.action.VIEW"
|
||||
data = Uri.parse("https://github.com/fankes/MIUINativeNotifyIcon")
|
||||
/** 防止顶栈一样重叠在自己的 APP 中 */
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
})
|
||||
}.onFailure {
|
||||
toast(msg = "无法启动系统默认浏览器")
|
||||
}
|
||||
openBrowser(url = "https://github.com/fankes/MIUINativeNotifyIcon")
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,11 +20,15 @@
|
||||
*
|
||||
* This file is Created by fankes on 2022/2/25.
|
||||
*/
|
||||
@file:Suppress("TrustAllX509TrustManager", "CustomX509TrustManager")
|
||||
@file:Suppress("TrustAllX509TrustManager", "CustomX509TrustManager", "DEPRECATION")
|
||||
|
||||
package com.fankes.miui.notify.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.ProgressDialog
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.Settings
|
||||
import com.highcapable.yukihookapi.hook.log.loggerD
|
||||
import okhttp3.*
|
||||
import java.io.IOException
|
||||
@@ -37,6 +41,38 @@ import javax.net.ssl.*
|
||||
*/
|
||||
object ClientRequestTool {
|
||||
|
||||
/**
|
||||
* 检查网络连接情况
|
||||
* @param context 实例
|
||||
* @param it 已连接回调
|
||||
*/
|
||||
fun checkingInternetConnect(context: Activity, it: () -> Unit) =
|
||||
ProgressDialog(context).apply {
|
||||
setDefaultStyle(context)
|
||||
setCancelable(false)
|
||||
setTitle("准备中")
|
||||
setMessage("正在检查网络连接情况")
|
||||
}.apply {
|
||||
wait(context, url = "https://www.baidu.com") { isDone, _ ->
|
||||
cancel()
|
||||
if (isDone) it() else
|
||||
context.showDialog {
|
||||
title = "网络不可用"
|
||||
msg = "无法连接到互联网,请检查你当前的设备是否可以上网,且没有在手机管家中禁用本模块的联网权限。"
|
||||
confirmButton(text = "检查设置") {
|
||||
runCatching {
|
||||
context.startActivity(Intent().apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
||||
data = Uri.fromParts("package", context.packageName, null)
|
||||
})
|
||||
}.onFailure { context.snake(msg = "启动应用信息页面失败") }
|
||||
}
|
||||
cancelButton()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
|
||||
/**
|
||||
* 发送 GET 请求内容并等待
|
||||
* @param context 实例
|
||||
|
@@ -27,6 +27,7 @@ package com.fankes.miui.notify.utils
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
@@ -34,6 +35,7 @@ import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import android.util.Base64
|
||||
@@ -276,6 +278,26 @@ fun Context.snake(msg: String, actionText: String = "", it: () -> Unit = {}) =
|
||||
setAction(actionText) { it() }
|
||||
}.show()
|
||||
|
||||
/**
|
||||
* 启动系统浏览器
|
||||
* @param url 网址
|
||||
* @param packageName 指定包名 - 可不填
|
||||
*/
|
||||
fun Context.openBrowser(url: String, packageName: String = "") =
|
||||
runCatching {
|
||||
startActivity(Intent().apply {
|
||||
if (packageName.isNotBlank()) setPackage(packageName)
|
||||
action = Intent.ACTION_VIEW
|
||||
data = Uri.parse(url)
|
||||
/** 防止顶栈一样重叠在自己的 APP 中 */
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
})
|
||||
}.onFailure {
|
||||
if (packageName.isNotBlank())
|
||||
snake(msg = "启动 $packageName 失败")
|
||||
else snake(msg = "启动系统浏览器失败")
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略异常返回值
|
||||
* @param it 回调 - 如果异常为空
|
||||
|
@@ -5,8 +5,8 @@ plugins {
|
||||
}
|
||||
|
||||
ext {
|
||||
appVersionName = "1.86"
|
||||
appVersionCode = 19
|
||||
appVersionName = "1.87"
|
||||
appVersionCode = 20
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
|
Reference in New Issue
Block a user