Crash while switching to hardware keyboard: `IllegalStateException: Fragment NoteEditFragment [...] not attached to a context`
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:
- Open a new or existing note in Nextcloud Notes
- Connect a keyboard via bluetooth
- 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)