├── .gitignore ├── README.MD ├── app ├── .gitignore ├── build.gradle.kts ├── proguard-rules.pro ├── release │ ├── app-release.apk │ ├── baselineProfiles │ │ ├── 0 │ │ │ └── app-release.dm │ │ └── 1 │ │ │ └── app-release.dm │ └── output-metadata.json └── src │ ├── androidTest │ └── java │ │ └── kg │ │ └── edu │ │ └── yjut │ │ └── enhancenoticehyperos │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── yhxy.html │ │ └── ysxy.html │ ├── ic_launcher-playstore.png │ ├── java │ │ └── kg │ │ │ └── edu │ │ │ └── yjut │ │ │ └── enhancenoticehyperos │ │ │ ├── AboutActivity.kt │ │ │ ├── ChannelActivity.kt │ │ │ ├── HisActivity.kt │ │ │ ├── MainActivity.kt │ │ │ ├── MainHomeActivity.kt │ │ │ ├── MoreFunctionActivity.kt │ │ │ ├── PrivacyAgreementActivity.kt │ │ │ ├── SettingsActivity.kt │ │ │ ├── UserAgreementActivity.kt │ │ │ ├── base │ │ │ └── CodeDatabase.kt │ │ │ ├── bean │ │ │ ├── AppInfo.kt │ │ │ ├── ChannelInfo.kt │ │ │ ├── Code.kt │ │ │ ├── HttpBeam.java │ │ │ ├── InfoData.java │ │ │ └── LogBeam.kt │ │ │ ├── dao │ │ │ └── NoticeDao.kt │ │ │ ├── entity │ │ │ ├── NoticeHistory.kt │ │ │ └── Tickets.kt │ │ │ ├── miui │ │ │ ├── MiuiStringToast.kt │ │ │ ├── ToastConfig.kt │ │ │ ├── devicesSDK │ │ │ │ ├── PropUtils.kt │ │ │ │ └── SystemSDK.kt │ │ │ ├── res │ │ │ │ ├── IconParams.kt │ │ │ │ ├── Left.kt │ │ │ │ ├── Right.kt │ │ │ │ ├── StringToastBean.kt │ │ │ │ ├── StringToastBundle.kt │ │ │ │ └── TextParams.kt │ │ │ └── service │ │ │ │ ├── DynamicIslandService.kt │ │ │ │ ├── FloatLayout.kt │ │ │ │ ├── FloatWindowManager.kt │ │ │ │ └── HomeKeyObserverReceiver.kt │ │ │ ├── receive │ │ │ └── MessageReciever.kt │ │ │ ├── service │ │ │ ├── CodeConfig.kt │ │ │ ├── FocusLayout.kt │ │ │ ├── FocusService.kt │ │ │ ├── FocusWindowManager.kt │ │ │ ├── GuardNotificationListenerService.kt │ │ │ ├── HomeKeyObserverReceiver.kt │ │ │ └── MessageService.kt │ │ │ ├── ui │ │ │ └── theme │ │ │ │ ├── Color.kt │ │ │ │ ├── Theme.kt │ │ │ │ └── Type.kt │ │ │ ├── utils │ │ │ ├── Configs.kt │ │ │ ├── MyStoreTools.kt │ │ │ ├── PickupCodeUtils.kt │ │ │ ├── SupposedApplication.kt │ │ │ └── Utils.kt │ │ │ └── widget │ │ │ └── EasyDialog.kt │ └── res │ │ ├── drawable │ │ ├── about.xml │ │ ├── back.xml │ │ ├── background.xml │ │ ├── baseline_airplane_ticket_24.xml │ │ ├── baseline_apps_24.xml │ │ ├── baseline_content_copy_24.xml │ │ ├── baseline_format_list_bulleted_24.xml │ │ ├── baseline_history_24.xml │ │ ├── baseline_notifications_24.xml │ │ ├── baseline_pause_circle_outline_24.xml │ │ ├── baseline_play_circle_outline_24.xml │ │ ├── bili.xml │ │ ├── buss.xml │ │ ├── dd.xml │ │ ├── dy.xml │ │ ├── hyperos.xml │ │ ├── ic_kuaidi_foreground.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_launcher_foreground.xml │ │ ├── init.xml │ │ ├── island.xml │ │ ├── loading.xml │ │ ├── logo.xml │ │ ├── logo_color.xml │ │ ├── nt.xml │ │ ├── pa.xml │ │ ├── qq.xml │ │ ├── qqmusic.xml │ │ ├── rl.xml │ │ ├── sendtz.xml │ │ ├── tz.xml │ │ ├── ua.xml │ │ ├── vpn.xml │ │ ├── wechat.xml │ │ ├── weibo.xml │ │ ├── xfc.xml │ │ ├── xhs.xml │ │ ├── xuexi.xml │ │ ├── zhihu.xml │ │ └── zz.xml │ │ ├── layout │ │ ├── code_item.xml │ │ ├── lld.xml │ │ └── qujianma2.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_playstore.png │ │ ├── ic_launcher_round.webp │ │ └── yzm.png │ │ ├── values-night │ │ └── colors.xml │ │ ├── values │ │ ├── colors.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test │ └── java │ └── kg │ └── edu │ └── yjut │ └── enhancenoticehyperos │ └── ExampleUnitTest.kt ├── build.gradle.kts ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle.kts /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | keystore 17 | gradle 18 | .kotlin 19 | .idea 20 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # 灵动通知 (For HyperOS)重构版 refactored 2 | 1. 由于忘记备份先前的代码,此次更新实现软件重构,仅实现将通知转成“灵动”的形式(需要开启应用通知权限,建议将对应软件的通知弹窗关闭)(在Xiaomi HyperOS中为系统样式的灵动额头)的功能。 3 | 2. 取件码功能请移步轻笔记 4 | 5 | _作者:Syutung_ 6 | 7 | _版本:v1.0.0_ 8 | 9 | ## 致谢 10 | - 感谢 [HyperOS]('https://hyperos.mi.com/') 11 | - 感谢 [HyperCeiler]('https://github.com/ReChronoRain/HyperCeiler') 项目提供的 MiuiStringToast 调用部分的代码 12 | 13 | ## 功能 14 | ### 为了保证质量、暂未对所有的APP开启“灵动额头”显示,目前支持应用 15 | 1. 小米智能卡 16 | 2. 微信 17 | 3. 抖音 18 | 4. 电子邮箱 19 | 5. QQ 20 | 6. 微博/微博轻享版 21 | 7. 小红书 22 | 8. 学习强国 23 | 9. 知乎 24 | 10. 25 | ### 添加到任何用户的应用程序的支持, 但不完美。 26 | 有些应用程序的通知没有标题或内容,使用常用信息代替。如遇到此类应用,可在设置中关闭该应用/通知通道的通知转发。 27 | 另外,有的应用通知是常驻的,可能多次触发通知转发,可在设置中关闭该应用/通知通道的通知转发。 28 | 29 | 30 | 31 | ### 建议关闭原应用的悬浮通知 32 | ### HyperOS 似乎没有横屏的“灵动额头” 33 | ### 权限需要: 34 | 1. 后台权限、自启动、电量无限制 35 | 2. 通知读取权限、悬浮窗权限、通知权限 36 | 3. 读取应用列表权限 37 | 38 | ## Stargazers over time 39 | [![Stargazers over time](https://starchart.cc/trueWangSyutung/Dynamic-Notification-for-HyperOS.svg?variant=adaptive)](https://starchart.cc/trueWangSyutung/Dynamic-Notification-for-HyperOS) 40 | 41 | [![Sparkline](https://stars.medv.io/trueWangSyutung/Dynamic-Notification-for-HyperOS.svg)](https://stars.medv.io/trueWangSyutung/Dynamic-Notification-for-HyperOS) 42 | z -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | val vc = 40001 2 | val isBeta = true 3 | val vn4 = "1.0.1." 4 | val vn = vn4 + vc.toString() + if (isBeta) ".dev" else "" 5 | 6 | 7 | plugins { 8 | alias(libs.plugins.android.application) 9 | alias(libs.plugins.jetbrains.kotlin.android) 10 | kotlin("kapt") version "2.0.0" 11 | alias(libs.plugins.compose.compiler) 12 | } 13 | 14 | android { 15 | namespace = "kg.edu.yjut.enhancenoticehyperos" 16 | compileSdk = 34 17 | 18 | defaultConfig { 19 | applicationId = "kg.edu.yjut.enhancenoticehyperos" 20 | minSdk = 26 21 | targetSdk = 35 22 | versionCode = vc 23 | versionName = vn 24 | 25 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 26 | vectorDrawables { 27 | useSupportLibrary = true 28 | } 29 | } 30 | 31 | signingConfigs { 32 | create("dp") { 33 | storeFile = file("../keystore/keystore.jks") 34 | storePassword = "wxdqwe123" 35 | keyAlias = "key0" 36 | keyPassword = "wxdqwe123" 37 | } 38 | create("dp2") { 39 | storeFile = file("../keystore/keystore.jks") 40 | storePassword = "wxdqwe123" 41 | keyAlias = "key0" 42 | keyPassword = "wxdqwe123" 43 | } 44 | 45 | } 46 | 47 | buildTypes { 48 | release { 49 | isMinifyEnabled = false 50 | proguardFiles( 51 | getDefaultProguardFile("proguard-android-optimize.txt"), 52 | "proguard-rules.pro" 53 | ) 54 | signingConfig = signingConfigs.getByName("dp2") 55 | } 56 | debug{ 57 | isMinifyEnabled = false 58 | proguardFiles( 59 | getDefaultProguardFile("proguard-android-optimize.txt"), 60 | "proguard-rules.pro" 61 | ) 62 | signingConfig = signingConfigs.getByName("dp2") 63 | } 64 | release { 65 | isMinifyEnabled = false 66 | signingConfig = signingConfigs.getByName("dp2") 67 | 68 | proguardFiles( 69 | getDefaultProguardFile("proguard-android-optimize.txt"), 70 | "proguard-rules.pro" 71 | ) 72 | } 73 | 74 | } 75 | compileOptions { 76 | sourceCompatibility = JavaVersion.VERSION_1_8 77 | targetCompatibility = JavaVersion.VERSION_1_8 78 | } 79 | kotlinOptions { 80 | jvmTarget = "1.8" 81 | } 82 | buildFeatures { 83 | compose = true 84 | } 85 | composeOptions { 86 | kotlinCompilerExtensionVersion = "1.5.1" 87 | } 88 | packaging { 89 | resources { 90 | excludes += "/META-INF/{AL2.0,LGPL2.1}" 91 | } 92 | } 93 | } 94 | 95 | dependencies { 96 | 97 | implementation(libs.androidx.core.ktx) 98 | implementation(libs.androidx.lifecycle.runtime.ktx) 99 | implementation(libs.androidx.activity.compose) 100 | implementation(platform(libs.androidx.compose.bom)) 101 | implementation(libs.androidx.ui) 102 | implementation(libs.androidx.ui.graphics) 103 | implementation(libs.androidx.ui.tooling.preview) 104 | implementation(libs.androidx.material3) 105 | implementation(libs.constraintlayout) 106 | testImplementation(libs.junit) 107 | androidTestImplementation(libs.androidx.junit) 108 | androidTestImplementation(libs.androidx.espresso.core) 109 | androidTestImplementation(platform(libs.androidx.compose.bom)) 110 | androidTestImplementation(libs.androidx.ui.test.junit4) 111 | debugImplementation(libs.androidx.ui.tooling) 112 | debugImplementation(libs.androidx.ui.test.manifest) 113 | 114 | 115 | val room_version = "2.6.1" 116 | 117 | implementation(libs.com.github.promeg.tinypinyin19) // TinyPinyin核心包, 118 | 119 | 120 | 121 | implementation("androidx.room:room-runtime:$room_version") 122 | annotationProcessor("androidx.room:room-compiler:$room_version") 123 | 124 | // To use Kotlin annotation processing tool (kapt) 125 | // To use Kotlin Symbol Processing (KSP) 126 | kapt("androidx.room:room-compiler:$room_version") 127 | implementation("com.belerweb:pinyin4j:2.5.0") 128 | //ksp("androidx.room:room-compiler:$room_version") 129 | // optional - Kotlin Extensions and Coroutines support for Room 130 | implementation("androidx.room:room-ktx:$room_version") 131 | // optional - RxJava2 support for Room 132 | implementation("androidx.room:room-rxjava2:$room_version") 133 | // optional - RxJava3 support for Room 134 | implementation("androidx.room:room-rxjava3:$room_version") 135 | // optional - Guavasupport for Room, including Optional and ListenableFuture 136 | implementation("androidx.room:room-guava:$room_version") 137 | // optional - Test helpers 138 | testImplementation("androidx.room:room-testing:$room_version") 139 | // optional - Paging 3 Integration 140 | implementation("androidx.room:room-paging:$room_version") 141 | implementation("com.google.accompanist:accompanist-drawablepainter:0.19.0") 142 | implementation("com.google.code.gson:gson:2.10.1") 143 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/release/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/release/app-release.apk -------------------------------------------------------------------------------- /app/release/baselineProfiles/0/app-release.dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/release/baselineProfiles/0/app-release.dm -------------------------------------------------------------------------------- /app/release/baselineProfiles/1/app-release.dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/release/baselineProfiles/1/app-release.dm -------------------------------------------------------------------------------- /app/release/output-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "artifactType": { 4 | "type": "APK", 5 | "kind": "Directory" 6 | }, 7 | "applicationId": "kg.edu.yjut.enhancenoticehyperos", 8 | "variantName": "release", 9 | "elements": [ 10 | { 11 | "type": "SINGLE", 12 | "filters": [], 13 | "attributes": [], 14 | "versionCode": 40001, 15 | "versionName": "1.0.1.40001.dev", 16 | "outputFile": "app-release.apk" 17 | } 18 | ], 19 | "elementType": "File", 20 | "baselineProfiles": [ 21 | { 22 | "minApi": 28, 23 | "maxApi": 30, 24 | "baselineProfiles": [ 25 | "baselineProfiles/1/app-release.dm" 26 | ] 27 | }, 28 | { 29 | "minApi": 31, 30 | "maxApi": 2147483647, 31 | "baselineProfiles": [ 32 | "baselineProfiles/0/app-release.dm" 33 | ] 34 | } 35 | ], 36 | "minSdkVersionForDexing": 26 37 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/kg/edu/yjut/enhancenoticehyperos/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("kg.edu.yjut.enhancenoticehyperos", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 32 | 33 | 34 | 39 | 44 | 49 | 54 | 55 | 60 | 61 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 77 | 82 | 87 | 92 | 96 | 97 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 119 | 122 | 123 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /app/src/main/assets/yhxy.html: -------------------------------------------------------------------------------- 1 |

用户协议

2 |

汝阳县斯普锐思软件技术工作室(以下简称“我们”)依据本协议为用户(以下简称“你”)提供灵动通知服务。本协议对你和我们均具有法律约束力。

3 |

一、本服务的功能

4 |

你可以使用本服务基于您的收到的快递取件码通知,为您记录并以小组件的形式提醒您。

5 |

二、责任范围及限制

6 |

你使用本服务得到的结果仅供参考,实际情况以官方为准。

7 |

三、隐私保护

8 |

我们重视对你隐私的保护,你的个人隐私信息将根据《隐私政策》受到保护与规范,详情请参阅《隐私政策》。

9 |

四、其他条款

10 |

4.1 本协议所有条款的标题仅为阅读方便,本身并无实际涵义,不能作为本协议涵义解释的依据。

11 |

4.2 本协议条款无论因何种原因部分无效或不可执行,其余条款仍有效,对双方具有约束力。

12 | -------------------------------------------------------------------------------- /app/src/main/assets/ysxy.html: -------------------------------------------------------------------------------- 1 |

隐私政策

2 |
更新日期:2024/2/7
3 |
生效日期:2024/2/7
4 |

导言

5 |

6 | 灵动通知 是一款由 汝阳县斯普锐思软件技术工作室 (以下简称“我们”)提供的产品。 7 | 您在使用我们的服务时,我们可能会收集和使用您的相关信息。我们希望通过本《隐私政策》向您说明,在使用我们的服务时,我们如何收集、使用、储存和分享这些信息,以及我们为您提供的访问、更新、控制和保护这些信息的方式。 8 | 本《隐私政策》与您所使用的 灵动通知 服务息息相关,希望您仔细阅读,在需要时,按照本《隐私政策》的指引,作出您认为适当的选择。本《隐私政策》中涉及的相关技术词汇,我们尽量以简明扼要的表述,并提供进一步说明的链接,以便您的理解。 9 |

10 |

您使用或继续使用我们的服务,即意味着同意我们按照本《隐私政策》收集、使用、储存和分享您的相关信息。

11 |

如对本《隐私政策》或相关事宜有任何问题,请通过 wangxudong@yjut.edu.kg 与我们联系。

12 | 13 |

1. 我们收集的信息

14 |

我们提供服务时,可能会收集、储存和使用下列与您有关的信息。如果您不提供相关信息,可能无法享受我们提供的某些服务,或者无法达到相关服务拟达到的效果。

15 | 16 | 21 | 22 | 23 |

我们接入的第三方SDK:

24 | 27 | 28 | 29 | 30 | 31 |

2. 信息的存储

32 | 2.1 信息存储的方式和期限 33 | 37 | 38 | 2.2 信息存储的地域 39 | 43 | 44 | 2.3 产品或服务停止运营时的通知 45 | 48 | 49 |

3. 信息安全

50 |

51 | 我们使用各种安全技术和程序,以防信息的丢失、不当使用、未经授权阅览或披露。例如,在某些服务中,我们将利用加密技术(例如SSL)来保护您提供的个人信息。但请您理解,由于技术的限制以及可能存在的各种恶意手段,在互联网行业,即便竭尽所能加强安全措施,也不可能始终保证信息百分之百的安全。您需要了解,您接入我们的服务所用的系统和通讯网络,有可能因我们可控范围外的因素而出现问题。 52 |

53 | 54 |

4. 我们如何使用信息

55 |

我们可能将在向您提供服务的过程之中所收集的信息用作下列用途:

56 | 59 | 60 |

6. 您的权利

61 |

62 | 在您使用我们的服务期间,我们可能会视产品具体情况为您提供相应的操作设置,以便您可以查询、删除、更正或撤回您的相关个人信息,您可参考相应的具体指引进行操作。此外,我们还设置了投诉举报渠道,您的意见将会得到及时的处理。如果您无法通过上述途径和方式行使您的个人信息主体权利,您可以通过本《隐私政策》中提供的联系方式提出您的请求,我们会按照法律法规的规定予以反馈。 63 |

64 | 65 |

7. 变更

66 |

67 | 我们可能适时修订本《隐私政策》的条款。当变更发生时,我们会在版本更新时向您提示新的《隐私政策》,并向您说明生效日期。请您仔细阅读变更后的《隐私政策》内容,若您继续使用我们的服务,即表示您同意我们按照更新后的《隐私政策》处理您的个人信息。 68 |

69 | 70 |

8. 未成年人保护

71 |

72 | 我们鼓励父母或监护人指导未满十八岁的未成年人使用我们的服务。我们建议未成年人鼓励他们的父母或监护人阅读本《隐私政策》,并建议未成年人在提交的个人信息之前寻求父母或监护人的同意和指导。 73 |

74 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/ChannelActivity.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.graphics.drawable.Drawable 7 | import android.os.Bundle 8 | import androidx.activity.ComponentActivity 9 | import androidx.activity.compose.setContent 10 | import androidx.compose.foundation.Image 11 | import androidx.compose.foundation.layout.Arrangement 12 | import androidx.compose.foundation.layout.Column 13 | import androidx.compose.foundation.layout.Row 14 | import androidx.compose.foundation.layout.Spacer 15 | import androidx.compose.foundation.layout.fillMaxSize 16 | import androidx.compose.foundation.layout.fillMaxWidth 17 | import androidx.compose.foundation.layout.padding 18 | import androidx.compose.foundation.lazy.LazyColumn 19 | import androidx.compose.foundation.rememberScrollState 20 | import androidx.compose.foundation.verticalScroll 21 | import androidx.compose.material3.Button 22 | import androidx.compose.material3.MaterialTheme 23 | import androidx.compose.material3.Scaffold 24 | import androidx.compose.material3.Surface 25 | import androidx.compose.material3.Switch 26 | import androidx.compose.material3.Text 27 | import androidx.compose.runtime.Composable 28 | import androidx.compose.runtime.mutableStateOf 29 | import androidx.compose.runtime.remember 30 | import androidx.compose.ui.Alignment 31 | import androidx.compose.ui.Modifier 32 | import androidx.compose.ui.tooling.preview.Preview 33 | import androidx.compose.ui.unit.dp 34 | import androidx.core.app.NotificationManagerCompat 35 | import androidx.core.view.WindowCompat 36 | import com.google.accompanist.drawablepainter.rememberDrawablePainter 37 | import com.google.gson.Gson 38 | import kg.edu.yjut.enhancenoticehyperos.bean.ChannelInfo 39 | import kg.edu.yjut.enhancenoticehyperos.utils.MyStoreTools 40 | 41 | class ChannelActivity : ComponentActivity() { 42 | var appName = mutableStateOf("") 43 | lateinit var appIcon : Drawable 44 | var packageName = mutableStateOf("") 45 | 46 | 47 | @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") 48 | override fun onCreate(savedInstanceState: Bundle?) { 49 | super.onCreate(savedInstanceState) 50 | var channelStr = intent.getStringExtra("channel") 51 | // 转为 数组 对象 52 | 53 | packageName.value = intent.getStringExtra("packageName")!! 54 | 55 | 56 | val applicaton = packageManager.getApplicationInfo(packageName.value, 0)!! 57 | 58 | // 获取 app 的 信息 59 | appName.value = packageManager.getApplicationLabel(applicaton).toString() 60 | appIcon = packageManager.getApplicationIcon(applicaton) 61 | 62 | var sp = getSharedPreferences("application_config", Context.MODE_PRIVATE) 63 | var channel = MyStoreTools.getChannalList(this, packageName.value) 64 | 65 | var that = this 66 | WindowCompat.setDecorFitsSystemWindows(window, false) 67 | 68 | setContent { 69 | MaterialTheme { 70 | // A surface container using the 'background' color from the theme 71 | 72 | Surface( 73 | modifier = Modifier.fillMaxSize(), 74 | color = MaterialTheme.colorScheme.background 75 | ) { 76 | Scaffold { padding -> 77 | Column( 78 | modifier = Modifier.padding(padding) 79 | .fillMaxWidth() 80 | .verticalScroll( 81 | rememberScrollState() 82 | ) 83 | .padding(10.dp) 84 | ) { 85 | Spacer(modifier = Modifier 86 | .fillMaxWidth()) 87 | Column( 88 | modifier = Modifier 89 | .padding(10.dp) 90 | .fillMaxWidth() 91 | 92 | .padding(10.dp), 93 | verticalArrangement = Arrangement.spacedBy(10.dp), 94 | horizontalAlignment = Alignment.Start 95 | ) { 96 | Image( 97 | painter = rememberDrawablePainter(drawable = appIcon), 98 | contentDescription = "appIcon" 99 | ) 100 | Text( 101 | text = "${appName.value}", 102 | fontSize = MaterialTheme.typography.headlineMedium.fontSize, 103 | fontWeight = MaterialTheme.typography.headlineMedium.fontWeight 104 | ) 105 | Text(text = "${packageName.value}") 106 | 107 | } 108 | 109 | Column( 110 | modifier = Modifier 111 | .fillMaxWidth() 112 | 113 | ) { 114 | for (index in 0 until channel.size){ 115 | val item = channel[index] 116 | var checked = remember { 117 | mutableStateOf( 118 | sp.getBoolean( 119 | "${packageName.value}_${item.channelName}", 120 | true 121 | ) 122 | ) 123 | } 124 | Row( 125 | modifier = Modifier 126 | .fillMaxWidth() 127 | .padding(10.dp), 128 | horizontalArrangement = Arrangement.SpaceBetween, 129 | verticalAlignment = Alignment.CenterVertically 130 | ) { 131 | Text(text = item.channelStr) 132 | 133 | Switch(checked = checked.value, onCheckedChange = { 134 | checked.value = it 135 | sp.edit().putBoolean( 136 | "${packageName.value}_${item.channelName}", 137 | it 138 | ).apply() 139 | 140 | }) 141 | 142 | } 143 | } 144 | 145 | 146 | } 147 | } 148 | } 149 | } 150 | } 151 | } 152 | } 153 | } 154 | 155 | -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/PrivacyAgreementActivity.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos 2 | 3 | import android.annotation.SuppressLint 4 | import android.os.Build 5 | import android.os.Bundle 6 | import androidx.activity.ComponentActivity 7 | import androidx.activity.compose.setContent 8 | import androidx.annotation.RequiresApi 9 | import androidx.compose.foundation.layout.Column 10 | import androidx.compose.foundation.layout.fillMaxSize 11 | import androidx.compose.foundation.layout.fillMaxWidth 12 | import androidx.compose.foundation.rememberScrollState 13 | import androidx.compose.foundation.verticalScroll 14 | import androidx.compose.material3.MaterialTheme 15 | import androidx.compose.material3.Scaffold 16 | import androidx.compose.material3.Surface 17 | import androidx.compose.ui.Modifier 18 | 19 | 20 | class PrivacyAgreementActivity : ComponentActivity() { 21 | @RequiresApi(Build.VERSION_CODES.GINGERBREAD) 22 | @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") 23 | override fun onCreate(savedInstanceState: Bundle?) { 24 | super.onCreate(savedInstanceState) 25 | val dm = resources.displayMetrics 26 | val width = dm.widthPixels 27 | val height = dm.heightPixels 28 | // 获取传递过来的数据 29 | val intent = intent 30 | val type = intent.getStringExtra("type") 31 | var isShow = false 32 | // 如果不是 look 则不显示下方按钮 33 | if (type == "look") { 34 | isShow = true 35 | } 36 | 37 | setContent { 38 | MaterialTheme { 39 | // A surface container using the 'background' color from the theme 40 | Surface( 41 | modifier = Modifier.fillMaxSize(), 42 | color = MaterialTheme.colorScheme.background 43 | ) { 44 | Scaffold( 45 | 46 | ) { 47 | Column( 48 | modifier = Modifier 49 | .fillMaxWidth() 50 | .verticalScroll( 51 | rememberScrollState() 52 | ) 53 | ) { 54 | Web("file:///android_asset/ysxy.html") 55 | 56 | 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/UserAgreementActivity.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Intent 5 | import android.os.Bundle 6 | import androidx.activity.ComponentActivity 7 | import androidx.activity.compose.setContent 8 | import androidx.compose.animation.AnimatedVisibility 9 | import androidx.compose.foundation.background 10 | import androidx.compose.foundation.layout.Arrangement 11 | import androidx.compose.foundation.layout.Column 12 | import androidx.compose.foundation.layout.Row 13 | import androidx.compose.foundation.layout.fillMaxSize 14 | import androidx.compose.foundation.layout.fillMaxWidth 15 | import androidx.compose.foundation.layout.height 16 | import androidx.compose.foundation.layout.padding 17 | import androidx.compose.foundation.layout.width 18 | import androidx.compose.foundation.rememberScrollState 19 | import androidx.compose.foundation.verticalScroll 20 | import androidx.compose.material3.Button 21 | import androidx.compose.material3.MaterialTheme 22 | import androidx.compose.material3.Scaffold 23 | import androidx.compose.material3.Surface 24 | import androidx.compose.material3.Text 25 | import androidx.compose.runtime.Composable 26 | import androidx.compose.ui.Alignment 27 | import androidx.compose.ui.Modifier 28 | import androidx.compose.ui.tooling.preview.Preview 29 | import androidx.compose.ui.unit.dp 30 | import androidx.compose.ui.unit.sp 31 | import androidx.compose.ui.viewinterop.AndroidView 32 | 33 | class UserAgreementActivity : ComponentActivity() { 34 | @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") 35 | override fun onCreate(savedInstanceState: Bundle?) { 36 | super.onCreate(savedInstanceState) 37 | // 获取 手机宽度 38 | val dm = resources.displayMetrics 39 | val width = dm.widthPixels 40 | val height = dm.heightPixels 41 | val intent = intent 42 | val type = intent.getStringExtra("type") 43 | var isShow = false 44 | // 如果不是 look 则不显示下方按钮 45 | if (type == "look") { 46 | isShow = true 47 | } 48 | 49 | setContent { 50 | MaterialTheme { 51 | // A surface container using the 'background' color from the theme 52 | Surface( 53 | modifier = Modifier.fillMaxSize(), 54 | color = MaterialTheme.colorScheme.background 55 | ) { 56 | Scaffold( 57 | 58 | ) { 59 | Column( 60 | modifier = Modifier 61 | .fillMaxWidth() 62 | .verticalScroll( 63 | rememberScrollState() 64 | ) 65 | ) { 66 | Web("file:///android_asset/yhxy.html") 67 | 68 | } 69 | } 70 | } 71 | } 72 | } 73 | } 74 | } 75 | 76 | 77 | @Composable 78 | fun Web( 79 | url : String = "file:///android_asset/yhxy.html" 80 | ) { 81 | AndroidView( 82 | modifier = Modifier.fillMaxSize(), 83 | factory = { context -> 84 | val webView = android.webkit.WebView(context) 85 | webView.settings.javaScriptEnabled = true 86 | webView.settings.javaScriptCanOpenWindowsAutomatically = true 87 | webView.settings.domStorageEnabled = true 88 | webView.settings.loadsImagesAutomatically = true 89 | webView.settings.mediaPlaybackRequiresUserGesture = false 90 | webView.webViewClient = android.webkit.WebViewClient() 91 | webView.loadUrl(url) 92 | webView 93 | }) 94 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/base/CodeDatabase.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.base 2 | 3 | import android.content.Context 4 | import androidx.room.Database 5 | import androidx.room.Room 6 | import androidx.room.RoomDatabase 7 | import androidx.sqlite.db.SupportSQLiteOpenHelper 8 | import kg.edu.yjut.enhancenoticehyperos.dao.NoticeDao 9 | import kg.edu.yjut.enhancenoticehyperos.entity.NoticeHistory 10 | 11 | 12 | @Database(entities = [ 13 | NoticeHistory::class, 14 | 15 | 16 | 17 | 18 | ], version = 1, exportSchema = false) 19 | abstract class CodeDatabase : RoomDatabase() { 20 | 21 | abstract fun noticeDao(): NoticeDao 22 | 23 | 24 | companion object { 25 | @Volatile 26 | private var INSTANCE: CodeDatabase? = null 27 | fun getDatabase(context: Context): CodeDatabase { 28 | 29 | return INSTANCE ?: synchronized(this) { 30 | val instance = Room.databaseBuilder( 31 | context.applicationContext, 32 | CodeDatabase::class.java, 33 | "new_database" 34 | ).allowMainThreadQueries() 35 | .build() 36 | INSTANCE = instance 37 | return instance 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/bean/AppInfo.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.bean 2 | 3 | import android.graphics.drawable.AdaptiveIconDrawable 4 | import android.graphics.drawable.Drawable 5 | 6 | data class AppInfo( 7 | var appName: String, 8 | var packageName: String, 9 | var icon : Drawable 10 | ) 11 | data class ActionInfo( 12 | var packageName: String, 13 | var actionRouter: String, 14 | var actionName: String, 15 | var channels : List 16 | ) 17 | 18 | data class ShowActionInfo( 19 | var appName: String, 20 | var icon : Drawable, 21 | var packageName: String, 22 | var actionName: String, 23 | var actionRouter: String, 24 | var channels : List 25 | 26 | 27 | ) 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/bean/ChannelInfo.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.bean 2 | 3 | data class ChannelInfo( 4 | var channelName: String, 5 | var channelStr: String, 6 | ) 7 | // mipush 8 | 9 | data class LogsInfo( 10 | var insertTime: String, 11 | var logs: ArrayList, 12 | var packageName: String, 13 | ) 14 | 15 | data class Log( 16 | var id: Int, 17 | var title : String, 18 | var content: String, 19 | 20 | var channelName: String, 21 | 22 | ) -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/bean/Code.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.bean 2 | 3 | data class Code( 4 | var id:Int, 5 | var code:String, 6 | 7 | var yz:String, 8 | var kd:String, 9 | var insertTime:String, 10 | var status :Int 11 | ) -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/bean/HttpBeam.java: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.bean; 2 | 3 | public class HttpBeam { 4 | private int code; 5 | private String msg; 6 | private InfoData data; 7 | public void setCode(int code) { 8 | this.code = code; 9 | } 10 | public int getCode() { 11 | return code; 12 | } 13 | 14 | public void setMsg(String msg) { 15 | this.msg = msg; 16 | } 17 | public String getMsg() { 18 | return msg; 19 | } 20 | 21 | public void setData(InfoData data) { 22 | this.data = data; 23 | } 24 | public InfoData getData() { 25 | return data; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/bean/InfoData.java: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.bean; 2 | 3 | public class InfoData { 4 | private int version_code; 5 | private String version_info; 6 | private String apk_url; 7 | private String apk_size; 8 | private String apk_md5; 9 | private String apk_type; 10 | public void setVersion_code(int version_code) { 11 | this.version_code = version_code; 12 | } 13 | public int getVersion_code() { 14 | return version_code; 15 | } 16 | 17 | public void setVersion_info(String version_info) { 18 | this.version_info = version_info; 19 | } 20 | public String getVersion_info() { 21 | return version_info; 22 | } 23 | 24 | public void setApk_url(String apk_url) { 25 | this.apk_url = apk_url; 26 | } 27 | public String getApk_url() { 28 | return apk_url; 29 | } 30 | 31 | public void setApk_size(String apk_size) { 32 | this.apk_size = apk_size; 33 | } 34 | public String getApk_size() { 35 | return apk_size; 36 | } 37 | 38 | public void setApk_md5(String apk_md5) { 39 | this.apk_md5 = apk_md5; 40 | } 41 | public String getApk_md5() { 42 | return apk_md5; 43 | } 44 | 45 | public void setApk_type(String apk_type) { 46 | this.apk_type = apk_type; 47 | } 48 | public String getApk_type() { 49 | return apk_type; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/bean/LogBeam.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.bean 2 | 3 | // String sql2 = "create table logs(" + 4 | // "id integer primary key autoincrement," + 5 | // "title varchar(64)," + 6 | // "content varchar(256)," + 7 | // "package_name varchar(256)," + 8 | // "channel_name varchar(256)," + 9 | // "insert_time datetime default (datetime('now', 'localtime'))" + 10 | // ")"; 11 | data class LogBeam( 12 | var id: Int = 0, 13 | var title: String, 14 | var content: String= "", 15 | var packageName: String = "", 16 | var channelName: String = "", 17 | var insertTime: String = "", 18 | ) -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/dao/NoticeDao.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit. 3 | * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. 4 | * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. 5 | * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. 6 | * Vestibulum commodo. Ut rhoncus gravida arcu. 7 | */ 8 | 9 | package kg.edu.yjut.enhancenoticehyperos.dao 10 | 11 | import androidx.room.Dao 12 | import androidx.room.Delete 13 | import androidx.room.Insert 14 | import androidx.room.Query 15 | import androidx.room.Update 16 | import kg.edu.yjut.enhancenoticehyperos.entity.NoticeHistory 17 | 18 | @Dao 19 | interface NoticeDao { 20 | @Insert 21 | fun insertNotice(notice: NoticeHistory) 22 | @Insert 23 | fun insertNoticeList(notice: List) 24 | @Update 25 | fun updateNotice(notice: NoticeHistory) 26 | @Update 27 | fun updateNoticeList(notice: List) 28 | @Delete 29 | fun deleteNotice(notice: NoticeHistory) 30 | @Delete 31 | fun deleteNoticeList(notice: List) 32 | @Query("SELECT * FROM notice ORDER BY sendTime DESC LIMIT :limit OFFSET :offset ") 33 | fun getNoticeList(limit: Int, offset: Int): List 34 | @Query("SELECT * FROM notice WHERE id = :id") 35 | fun getNotice(id: String): NoticeHistory? 36 | 37 | // 删除七天以外的记录 38 | @Query("DELETE FROM notice WHERE sendTime < :time") 39 | fun deleteNoticeBeforeTime(time: Long) 40 | 41 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/entity/NoticeHistory.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.entity 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | 6 | 7 | @Entity(tableName = "notice") 8 | data class NoticeHistory( 9 | @PrimaryKey(autoGenerate = true) 10 | var id: Long = 0, 11 | var packageName: String = "", 12 | var title: String = "", 13 | var content: String = "", 14 | var chennel: String = "", 15 | var sendTime: Long = 0L, 16 | ) -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/entity/Tickets.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.entity 2 | 3 | import androidx.room.Entity 4 | import androidx.room.PrimaryKey 5 | 6 | class Tickets { 7 | } 8 | @Entity(tableName = "ticket") 9 | data class TrainTicket( 10 | @PrimaryKey(autoGenerate = true) 11 | var id: Int = 0, 12 | val departure: String, // 出发地 13 | val departureTime: Long, // 出发时间戳 14 | val arrival: String, // 到达地 15 | val arrivalTime: Long, // 到达时间戳 16 | val trainNumber: String, // 车次号,航班号 17 | val trainType: String? = null, // 车型号 18 | val passenger: String, // 乘车人 19 | val travelDate: Long, // 乘车日期 20 | val ticketColor: TicketColor, // 车票颜色类型 21 | val note: String? = null, // 备注 22 | val insertTime: Long = System.currentTimeMillis() // 添加时间 23 | ) 24 | 25 | enum class TicketColor { 26 | RED, // 红票 27 | BLUE // 蓝票 28 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/ToastConfig.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui 2 | 3 | import android.app.PendingIntent 4 | import android.widget.Toast 5 | 6 | data class ToastConfig( 7 | var text: String, 8 | var textColor: String, 9 | var image : String , 10 | var duration : Long = 3000L, 11 | var intent : PendingIntent? = null 12 | ) -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/devicesSDK/PropUtils.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.devicesSDK 2 | 3 | /* 4 | * This file is part of HyperCeiler. 5 | 6 | * HyperCeiler is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License. 10 | 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | 19 | * Copyright (C) 2023-2024 HyperCeiler Contributions 20 | */ 21 | import android.annotation.SuppressLint 22 | import android.util.Log 23 | 24 | 25 | @SuppressLint("PrivateApi") 26 | object PropUtils { 27 | private val TAG: String =" ITAG.TAG" 28 | 29 | 30 | fun getProp(name: String?): String { 31 | return try { 32 | invokeMethod( 33 | Class.forName("android.os.SystemProperties"), 34 | "get", arrayOf(String::class.java), name!! 35 | ) 36 | } catch (e: Throwable) { 37 | Log.e(TAG, "PropUtils getProp String no def", e) 38 | "" 39 | } 40 | } 41 | 42 | 43 | 44 | 45 | /** 46 | * @noinspection unchecked 47 | */ 48 | @Throws(Throwable::class) 49 | private fun invokeMethod( 50 | cls: Class<*>, 51 | str: String, 52 | clsArr: Array?>, 53 | vararg objArr: Any 54 | ): T { 55 | val declaredMethod = cls.getDeclaredMethod(str, *clsArr) 56 | declaredMethod.isAccessible = true 57 | return declaredMethod.invoke(null, *objArr) as T 58 | } 59 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/devicesSDK/SystemSDK.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.devicesSDK 2 | /* 3 | * This file is part of HyperCeiler. 4 | 5 | * HyperCeiler is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as 7 | * published by the Free Software Foundation, either version 3 of the 8 | * License. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | 18 | * Copyright (C) 2023-2024 HyperCeiler Contributions 19 | */ 20 | 21 | import android.content.Context 22 | import kg.edu.yjut.enhancenoticehyperos.miui.devicesSDK.PropUtils.getProp 23 | 24 | /** 25 | 获取设备 Android 版本 、MIUI 版本 、HyperOS 版本 等 26 | 并判断设备指定类型 27 | */ 28 | 29 | // ----- HyperOS ---------------------------------------------------------------------------------- 30 | 31 | fun getHyperOSVersion(): Float = when (getProp("ro.mi.os.version.name")) { 32 | "OS1.0" -> 1f 33 | else -> 0f 34 | } 35 | 36 | 37 | //判断是否是横屏 38 | fun isLandscape( 39 | context : Context 40 | ): Boolean { 41 | var w = context.resources.displayMetrics.widthPixels 42 | var h = context.resources.displayMetrics.heightPixels 43 | return w > h 44 | } 45 | 46 | fun isMoreHyperOSVersion(version: Float): Boolean { 47 | return getHyperOSVersion() >= version 48 | } 49 | 50 | fun isUnHyperOSNotices(context: Context): Boolean { 51 | var sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 52 | return sp.getBoolean("useHyperOSNotices", true) 53 | } 54 | 55 | fun closeUseHyperOSNotices(context: Context) { 56 | var sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 57 | var editor = sp.edit() 58 | editor.putBoolean("useHyperOSNotices", true) 59 | editor.apply() 60 | } 61 | 62 | fun openUseHyperOSNotices(context: Context) { 63 | var sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 64 | var editor = sp.edit() 65 | editor.putBoolean("useHyperOSNotices", false) 66 | editor.apply() 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/res/IconParams.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.res 2 | /* 3 | * This file is part of HyperCeiler. 4 | 5 | * HyperCeiler is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as 7 | * published by the Free Software Foundation, either version 3 of the 8 | * License. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | 18 | * Copyright (C) 2023-2024 HyperCeiler Contributions 19 | */ 20 | 21 | class IconParams { 22 | private var category: String? = null 23 | private var iconFormat: String? = null 24 | private var iconResName: String? = null 25 | private var iconType = 0 26 | 27 | fun setCategory(category: String?) { 28 | this.category = category 29 | } 30 | 31 | fun setIconFormat(iconFormat: String?) { 32 | this.iconFormat = iconFormat 33 | } 34 | 35 | fun setIconType(iconType: Int) { 36 | this.iconType = iconType 37 | } 38 | 39 | fun setIconResName(iconResName: String?) { 40 | this.iconResName = iconResName 41 | } 42 | 43 | fun getCategory(): String? { 44 | return category 45 | } 46 | 47 | fun getIconFormat(): String? { 48 | return iconFormat 49 | } 50 | 51 | fun getIconType(): Int { 52 | return iconType 53 | } 54 | 55 | fun getIconResName(): String? { 56 | return iconResName 57 | } 58 | 59 | override fun toString(): String { 60 | return "IconParams{category='$category', iconFormat='$iconFormat', iconResName='$iconResName', iconType=$iconType}" 61 | } 62 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/res/Left.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.res 2 | /* 3 | * This file is part of HyperCeiler. 4 | 5 | * HyperCeiler is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as 7 | * published by the Free Software Foundation, either version 3 of the 8 | * License. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | 18 | * Copyright (C) 2023-2024 HyperCeiler Contributions 19 | */ 20 | 21 | class Left { 22 | private var iconParams: IconParams? = null 23 | private var textParams: TextParams? = null 24 | 25 | fun setIconParams(iconParams: IconParams?) { 26 | this.iconParams = iconParams 27 | } 28 | 29 | fun setTextParams(textParams: TextParams?) { 30 | this.textParams = textParams 31 | } 32 | 33 | fun getIconParams(): IconParams? { 34 | return iconParams 35 | } 36 | 37 | fun getTextParams(): TextParams? { 38 | return textParams 39 | } 40 | 41 | override fun toString(): String { 42 | return "Left{iconParams=$iconParams, textParams=$textParams}" 43 | } 44 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/res/Right.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.res 2 | 3 | /* 4 | * This file is part of HyperCeiler. 5 | 6 | * HyperCeiler is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License. 10 | 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | 19 | * Copyright (C) 2023-2024 HyperCeiler Contributions 20 | */ 21 | 22 | class Right { 23 | private var iconParams: IconParams? = null 24 | private var textParams: TextParams? = null 25 | 26 | fun setIconParams(iconParams: IconParams?) { 27 | this.iconParams = iconParams 28 | } 29 | 30 | fun setTextParams(textParams: TextParams?) { 31 | this.textParams = textParams 32 | } 33 | 34 | fun getIconParams(): IconParams { 35 | return iconParams!! 36 | } 37 | 38 | fun getTextParams(): TextParams { 39 | return textParams!! 40 | } 41 | 42 | override fun toString(): String { 43 | return "Right{iconParams=$iconParams, textParams=$textParams}" 44 | } 45 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/res/StringToastBean.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.res 2 | /* 3 | * This file is part of HyperCeiler. 4 | 5 | * HyperCeiler is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU Affero General Public License as 7 | * published by the Free Software Foundation, either version 3 of the 8 | * License. 9 | 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Affero General Public License for more details. 14 | 15 | * You should have received a copy of the GNU Affero General Public License 16 | * along with this program. If not, see . 17 | 18 | * Copyright (C) 2023-2024 HyperCeiler Contributions 19 | */ 20 | 21 | class StringToastBean { 22 | private var left: Left? = null 23 | private var right: Right? = null 24 | 25 | fun getLeft(): Left { 26 | return left!! 27 | } 28 | 29 | fun setLeft(left: Left?) { 30 | this.left = left 31 | } 32 | 33 | fun getRight(): Right { 34 | return right!! 35 | } 36 | 37 | fun setRight(right: Right?) { 38 | this.right = right 39 | } 40 | 41 | fun getStringToastBundle(): StringToastBundle { 42 | return StringToastBundle() 43 | } 44 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/res/StringToastBundle.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.res 2 | 3 | /* 4 | * This file is part of HyperCeiler. 5 | 6 | * HyperCeiler is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License. 10 | 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | 19 | * Copyright (C) 2023-2024 HyperCeiler Contributions 20 | */ 21 | 22 | import android.app.PendingIntent 23 | import android.os.Bundle 24 | 25 | 26 | class StringToastBundle { 27 | private var mBundle: Bundle = Bundle() 28 | private var mPackageName: String? = null 29 | private var mCategory: String? = null 30 | private var mIntent: PendingIntent? = null 31 | private var mDuration: Long = 0 32 | private var mLevel = 0f 33 | private var mRate = 0f 34 | private var mCharge: String? = null 35 | private var mFlag = 0 36 | private var mParam: String? = null 37 | private var mStatus: String? = null 38 | 39 | fun setPackageName(name: String?) { 40 | mPackageName = name 41 | } 42 | 43 | fun setStrongToastCategory(category: String?) { 44 | mCategory = category 45 | } 46 | 47 | fun setTarget(intent: PendingIntent?) { 48 | mIntent = intent 49 | } 50 | 51 | fun setDuration(duration: Long) { 52 | mDuration = duration 53 | } 54 | 55 | fun setLevel(level: Float) { 56 | mLevel = level 57 | } 58 | 59 | fun setRapidRate(rate: Float) { 60 | mRate = rate 61 | } 62 | 63 | fun setCharge(charge: String?) { 64 | mCharge = charge 65 | } 66 | 67 | fun setStringToastChargeFlag(flag: Int) { 68 | mFlag = flag 69 | } 70 | 71 | fun setParam(param: String?) { 72 | mParam = param 73 | } 74 | 75 | fun setStatusBarStrongToast(status: String?) { 76 | mStatus = status 77 | } 78 | 79 | fun onCreate() { 80 | mBundle.putString("package_name", mPackageName) 81 | mBundle.putString("strong_toast_category", mCategory) 82 | mBundle.putParcelable("target", mIntent) 83 | mBundle.putLong("duration", mDuration) 84 | mBundle.putFloat("level", mLevel) 85 | mBundle.putFloat("rapid_rate", mRate) 86 | mBundle.putString("charge", mCharge) 87 | mBundle.putInt("string_toast_charge_flag", mFlag) 88 | mBundle.putString("param", mParam) 89 | mBundle.putString("status_bar_strong_toast", mStatus) 90 | } 91 | 92 | class Builder { 93 | private var mBundle: Bundle = Bundle() 94 | 95 | fun setPackageName(name: String?): Builder { 96 | mBundle.putString("package_name", name) 97 | return this 98 | } 99 | 100 | fun setStrongToastCategory(category: String?): Builder { 101 | mBundle.putString("strong_toast_category", category) 102 | return this 103 | } 104 | 105 | fun setTarget(intent: PendingIntent?): Builder { 106 | mBundle.putParcelable("target", intent) 107 | return this 108 | } 109 | 110 | fun setDuration(duration: Long): Builder { 111 | mBundle.putLong("duration", duration) 112 | return this 113 | } 114 | 115 | fun setLevel(level: Float): Builder { 116 | mBundle.putFloat("level", level) 117 | return this 118 | } 119 | 120 | fun setRapidRate(rate: Float): Builder { 121 | mBundle.putFloat("rapid_rate", rate) 122 | return this 123 | } 124 | 125 | fun setCharge(charge: String?): Builder { 126 | mBundle.putString("charge", charge) 127 | return this 128 | } 129 | 130 | fun setStringToastChargeFlag(flag: Int): Builder { 131 | mBundle.putInt("string_toast_charge_flag", flag) 132 | return this 133 | } 134 | 135 | fun setParam(param: String?): Builder { 136 | mBundle.putString("param", param) 137 | return this 138 | } 139 | 140 | fun setStatusBarStrongToast(status: String?): Builder { 141 | mBundle.putString("status_bar_strong_toast", status) 142 | return this 143 | } 144 | 145 | fun onCreate(): Bundle { 146 | return mBundle 147 | } 148 | } 149 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/res/TextParams.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.res 2 | 3 | /* 4 | * This file is part of HyperCeiler. 5 | 6 | * HyperCeiler is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License. 10 | 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see . 18 | 19 | * Copyright (C) 2023-2024 HyperCeiler Contributions 20 | */ 21 | 22 | class TextParams { 23 | private var text: String? = null 24 | private var textColor = 0 25 | 26 | fun setText(text: String?) { 27 | this.text = text 28 | } 29 | 30 | fun setTextColor(textColor: Int) { 31 | this.textColor = textColor 32 | } 33 | 34 | fun getText(): String { 35 | return text!! 36 | } 37 | 38 | fun getTextColor(): Int { 39 | return textColor 40 | } 41 | 42 | override fun toString(): String { 43 | return "TextParams{text='$text', textColor=$textColor}" 44 | } 45 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/service/DynamicIslandService.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.service 2 | 3 | import android.app.Notification 4 | import android.app.NotificationChannel 5 | import android.app.NotificationManager 6 | import android.app.PendingIntent 7 | import android.app.PendingIntent.FLAG_IMMUTABLE 8 | import android.app.Service 9 | import android.content.Intent 10 | import android.content.IntentFilter 11 | import android.graphics.BitmapFactory 12 | import android.os.Build 13 | import android.os.IBinder 14 | import android.util.Log 15 | import androidx.annotation.RequiresApi 16 | import androidx.core.app.NotificationCompat 17 | import kg.edu.yjut.enhancenoticehyperos.MainActivity 18 | import kg.edu.yjut.enhancenoticehyperos.R 19 | import kg.edu.yjut.enhancenoticehyperos.miui.ToastConfig 20 | import kg.edu.yjut.enhancenoticehyperos.miui.devicesSDK.isLandscape 21 | 22 | 23 | class DynamicIslandService : Service() { 24 | 25 | private val TAG = DynamicIslandService::class.java.simpleName 26 | private var mFloatWindowManager: FloatWindowManager? = null 27 | private var mHomeKeyObserverReceiver: HomeKeyObserverReceiver? = null 28 | private var logMode = false 29 | @RequiresApi(Build.VERSION_CODES.TIRAMISU) 30 | override fun onCreate() { 31 | var id = "service.DynamicIslandService" 32 | var name = "灵动岛服务" 33 | var description = "GuardNotificationListenerService" 34 | 35 | 36 | 37 | var intent = Intent(this, MainActivity::class.java) 38 | var pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE) 39 | var notification: Notification = NotificationCompat.Builder(this, id) 40 | .setContentTitle("灵动岛服务正在启动") 41 | .setContentText("灵动岛服务正在启动,点击进入应用") 42 | .setWhen(System.currentTimeMillis()) 43 | .setSmallIcon(R.mipmap.ic_launcher_round) 44 | .setLargeIcon(BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher_round)) 45 | .setContentIntent(pendingIntent) 46 | .build() 47 | 48 | 49 | var manager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager 50 | 51 | var channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH) 52 | channel.enableLights(true); 53 | channel.setShowBadge(true); 54 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { 55 | channel.lockscreenVisibility = Notification.FOREGROUND_SERVICE_DEFAULT; 56 | }else{ 57 | channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC; 58 | } 59 | manager.createNotificationChannel(channel); 60 | 61 | var notification1 = notification; 62 | // 通知id 63 | var notificationId = 3 64 | // 显示通知 65 | startForeground(notificationId, notification1) 66 | 67 | 68 | 69 | mFloatWindowManager = FloatWindowManager(applicationContext) 70 | mHomeKeyObserverReceiver = HomeKeyObserverReceiver() 71 | // 获取传递给服务的数据 通过 sharePreference 72 | val sp = getSharedPreferences("data", MODE_PRIVATE) 73 | var pendingIntentText = sp.getString("intent", "") 74 | var config = ToastConfig( 75 | sp.getString("text", "default")!!, 76 | sp.getString("textColor", "default")!!, 77 | sp.getString("image", "default")!!, 78 | sp.getLong("duration", 3000L), 79 | null 80 | ) 81 | Log.d(TAG, "onCreate: $pendingIntentText") 82 | if (pendingIntentText == "" || pendingIntentText == null) { 83 | config.intent = null 84 | } else{ 85 | var my = PendingIntent.getActivity(this, 0, Intent(pendingIntentText), FLAG_IMMUTABLE) 86 | config.intent = my 87 | } 88 | // 将 toSting var转换为 PendingIntent 89 | 90 | 91 | logMode = sp.getBoolean("logMode", false) 92 | 93 | 94 | registerReceiver(mHomeKeyObserverReceiver, IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS), 95 | RECEIVER_NOT_EXPORTED 96 | ) 97 | mFloatWindowManager!!.createWindow( 98 | config, 99 | logMode, 100 | isLandscape(applicationContext) 101 | ) 102 | 103 | if (!logMode) { 104 | // 等待 3 秒后,移除悬浮窗 105 | Thread { 106 | Thread.sleep(config.duration+2000) 107 | // 结束服务 108 | stopSelf() 109 | }.start() 110 | 111 | } 112 | 113 | } 114 | 115 | override fun onBind(intent: Intent?): IBinder? { 116 | return null 117 | } 118 | 119 | override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { 120 | return START_NOT_STICKY 121 | } 122 | 123 | override fun onDestroy() { 124 | mFloatWindowManager?.removeWindow() 125 | if (mHomeKeyObserverReceiver != null) { 126 | unregisterReceiver(mHomeKeyObserverReceiver) 127 | } 128 | } 129 | 130 | 131 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/service/FloatLayout.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.service 2 | 3 | import android.annotation.SuppressLint 4 | import android.app.PendingIntent 5 | import android.content.Context 6 | import android.content.Intent 7 | import android.util.AttributeSet 8 | import android.view.LayoutInflater 9 | import android.widget.ImageView 10 | import android.widget.Scroller 11 | import android.widget.TextView 12 | import androidx.constraintlayout.widget.ConstraintLayout 13 | import kg.edu.yjut.enhancenoticehyperos.R 14 | import org.w3c.dom.Text 15 | 16 | class FloatLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0) : 17 | ConstraintLayout(context, attrs, defStyleAttr, defStyleRes) { 18 | 19 | private var mText: TextView 20 | private var mImg: ImageView 21 | 22 | init { 23 | val view = LayoutInflater.from(context).inflate(R.layout.lld, this, true) 24 | mText = view.findViewById(R.id.contentText) 25 | mImg = view.findViewById(R.id.img) 26 | 27 | } 28 | 29 | fun setText(text: String) { 30 | mText.text = text 31 | 32 | } 33 | fun setTextSize(size: Float) { 34 | mText.textSize = size 35 | } 36 | 37 | fun setTextColor(color: Int) { 38 | mText.setTextColor(color) 39 | } 40 | 41 | @SuppressLint("DiscouragedApi") 42 | fun setImage(resId: String, context: Context, type : String) { 43 | if (type == "drawable") { 44 | mImg.setImageResource(context.resources.getIdentifier(resId, type, context.packageName)) 45 | } 46 | } 47 | 48 | // 设置文本框可以水平滚动 49 | fun setHorizontallyScrolling() { 50 | mText.setHorizontallyScrolling(true) 51 | // 设置自动滚动 52 | mText.isSelected = true 53 | // 设置滚动速度 54 | mText.setScroller(Scroller(context)) 55 | 56 | } 57 | 58 | fun setOnClickListener(pendingIntent: PendingIntent) { 59 | mImg.setOnClickListener(OnClickListener { 60 | // 发送广播,点击图片时触发 61 | pendingIntent.send( 62 | context, 63 | 0, 64 | Intent(), 65 | null, 66 | null, 67 | null 68 | ) 69 | }) 70 | 71 | } 72 | 73 | 74 | 75 | 76 | 77 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/service/FloatWindowManager.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.service 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.graphics.PixelFormat 6 | import android.util.Log 7 | import android.view.Gravity 8 | import android.view.View 9 | import android.view.WindowManager 10 | import androidx.compose.ui.graphics.Color 11 | import androidx.compose.ui.graphics.toArgb 12 | import kg.edu.yjut.enhancenoticehyperos.miui.ToastConfig 13 | import kg.edu.yjut.enhancenoticehyperos.miui.devicesSDK.isLandscape 14 | 15 | 16 | class FloatWindowManager constructor(context: Context) { 17 | 18 | var isShowing = false 19 | private val TAG = FloatWindowManager::class.java.simpleName 20 | private var mContext: Context = context 21 | private var mFloatLayout = FloatLayout(mContext) 22 | private var mLayoutParams: WindowManager.LayoutParams? = null 23 | private var mWindowManager: WindowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager 24 | private var mToastConfig: ToastConfig? = null 25 | private var mlogMode = false 26 | fun createWindow( 27 | config: ToastConfig, 28 | logMode: Boolean = false, 29 | landscape: Boolean 30 | ) { 31 | mToastConfig = config 32 | // 对象配置操作使用apply,额外的处理使用also 33 | mlogMode = logMode 34 | var view = mFloatLayout 35 | // 获取屏幕的宽高 dp 36 | val wm = mContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager 37 | val dpi = mContext.resources.displayMetrics.density 38 | val height = wm.defaultDisplay.height 39 | val width = wm.defaultDisplay.width 40 | 41 | // 设置悬浮窗的宽高 42 | Log.d(TAG, "onInit: ${width} ${height}") 43 | if (landscape){ 44 | var islandwidth = width/3 45 | mLayoutParams = WindowManager.LayoutParams().apply { 46 | type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY 47 | // 设置图片格式,效果为背景透明 48 | format = PixelFormat.RGBA_8888 49 | // 设置浮动窗口不可聚焦(实现操作除浮动窗口外的其他可见窗口的操作) 50 | flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 51 | // 调整悬浮窗显示的停靠位置为右侧置顶 52 | gravity = Gravity.TOP or Gravity.END 53 | 54 | // 以屏幕左上角为原点,设置x、y初始值 55 | x = width/2 - islandwidth/2 56 | y = 20 57 | 58 | 59 | } 60 | mLayoutParams!!.width = islandwidth 61 | mLayoutParams!!.height = 120 62 | // 设置悬浮窗的宽高 63 | view.setText(config.text) 64 | view.setTextSize(15f) 65 | view.setHorizontallyScrolling() 66 | 67 | }else{ 68 | var islandwidth = width*2/3 69 | mLayoutParams = WindowManager.LayoutParams().apply { 70 | type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY 71 | // 设置图片格式,效果为背景透明 72 | format = PixelFormat.RGBA_8888 73 | // 设置浮动窗口不可聚焦(实现操作除浮动窗口外的其他可见窗口的操作) 74 | flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 75 | // 调整悬浮窗显示的停靠位置为右侧置顶 76 | gravity = Gravity.TOP or Gravity.END 77 | // 以屏幕左上角为原点,设置x、y初始值 78 | x = width/2 - islandwidth/2 79 | y = 20 80 | 81 | 82 | } 83 | mLayoutParams!!.width = islandwidth 84 | mLayoutParams!!.height = 100 85 | // 设置悬浮窗的宽高 86 | view.setText(config.text) 87 | view.setTextSize(15f) 88 | view.setHorizontallyScrolling() 89 | } 90 | // 设置位置 91 | // 屏幕水平正中心 92 | 93 | 94 | // 将 #RRGGBB 格式的颜色转换为 Color 对象 95 | var color = Color( 96 | android.graphics.Color.parseColor(config.textColor) 97 | ) 98 | 99 | view.setTextColor(color.toArgb()) 100 | view.setImage(config.image, mContext, "drawable") 101 | Log.d(TAG, "onInit: ${config.intent}") 102 | if (config.intent != null){ 103 | view.setOnClickListener(config.intent!!) 104 | } else { 105 | view.setOnClickListener(null) 106 | } 107 | 108 | mWindowManager.addView(view, mLayoutParams) 109 | 110 | isShowing = true 111 | } 112 | 113 | 114 | fun showWindow() { 115 | if (!isShowing) { 116 | if (mLayoutParams == null) { 117 | createWindow( 118 | mToastConfig!!, 119 | landscape = isLandscape(mContext) 120 | ) 121 | } else { 122 | mWindowManager.addView(mFloatLayout, mLayoutParams) 123 | isShowing = true 124 | } 125 | } 126 | } 127 | 128 | fun removeWindow() { 129 | mWindowManager.removeView(mFloatLayout) 130 | // 保存悬浮窗的位置 131 | 132 | 133 | isShowing = false 134 | } 135 | 136 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/miui/service/HomeKeyObserverReceiver.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.miui.service 2 | 3 | import android.content.BroadcastReceiver 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.view.KeyEvent 7 | import kg.edu.yjut.enhancenoticehyperos.miui.service.DynamicIslandService 8 | 9 | class HomeKeyObserverReceiver : BroadcastReceiver() { 10 | 11 | override fun onReceive(context: Context?, intent: Intent?) { 12 | try { 13 | val action = intent!!.action 14 | val reason = intent.getStringExtra("reason") 15 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS == action && "homekey" == reason) { 16 | val keyCode = intent.getIntExtra("keycode", KeyEvent.KEYCODE_UNKNOWN) 17 | context?.stopService(Intent(context, DynamicIslandService::class.java)) 18 | } 19 | 20 | } catch (ex: Exception) { 21 | ex.printStackTrace() 22 | } 23 | } 24 | 25 | companion object { 26 | private val TAG = HomeKeyObserverReceiver::class.java.simpleName 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/receive/MessageReciever.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 The LiteNote Project 3 | * @author OpenAcademic 4 | * @version 1.0 5 | * 6 | */ 7 | package kg.edu.yjut.enhancenoticehyperos.receive 8 | 9 | import android.annotation.SuppressLint 10 | import android.app.Service.CLIPBOARD_SERVICE 11 | import android.content.BroadcastReceiver 12 | import android.content.ClipboardManager 13 | import android.content.Context 14 | import android.content.Intent 15 | import android.os.Build 16 | import android.provider.Settings 17 | import android.telephony.SmsMessage 18 | import android.util.Log 19 | import android.widget.Toast 20 | import androidx.core.content.ContextCompat 21 | import kg.edu.yjut.enhancenoticehyperos.miui.MiuiStringToast 22 | import kg.edu.yjut.enhancenoticehyperos.miui.devicesSDK.isMoreHyperOSVersion 23 | import kg.edu.yjut.enhancenoticehyperos.miui.devicesSDK.isUnHyperOSNotices 24 | import kg.edu.yjut.enhancenoticehyperos.service.CodeConfig 25 | import kg.edu.yjut.enhancenoticehyperos.service.FocusService 26 | import kg.edu.yjut.enhancenoticehyperos.utils.Configs 27 | import kg.edu.yjut.enhancenoticehyperos.utils.PickupCodeUtils 28 | 29 | import java.text.SimpleDateFormat 30 | import kotlin.concurrent.thread 31 | 32 | 33 | class MessageReciever : BroadcastReceiver() { 34 | private final var SMS_RECEIVER_ACTION = "android.provider.Telephony.SMS_RECEIVED" 35 | private final var TAG = "com.example.litenote.reciever.MessageReciever" 36 | 37 | override fun onReceive(context: Context, intent: Intent) { 38 | var sBuilder = StringBuilder(); 39 | val format = intent.getStringExtra("format"); 40 | var from = "" 41 | if(SMS_RECEIVER_ACTION.equals(intent.getAction())) 42 | { 43 | val bundle = intent.getExtras(); 44 | if(null != bundle) 45 | { 46 | val pdus = bundle.get("pdus") as Array; 47 | val messages = arrayOfNulls(pdus.size); 48 | for(i in messages.indices) 49 | { 50 | messages[i] = SmsMessage.createFromPdu(pdus[i] as ByteArray,format); 51 | } 52 | for(msg in messages) 53 | { 54 | if (msg != null) { 55 | //sBuilder.append("来自:").append(msg.getDisplayOriginatingAddress()).append("\n") 56 | // .append("短信内容:") 57 | sBuilder.append(msg.getDisplayMessageBody()).append("\n") 58 | from = msg.getDisplayOriginatingAddress() // 获取短信发送方 59 | 60 | }; 61 | } 62 | } 63 | } 64 | 65 | if (sBuilder.toString().isEmpty()) { 66 | return; 67 | } 68 | else{ 69 | if (Configs.getSettingItems(context,"yanzhengma",false)){ 70 | if (PickupCodeUtils.isYanzhengma(sBuilder.toString())){ 71 | var str = sBuilder.toString().replace(Regex("[0-9]{11}"),"") 72 | var code = PickupCodeUtils.getYanzhengma(str) 73 | var from = from 74 | 75 | if (code.isNotEmpty()){ 76 | try { 77 | showQujianma( 78 | context, 79 | CodeConfig( 80 | code, 81 | "", 82 | 1, 83 | from 84 | ) 85 | ) 86 | return 87 | }catch (e:Exception){ 88 | return 89 | } 90 | return 91 | }else{ 92 | return 93 | } 94 | } 95 | } 96 | } 97 | 98 | Log.d("MessageReciever", sBuilder.toString()); 99 | } 100 | @SuppressLint("SimpleDateFormat") 101 | private fun timeStempToTime(timest: Long,mode:Int): String { 102 | //val ptimest=1000L*timest 103 | // 转换为 2024-12-12 12:12 104 | if (mode == 1){ 105 | val sdf = SimpleDateFormat("yyyy-MM-dd"); 106 | val dateStr = sdf.format(java.util.Date(timest).time); 107 | return dateStr; 108 | }else if (mode == 2){ 109 | val sdf = SimpleDateFormat("yyyy-MM"); 110 | val dateStr = sdf.format(java.util.Date(timest).time); 111 | return dateStr; 112 | }else if (mode == 3){ 113 | val sdf = SimpleDateFormat("yyyy"); 114 | val dateStr = sdf.format(java.util.Date(timest).time); 115 | return dateStr; 116 | }else{ 117 | val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm"); 118 | val dateStr = sdf.format(java.util.Date(timest).time); 119 | return dateStr; 120 | } 121 | 122 | } 123 | @SuppressLint("WrongConstant") 124 | fun showQujianma( 125 | context: Context, 126 | config: CodeConfig 127 | ){ 128 | if (Settings.canDrawOverlays(context)) { 129 | val intent = Intent(context, FocusService::class.java) 130 | intent.putExtra("text", config.text) 131 | intent.putExtra("express", config.express) 132 | intent.putExtra("type", config.type) 133 | intent.putExtra("from", config.from) 134 | intent.putExtra("logMode", false) 135 | 136 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { 137 | // 检查 auto_fill 138 | if (Configs.getSettingItems(context,"auto_fill",false)){ 139 | // 将验证码 自动填充 到 剪切板 140 | // 写入剪切板 141 | val clipboard = context.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager 142 | val clip = android.content.ClipData.newPlainText("text", config.text) 143 | clipboard.setPrimaryClip(clip) 144 | } 145 | ContextCompat.startForegroundService(context, intent) 146 | } else { 147 | context.startService(intent) 148 | } 149 | 150 | 151 | 152 | 153 | 154 | } 155 | 156 | } 157 | 158 | 159 | 160 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/service/CodeConfig.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 The LiteNote Project 3 | * @author OpenAcademic 4 | * @version 1.0 5 | * 6 | */ 7 | package kg.edu.yjut.enhancenoticehyperos.service 8 | 9 | data class CodeConfig( 10 | var text: String, 11 | var express : String, 12 | var type : Int, 13 | // 0 - 取件码 1 - 验证码 14 | var from : String 15 | ) -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/service/FocusLayout.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 The LiteNote Project 3 | * @author OpenAcademic 4 | * @version 1.0 5 | * 6 | */ 7 | package kg.edu.yjut.enhancenoticehyperos.service 8 | 9 | import android.annotation.SuppressLint 10 | import android.content.Context 11 | import android.text.TextUtils 12 | import android.util.AttributeSet 13 | import android.view.LayoutInflater 14 | import android.view.View 15 | import android.widget.ImageView 16 | import android.widget.LinearLayout 17 | import android.widget.Scroller 18 | import android.widget.TextView 19 | import androidx.constraintlayout.widget.ConstraintLayout 20 | import kg.edu.yjut.enhancenoticehyperos.R 21 | 22 | 23 | @SuppressLint("MissingInflatedId") 24 | class FocusLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0) : 25 | ConstraintLayout(context, attrs, defStyleAttr, defStyleRes) { 26 | 27 | private var mText: TextView 28 | private var mView: View 29 | private var mSpaceArea : View 30 | private var mCopy : ImageView 31 | private var mSave : ImageView 32 | private var mShowText: TextView 33 | private var mExpressText: TextView 34 | 35 | init { 36 | val view = LayoutInflater.from(context).inflate(R.layout.qujianma2, this, true) 37 | mView = view 38 | mText = view.findViewById(R.id.contentqjmText) 39 | mSpaceArea = view.findViewById(R.id.spaceArea) 40 | mCopy = view.findViewById(R.id.copy) 41 | mSave = view.findViewById(R.id.save) 42 | mShowText = view.findViewById(R.id.contentqjmShow) 43 | mExpressText = view.findViewById(R.id.contentqjmKuaidi) 44 | 45 | } 46 | 47 | fun setSaveUnVisible() { 48 | mSave.visibility = View.GONE 49 | } 50 | fun setExpressText(text: String) { 51 | mExpressText.text = text 52 | } 53 | 54 | fun setShowText(text: String) { 55 | mShowText.text = text 56 | } 57 | 58 | fun setText(text: String) { 59 | mText.text = text 60 | // 设置超出隐藏 61 | mText.ellipsize = TextUtils.TruncateAt.END 62 | mText.maxLines = 1 63 | 64 | 65 | } 66 | fun setTextSize(size: Float) { 67 | mText.textSize = size 68 | } 69 | 70 | 71 | 72 | 73 | // 设置文本框可以水平滚动 74 | fun setHorizontallyScrolling() { 75 | mText.setHorizontallyScrolling(true) 76 | // 设置自动滚动 77 | mText.isSelected = true 78 | // 设置滚动速度 79 | mText.setScroller(Scroller(context)) 80 | 81 | } 82 | 83 | fun setOnClickListener( 84 | function: () -> Unit 85 | ) { 86 | mSpaceArea.setOnClickListener { 87 | // 结束服务 88 | function() 89 | } 90 | } 91 | 92 | fun setOnCopyClickListener( 93 | function: () -> Unit 94 | ) { 95 | mCopy.setOnClickListener { 96 | // 结束服务 97 | function() 98 | } 99 | } 100 | 101 | fun setOnSaveClickListener( 102 | function: () -> Unit 103 | ) { 104 | mSave.setOnClickListener { 105 | // 结束服务 106 | function() 107 | } 108 | } 109 | 110 | 111 | 112 | 113 | 114 | 115 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/service/FocusService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 The LiteNote Project 3 | * @author OpenAcademic 4 | * @version 1.0 5 | * 6 | */ 7 | package kg.edu.yjut.enhancenoticehyperos.service 8 | 9 | import android.app.Service 10 | import android.content.Intent 11 | import android.os.IBinder 12 | 13 | 14 | import android.app.Notification 15 | import android.app.NotificationChannel 16 | import android.app.NotificationManager 17 | import android.app.PendingIntent 18 | import android.content.ClipboardManager 19 | import android.content.ContentValues 20 | import android.content.IntentFilter 21 | import android.graphics.BitmapFactory 22 | import android.os.Build 23 | import android.util.Log 24 | import android.widget.Toast 25 | import androidx.core.app.NotificationCompat 26 | import kg.edu.yjut.enhancenoticehyperos.MainActivity 27 | import kg.edu.yjut.enhancenoticehyperos.R 28 | import kg.edu.yjut.enhancenoticehyperos.miui.devicesSDK.isLandscape 29 | 30 | 31 | class FocusService : Service() { 32 | 33 | private val TAG = FocusService::class.java.simpleName 34 | private var mFloatWindowManager: FocusWindowManager? = null 35 | private var mHomeKeyObserverReceiver: HomeKeyObserverReceiver? = null 36 | private var logMode = false 37 | 38 | override fun onBind(intent: Intent?): IBinder? { 39 | return null 40 | } 41 | 42 | override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { 43 | super.onStartCommand(intent, flags, startId) 44 | if (mFloatWindowManager != null) { 45 | // 清除 46 | mFloatWindowManager!!.removeWindow() 47 | } 48 | 49 | mFloatWindowManager = FocusWindowManager(applicationContext) 50 | mHomeKeyObserverReceiver = HomeKeyObserverReceiver() 51 | // 获取传递给服务的数据 通过 sharePreference 52 | val sp = getSharedPreferences("curr_data", MODE_PRIVATE) 53 | 54 | val config = CodeConfig( 55 | intent?.getStringExtra("text")!!, 56 | intent.getStringExtra("express")!!, 57 | intent.getIntExtra("type", 0), 58 | intent.getStringExtra("from")!! 59 | ) 60 | 61 | 62 | logMode = intent.getBooleanExtra("logMode", false) 63 | registerReceiver(mHomeKeyObserverReceiver, IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS), 64 | RECEIVER_NOT_EXPORTED 65 | ) 66 | mFloatWindowManager!!.createWindow( 67 | config = config, 68 | function = { 69 | stopSelf() 70 | }, 71 | copy = { 72 | // 写入剪切板 73 | val clipboard = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager 74 | val clip = android.content.ClipData.newPlainText("text", config.text) 75 | clipboard.setPrimaryClip(clip) 76 | Toast.makeText(this, "已复制到剪切板", Toast.LENGTH_SHORT).show() 77 | stopSelf() 78 | 79 | }, 80 | save = { 81 | // 保存到数据库 82 | 83 | stopSelf() 84 | 85 | }, 86 | landscape = isLandscape(applicationContext) 87 | ) 88 | return START_NOT_STICKY 89 | } 90 | 91 | override fun onDestroy() { 92 | mFloatWindowManager?.removeWindow() 93 | if (mHomeKeyObserverReceiver != null) { 94 | unregisterReceiver(mHomeKeyObserverReceiver) 95 | } 96 | } 97 | 98 | override fun onCreate() { 99 | var id = "service.FocusService" 100 | var name = "取件码服务" 101 | var description = "FocusService" 102 | 103 | 104 | 105 | var intent = Intent(this, MainActivity::class.java) 106 | var pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE) 107 | var notification: Notification = NotificationCompat.Builder(this, id) 108 | .setContentTitle("取件码服务正在启动") 109 | .setContentText("取件码服务正在启动,点击进入应用") 110 | .setWhen(System.currentTimeMillis()) 111 | .setSmallIcon(R.drawable.dd) 112 | .setLargeIcon(BitmapFactory.decodeResource(resources, R.drawable.dd)) 113 | .setContentIntent(pendingIntent) 114 | .build() 115 | 116 | 117 | var manager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager 118 | 119 | var channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH) 120 | channel.enableLights(true); 121 | channel.setShowBadge(true); 122 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { 123 | channel.lockscreenVisibility = Notification.FOREGROUND_SERVICE_DEFAULT; 124 | }else{ 125 | channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC; 126 | } 127 | manager.createNotificationChannel(channel); 128 | 129 | var notification1 = notification; 130 | // 通知id 131 | var notificationId = 4 132 | // 显示通知 133 | startForeground(notificationId, notification1) 134 | 135 | 136 | 137 | 138 | } 139 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/service/FocusWindowManager.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 The LiteNote Project 3 | * @author OpenAcademic 4 | * @version 1.0 5 | * 6 | */ 7 | package kg.edu.yjut.enhancenoticehyperos.service 8 | 9 | import android.annotation.SuppressLint 10 | import android.content.Context 11 | import android.graphics.PixelFormat 12 | import android.util.Log 13 | import android.view.Gravity 14 | import android.view.View 15 | import android.view.WindowManager 16 | import kg.edu.yjut.enhancenoticehyperos.service.FocusLayout 17 | 18 | class FocusWindowManager constructor(context: Context) { 19 | 20 | var isShowing = false 21 | private val TAG = FocusWindowManager::class.java.simpleName 22 | private var mContext: Context = context 23 | private var mFloatLayout = FocusLayout(mContext) 24 | private var mLayoutParams: WindowManager.LayoutParams? = null 25 | private var mWindowManager: WindowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager 26 | private var mToastConfig: CodeConfig? = null 27 | @SuppressLint("WrongConstant") 28 | fun createWindow( 29 | config: CodeConfig, 30 | function: () -> Unit, 31 | copy : () -> Unit, 32 | save : () -> Unit, 33 | landscape: Boolean 34 | ) { 35 | mToastConfig = config 36 | // 对象配置操作使用apply,额外的处理使用also 37 | 38 | // 获取屏幕的宽高 dp 39 | val wm = mContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager 40 | val dpi = mContext.resources.displayMetrics.density 41 | val height = wm.defaultDisplay.height 42 | val width = wm.defaultDisplay.width 43 | var sp = mContext.getSharedPreferences("curr_data", Context.MODE_PRIVATE) 44 | 45 | // 设置悬浮窗的宽高 46 | Log.d(TAG, "onInit: ${width} ${height}") 47 | 48 | if (!landscape){ 49 | mLayoutParams = WindowManager.LayoutParams().apply { 50 | type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY or WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY 51 | // 设置图片格式,效果为背景透明 52 | format = PixelFormat.RGBA_8888 53 | // 设置浮动窗口不可聚焦(实现操作除浮动窗口外的其他可见窗口的操作) 54 | flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS or 55 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 56 | 57 | // 调整悬浮窗显示的停靠位置为右侧置顶 58 | gravity = Gravity.TOP or Gravity.START 59 | // 以屏幕左上角为原点,设置x、y初始值 60 | x = 10 61 | y = 20 62 | 63 | 64 | } 65 | mLayoutParams!!.width = (width - 20).toInt() 66 | mLayoutParams!!.height = ((height)/5).toInt() 67 | // 设置悬浮窗的宽高 68 | //mFloatLayout.setHorizontallyScrolling() 69 | 70 | }else{ 71 | mLayoutParams = WindowManager.LayoutParams().apply { 72 | type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY 73 | // 设置图片格式,效果为背景透明 74 | format = PixelFormat.RGBA_8888 75 | // 设置浮动窗口不可聚焦(实现操作除浮动窗口外的其他可见窗口的操作) 76 | flags = 77 | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS or 78 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or 79 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or 80 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS 81 | // 调整悬浮窗显示的停靠位置为右侧置顶 82 | gravity = Gravity.TOP or Gravity.START 83 | // 以屏幕左上角为原点,设置x、y初始值 84 | x = (width/4).toInt() 85 | y = 20 86 | 87 | 88 | } 89 | mLayoutParams!!.width = (width/2).toInt() 90 | mLayoutParams!!.height = (width/7).toInt() 91 | // 设置悬浮窗的宽高 92 | mFloatLayout.setTextSize(sp.getInt("lastTextSize", 10).toFloat()) 93 | //mFloatLayout.setHorizontallyScrolling() 94 | 95 | } 96 | mFloatLayout.setText(config.text) 97 | if (config.type == 0){ 98 | mFloatLayout.setShowText("您收到快递取件码") 99 | mFloatLayout.setExpressText(config.express) 100 | mFloatLayout.setSaveUnVisible() 101 | 102 | 103 | }else{ 104 | mFloatLayout.setShowText("您收到短信验证码") 105 | mFloatLayout.setSaveUnVisible() 106 | mFloatLayout.setExpressText(config.from) 107 | 108 | } 109 | 110 | 111 | // 设置位置 112 | // 屏幕水平正中心 113 | mFloatLayout!!.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN 114 | 115 | mFloatLayout.setOnClickListener(function) 116 | mFloatLayout.setOnCopyClickListener(copy) 117 | mFloatLayout.setOnSaveClickListener(save) 118 | 119 | mWindowManager.addView(mFloatLayout, mLayoutParams) 120 | 121 | isShowing = true 122 | } 123 | 124 | // 设置拖动事件 125 | 126 | 127 | 128 | 129 | fun removeWindow() { 130 | mWindowManager.removeView(mFloatLayout) 131 | // 保存悬浮窗的位置 132 | 133 | 134 | isShowing = false 135 | } 136 | 137 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/service/HomeKeyObserverReceiver.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 The LiteNote Project 3 | * @author OpenAcademic 4 | * @version 1.0 5 | * 6 | */ 7 | package kg.edu.yjut.enhancenoticehyperos.service 8 | 9 | import android.content.BroadcastReceiver 10 | import android.content.Context 11 | import android.content.Intent 12 | import android.view.KeyEvent 13 | 14 | class HomeKeyObserverReceiver : BroadcastReceiver() { 15 | 16 | override fun onReceive(context: Context?, intent: Intent?) { 17 | try { 18 | val action = intent!!.action 19 | val reason = intent.getStringExtra("reason") 20 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS == action && "homekey" == reason) { 21 | val keyCode = intent.getIntExtra("keycode", KeyEvent.KEYCODE_UNKNOWN) 22 | context?.stopService(Intent(context, FocusService::class.java)) 23 | } 24 | 25 | } catch (ex: Exception) { 26 | ex.printStackTrace() 27 | } 28 | } 29 | 30 | companion object { 31 | private val TAG = HomeKeyObserverReceiver::class.java.simpleName 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/service/MessageService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 The LiteNote Project 3 | * @author OpenAcademic 4 | * @version 1.0 5 | * 6 | */ 7 | package kg.edu.yjut.enhancenoticehyperos.service 8 | 9 | import android.app.Notification 10 | import android.app.NotificationChannel 11 | import android.app.NotificationManager 12 | import android.app.PendingIntent 13 | import android.app.Service 14 | import android.content.Intent 15 | import android.content.IntentFilter 16 | import android.graphics.BitmapFactory 17 | import android.os.Build 18 | import android.os.IBinder 19 | import androidx.core.app.NotificationCompat 20 | import kg.edu.yjut.enhancenoticehyperos.MainActivity 21 | import kg.edu.yjut.enhancenoticehyperos.R 22 | import kg.edu.yjut.enhancenoticehyperos.receive.MessageReciever 23 | 24 | 25 | class MessageService : Service() { 26 | var mReceiver : MessageReciever? = null 27 | override fun onBind(intent: Intent): IBinder? { 28 | return null 29 | } 30 | 31 | override fun onDestroy() { 32 | super.onDestroy() 33 | if (mReceiver != null) { 34 | unregisterReceiver(mReceiver) 35 | } 36 | } 37 | 38 | override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { 39 | return super.onStartCommand(intent, flags, startId) 40 | } 41 | 42 | override fun onUnbind(intent: Intent?): Boolean { 43 | return super.onUnbind(intent) 44 | } 45 | 46 | override fun onCreate() { 47 | super.onCreate() 48 | var id = "cn.tw.sar.note.service.MessageService" 49 | var name = "短信服务" 50 | var description = "GuardNotificationListenerService" 51 | 52 | 53 | var intent = Intent(this, MainActivity::class.java) 54 | var pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE) 55 | var notification: Notification = NotificationCompat.Builder(this, id) 56 | .setContentTitle("短信监听服务") 57 | .setContentText("正在运行...") 58 | .setWhen(System.currentTimeMillis()) 59 | .setSmallIcon(R.mipmap.ic_launcher) 60 | .setLargeIcon(BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)) 61 | .setContentIntent(pendingIntent) 62 | .build() 63 | 64 | var manager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager 65 | 66 | var channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH) 67 | channel.enableLights(true); 68 | channel.setShowBadge(true); 69 | // 锁定屏幕不可见 70 | // 不弹出通知 71 | channel.setSound(null, null); 72 | channel.enableVibration(false); 73 | 74 | 75 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { 76 | channel.lockscreenVisibility = Notification.FOREGROUND_SERVICE_DEFAULT; 77 | } else { 78 | channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC; 79 | } 80 | manager.createNotificationChannel(channel); 81 | 82 | var notification1 = notification; 83 | // 通知id 84 | var notificationId = 2 85 | // 显示通知 86 | startForeground(notificationId, notification1) 87 | 88 | mReceiver = MessageReciever() 89 | val filter = IntentFilter("android.provider.Telephony.SMS_RECEIVED") 90 | registerReceiver(mReceiver, filter) 91 | 92 | } 93 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.ui.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val Purple80 = Color(0xFFD0BCFF) 6 | val PurpleGrey80 = Color(0xFFCCC2DC) 7 | val Pink80 = Color(0xFFEFB8C8) 8 | 9 | val Purple40 = Color(0xFF6650a4) 10 | val PurpleGrey40 = Color(0xFF625b71) 11 | val Pink40 = Color(0xFF7D5260) -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/ui/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.ui.theme 2 | 3 | import android.app.Activity 4 | import android.os.Build 5 | import androidx.compose.foundation.isSystemInDarkTheme 6 | import androidx.compose.material3.MaterialTheme 7 | import androidx.compose.material3.darkColorScheme 8 | import androidx.compose.material3.dynamicDarkColorScheme 9 | import androidx.compose.material3.dynamicLightColorScheme 10 | import androidx.compose.material3.lightColorScheme 11 | import androidx.compose.runtime.Composable 12 | import androidx.compose.ui.platform.LocalContext 13 | 14 | private val DarkColorScheme = darkColorScheme( 15 | primary = Purple80, 16 | secondary = PurpleGrey80, 17 | tertiary = Pink80 18 | ) 19 | 20 | private val LightColorScheme = lightColorScheme( 21 | primary = Purple40, 22 | secondary = PurpleGrey40, 23 | tertiary = Pink40 24 | 25 | /* Other default colors to override 26 | background = Color(0xFFFFFBFE), 27 | surface = Color(0xFFFFFBFE), 28 | onPrimary = Color.White, 29 | onSecondary = Color.White, 30 | onTertiary = Color.White, 31 | onBackground = Color(0xFF1C1B1F), 32 | onSurface = Color(0xFF1C1B1F), 33 | */ 34 | ) 35 | 36 | @Composable 37 | fun DynamicNotificationTheme( 38 | darkTheme: Boolean = isSystemInDarkTheme(), 39 | // Dynamic color is available on Android 12+ 40 | dynamicColor: Boolean = true, 41 | content: @Composable () -> Unit 42 | ) { 43 | val colorScheme = when { 44 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { 45 | val context = LocalContext.current 46 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) 47 | } 48 | 49 | darkTheme -> DarkColorScheme 50 | else -> LightColorScheme 51 | } 52 | 53 | MaterialTheme( 54 | colorScheme = colorScheme, 55 | typography = Typography, 56 | content = content 57 | ) 58 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.ui.theme 2 | 3 | import androidx.compose.material3.Typography 4 | import androidx.compose.ui.text.TextStyle 5 | import androidx.compose.ui.text.font.FontFamily 6 | import androidx.compose.ui.text.font.FontWeight 7 | import androidx.compose.ui.unit.sp 8 | 9 | // Set of Material typography styles to start with 10 | val Typography = Typography( 11 | bodyLarge = TextStyle( 12 | fontFamily = FontFamily.Default, 13 | fontWeight = FontWeight.Normal, 14 | fontSize = 16.sp, 15 | lineHeight = 24.sp, 16 | letterSpacing = 0.5.sp 17 | ) 18 | /* Other default text styles to override 19 | titleLarge = TextStyle( 20 | fontFamily = FontFamily.Default, 21 | fontWeight = FontWeight.Normal, 22 | fontSize = 22.sp, 23 | lineHeight = 28.sp, 24 | letterSpacing = 0.sp 25 | ), 26 | labelSmall = TextStyle( 27 | fontFamily = FontFamily.Default, 28 | fontWeight = FontWeight.Medium, 29 | fontSize = 11.sp, 30 | lineHeight = 16.sp, 31 | letterSpacing = 0.5.sp 32 | ) 33 | */ 34 | ) -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/utils/Configs.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.utils 2 | 3 | import android.content.Context 4 | 5 | enum class SoftwareMode(val value: String) { 6 | CompatibleMode("compatible"), 7 | AllApplication("allApplication") 8 | } 9 | 10 | fun getSoftwareMode(value : String) : SoftwareMode { 11 | return when (value) { 12 | "compatible" -> SoftwareMode.CompatibleMode 13 | "allApplication" -> SoftwareMode.AllApplication 14 | else -> SoftwareMode.AllApplication 15 | } 16 | } 17 | 18 | object Configs { 19 | fun checkAgreeUser(context: Context) : Boolean { 20 | val sp = context.getSharedPreferences("agree", Context.MODE_PRIVATE) 21 | return sp.getBoolean("agree", false) 22 | } 23 | fun setAgreeUser(context: Context, agree: Boolean) { 24 | val sp = context.getSharedPreferences("agree", Context.MODE_PRIVATE) 25 | sp.edit().putBoolean("agree", agree).apply() 26 | } 27 | fun checkFirstLaunch(context: Context) : Boolean { 28 | val sp = context.getSharedPreferences("firstLaunch", Context.MODE_PRIVATE) 29 | return sp.getBoolean("firstLaunch", true) 30 | } 31 | fun setFirstLaunch(context: Context, firstLaunch: Boolean) { 32 | val sp = context.getSharedPreferences("firstLaunch", Context.MODE_PRIVATE) 33 | sp.edit().putBoolean("firstLaunch", firstLaunch).apply() 34 | } 35 | fun getSoftwareMode(context: Context) : SoftwareMode { 36 | val sp = context.getSharedPreferences("softwareMode", Context.MODE_PRIVATE) 37 | return getSoftwareMode(sp.getString("mode", "allApplication")!!) 38 | } 39 | fun setSoftwareMode(context: Context, mode: SoftwareMode) { 40 | val sp = context.getSharedPreferences("softwareMode", Context.MODE_PRIVATE) 41 | sp.edit().putString("mode", mode.value).apply() 42 | } 43 | 44 | // var sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 45 | // return sp.getBoolean("useHyperOSNotices", false) 46 | fun checkUseHyperOSNotices(context: Context) : Boolean { 47 | val sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 48 | return sp.getBoolean("useHyperOSNotices", true) 49 | } 50 | fun setUseHyperOSNotices(context: Context, useHyperOSNotices: Boolean) { 51 | val sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 52 | sp.edit().putBoolean("useHyperOSNotices", useHyperOSNotices).apply() 53 | } 54 | 55 | 56 | // 检查是否接管系统通知 57 | fun checkInterceptSystemNotices(context: Context) : Boolean { 58 | val sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 59 | return sp.getBoolean("interceptSystemNotices", false) 60 | } 61 | fun setInterceptSystemNotices(context: Context, interceptSystemNotices: Boolean) { 62 | val sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 63 | sp.edit().putBoolean("interceptSystemNotices", interceptSystemNotices).apply() 64 | } 65 | 66 | fun setSettingItems(context: Context, label : String, value: Boolean) { 67 | val sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 68 | sp.edit().putBoolean(label, value).apply() 69 | 70 | } 71 | fun getSettingItems(context: Context, label : String, defaultValue:Boolean) : Boolean { 72 | val sp = context.getSharedPreferences("config", Context.MODE_PRIVATE) 73 | return sp.getBoolean(label, defaultValue) 74 | } 75 | 76 | 77 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/utils/MyStoreTools.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.utils 2 | 3 | import android.content.Context 4 | import com.google.gson.Gson 5 | import kg.edu.yjut.enhancenoticehyperos.bean.ChannelInfo 6 | 7 | object MyStoreTools { 8 | 9 | 10 | 11 | 12 | fun getChannalList(context: Context, packageName: String) : List 13 | { 14 | var sp = context.getSharedPreferences("channels", Context.MODE_PRIVATE) 15 | var channelStr = sp.getString(packageName, "[]") 16 | // 转为 数组 对象 17 | return Gson().fromJson(channelStr, Array::class.java).toList() 18 | } 19 | 20 | fun saveChannalList(context: Context, packageName: String, list: List) 21 | { 22 | var sp = context.getSharedPreferences("channels", Context.MODE_PRIVATE) 23 | var channelStr = Gson().toJson(list) 24 | sp.edit().putString(packageName, channelStr).apply() 25 | } 26 | 27 | fun checkChannel(context: Context, packageName: String, channelName: String) : Boolean 28 | { 29 | var sp = context.getSharedPreferences("channels", Context.MODE_PRIVATE) 30 | var channelStr = sp.getString(packageName, "[]") 31 | // 转为 数组 对象 32 | var channelList = Gson().fromJson(channelStr, Array::class.java).toList() 33 | for (channel in channelList) 34 | { 35 | if (channel.channelName == channelName) 36 | { 37 | return true 38 | } 39 | } 40 | return false 41 | } 42 | 43 | fun addChannel(context: Context, packageName: String, channel: ChannelInfo) 44 | { 45 | var sp = context.getSharedPreferences("channels", Context.MODE_PRIVATE) 46 | var channelStr = sp.getString(packageName, "[]") 47 | // 转为 数组 对象 48 | var channelList = Gson().fromJson(channelStr, Array::class.java).toMutableList() 49 | channelList.add(channel) 50 | sp.edit().putString(packageName, Gson().toJson(channelList)).apply() 51 | } 52 | 53 | 54 | fun isPad(context: Context): Boolean { 55 | return context.resources.configuration.smallestScreenWidthDp >= 600 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/utils/PickupCodeUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 The LiteNote Project 3 | * @author OpenAcademic 4 | * @version 1.0 5 | * 6 | */ 7 | package kg.edu.yjut.enhancenoticehyperos.utils 8 | 9 | import android.content.Context 10 | import android.util.Log 11 | import androidx.compose.runtime.MutableState 12 | import androidx.compose.runtime.mutableStateListOf 13 | import androidx.compose.runtime.mutableStateOf 14 | import kotlin.concurrent.thread 15 | 16 | object PickupCodeUtils { 17 | fun isYanzhengma(code: String): Boolean { 18 | // 如果存在 验证码、验证码、验证码字样,说明是验证码 19 | if (code.contains("验证码")) { 20 | return true 21 | } 22 | return false 23 | } 24 | fun getYanzhengma(code:String):String{ 25 | // 验证码通常为4-6位数字、也有甚者是 六位大写字母 26 | // 例如:验证码:123456、验证码:ABCEF、验证码:1234 27 | var reg1 = Regex("[0-9]{4,6}") 28 | var reg2 = Regex("[A-Z]{6}") 29 | var result = reg1.find(code) 30 | if (result!=null) { 31 | // 获取结果 32 | return result.value 33 | 34 | } 35 | result = reg2.find(code) 36 | if (result!=null) { 37 | // 获取结果 38 | return result.value 39 | } 40 | return "" 41 | 42 | 43 | } 44 | 45 | 46 | } -------------------------------------------------------------------------------- /app/src/main/java/kg/edu/yjut/enhancenoticehyperos/utils/SupposedApplication.kt: -------------------------------------------------------------------------------- 1 | package kg.edu.yjut.enhancenoticehyperos.utils 2 | 3 | import android.content.Context 4 | import android.content.pm.ApplicationInfo 5 | import android.content.pm.PackageManager 6 | import androidx.compose.runtime.Composable 7 | import androidx.compose.ui.graphics.Color 8 | import kg.edu.yjut.enhancenoticehyperos.R 9 | import kg.edu.yjut.enhancenoticehyperos.bean.ActionInfo 10 | import kg.edu.yjut.enhancenoticehyperos.bean.ChannelInfo 11 | 12 | var supportList = listOf( 13 | ActionInfo("com.android.mms", "MyHomeActivity", "自动识别短信中的快递取件码短信,通过“舞台动效”提醒您。", listOf()), 14 | ActionInfo("com.tencent.mm", "ChannelActivity", "将微信消息通知通过“舞台动效”提醒您。", listOf( 15 | ChannelInfo( 16 | "message_channel_new_id", "新消息" 17 | ), 18 | ChannelInfo( 19 | "voip_norify_channel_silent1704436236834","音视频消息" 20 | ), 21 | )), 22 | ActionInfo("com.ss.android.ugc.aweme", "ChannelActivity", "将抖音消息通知通过“舞台动效”提醒您。", listOf( 23 | ChannelInfo( 24 | "mipush", "小米推送" 25 | ), 26 | 27 | )), 28 | ActionInfo("com.android.email", "ChannelActivity", "将邮件消息通知通过“舞台动效”提醒您。", listOf( 29 | ChannelInfo( 30 | "mipush", "小米推送" 31 | ), 32 | )), 33 | ActionInfo("com.tencent.mobileqq", "ChannelActivity", "将QQ消息通知通过“舞台动效”提醒您。", listOf( 34 | ChannelInfo( 35 | "mipush", "小米推送" 36 | ), 37 | )), 38 | ActionInfo("com.weico.international", "ChannelActivity", "将微博轻享版消息通知通过“舞台动效”提醒您。", listOf( 39 | ChannelInfo( 40 | "mipush", "小米推送" 41 | ), 42 | )), 43 | ActionInfo("com.sina.weibo", "ChannelActivity", "将微博消息通知通过“舞台动效”提醒您。", listOf( 44 | ChannelInfo( 45 | "mipush", "小米推送" 46 | ), 47 | )), 48 | ActionInfo("com.xingin.xhs", "ChannelActivity", "将小红书消息通知通过“舞台动效”提醒您。", listOf( 49 | ChannelInfo( 50 | "mipush", "小米推送" 51 | ), 52 | )), 53 | ActionInfo("cn.xuexi.android", "ChannelActivity", "将学习强国消息通知通过“舞台动效”提醒您。", listOf( 54 | ChannelInfo( 55 | "mipush", "小米推送" 56 | ), 57 | )), 58 | ActionInfo("com.zhihu.android", "ChannelActivity", "将知乎消息通知通过“舞台动效”提醒您。", listOf( 59 | ChannelInfo( 60 | "mipush", "小米推送" 61 | ), 62 | )), 63 | ActionInfo("tv.danmaku.bili", "ChannelActivity", "将B站消息通知通过“舞台动效”提醒您。", listOf( 64 | ChannelInfo( 65 | "mipush", "小米推送" 66 | ), 67 | )), 68 | 69 | ActionInfo("com.tencent.qqmusic", "ChannelActivity", "将QQ音乐消息通知通过“舞台动效”提醒您。", listOf( 70 | ChannelInfo( 71 | "mipush", "小米推送" 72 | ), 73 | )), 74 | // TMS_CHANNEL_BACKGROUND_SERVICE 75 | ActionInfo("com.miui.tsmclient", "ChannelActivity", "将小米推送消息通知通过“舞台动效”提醒您。", listOf( 76 | ChannelInfo( 77 | "TMS_CHANNEL", "小米智能卡服务" 78 | ), 79 | )), 80 | ) 81 | 82 | var supposedPackageName = arrayOf( 83 | "com.tencent.mm", 84 | "com.ss.android.ugc.aweme", 85 | "com.android.email", 86 | "com.tencent.mobileqq", 87 | "com.weico.international", 88 | "com.sina.weibo", 89 | "com.xingin.xhs", 90 | "cn.xuexi.android", 91 | "com.zhihu.android", 92 | "com.tencent.qqmusic", 93 | "tv.danmaku.bili", 94 | "com.miui.tsmclient" 95 | ) 96 | var supposedIconMap = mapOf( 97 | "com.tencent.mm" to "wechat", 98 | "com.ss.android.ugc.aweme" to "dy", 99 | "com.android.email" to "vpn", 100 | "com.tencent.mobileqq" to "qq", 101 | "com.weico.international" to "weibo", 102 | "com.sina.weibo" to "weibo", 103 | "com.xingin.xhs" to "xhs", 104 | "cn.xuexi.android" to "xuexi", 105 | "com.zhihu.android" to "zhihu", 106 | "com.tencent.qqmusic" to "qqmusic", 107 | "tv.danmaku.bili" to "bili", 108 | "com.miui.tsmclient" to "buss", 109 | ) 110 | var suppsedColorStr = mapOf( 111 | "com.tencent.mm" to "#058B0E", 112 | "com.ss.android.ugc.aweme" to "#FFFFFF", 113 | "com.android.email" to "#91C8E4", 114 | "com.tencent.mobileqq" to "#1296DB", 115 | "com.weico.international" to "#FFFFFF", 116 | "com.sina.weibo" to "#FFFFFF", 117 | "com.xingin.xhs" to "#FFFFFF", 118 | "cn.xuexi.android" to "#D81E06", 119 | "com.zhihu.android" to "#1296db", 120 | "com.tencent.qqmusic" to "#FFD700", 121 | "tv.danmaku.bili" to "#03A7FD", 122 | "com.miui.tsmclient" to "#4871C0", 123 | ) 124 | var supposedDuration = mapOf( 125 | "com.tencent.mm" to 6000L, 126 | "com.ss.android.ugc.aweme" to 4000L, 127 | "com.android.email" to 4000L, 128 | "com.tencent.mobileqq" to 6000L, 129 | "com.weico.international" to 4000L, 130 | "com.sina.weibo" to 5000L, 131 | "com.xingin.xhs" to 5000L, 132 | "cn.xuexi.android" to 5000L, 133 | "com.zhihu.android" to 5000L, 134 | "com.tencent.qqmusic" to 5000L, 135 | "tv.danmaku.bili" to 5000L, 136 | "com.miui.tsmclient" to 5000L, 137 | ) 138 | 139 | fun getIcons(str:String) : Int{ 140 | var icon = when(str){ 141 | "dy" -> R.drawable.dy 142 | "wechat" -> R.drawable.wechat 143 | "vpn" -> R.drawable.vpn 144 | "qq" -> R.drawable.qq 145 | "logo" -> R.drawable.dd 146 | "weibo" -> R.drawable.weibo 147 | "xhs" -> R.drawable.xhs 148 | "xuexi" -> R.drawable.xuexi 149 | "zhihu" -> R.drawable.zhihu 150 | "qqmusic" -> R.drawable.qqmusic 151 | "bili" -> R.drawable.bili 152 | "logo" -> R.drawable.logo 153 | "buss" -> R.drawable.buss 154 | "jieguan" -> R.drawable.ic_launcher_foreground 155 | else -> R.drawable.ic_kuaidi_foreground 156 | } 157 | return icon 158 | } 159 | 160 | 161 | 162 | 163 | 164 | fun getSystemPackages( context : Context) : ArrayList { 165 | var installedPackageList = ArrayList(); 166 | var installedPackageInfoList = context.getPackageManager().getInstalledPackages(PackageManager.MATCH_SYSTEM_ONLY); 167 | 168 | for ( packageInfo in installedPackageInfoList) { 169 | installedPackageList.add(packageInfo.packageName); 170 | } 171 | // 检查 如果 系统 应用 com.miui.tsmclient 存在 , 172 | if(isSystemApplication(context,"com.miui.tsmclient")){ 173 | installedPackageList.add("com.miui.tsmclient"); 174 | } 175 | return installedPackageList; 176 | } 177 | 178 | fun isSystemApplication( context : Context, packageName :String ):Boolean{ 179 | var mPackageManager = context.packageManager; 180 | try { 181 | var packageInfo = mPackageManager.getPackageInfo(packageName, PackageManager.GET_CONFIGURATIONS); 182 | if((packageInfo.applicationInfo!!.flags and ApplicationInfo.FLAG_SYSTEM)!=0){ 183 | return true; 184 | } else { 185 | return false; 186 | } 187 | } catch ( e :PackageManager.NameNotFoundException) { 188 | e.printStackTrace(); 189 | } 190 | return false; 191 | } 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/about.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/back.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_airplane_ticket_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_apps_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_content_copy_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_format_list_bulleted_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_history_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_notifications_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_pause_circle_outline_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_play_circle_outline_24.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bili.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/buss.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/dd.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/dy.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/hyperos.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 11 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_kuaidi_foreground.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | 14 | 16 | 18 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/init.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/island.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | 15 | 17 | 19 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | 14 | 16 | 18 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/nt.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/pa.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/qq.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/qqmusic.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rl.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sendtz.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/tz.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ua.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/vpn.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 13 | 14 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/wechat.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/weibo.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/xfc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/xhs.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 13 | 15 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/zhihu.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/zz.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/code_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/lld.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 22 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/layout/qujianma2.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 25 | 33 | 41 | 42 | 43 | 49 | 50 | 61 | 62 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-xxxhdpi/ic_launcher_playstore.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/yzm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trueWangSyutung/Dynamic-Notification-for-HyperOS/cf7d109942c4097429157c915f6faa023b0ca492/app/src/main/res/mipmap-xxxhdpi/yzm.png -------------------------------------------------------------------------------- /app/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #FF01579B 11 | 12 | #FFE1F5FE 13 | #FF81D4FA 14 | #FF039BE5 15 | #FF01579B 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #FFE1F5FE 11 | 12 | #FFE1F5FE 13 | #FF81D4FA 14 | #FF039BE5 15 | #FF01579B 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #070094 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 灵动通知 3 | AboutActivity 4 | SettingsActivity 5 | HisActivity 6 | MoreFunctionActivity 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |