Repository navigation
fix: resolve deprecation warnings in ExportModels, GitHubAppUpdater, and LocalClipboard - #38
5 commits merged into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughEnhanced deprecation annotations for legacy Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 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() |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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 | 🟠 MajorAdd
ACTION_VIEWintent filter to manifest<queries>block to restore APK install on Android 11+.
- Issue:
createInstallIntent()usesIntent.ACTION_VIEWwithapplication/vnd.android.package-archiveMIME type, butapp/src/main/AndroidManifest.xml:17-26declares onlyACTION_INSTALL_PACKAGEin the<queries>block. On Android 11+, package visibility filtering restrictsresolveActivity()to intents declared in the manifest, causing it to returnnulleven 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
📒 Files selected for processing (5)
app/src/main/java/com/kingpaging/qwelcome/data/ExportModels.ktapp/src/main/java/com/kingpaging/qwelcome/data/GitHubAppUpdater.ktapp/src/main/java/com/kingpaging/qwelcome/ui/components/TemplateVariablesSheet.ktapp/src/main/java/com/kingpaging/qwelcome/ui/import_pkg/ImportScreen.ktgradle/libs.versions.toml
| 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() |
There was a problem hiding this comment.
🧩 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:
- 1: https://developer.android.com/reference/android/content/ClipData.Item
- 2: https://developer.android.com/reference/kotlin/android/content/ClipData.Item
- 3: https://developer.android.com/reference/android/content/ClipData
- 4: https://developer.android.com/develop/ui/views/touch-and-input/copy-paste
Use coerceToText(context) for arbitrary clipboard content.
- Issue:
ClipData.Itemcan 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.
There was a problem hiding this comment.
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 | 🔴 CriticalNullable format argument passed to
stringResourcein error textLine 895:
contentErrorisString?, butstringResource(..., formatArgs: Any)requires non-null arguments. ThehasContentErrorboolean flag does not enable Kotlin smart-cast, leavingcontentErrornullable in the block.Fix: Replace
if (hasContentError)withif (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
📒 Files selected for processing (2)
app/src/main/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreen.ktgradle/libs.versions.toml
This PR fixes deprecation warnings introduced by the dependency updates (e.g. LocalClipboardManager, intent actions, etc).
Summary by CodeRabbit
Chores
Refactor
Bug Fixes
UX