From da1f390d3923ea789288a11f02ac55500e81e29e Mon Sep 17 00:00:00 2001 From: Fankesyooni Date: Sat, 26 Mar 2022 12:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=80=9A=E7=9F=A5=E6=A0=8F?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E7=A3=81=E8=B4=B4=E6=89=93=E5=BC=80=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E8=A7=84=E5=88=99=E5=88=97=E8=A1=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 1 + app/src/main/AndroidManifest.xml | 13 ++++++- .../notify/service/QuickStartTileService.kt | 36 +++++++++++++++++++ .../notify/utils/factory/FunctionFactory.kt | 11 +++++- app/src/main/res/drawable/ic_notify_icon.xml | 6 ++-- app/src/main/res/values/strings.xml | 1 + 6 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/fankes/miui/notify/service/QuickStartTileService.kt diff --git a/.idea/misc.xml b/.idea/misc.xml index 2048392..e4bca2a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -14,6 +14,7 @@ + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 797182f..0ae4838 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -5,7 +5,6 @@ - + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/fankes/miui/notify/service/QuickStartTileService.kt b/app/src/main/java/com/fankes/miui/notify/service/QuickStartTileService.kt new file mode 100644 index 0000000..150de8c --- /dev/null +++ b/app/src/main/java/com/fankes/miui/notify/service/QuickStartTileService.kt @@ -0,0 +1,36 @@ +/* + * MIUINativeNotifyIcon - Fix the native notification bar icon function abandoned by the MIUI development team. + * Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com) + * https://github.com/fankes/MIUINativeNotifyIcon + * + * This software is non-free but opensource software: you can redistribute it + * and/or modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + *

+ * + * This software 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 + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * and eula along with this software. If not, see + * + * + * This file is Created by fankes on 2022/3/26. + */ +package com.fankes.miui.notify.service + +import android.service.quicksettings.TileService +import com.fankes.miui.notify.ui.activity.ConfigureActivity +import com.fankes.miui.notify.utils.factory.navigate + +class QuickStartTileService : TileService() { + + override fun onClick() { + super.onClick() + /** 启动通知图标优化列表窗口 */ + navigate() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fankes/miui/notify/utils/factory/FunctionFactory.kt b/app/src/main/java/com/fankes/miui/notify/utils/factory/FunctionFactory.kt index d993f13..edd783e 100644 --- a/app/src/main/java/com/fankes/miui/notify/utils/factory/FunctionFactory.kt +++ b/app/src/main/java/com/fankes/miui/notify/utils/factory/FunctionFactory.kt @@ -26,6 +26,7 @@ package com.fankes.miui.notify.utils.factory import android.app.Activity import android.app.Notification +import android.app.Service import android.content.ClipData import android.content.ClipboardManager import android.content.Context @@ -377,7 +378,15 @@ fun toast(msg: String) = Toast.makeText(appContext, msg, Toast.LENGTH_SHORT).sho * * [T] 为指定的 [Activity] */ -inline fun Context.navigate() = startActivity(Intent(this, T::class.java)) +inline fun Context.navigate() = runInSafe { startActivity(Intent(this, T::class.java)) } + +/** + * 跳转到指定页面 + * + * [T] 为指定的 [Activity] + */ +inline fun Service.navigate() = + runInSafe { startActivity(Intent(this, T::class.java).apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK }) } /** * 弹出 [Snackbar] diff --git a/app/src/main/res/drawable/ic_notify_icon.xml b/app/src/main/res/drawable/ic_notify_icon.xml index 30a3a2b..28818a5 100644 --- a/app/src/main/res/drawable/ic_notify_icon.xml +++ b/app/src/main/res/drawable/ic_notify_icon.xml @@ -3,7 +3,7 @@ android:height="150dp" android:viewportWidth="1024" android:viewportHeight="1024"> - + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ae9b782..6697c8f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ MIUI 原生通知图标 + 通知图标 \ No newline at end of file