diff --git a/android/app/build.gradle b/android/app/build.gradle index e50d108..7984e2d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -18,7 +18,7 @@ android { } } - // 显式统一 Java / Kotlin 的编译目标版本,保持与 Capacitor 生成配置一致(Java 21) + // 鏄惧紡缁熶竴 Java / Kotlin 鐨勭紪璇戠洰鏍囩増鏈紝淇濇寔涓 Capacitor 鐢熸垚閰嶇疆涓鑷达紙Java 21锛 compileOptions { sourceCompatibility JavaVersion.VERSION_21 targetCompatibility JavaVersion.VERSION_21 @@ -52,4 +52,5 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } -apply from: 'capacitor.build.gradle' \ No newline at end of file +apply from: 'capacitor.build.gradle' + diff --git a/android/app/src/main/java/com/echo/app/notification/NotificationBridgePlugin.kt b/android/app/src/main/java/com/echo/app/notification/NotificationBridgePlugin.kt index c394947..ae28c57 100644 --- a/android/app/src/main/java/com/echo/app/notification/NotificationBridgePlugin.kt +++ b/android/app/src/main/java/com/echo/app/notification/NotificationBridgePlugin.kt @@ -1,9 +1,10 @@ -package com.echo.app.notification +锘縫ackage com.echo.app.notification import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter +import android.provider.Settings import androidx.core.app.NotificationManagerCompat import com.getcapacitor.JSArray import com.getcapacitor.JSObject @@ -12,7 +13,7 @@ import com.getcapacitor.PluginCall import com.getcapacitor.PluginMethod import com.getcapacitor.annotation.CapacitorPlugin -// Capacitor 插件:向前端暴露通知权限检查、队列读取,以及通知到达事件 +// Capacitor 鎻掍欢锛氬悜鍓嶇鏆撮湶閫氱煡鏉冮檺銆侀氱煡闃熷垪浠ュ強閫氱煡浜嬩欢 @CapacitorPlugin(name = "NotificationBridge") class NotificationBridgePlugin : Plugin() { @@ -21,7 +22,7 @@ class NotificationBridgePlugin : Plugin() { override fun load() { super.load() - // 监听来自 NotificationBridgeService 的应用内广播,并转发为 JS 事件 + // 鐩戝惉 NotificationBridgeService 鍙戦佺殑搴旂敤鍐呭箍鎾紝骞惰浆鍙戜负 JS 浜嬩欢 val filter = IntentFilter("com.echo.app.NOTIFICATION_POSTED") notificationPostedReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { @@ -52,10 +53,19 @@ class NotificationBridgePlugin : Plugin() { @PluginMethod fun requestPermission(call: PluginCall) { - // 当前仅返回状态,如需引导用户可在前端跳转到系统设置 + // 褰撳墠浠呰繑鍥炴潈闄愮姸鎬侊紝瀹為檯鐨勫紩瀵兼枃妗堝拰璺宠浆鐢卞墠绔帶鍒 hasPermission(call) } + @PluginMethod + fun openNotificationSettings(call: PluginCall) { + // 璺宠浆鍒扮郴缁熺殑鈥滈氱煡浣跨敤鏉冣濊缃〉闈紝寮曞鐢ㄦ埛鎵嬪姩寮鍚洃鍚潈闄 + val intent = Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS) + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + context.startActivity(intent) + call.resolve() + } + @PluginMethod fun getPendingNotifications(call: PluginCall) { val queue = NotificationStorage.list(context) @@ -80,4 +90,4 @@ class NotificationBridgePlugin : Plugin() { NotificationStorage.clear(context) call.resolve() } -} \ No newline at end of file +} diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index c1b0f2b..90836f6 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,10 +1,13 @@ - - +锘 + - +