mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-05 18:25:23 +08:00
Added open MIUI notification style settings function in MainActivity, SystemUITool, activity_main
This commit is contained in:
@@ -159,6 +159,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
binding.mainTextVersion.text = "模块版本:$moduleVersion $pendingFlag"
|
binding.mainTextVersion.text = "模块版本:$moduleVersion $pendingFlag"
|
||||||
binding.mainTextMiuiVersion.text = "系统版本:[$androidVersionCodeName] $miuiFullVersion"
|
binding.mainTextMiuiVersion.text = "系统版本:[$androidVersionCodeName] $miuiFullVersion"
|
||||||
binding.warnSCountDisTip.isGone = miuiVersionCode > 12.5
|
binding.warnSCountDisTip.isGone = miuiVersionCode > 12.5
|
||||||
|
binding.warnMiuiNotifyStyleTip.isGone = miuiVersionCode > 12
|
||||||
binding.notifyIconCustomCornerSeekbar.progress = ConfigData.notifyIconCornerSize
|
binding.notifyIconCustomCornerSeekbar.progress = ConfigData.notifyIconCornerSize
|
||||||
binding.notifyIconCustomCornerText.text = "${ConfigData.notifyIconCornerSize} dp"
|
binding.notifyIconCustomCornerText.text = "${ConfigData.notifyIconCornerSize} dp"
|
||||||
binding.statusIconCountText.text = ConfigData.liftedStatusIconCount.toString()
|
binding.statusIconCountText.text = ConfigData.liftedStatusIconCount.toString()
|
||||||
@@ -259,6 +260,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
|
|
||||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
|
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
|
||||||
})
|
})
|
||||||
|
/** MIUI 通知显示设置按钮点击事件 */
|
||||||
|
binding.miuiNotifyStyleButton.setOnClickListener { SystemUITool.openMiuiNotificationDisplaySettings(context = this) }
|
||||||
/** 通知图标优化名单按钮点击事件 */
|
/** 通知图标优化名单按钮点击事件 */
|
||||||
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
binding.notifyIconFixButton.setOnClickListener { navigate<ConfigureActivity>() }
|
||||||
/** 修改状态栏通知图标个数按钮点击事件 */
|
/** 修改状态栏通知图标个数按钮点击事件 */
|
||||||
|
@@ -22,7 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.fankes.miui.notify.utils.tool
|
package com.fankes.miui.notify.utils.tool
|
||||||
|
|
||||||
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.fankes.miui.notify.const.PackageName
|
import com.fankes.miui.notify.const.PackageName
|
||||||
import com.fankes.miui.notify.ui.activity.MainActivity
|
import com.fankes.miui.notify.ui.activity.MainActivity
|
||||||
@@ -67,20 +69,48 @@ object SystemUITool {
|
|||||||
fun checkingActivated(context: Context, result: (Boolean) -> Unit) =
|
fun checkingActivated(context: Context, result: (Boolean) -> Unit) =
|
||||||
context.dataChannel(PackageName.SYSTEMUI).checkingVersionEquals(result = result)
|
context.dataChannel(PackageName.SYSTEMUI).checkingVersionEquals(result = result)
|
||||||
|
|
||||||
|
/** 当 Root 权限获取失败时显示对话框 */
|
||||||
|
private fun Context.showWhenAccessRootFail() =
|
||||||
|
showDialog {
|
||||||
|
title = "获取 Root 权限失败"
|
||||||
|
msg = "当前无法获取 Root 权限,请确认你的设备已经被 Root 且同意授予 Root 权限。\n" +
|
||||||
|
"如果你正在使用 Magisk 并安装了 Shamiko 模块," +
|
||||||
|
"请确认当前是否正处于白名单模式。 (白名单模式将导致无法申请 Root 权限)"
|
||||||
|
confirmButton(text = "我知道了")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开 MIUI 通知显示设置界面
|
||||||
|
* @param context 实例
|
||||||
|
*/
|
||||||
|
fun openMiuiNotificationDisplaySettings(context: Context) {
|
||||||
|
runCatching {
|
||||||
|
context.startActivity(Intent().apply {
|
||||||
|
component = ComponentName(
|
||||||
|
"com.miui.notification",
|
||||||
|
"miui.notification.management.activity.NotificationDisplaySettingsActivity"
|
||||||
|
)
|
||||||
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
})
|
||||||
|
}.onFailure {
|
||||||
|
execShell(
|
||||||
|
cmd = "am start -a" +
|
||||||
|
"com.miui.notification " +
|
||||||
|
"com.miui.notification/miui.notification.management.activity.NotificationDisplaySettingsActivity"
|
||||||
|
).also {
|
||||||
|
when {
|
||||||
|
it.isBlank() -> context.showWhenAccessRootFail()
|
||||||
|
else -> context.snake(msg = "已发送请求,如果未打开则是当前系统不支持此功能")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重启系统界面
|
* 重启系统界面
|
||||||
* @param context 实例
|
* @param context 实例
|
||||||
*/
|
*/
|
||||||
fun restartSystemUI(context: Context) {
|
fun restartSystemUI(context: Context) {
|
||||||
/** 当 Root 权限获取失败时显示对话框 */
|
|
||||||
fun showWhenAccessRootFail() =
|
|
||||||
context.showDialog {
|
|
||||||
title = "获取 Root 权限失败"
|
|
||||||
msg = "当前无法获取 Root 权限,请确认你的设备已经被 Root 且同意授予 Root 权限。\n" +
|
|
||||||
"如果你正在使用 Magisk 并安装了 Shamiko 模块," +
|
|
||||||
"请确认当前是否正处于白名单模式。 (白名单模式将导致无法申请 Root 权限)"
|
|
||||||
confirmButton(text = "我知道了")
|
|
||||||
}
|
|
||||||
context.showDialog {
|
context.showDialog {
|
||||||
title = "重启系统界面"
|
title = "重启系统界面"
|
||||||
msg = "你确定要立即重启系统界面吗?\n\n" +
|
msg = "你确定要立即重启系统界面吗?\n\n" +
|
||||||
@@ -91,7 +121,7 @@ object SystemUITool {
|
|||||||
execShell(cmd = "pgrep systemui").also { pid ->
|
execShell(cmd = "pgrep systemui").also { pid ->
|
||||||
if (pid.isNotBlank())
|
if (pid.isNotBlank())
|
||||||
execShell(cmd = "kill -9 $pid")
|
execShell(cmd = "kill -9 $pid")
|
||||||
else showWhenAccessRootFail()
|
else context.showWhenAccessRootFail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cancelButton()
|
cancelButton()
|
||||||
|
@@ -553,6 +553,47 @@
|
|||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/miui_notify_style_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="13dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginRight="13dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:background="@drawable/bg_button_round"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="打开 MIUI 通知显示设置"
|
||||||
|
android:textColor="@color/colorTextGray"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:lineSpacingExtra="6dp"
|
||||||
|
android:text="点击上方按钮可以直接打开 MIUI 的通知显示设置界面,可以调整当前通知栏显示的通知样式为 MIUI 经典样式或原生样式,如果无法打开则是当前系统不支持此功能。"
|
||||||
|
android:textColor="@color/colorTextDark"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/warn_miui_notify_style_tip"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:lineSpacingExtra="6dp"
|
||||||
|
android:text="⚠️ 在 MIUI 11、12 上可能需要 Root 权限才能打开。"
|
||||||
|
android:textColor="@color/colorTextDark"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/notify_icon_custom_corner_item"
|
android:id="@+id/notify_icon_custom_corner_item"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Reference in New Issue
Block a user