mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-10-22 13:29:20 +08:00
加入白痴文案,修改部分设置,加入提示
This commit is contained in:
@@ -99,6 +99,14 @@ class HookMain : IXposedHookLoadPackage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 仅作用于替换的 Hook 方法体 */
|
||||||
|
@Suppress("unused")
|
||||||
|
private val replaceToFalse = object : XC_MethodReplacement() {
|
||||||
|
override fun replaceHookedMethod(param: MethodHookParam?): Any {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 忽略异常运行
|
* 忽略异常运行
|
||||||
* @param error 错误信息
|
* @param error 错误信息
|
||||||
@@ -248,7 +256,7 @@ class HookMain : IXposedHookLoadPackage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - 这个是修复彩色图标的关键核心代码判断
|
* - ⚡这个是修复彩色图标的关键核心代码判断
|
||||||
*
|
*
|
||||||
* 判断是否为灰度图标 - 反射执行系统方法
|
* 判断是否为灰度图标 - 反射执行系统方法
|
||||||
* @param context 实例
|
* @param context 实例
|
||||||
@@ -642,8 +650,12 @@ class HookMain : IXposedHookLoadPackage {
|
|||||||
isAccessible = true
|
isAccessible = true
|
||||||
}[param.thisObject] as? StatusBarNotification?
|
}[param.thisObject] as? StatusBarNotification?
|
||||||
|
|
||||||
/** 强制设置图标 - 防止 MIPUSH 不生效 */
|
/**
|
||||||
if (lpparam.hasIgnoreStatusBarIconColor() || !lpparam.isShowMiuiStyle())
|
* 强制设置图标 - 防止 MIPUSH 不生效
|
||||||
|
* 由于之前版本没有 [hasIgnoreStatusBarIconColor] 判断 - MIPUSH 的图标颜色也是白色的
|
||||||
|
* 所以之前的版本取消这个 Hook - 实在找不到设置图标的地方 - 状态栏图标就彩色吧
|
||||||
|
*/
|
||||||
|
if (lpparam.hasIgnoreStatusBarIconColor())
|
||||||
lpparam.hookSmallIconOnSet(
|
lpparam.hookSmallIconOnSet(
|
||||||
context = iconImageView.context,
|
context = iconImageView.context,
|
||||||
expandedNf,
|
expandedNf,
|
||||||
|
@@ -37,6 +37,7 @@ import com.fankes.miui.notify.R
|
|||||||
import com.fankes.miui.notify.hook.HookMedium
|
import com.fankes.miui.notify.hook.HookMedium
|
||||||
import com.fankes.miui.notify.params.IconPackParams
|
import com.fankes.miui.notify.params.IconPackParams
|
||||||
import com.fankes.miui.notify.ui.base.BaseActivity
|
import com.fankes.miui.notify.ui.base.BaseActivity
|
||||||
|
import com.fankes.miui.notify.utils.SystemUITool
|
||||||
import com.fankes.miui.notify.view.MaterialSwitch
|
import com.fankes.miui.notify.view.MaterialSwitch
|
||||||
|
|
||||||
class ConfigureActivity : BaseActivity() {
|
class ConfigureActivity : BaseActivity() {
|
||||||
@@ -92,11 +93,13 @@ class ConfigureActivity : BaseActivity() {
|
|||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
HookMedium.putAppNotifyHookOf(it, b)
|
HookMedium.putAppNotifyHookOf(it, b)
|
||||||
holder.switchAll.isEnabled = b
|
holder.switchAll.isEnabled = b
|
||||||
|
SystemUITool.showNeedRestartSnake(context = this@ConfigureActivity)
|
||||||
}
|
}
|
||||||
holder.switchAll.isChecked = HookMedium.isAppNotifyHookAllOf(it)
|
holder.switchAll.isChecked = HookMedium.isAppNotifyHookAllOf(it)
|
||||||
holder.switchAll.setOnCheckedChangeListener { btn, b ->
|
holder.switchAll.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
HookMedium.putAppNotifyHookAllOf(it, b)
|
HookMedium.putAppNotifyHookAllOf(it, b)
|
||||||
|
SystemUITool.showNeedRestartSnake(context = this@ConfigureActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cView!!
|
return cView!!
|
||||||
|
@@ -108,6 +108,8 @@ class MainActivity : BaseActivity() {
|
|||||||
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
|
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
|
||||||
val colorIconHookSwitch = findViewById<SwitchCompat>(R.id.color_icon_fix_switch)
|
val colorIconHookSwitch = findViewById<SwitchCompat>(R.id.color_icon_fix_switch)
|
||||||
val notifyIconHookSwitch = findViewById<SwitchCompat>(R.id.notify_icon_fix_switch)
|
val notifyIconHookSwitch = findViewById<SwitchCompat>(R.id.notify_icon_fix_switch)
|
||||||
|
/** 设置旧版本警告 */
|
||||||
|
findViewById<View>(R.id.config_notify_app_icon_warn).isVisible = miuiVersion == "12"
|
||||||
/** 获取 Sp 存储的信息 */
|
/** 获取 Sp 存储的信息 */
|
||||||
notifyIconConfigItem.isVisible = getBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, default = true)
|
notifyIconConfigItem.isVisible = getBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, default = true)
|
||||||
moduleEnableLogSwitch.isVisible = getBoolean(HookMedium.ENABLE_MODULE, default = true)
|
moduleEnableLogSwitch.isVisible = getBoolean(HookMedium.ENABLE_MODULE, default = true)
|
||||||
@@ -120,10 +122,12 @@ class MainActivity : BaseActivity() {
|
|||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
putBoolean(HookMedium.ENABLE_MODULE, b)
|
putBoolean(HookMedium.ENABLE_MODULE, b)
|
||||||
moduleEnableLogSwitch.isVisible = b
|
moduleEnableLogSwitch.isVisible = b
|
||||||
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b ->
|
moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
putBoolean(HookMedium.ENABLE_MODULE_LOG, b)
|
putBoolean(HookMedium.ENABLE_MODULE_LOG, b)
|
||||||
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
hideIconInLauncherSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
@@ -138,21 +142,15 @@ class MainActivity : BaseActivity() {
|
|||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
putBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, b)
|
putBoolean(HookMedium.ENABLE_COLOR_ICON_HOOK, b)
|
||||||
notifyIconConfigItem.isVisible = b
|
notifyIconConfigItem.isVisible = b
|
||||||
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
notifyIconHookSwitch.setOnCheckedChangeListener { btn, b ->
|
notifyIconHookSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
putBoolean(HookMedium.ENABLE_NOTIFY_ICON_HOOK, b)
|
putBoolean(HookMedium.ENABLE_NOTIFY_ICON_HOOK, b)
|
||||||
|
SystemUITool.showNeedRestartSnake(context = this)
|
||||||
}
|
}
|
||||||
/** 重启按钮点击事件 */
|
/** 重启按钮点击事件 */
|
||||||
findViewById<View>(R.id.title_restart_icon).setOnClickListener {
|
findViewById<View>(R.id.title_restart_icon).setOnClickListener { SystemUITool.restartSystemUI(context = this) }
|
||||||
showDialog {
|
|
||||||
title = "重启系统界面"
|
|
||||||
msg = "你确定要立即重启系统界面吗?\n\n" +
|
|
||||||
"部分 MIUI 系统使用了状态栏主题可能会发生主题失效的情况,这种情况请再重启一次即可。"
|
|
||||||
confirmButton { restartSystemUI() }
|
|
||||||
cancelButton()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** 通知图标优化名单按钮点击事件 */
|
/** 通知图标优化名单按钮点击事件 */
|
||||||
findViewById<View>(R.id.config_notify_app_button).setOnClickListener {
|
findViewById<View>(R.id.config_notify_app_button).setOnClickListener {
|
||||||
startActivity(Intent(this, ConfigureActivity::class.java))
|
startActivity(Intent(this, ConfigureActivity::class.java))
|
||||||
@@ -206,14 +204,6 @@ class MainActivity : BaseActivity() {
|
|||||||
*/
|
*/
|
||||||
private fun isHooked() = HookMedium.isHooked()
|
private fun isHooked() = HookMedium.isHooked()
|
||||||
|
|
||||||
/** 重启系统界面 */
|
|
||||||
private fun restartSystemUI() =
|
|
||||||
execShellSu(cmd = "pgrep systemui").also { pid ->
|
|
||||||
if (pid.isNotBlank())
|
|
||||||
execShellSu(cmd = "kill -9 $pid")
|
|
||||||
else Toast.makeText(this, "ROOT 权限获取失败", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取保存的值
|
* 获取保存的值
|
||||||
* @param key 名称
|
* @param key 名称
|
||||||
|
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2022. Fankes Studio(qzmmcn@163.com)
|
||||||
|
*
|
||||||
|
* This file is part of MIUINativeNotifyIcon.
|
||||||
|
*
|
||||||
|
* MIUINativeNotifyIcon is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* MIUINativeNotifyIcon is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/02/08.
|
||||||
|
*/
|
||||||
|
package com.fankes.miui.notify.utils
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.widget.Toast
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统界面工具
|
||||||
|
*/
|
||||||
|
object SystemUITool {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重启系统界面
|
||||||
|
* @param context 实例
|
||||||
|
*/
|
||||||
|
fun restartSystemUI(context: Context) =
|
||||||
|
context.showDialog {
|
||||||
|
title = "重启系统界面"
|
||||||
|
msg = "你确定要立即重启系统界面吗?\n\n" +
|
||||||
|
"部分 MIUI 系统使用了状态栏主题可能会发生主题失效的情况,这种情况请再重启一次即可。"
|
||||||
|
confirmButton {
|
||||||
|
execShellSu(cmd = "pgrep systemui").also { pid ->
|
||||||
|
if (pid.isNotBlank())
|
||||||
|
execShellSu(cmd = "kill -9 $pid")
|
||||||
|
else Toast.makeText(context, "ROOT 权限获取失败", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cancelButton()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示需要重启系统界面的 [Snackbar]
|
||||||
|
* @param context 实例
|
||||||
|
*/
|
||||||
|
fun showNeedRestartSnake(context: Context) =
|
||||||
|
Snackbar.make((context as Activity).findViewById(android.R.id.content), "设置需要重启系统界面才能生效", Snackbar.LENGTH_LONG)
|
||||||
|
.apply {
|
||||||
|
setActionTextColor(Color.WHITE)
|
||||||
|
setAction("立即重启") { restartSystemUI(context) }
|
||||||
|
}.show()
|
||||||
|
}
|
@@ -32,11 +32,13 @@
|
|||||||
<androidx.constraintlayout.utils.widget.ImageFilterView
|
<androidx.constraintlayout.utils.widget.ImageFilterView
|
||||||
android:id="@+id/title_restart_icon"
|
android:id="@+id/title_restart_icon"
|
||||||
style="?android:attr/selectableItemBackgroundBorderless"
|
style="?android:attr/selectableItemBackgroundBorderless"
|
||||||
android:layout_width="25dp"
|
android:layout_width="28dp"
|
||||||
android:layout_height="25dp"
|
android:layout_height="28dp"
|
||||||
android:layout_marginEnd="5dp"
|
android:layout_marginEnd="5dp"
|
||||||
|
android:alpha="0.85"
|
||||||
android:src="@mipmap/restart"
|
android:src="@mipmap/restart"
|
||||||
android:tint="@color/colorTextGray" />
|
android:tint="@color/colorTextGray"
|
||||||
|
android:tooltipText="重启系统界面" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -264,9 +266,23 @@
|
|||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:alpha="0.6"
|
android:alpha="0.6"
|
||||||
android:lineSpacingExtra="6dp"
|
android:lineSpacingExtra="6dp"
|
||||||
android:text="此选项默认开启,开启后将对优化名单内 APP 通知小图标进行色彩修复,使得它们的图标看起来更加美观。"
|
android:text="此选项默认开启,开启后将对优化名单内 APP 通知小图标进行色彩修复,特别是通过 MIPUSH 推送的通知,它们始终是彩色的,修复后使得它们的图标看起来更加符合原生规范。"
|
||||||
android:textColor="@color/colorTextDark"
|
android:textColor="@color/colorTextDark"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/config_notify_app_icon_warn"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:lineSpacingExtra="6dp"
|
||||||
|
android:text="⚠️ 由于你的系统版本过低,状态栏上 MIPUSH 的彩色图标由于不能识别反色将不会被优化为黑白小图标,仅在通知栏生效。"
|
||||||
|
android:textColor="#FF9800"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.8 KiB |
Reference in New Issue
Block a user