Skip to content

ADFA-2548 | Fix drag-and-drop crash on Android 12+ for TextViews#875

Merged
jatezzz merged 1 commit intostagefrom
fix/ADFA-2548-textview-drag-crash
Jan 26, 2026
Merged

ADFA-2548 | Fix drag-and-drop crash on Android 12+ for TextViews#875
jatezzz merged 1 commit intostagefrom
fix/ADFA-2548-textview-drag-crash

Conversation

@jatezzz
Copy link
Collaborator

@jatezzz jatezzz commented Jan 23, 2026

Description

This PR fixes a NullPointerException occurring on Android 12+ (API 31) when dropping elements onto an EditText or other TextView subclasses within the Design Editor.

The crash happens because android.widget.Editor attempts to handle the ACTION_DROP event assuming valid ClipData, which is null during internal drag operations. To prevent this, I introduced a configureForDesignMode extension function that:

  • Disables focus and touch mode focus for all views.
  • Explicitly disables textIsSelectable, cursorVisible, and removes the keyListener for TextView subclasses.

This ensures these components remain passive visual elements in the editor, preventing the system's text editing logic from intercepting drag events. Additionally, I refactored the Spinner listener assignment for better readability.

Details

Logic-related fix. This resolves the following crash on API 31+:
java.lang.NullPointerException: null at android.widget.Editor.onDrop(Editor.java:3089)

Before changes

Screen.Recording.2026-01-23.at.12.11.53.PM.mov

After changes

Screen.Recording.2026-01-23.at.12.14.18.PM.mov

Ticket

ADFA-2548

Observation

This fix applies to all views inheriting from TextView (e.g., Button, CheckBox, EditText), ensuring consistency across the editor.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Warning

Rate limit exceeded

@jatezzz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Introduced a private extension function View.configureForDesignMode() in the DesignEditor that disables focusability, text editing, cursor visibility, and text selection for views in design mode. The function is applied to views during rearrangement operations, with minor formatting adjustments to listener blocks.

Changes

Cohort / File(s) Summary
Design Mode View Configuration
layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DesignEditor.kt
Added private extension function View.configureForDesignMode() that disables focus, touch focus, and text editing capabilities (keyListener, cursor, selection) for TextView subclasses. Applied during view rearrangement. Includes minor Spinner listener formatting adjustments.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • Daniel-ADFA
  • jomen-adfa

Poem

🐰 In design mode, views must be still,
No tapping, typing, or cursor's thrill,
An extension so neat, a helper most fine,
Makes interactive elements resign.
Arranged and disabled—perfectly mine! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% 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
Title check ✅ Passed The title directly matches the main fix: resolving a drag-and-drop crash on Android 12+ for TextViews, which is the primary change in the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the NullPointerException crash, the introduced configureForDesignMode extension function, and the specific changes made to fix the issue.

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


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
Contributor

@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
`@layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DesignEditor.kt`:
- Around line 579-584: The empty override onNothingSelected in the anonymous
AdapterView.OnItemSelectedListener is flagged by detekt; update the override in
the view.onItemSelectedListener block (the onNothingSelected(parent:
AdapterView<*>?)) to include an explicit no-op comment (e.g. add a "// no-op"
comment inside the method body) so the empty override is intentional and detekt
stops flagging it, leaving the onItemSelected implementation that calls
showDefinedAttributes(view) unchanged.

@jatezzz jatezzz requested a review from a team January 23, 2026 21:31
…View interaction

Disable text selection and input focus in DesignEditor to avoid conflictive base class interactions in TextView.
@jatezzz jatezzz force-pushed the fix/ADFA-2548-textview-drag-crash branch from 256e6a2 to 6a32976 Compare January 26, 2026 13:10
@jatezzz jatezzz merged commit 2213623 into stage Jan 26, 2026
2 checks passed
@jatezzz jatezzz deleted the fix/ADFA-2548-textview-drag-crash branch January 26, 2026 15:11
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.

2 participants