Skip to content

fix: resolve deprecation warnings in ExportModels, GitHubAppUpdater, and LocalClipboard - #38

Merged
5 commits merged into
masterfrom
fix/deprecation-warnings
Apr 18, 2026
Merged

5 commits merged into
masterfrom
fix/deprecation-warnings

Conversation

@H2OKing89

@H2OKing89 H2OKing89 commented Apr 18, 2026 •

Copy link
Copy Markdown
Owner

This PR fixes deprecation warnings introduced by the dependency updates (e.g. LocalClipboardManager, intent actions, etc).

Summary by CodeRabbit

  • Chores

    • Updated multiple platform and library versions (Kotlin, Compose, AGP, Firebase, protobuf) for stability and security.
  • Refactor

    • Switched clipboard handling to asynchronous APIs for copying/pasting template variables and imports.
    • Clarified deprecation guidance for legacy template defaults to reduce warnings.
  • Bug Fixes

    • Adjusted APK install intent handling for more reliable install behavior.
  • UX

    • Improved template editor error display and updated template-limit messaging to use proper pluralization and ellipsis.

@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5a4fa462-0580-49b3-956b-48c72660577c

📥 Commits

Reviewing files that changed from the base of the PR and between d728dcf and f3880de.

📒 Files selected for processing (2)
  • app/src/main/java/com/kingpaging/qwelcome/ui/templates/TemplateListScreen.kt
  • app/src/main/res/values/strings.xml

📝 Walkthrough

Walkthrough

Enhanced deprecation annotations for legacy defaultTemplateId, silenced deprecation warnings when reading the fallback, changed APK install intent action to ACTION_VIEW, migrated clipboard usage to coroutine-based LocalClipboard in two UI screens, bumped multiple version refs, and adjusted a few UI string/plural resources and proto config.

Changes

Cohort / File(s) Summary
Deprecation Signaling
app/src/main/java/com/kingpaging/qwelcome/data/ExportModels.kt
Added ReplaceWith("defaults.defaultTemplateId") to deprecated defaultTemplateId on TemplatePack and FullBackup. Wrapped fallback reads with @Suppress("DEPRECATION") in getEffectiveDefaultTemplateId(); runtime behavior unchanged.
Installation Intent Revision
app/src/main/java/com/kingpaging/qwelcome/data/GitHubAppUpdater.kt
createInstallIntent() now uses Intent.ACTION_VIEW instead of ACTION_INSTALL_PACKAGE, keeping URI, MIME type, flags, and resolveActivity gating.
Clipboard API Migration
app/src/main/java/com/kingpaging/qwelcome/ui/components/TemplateVariablesSheet.kt, app/src/main/java/com/kingpaging/qwelcome/ui/import_pkg/ImportScreen.kt
Replaced synchronous LocalClipboardManager calls with coroutine-based LocalClipboard getClipEntry() / setClipEntry(ClipEntry(...)). Handlers now use rememberCoroutineScope() and operate asynchronously with ClipData payloads.
Dependency Version Catalog
gradle/libs.versions.toml
Bumped multiple version refs: agp 9.1.0→9.1.1, coreKtx 1.17.0→1.18.0, activityCompose 1.12.2→1.13.0, kotlin 2.2.10→2.3.20, composeBom 2026.01.00→2026.03.01, datastorePreferences 1.2.0→1.2.1, kotlinxSerializationJson 1.10.0→1.11.0, protobuf 3.25.5→4.34.1, navigationCompose 2.9.0→2.9.7, firebaseBom 34.8.0→34.12.0.
UI text & Plurals
app/src/main/res/values/strings.xml, app/src/main/java/.../TemplateListScreen.kt, app/src/main/java/.../TemplateEditorScreen.kt
Converted warning_template_limit to a plurals resource and switched several status strings to use Unicode ellipsis; TemplateListScreen now uses pluralStringResource(...); TemplateEditorScreen passes contentError directly when non-null.
Proto build config
proto/build.gradle.kts
Switched protoc artifact configuration to an explicit Maven coordinate (com.google.protobuf:protoc:${...}) instead of deriving from the version catalog.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI as TemplateVariablesSheet / ImportScreen
    participant Scope as CoroutineScope
    participant LocalCB as LocalClipboard
    participant Android as Android Clipboard

    User->>UI: Tap copy / paste
    UI->>Scope: launch coroutine
    Scope->>LocalCB: setClipEntry(ClipEntry(ClipData))
    Scope->>LocalCB: getClipEntry()
    LocalCB->>Android: read/write ClipData
    Android-->>LocalCB: ClipData response
    LocalCB-->>Scope: suspend returns ClipEntry
    Scope-->>UI: resume with ClipEntry
    UI->>UI: extract text / update state / show toast
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary changes across three main files addressing deprecation warnings from dependency updates (ExportModels, GitHubAppUpdater, LocalClipboard APIs).

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deprecation-warnings

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6f1a438da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

clipboardManager.getText()?.let {
if (exceedsImportLimit(it.text, MAX_IMPORT_SIZE_BYTES)) {
clipboardManager.getClipEntry()?.let {
val text = it.clipData.getItemAt(0).text.toString()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle non-text clipboard items before importing

ClipData.Item.text may be null for URI/intent clipboard entries, and calling toString() here turns that into the literal string "null". That value is then passed to vm.onPasteContent(...), causing a misleading JSON import error path instead of treating the clipboard as non-text/empty. This regression is user-visible when pasting content copied from apps that publish URI-only clip data.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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/com/kingpaging/qwelcome/data/GitHubAppUpdater.kt (1)

213-219: ⚠️ Potential issue | 🟠 Major

Add ACTION_VIEW intent filter to manifest <queries> block to restore APK install on Android 11+.

  • Issue: createInstallIntent() uses Intent.ACTION_VIEW with application/vnd.android.package-archive MIME type, but app/src/main/AndroidManifest.xml:17-26 declares only ACTION_INSTALL_PACKAGE in the <queries> block. On Android 11+, package visibility filtering restricts resolveActivity() to intents declared in the manifest, causing it to return null even when capable installers exist.
  • Impact: Self-update fails with error message "error_update_install_unavailable" on Android 11+ devices (failure is visible, not silent, due to error handling in SettingsViewModel:349-353).
  • Fix: Add the following to the manifest <queries> block:
<intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:mimeType="application/vnd.android.package-archive" />
</intent>
  • Test: On an Android 11+ device/emulator with a downloaded APK, confirm createInstallIntent() returns non-null and install proceeds.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/kingpaging/qwelcome/data/GitHubAppUpdater.kt` around
lines 213 - 219, createInstallIntent() builds an ACTION_VIEW intent with
APK_MIME_TYPE but resolveActivity(...) returns null on Android 11+ because the
manifest's <queries> block only declares ACTION_INSTALL_PACKAGE; update the app
manifest's <queries> block to include an intent query for
android.intent.action.VIEW with data mimeType
"application/vnd.android.package-archive" so
resolveActivity(appContext.packageManager) can find APK installers and
createInstallIntent() returns a non-null installer intent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/java/com/kingpaging/qwelcome/ui/import_pkg/ImportScreen.kt`:
- Around line 202-216: The clipboard handling currently calls
item.clipData.getItemAt(0).text.toString(), which assumes plain text; instead
obtain the first ClipData.Item from clipboardManager.getClipEntry(), call its
coerceToText(context) and treat null/blank as empty/invalid content, then use
that String for exceedsImportLimit(MAX_IMPORT_SIZE_BYTES) and vm.onPasteContent;
if coerceToText yields null/blank, show the R.string.toast_clipboard_empty toast
(and play soundPlayer.playBeep/Toast for oversized content as before) so
Uri/Intent-backed clipboard entries are safely coerced and rejected when not
convertible.

---

Outside diff comments:
In `@app/src/main/java/com/kingpaging/qwelcome/data/GitHubAppUpdater.kt`:
- Around line 213-219: createInstallIntent() builds an ACTION_VIEW intent with
APK_MIME_TYPE but resolveActivity(...) returns null on Android 11+ because the
manifest's <queries> block only declares ACTION_INSTALL_PACKAGE; update the app
manifest's <queries> block to include an intent query for
android.intent.action.VIEW with data mimeType
"application/vnd.android.package-archive" so
resolveActivity(appContext.packageManager) can find APK installers and
createInstallIntent() returns a non-null installer intent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a04cb58b-4a47-4092-a52d-5482f0367558

📥 Commits

Reviewing files that changed from the base of the PR and between ef402b1 and e6f1a43.

📒 Files selected for processing (5)
  • app/src/main/java/com/kingpaging/qwelcome/data/ExportModels.kt
  • app/src/main/java/com/kingpaging/qwelcome/data/GitHubAppUpdater.kt
  • app/src/main/java/com/kingpaging/qwelcome/ui/components/TemplateVariablesSheet.kt
  • app/src/main/java/com/kingpaging/qwelcome/ui/import_pkg/ImportScreen.kt
  • gradle/libs.versions.toml

Comment on lines +202 to 216
scope.launch {
try {
clipboardManager.getText()?.let {
if (exceedsImportLimit(it.text, MAX_IMPORT_SIZE_BYTES)) {
clipboardManager.getClipEntry()?.let {
val text = it.clipData.getItemAt(0).text.toString()
if (exceedsImportLimit(text, MAX_IMPORT_SIZE_BYTES)) {
soundPlayer.playBeep()
Toast.makeText(
context,
context.getString(R.string.toast_import_too_large, maxImportSizeLabel),
Toast.LENGTH_LONG
).show()
} else {
vm.onPasteContent(it.text)
vm.onPasteContent(text)
}
} ?: Toast.makeText(context, R.string.toast_clipboard_empty, Toast.LENGTH_SHORT).show()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Android official docs, can ClipData.Item represent Uri/Intent clipboard content, and is ClipData.Item.coerceToText(Context) the recommended way to convert arbitrary clipboard content into text?

💡 Result:

Yes, according to the official Android documentation, ClipData.Item can represent Uri and Intent clipboard content. Constructors exist for Item(Uri uri) and Item(Intent intent), and items can combine text, Intent, and/or URI. The types an individual item can contain explicitly include Text (CharSequence), Intent (arbitrary Intent object), and Uri (URI reference, often content: URI). Yes, ClipData.Item.coerceToText(Context) is the recommended way to convert arbitrary clipboard content into text. The API reference describes it as turning the item into text regardless of its type, with a fallback algorithm: prioritize getText if available; for Uri, attempt to retrieve text stream from content provider or return URI string; for Intent, convert to intent: URI string; otherwise empty string. The Copy and Paste guide explicitly states: "Even if your application only handles text, you can copy non-text data from the clipboard by converting it with the ClipData.Item.coerceToText(android.content.Context) method." The ClipData reference also notes: "If all you want is the textual representation of the clipped data, you can use the convenience method Item.coerceToText." This is presented as the standard convenience approach for text conversion without needing to handle specific MIME types manually.

Citations:


Use coerceToText(context) for arbitrary clipboard content.

  • Issue: ClipData.Item can carry Uri/Intent content, not just text. Reading .text.toString() directly skips the Android-recommended conversion path and assumes raw text exists.
  • Impact: Non-text clipboard entries bypass proper coercion logic; paste feedback becomes inconsistent and valid text conversions are missed.
  • Fix: Read the first item defensively, convert with coerceToText(context) (official Android clipboard API), and treat blank results as empty clipboard.
  • Test: Paste a Uri/image/file-backed clipboard item from another app; confirm it rejects cleanly without attempting raw import.
Suggested fix
-                                        clipboardManager.getClipEntry()?.let {
-                                            val text = it.clipData.getItemAt(0).text.toString()
-                                            if (exceedsImportLimit(text, MAX_IMPORT_SIZE_BYTES)) {
+                                        clipboardManager.getClipEntry()?.let { entry ->
+                                            val item = entry.clipData
+                                                .takeIf { it.itemCount > 0 }
+                                                ?.getItemAt(0)
+                                            val text = item?.coerceToText(context)?.toString().orEmpty()
+
+                                            if (text.isBlank()) {
+                                                Toast.makeText(
+                                                    context,
+                                                    R.string.toast_clipboard_empty,
+                                                    Toast.LENGTH_SHORT
+                                                ).show()
+                                            } else if (exceedsImportLimit(text, MAX_IMPORT_SIZE_BYTES)) {
                                                 soundPlayer.playBeep()
                                                 Toast.makeText(
                                                     context,
                                                     context.getString(R.string.toast_import_too_large, maxImportSizeLabel),
                                                     Toast.LENGTH_LONG
                                                 ).show()
                                             } else {
                                                 vm.onPasteContent(text)
                                             }
                                         } ?: Toast.makeText(context, R.string.toast_clipboard_empty, Toast.LENGTH_SHORT).show()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/kingpaging/qwelcome/ui/import_pkg/ImportScreen.kt`
around lines 202 - 216, The clipboard handling currently calls
item.clipData.getItemAt(0).text.toString(), which assumes plain text; instead
obtain the first ClipData.Item from clipboardManager.getClipEntry(), call its
coerceToText(context) and treat null/blank as empty/invalid content, then use
that String for exceedsImportLimit(MAX_IMPORT_SIZE_BYTES) and vm.onPasteContent;
if coerceToText yields null/blank, show the R.string.toast_clipboard_empty toast
(and play soundPlayer.playBeep/Toast for oversized content as before) so
Uri/Intent-backed clipboard entries are safely coerced and rejected when not
convertible.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreen.kt (1)

890-896: ⚠️ Potential issue | 🔴 Critical

Nullable format argument passed to stringResource in error text

Line 895: contentError is String?, but stringResource(..., formatArgs: Any) requires non-null arguments. The hasContentError boolean flag does not enable Kotlin smart-cast, leaving contentError nullable in the block.

Fix: Replace if (hasContentError) with if (contentError != null) to trigger smart-cast and guarantee non-null type:

Suggested patch
-                supportingText = if (hasContentError) {
+                supportingText = if (contentError != null) {
                     {
                         Text(
                             text = stringResource(
                                 R.string.error_template_missing_placeholders,
                                 contentError
                             ),

Alternatively, cast explicitly within the current block: requireNotNull(contentError).

Test: Verify Kotlin compiler passes on this module after applying the fix.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreen.kt`
around lines 890 - 896, The supportingText lambda passes contentError (String?)
into stringResource, causing a nullable format argument; change the condition
that controls this block to check the non-nullability (replace if
(hasContentError) with if (contentError != null)) or call
requireNotNull(contentError) inside the block so contentError is a non-null
String when passed to stringResource in TemplateEditorScreen's supportingText
lambda; ensure you update the conditional around supportingText (and any related
uses of hasContentError) so Kotlin can smart-cast contentError to a non-null
type.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@app/src/main/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreen.kt`:
- Around line 890-896: The supportingText lambda passes contentError (String?)
into stringResource, causing a nullable format argument; change the condition
that controls this block to check the non-nullability (replace if
(hasContentError) with if (contentError != null)) or call
requireNotNull(contentError) inside the block so contentError is a non-null
String when passed to stringResource in TemplateEditorScreen's supportingText
lambda; ensure you update the conditional around supportingText (and any related
uses of hasContentError) so Kotlin can smart-cast contentError to a non-null
type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1e6ea16c-13da-4c29-b665-07a871b9fc13

📥 Commits

Reviewing files that changed from the base of the PR and between e6f1a43 and 983014f.

📒 Files selected for processing (2)
  • app/src/main/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreen.kt
  • gradle/libs.versions.toml

@H2OKing89 H2OKing89 closed this pull request by merging all changes into master in a2f46ff Apr 18, 2026
@H2OKing89
H2OKing89 deleted the fix/deprecation-warnings branch August 9, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant