mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-06 02:35:41 +08:00
增加移除免打扰通知功能
This commit is contained in:
@@ -31,6 +31,7 @@ object HookConst {
|
||||
const val ENABLE_NOTIFY_ICON_FIX = "_notify_icon_fix"
|
||||
const val REMOVE_DEV_NOTIFY = "_remove_dev_notify"
|
||||
const val REMOVE_CHANGECP_NOTIFY = "_remove_charge_complete_notify"
|
||||
const val REMOVE_DNDALERT_NOTIFY = "_remove_dndalert_notify"
|
||||
const val NOTIFY_ICON_DATAS = "_notify_icon_datas"
|
||||
|
||||
const val SOURCE_SYNC_WAY = "_source_sync_way"
|
||||
|
@@ -38,6 +38,7 @@ import com.fankes.coloros.notify.hook.HookConst.ENABLE_MODULE_LOG
|
||||
import com.fankes.coloros.notify.hook.HookConst.ENABLE_NOTIFY_ICON_FIX
|
||||
import com.fankes.coloros.notify.hook.HookConst.REMOVE_CHANGECP_NOTIFY
|
||||
import com.fankes.coloros.notify.hook.HookConst.REMOVE_DEV_NOTIFY
|
||||
import com.fankes.coloros.notify.hook.HookConst.REMOVE_DNDALERT_NOTIFY
|
||||
import com.fankes.coloros.notify.hook.HookConst.SYSTEMUI_PACKAGE_NAME
|
||||
import com.fankes.coloros.notify.hook.factory.isAppNotifyHookAllOf
|
||||
import com.fankes.coloros.notify.hook.factory.isAppNotifyHookOf
|
||||
@@ -59,6 +60,7 @@ import com.highcapable.yukihookapi.hook.type.android.IconClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.ImageViewClass
|
||||
import com.highcapable.yukihookapi.hook.type.java.BooleanType
|
||||
import com.highcapable.yukihookapi.hook.type.java.IntType
|
||||
import com.highcapable.yukihookapi.hook.type.java.LongType
|
||||
import com.highcapable.yukihookapi.hook.xposed.proxy.YukiHookXposedInitProxy
|
||||
|
||||
@InjectYukiHookWithXposed
|
||||
@@ -90,6 +92,9 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
/** ColorOS 存在的类 */
|
||||
private const val SystemPromptControllerClass = "com.oplusos.systemui.statusbar.policy.SystemPromptController"
|
||||
|
||||
/** ColorOS 存在的类 */
|
||||
private const val DndAlertHelperClass = "com.oplusos.systemui.notification.helper.DndAlertHelper"
|
||||
|
||||
/** 根据多个版本存在不同的包名相同的类 */
|
||||
private val OplusPowerNotificationWarningsClass = VariousClass(
|
||||
"com.oplusos.systemui.notification.power.OplusPowerNotificationWarnings",
|
||||
@@ -309,11 +314,20 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
}
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 移除免打扰通知 */
|
||||
DndAlertHelperClass.hook {
|
||||
injectMember {
|
||||
method {
|
||||
name = "sendNotificationWithEndtime"
|
||||
param(LongType)
|
||||
}
|
||||
beforeHook {
|
||||
/** 是否移除 */
|
||||
if (prefs.getBoolean(REMOVE_DNDALERT_NOTIFY, default = false)) resultNull()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ import com.fankes.coloros.notify.hook.HookConst.ENABLE_MODULE_LOG
|
||||
import com.fankes.coloros.notify.hook.HookConst.ENABLE_NOTIFY_ICON_FIX
|
||||
import com.fankes.coloros.notify.hook.HookConst.REMOVE_CHANGECP_NOTIFY
|
||||
import com.fankes.coloros.notify.hook.HookConst.REMOVE_DEV_NOTIFY
|
||||
import com.fankes.coloros.notify.hook.HookConst.REMOVE_DNDALERT_NOTIFY
|
||||
import com.fankes.coloros.notify.ui.base.BaseActivity
|
||||
import com.fankes.coloros.notify.utils.factory.*
|
||||
import com.fankes.coloros.notify.utils.tool.SystemUITool
|
||||
@@ -98,6 +99,7 @@ class MainActivity : BaseActivity() {
|
||||
val notifyIconConfigItem = findViewById<View>(R.id.config_item_notify)
|
||||
val devNotifyConfigSwitch = findViewById<SwitchCompat>(R.id.remove_dev_n_enable_switch)
|
||||
val crcpNotifyConfigSwitch = findViewById<SwitchCompat>(R.id.remove_chargecp_n_enable_switch)
|
||||
val dndNotifyConfigSwitch = findViewById<SwitchCompat>(R.id.remove_dndalert_n_enable_switch)
|
||||
val a12StyleConfigSwitch = findViewById<SwitchCompat>(R.id.a12_style_enable_switch)
|
||||
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
|
||||
val notifyIconFixSwitch = findViewById<SwitchCompat>(R.id.notify_icon_fix_switch)
|
||||
@@ -110,6 +112,7 @@ class MainActivity : BaseActivity() {
|
||||
notifyIconFixButton.isVisible = modulePrefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
||||
devNotifyConfigSwitch.isChecked = modulePrefs.getBoolean(REMOVE_DEV_NOTIFY, default = true)
|
||||
crcpNotifyConfigSwitch.isChecked = modulePrefs.getBoolean(REMOVE_CHANGECP_NOTIFY, default = false)
|
||||
dndNotifyConfigSwitch.isChecked = modulePrefs.getBoolean(REMOVE_DNDALERT_NOTIFY, default = false)
|
||||
a12StyleConfigSwitch.isChecked = modulePrefs.getBoolean(ENABLE_ANDROID12_STYLE, isUpperOfAndroidS)
|
||||
moduleEnableSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE, default = true)
|
||||
moduleEnableLogSwitch.isChecked = modulePrefs.getBoolean(ENABLE_MODULE_LOG, default = false)
|
||||
@@ -154,6 +157,11 @@ class MainActivity : BaseActivity() {
|
||||
modulePrefs.putBoolean(REMOVE_CHANGECP_NOTIFY, b)
|
||||
SystemUITool.showNeedRestartSnake(context = this)
|
||||
}
|
||||
dndNotifyConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||
modulePrefs.putBoolean(REMOVE_DNDALERT_NOTIFY, b)
|
||||
SystemUITool.showNeedRestartSnake(context = this)
|
||||
}
|
||||
a12StyleConfigSwitch.setOnCheckedChangeListener { btn, b ->
|
||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||
modulePrefs.putBoolean(ENABLE_ANDROID12_STYLE, b)
|
||||
|
@@ -233,7 +233,6 @@
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/color_icon_compat_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
@@ -242,6 +241,25 @@
|
||||
android:text="充电完成后总是会推送一条通知,有时候甚至还不是静音状态,开启后将直接移除这个“你在教我做事”的通知功能。"
|
||||
android:textColor="@color/colorTextDark"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<com.fankes.coloros.notify.view.MaterialSwitch
|
||||
android:id="@+id/remove_dndalert_n_enable_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:text="移除免打扰通知"
|
||||
android:textColor="@color/colorTextGray"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:alpha="0.6"
|
||||
android:lineSpacingExtra="6dp"
|
||||
android:text="开启免打扰后无论任何时长,总是会推送一条通知,开启后将直接移除这个“你在教我做事”的通知功能。"
|
||||
android:textColor="@color/colorTextDark"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
Reference in New Issue
Block a user