Skip to content

Comments

[ui] add notification settings#309

Merged
capcom6 merged 3 commits intomasterfrom
issue/304-sorce-sse
Feb 17, 2026
Merged

[ui] add notification settings#309
capcom6 merged 3 commits intomasterfrom
issue/304-sorce-sse

Conversation

@capcom6
Copy link
Owner

@capcom6 capcom6 commented Jan 18, 2026

Summary by CodeRabbit

  • New Features

    • Added a notification mode preference in server settings with choices "Auto" and "SSE Only" and a notification icon.
  • New Resources

    • Added paired display titles and non‑translatable values for the notification mode.
    • Added visible strings and localized translations.
  • Behavior Change

    • Selecting "SSE Only" skips push-token registration.
  • Style

    • Reflowed/reformatted several string and XML resources (visible text unchanged).

@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds notification channel resources, UI and icon; introduces NotificationChannel enum and storage/export/import; makes DevicePatchRequest.pushToken nullable and always sent; PushService skips FCM registration when channel is SSE_ONLY; minor string formatting and preference whitespace tweaks.

Changes

Cohort / File(s) Summary
Resources: arrays & strings
app/src/main/res/values/arrays.xml, app/src/main/res/values/strings.xml, app/src/main/res/values-ru/strings.xml, app/src/main/res/values-zh/strings.xml
Added notification_channels_titles and notification_channels_values arrays; added notification_channel and notifications strings (including RU/ZH localizations); various string reflows/wrapping.
Preferences: server UI
app/src/main/res/xml/cloud_server_preferences.xml
Added ListPreference gateway.notification_channel using new arrays, default AUTO, icon @drawable/ic_notifications, and simple summary provider.
Drawable: notification icon
app/src/main/res/drawable/ic_notifications.xml
Added 24×24 vector drawable ic_notifications.
Preferences: whitespace tweak
app/src/main/res/xml/root_preferences.xml
Minor whitespace change in a self-closing preference tag.
Gateway settings & storage
app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewaySettings.kt
Added NotificationChannel enum (AUTO, SSE_ONLY), notificationChannel storage-backed property, NOTIFICATION_CHANNEL key, and import/export handling for the key.
API / device patch
app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayApi.kt
Made DevicePatchRequest.pushToken nullable.
Gateway service usage
app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewayService.kt
Removed null-guard; api.devicePatch is invoked regardless of pushToken being null.
Push registration flow
app/src/main/java/me/capcom/smsgateway/services/PushService.kt
If GatewaySettings.notificationChannel == SSE_ONLY, registration returns early after starting RegistrationWorker with a null token (skips FCM registration).
Orchestrator service
app/src/main/java/me/capcom/smsgateway/modules/orchestrator/OrchestratorService.kt
Removed platform-specific guard and early-return when starting services; added separate receiver registration try/catch and distinct warning log on failure.

Sequence Diagram(s)

sequenceDiagram
    participant Push as PushService
    participant Settings as GatewaySettings
    participant FCM as FcmRegistrar
    participant Worker as RegistrationWorker
    participant API as GatewayApi

    Push->>Settings: read notificationChannel
    alt notificationChannel == SSE_ONLY
        Push->>Worker: start(token=null, persist=false)
        Worker-->>Push: started
        Push-->>Push: return (skip FCM)
    else
        Push->>FCM: perform FCM registration
        FCM-->>Push: token
        Push->>Worker: start(token, persist=true)
        Worker->>API: devicePatch(pushToken=token or null)
        API-->>Worker: response
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and directly summarizes the primary change: adding notification settings UI components, which is the core purpose evident across all modified files (new ListPreference, string resources, enum, and service integration).
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue/304-sorce-sse

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@app/src/main/res/values/strings.xml`:
- Around line 70-79: The three description resources
(notification_mode_auto_description, notification_mode_fcm_only_description,
notification_mode_sse_only_description) are unused because the ListPreference in
notification_preferences.xml uses app:useSimpleSummaryProvider="true" which only
shows the selected title from notification_modes_titles; either remove the
unused strings or wire them into the UI: to wire them, replace
useSimpleSummaryProvider with an entrySummaries array (or set android:summary to
reference entrySummaries) that maps to these three description strings, or
implement a custom SummaryProvider in your PreferenceFragmentCompat (in the
fragment class that loads notification_preferences.xml) to set the
ListPreference summary based on the selected value and the corresponding
description resource; update the ListPreference declaration (same preference
key/name as the existing ListPreference) or the fragment's onCreatePreferences
logic to point to notification_mode_auto_description,
notification_mode_fcm_only_description, and
notification_mode_sse_only_description so they are actually displayed.

In `@app/src/main/res/xml/root_preferences.xml`:
- Around line 26-29: The Preference element for NotificationSettingsFragment
uses a hardcoded summary and lacks an icon; add a new string resource named
notification_delivery_mode_selection in strings.xml with the English text, then
update the Preference (the element with
app:fragment="me.capcom.smsgateway.ui.settings.NotificationSettingsFragment") to
use android:summary="@string/notification_delivery_mode_selection" and add the
same android:icon attribute pattern used by the other preferences (match their
drawable resource) so the preference is localizable and visually consistent.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@app/src/main/res/xml/cloud_server_preferences.xml`:
- Around line 15-22: The ListPreference element using android:icon should be
changed to use the AndroidX attribute app:icon for consistency with other
preferences; locate the ListPreference with key "gateway.notification_mode" and
replace the android:icon attribute with app:icon="@drawable/ic_notifications" so
the Preference (ListPreference) uses the androidx preference attribute namespace
like the EditTextPreference entries.

@capcom6 capcom6 force-pushed the issue/304-sorce-sse branch from de5bcec to 6e0d6b5 Compare January 20, 2026 01:37
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@app/src/main/java/me/capcom/smsgateway/modules/gateway/GatewaySettings.kt`:
- Around line 89-97: The import path for NOTIFICATION_CHANNEL uses
NotificationChannel.valueOf which will throw IllegalArgumentException on invalid
strings and abort the import; update the NOTIFICATION_CHANNEL branch to parse
safely (e.g., wrap NotificationChannel.valueOf in runCatching/try-catch or
lookup via enum values) to fall back to NotificationChannel.AUTO on failure,
keep the existing changed calculation (compare notificationChannel to the
resolved newValue) and still call storage.set(it.key, newValue.name) so invalid
inputs become AUTO instead of crashing the import.
- Around line 42-43: The stored enums were saved as raw names (e.g., "AUTO") but
the getters call storage.get<T>(...) which triggers Gson deserialization and
fails on unquoted strings; update each enum getter (e.g.,
GatewaySettings.notificationChannel and MessagesSettings.limitPeriod,
simSelectionMode, processingOrder) to read the stored value as a plain String
via storage.get<String>(KEY) (or storage.getFallback path) and then convert to
the enum using a safe mapping (e.g., EnumName.values().find { it.name == stored
} ?: DEFAULT) so invalid/missing values fall back to the existing defaults;
ensure the import() behavior (which uses storage.set(key, newValue.name))
remains unchanged and add this manual String-to-enum conversion wherever enums
are read from storage.
🧹 Nitpick comments (1)
app/src/main/java/me/capcom/smsgateway/services/PushService.kt (1)

59-62: Consider adding a log entry for the SSE_ONLY early-exit path.

The normal FCM registration path logs "FCM registration started" (Line 68), but the SSE_ONLY short-circuit is silent. A brief log entry here would help with debugging notification channel issues.

Proposed change
             if (settings.notificationChannel == GatewaySettings.NotificationChannel.SSE_ONLY) {
+                logger.insert(
+                    priority = LogEntry.Priority.INFO,
+                    module = PushService::class.java.simpleName,
+                    message = "FCM registration skipped: SSE_ONLY channel configured"
+                )
                 RegistrationWorker.start(context, null, false)
                 return
             }

@capcom6 capcom6 force-pushed the issue/304-sorce-sse branch from 6360438 to df340e9 Compare February 13, 2026 02:31
@capcom6 capcom6 marked this pull request as ready for review February 13, 2026 09:12
@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

🤖 Pull request artifacts

file commit
app-release.apk cce8be9
app-release.aab cce8be9
app-insecure.apk cce8be9
app-insecure.aab cce8be9

@capcom6 capcom6 added the ready label Feb 14, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/src/main/java/me/capcom/smsgateway/modules/orchestrator/OrchestratorService.kt (1)

34-54: ⚠️ Potential issue | 🔴 Critical

Bug: receiverService.start(context) is called twice.

receiverService.start(context) appears at line 37 (inside the foreground-services try block) and again at line 47 (in its own try block). Based on the summary, the intent was to decouple receiver registration into a separate try/catch — line 37 should have been removed.

Additionally, both catch blocks swallow the exception entirely (e is never referenced). Including the exception message in the log entries would aid debugging. This aligns with the detekt SwallowedException warning.

Proposed fix
         try {
             localServerSvc.start(context)
             pingSvc.start(context)
-            receiverService.start(context)
         } catch (e: Throwable) {
             logsSvc.insert(
                 LogEntry.Priority.WARN,
                 MODULE_NAME,
-                "Can't start foreground services while the app is running in the background"
+                "Can't start foreground services while the app is running in the background: ${e.message}"
             )
         }
 
         try {
             receiverService.start(context)
         } catch (e: Throwable) {
             logsSvc.insert(
                 LogEntry.Priority.WARN,
                 MODULE_NAME,
-                "Can't register receiver"
+                "Can't register receiver: ${e.message}"
             )
         }

@capcom6 capcom6 merged commit f5a24db into master Feb 17, 2026
3 checks passed
@capcom6 capcom6 deleted the issue/304-sorce-sse branch February 17, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Private server: messages are not delivered in real time when outbound internet is restricted (FCM relay unreachable)

1 participant