nextcloud / nextcloud/notes-android

Crash while switching to hardware keyboard: `IllegalStateException: Fragment NoteEditFragment [...] not attached to a context`

Open
#1,982 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
1.1k
Forks
168
Avg merge
1d 17h
Merged PRs (30d)
31

Description

Describe the bug
Whenenver I switch from the software keyboard (default Google keyboard app) to my hardware keyboard (Logitech G910, connected via Bluetooth) the Nextcloud Notes application crashes showing a stack trace. The keyboard switch happens by enabling Bluetooth mode on the keyboard which results in the keyboard connecting to the Android tablet triggering it. Switching from hardware to software keyboard works without any problems. If there's no active note opened for editing, there is also no crash.

To Reproduce
Steps to reproduce the behavior:

  1. Open a new or existing note in Nextcloud Notes
  2. Connect a keyboard via bluetooth
  3. See the error message

Expected behavior
The app continues to function without a crash while switching to hardware keyboard.

Screenshots
No screenshot since it instantly shows the posted exception message.

Smartphone (please complete the following information):

  • Nextcloud Notes-Version (android app): 4.1.0
  • F-Droid or Play Store: Play Store
  • Android-Version: 14
  • Device: Pixel Tablet

Server

  • Nextcloud version: 28.0.1
  • Nextcloud Notes version (server app): 4.9.2

Stacktrace

App Version: 4.1.0
App Version Code: 40010090
App Flavor: play

Files App Version Code: 30270090 (PROD)

---

OS Version: 5.10.177-android13-4-00003-ga7208022a7ea-ab10815828(11129216)
OS API Level: 34
Device: tangorpro
Manufacturer: Google
Model (and Product): Pixel Tablet (tangorpro)

---
java.lang.IllegalStateException: Fragment NoteEditFragment{fe3e016} (292b85d9-dd9e-4b22-ac32-fd0f9b940c55) not attached to a context.
	at androidx.fragment.app.Fragment.requireContext(Fragment.java:972)
	at it.niedermann.owncloud.notes.edit.NoteEditFragment.onNoteLoaded(NoteEditFragment.java:165)
	at it.niedermann.owncloud.notes.edit.BaseNoteFragment.lambda$onViewCreated$3$it-niedermann-owncloud-notes-edit-BaseNoteFragment(BaseNoteFragment.java:134)
	at it.niedermann.owncloud.notes.edit.BaseNoteFragment$$ExternalSyntheticLambda9.run(Unknown Source:2)
	at android.os.Handler.handleCallback(Handler.java:958)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8248)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with NoteEditFragment.onNoteLoaded at NoteEditFragment.java:165 and trace the callback from BaseNoteFragment.onViewCreated at BaseNoteFragment.java:134. Reproduce the crash by switching to a Bluetooth hardware keyboard while editing a note, then verify that the note editor remains usable and no detached-fragment exception occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.