mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-07 19:14:10 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
90dda0aa52 | |||
4699eb137e | |||
ef47eef989 | |||
7a5df6457f |
4
.idea/misc.xml
generated
4
.idea/misc.xml
generated
@@ -7,6 +7,7 @@
|
||||
<entry key="app/src/main/res/drawable-night/permotion_round.xml" value="0.256" />
|
||||
<entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.44871794871794873" />
|
||||
<entry key="app/src/main/res/drawable/bg_green_round.xml" value="0.255" />
|
||||
<entry key="app/src/main/res/drawable/bg_warn_round.xml" value="0.2325" />
|
||||
<entry key="app/src/main/res/drawable/bg_yellow_round.xml" value="0.255" />
|
||||
<entry key="app/src/main/res/drawable/permotion_round.xml" value="0.256" />
|
||||
<entry key="app/src/main/res/drawable/white_round.xml" value="0.256" />
|
||||
@@ -15,10 +16,11 @@
|
||||
<entry key="app/src/main/res/layout-w936dp/dia_status_icon_cout.xml" value="0.935546875" />
|
||||
<entry key="app/src/main/res/layout/activity_config.xml" value="0.42168674698795183" />
|
||||
<entry key="app/src/main/res/layout/activity_login.xml" value="0.4375" />
|
||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.343980343980344" />
|
||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.3448275862068966" />
|
||||
<entry key="app/src/main/res/layout/adapter_config.xml" value="0.375" />
|
||||
<entry key="app/src/main/res/layout/dia_icon_filter.xml" value="0.4307692307692308" />
|
||||
<entry key="app/src/main/res/layout/dia_icon_search.xml" value="0.4307692307692308" />
|
||||
<entry key="app/src/main/res/layout/dia_source_from.xml" value="0.3591278324070115" />
|
||||
<entry key="app/src/main/res/layout/dia_source_from_string.xml" value="0.4307692307692308" />
|
||||
<entry key="app/src/main/res/layout/dia_status_icon_count.xml" value="0.45" />
|
||||
<entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" value="0.44871794871794873" />
|
||||
|
@@ -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/>
|
||||
|
||||
|
@@ -119,6 +119,13 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
/** 缓存的通知优化图标数组 */
|
||||
private var iconDatas = ArrayList<IconDataBean>()
|
||||
|
||||
/** 是否显示通知图标 - 跟随 Hook 保存 */
|
||||
private var isShowNotificationIcons = true
|
||||
|
||||
/** 是否有最大图标设置功能 */
|
||||
private val PackageParam.hasMaxStaticIcons
|
||||
get() = safeOfFalse { NotificationIconContainerClass.clazz.hasField(name = "MAX_STATIC_ICONS") }
|
||||
|
||||
/**
|
||||
* - 这个是修复彩色图标的关键核心代码判断
|
||||
*
|
||||
@@ -546,25 +553,42 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
}
|
||||
}
|
||||
}
|
||||
NotificationIconContainerClass.hook {
|
||||
injectMember {
|
||||
method { name = "calculateIconTranslations" }
|
||||
afterHook {
|
||||
/** 修复最新开发版状态栏图标只能显示一个的问题 */
|
||||
instance<ViewGroup>().layoutParams.width = 9999
|
||||
if (hasMaxStaticIcons)
|
||||
NotificationIconContainerClass.hook {
|
||||
injectMember {
|
||||
method { name = "calculateIconTranslations" }
|
||||
afterHook {
|
||||
/** 修复最新开发版状态栏图标只能显示一个的问题 */
|
||||
instance<ViewGroup>().layoutParams.width = 9999
|
||||
}
|
||||
}
|
||||
}
|
||||
injectMember {
|
||||
method { name = "updateState" }
|
||||
beforeHook {
|
||||
/** 解除状态栏通知图标个数限制 */
|
||||
if (prefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true))
|
||||
field { name = "MAX_STATIC_ICONS" }
|
||||
.get(instance).set(prefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
|
||||
.let { if (it in 0..100) it else 5 })
|
||||
injectMember {
|
||||
method { name = "updateState" }
|
||||
beforeHook {
|
||||
/** 解除状态栏通知图标个数限制 */
|
||||
if (isShowNotificationIcons && prefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true))
|
||||
field { name = "MAX_STATIC_ICONS" }
|
||||
.get(instance).set(prefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
|
||||
.let { if (it in 0..100) it else 5 })
|
||||
}
|
||||
}
|
||||
/** 旧版方法 - 新版不存在 */
|
||||
injectMember {
|
||||
method {
|
||||
name = "setMaxStaticIcons"
|
||||
param(IntType)
|
||||
beforeHook { isShowNotificationIcons = firstArgs as Int > 0 }
|
||||
}
|
||||
}.ignoredHookingFailure()
|
||||
/** 新版方法 - 旧版不存在 */
|
||||
injectMember {
|
||||
method {
|
||||
name = "miuiShowNotificationIcons"
|
||||
param(BooleanType)
|
||||
}
|
||||
beforeHook { isShowNotificationIcons = firstArgs as Boolean }
|
||||
}.ignoredHookingFailure()
|
||||
}
|
||||
}
|
||||
NotificationHeaderViewWrapperClass.hook {
|
||||
/** 修复下拉通知图标自动设置回 APP 图标的方法 */
|
||||
injectMember {
|
||||
|
@@ -33,6 +33,7 @@ import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.SwitchCompat
|
||||
import androidx.constraintlayout.utils.widget.ImageFilterView
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import com.fankes.miui.notify.BuildConfig
|
||||
import com.fankes.miui.notify.R
|
||||
@@ -192,6 +193,8 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
/** 通知图标优化名单按钮点击事件 */
|
||||
notifyIconFixButton.setOnClickListener { startActivity(Intent(this, ConfigureActivity::class.java)) }
|
||||
/** 设置警告 */
|
||||
findViewById<View>(R.id.config_warn_s_count_dis_tip).isGone = miuiVersionCode > 12.5
|
||||
/** 修改状态栏通知图标个数按钮点击事件 */
|
||||
findViewById<View>(R.id.config_status_icon_count_button).setOnClickListener {
|
||||
showDialog {
|
||||
|
@@ -129,21 +129,26 @@ inline val isNotSupportMiuiVersion get() = !isSupportMiuiVersion
|
||||
* @return [String]
|
||||
*/
|
||||
val miuiVersion
|
||||
get() =
|
||||
if (isMIUI)
|
||||
findPropString(key = "ro.miui.ui.version.name", default = "V无法获取").let {
|
||||
when (it) {
|
||||
"V110" -> "11"
|
||||
"V11" -> "11"
|
||||
"V120" -> "12"
|
||||
"V12" -> "12"
|
||||
"V125" -> "12.5"
|
||||
"V130" -> "13"
|
||||
"V13" -> "13"
|
||||
else -> it.replace(oldValue = "V", newValue = "")
|
||||
}
|
||||
}.trim()
|
||||
else "NULL"
|
||||
get() = if (isMIUI)
|
||||
findPropString(key = "ro.miui.ui.version.name", default = "V无法获取").let {
|
||||
when (it) {
|
||||
"V110" -> "11"
|
||||
"V11" -> "11"
|
||||
"V120" -> "12"
|
||||
"V12" -> "12"
|
||||
"V125" -> "12.5"
|
||||
"V130" -> "13"
|
||||
"V13" -> "13"
|
||||
else -> it.replace(oldValue = "V", newValue = "")
|
||||
}
|
||||
}.trim()
|
||||
else "NULL"
|
||||
|
||||
/**
|
||||
* 获取 MIUI 版本号
|
||||
* @return [Float]
|
||||
*/
|
||||
val miuiVersionCode get() = safeOf(default = 0f) { miuiVersion.toFloat() }
|
||||
|
||||
/**
|
||||
* 获取 MIUI 完全版本
|
||||
@@ -211,18 +216,12 @@ val Context.versionName get() = packageInfo.versionName ?: ""
|
||||
*/
|
||||
val Context.versionCode get() = packageInfo.versionCode
|
||||
|
||||
/**
|
||||
* dp 转换为 px
|
||||
* @return [Int]
|
||||
*/
|
||||
val Number.dp get() = (toFloat() * appContext.resources.displayMetrics.density).toInt()
|
||||
|
||||
/**
|
||||
* dp 转换为 px
|
||||
* @param context 使用的实例
|
||||
* @return [Float]
|
||||
*/
|
||||
fun Number.dp(context: Context) = toFloat() * context.resources.displayMetrics.density
|
||||
fun Number.dp(context: Context) = (toFloat() * context.resources.displayMetrics.density)
|
||||
|
||||
/**
|
||||
* Base64 加密
|
||||
|
@@ -48,16 +48,16 @@ class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(cont
|
||||
.rectangle()
|
||||
.rounded()
|
||||
.solidColor(0xFF656565.toInt())
|
||||
.height(20.dp)
|
||||
.cornerRadius(15.dp)
|
||||
.height(20.dp(context).toInt())
|
||||
.cornerRadius(15.dp(context).toInt())
|
||||
.build()
|
||||
thumbDrawable = DrawableBuilder()
|
||||
.rectangle()
|
||||
.rounded()
|
||||
.solidColor(Color.WHITE)
|
||||
.size(20.dp, 20.dp)
|
||||
.cornerRadius(20.dp)
|
||||
.strokeWidth(8.dp)
|
||||
.size(20.dp(context).toInt(), 20.dp(context).toInt())
|
||||
.cornerRadius(20.dp(context).toInt())
|
||||
.strokeWidth(8.dp(context).toInt())
|
||||
.strokeColor(Color.TRANSPARENT)
|
||||
.build()
|
||||
trackTintList = toColors(
|
||||
|
@@ -233,6 +233,17 @@
|
||||
android:textColor="@color/colorTextDark"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/config_warn_s_count_dis_tip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:alpha="0.6"
|
||||
android:lineSpacingExtra="6dp"
|
||||
android:text="⚠️ 仅支持 MIUI 12.5 后期开发版以及最新版本"
|
||||
android:textColor="@color/colorTextDark"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/config_item_s_count_child_hook"
|
||||
android:layout_width="match_parent"
|
||||
|
@@ -5,8 +5,8 @@ plugins {
|
||||
}
|
||||
|
||||
ext {
|
||||
appVersionName = "2.0"
|
||||
appVersionCode = 23
|
||||
appVersionName = "2.15"
|
||||
appVersionCode = 25
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
|
Reference in New Issue
Block a user