Conversation
| getCurrentFragment()?.apply { | ||
| if (this is TextFragment) { | ||
| (this as TextFragment).getNotesView().isEnabled = !mCurrentNote.isReadOnly | ||
| } | ||
| } |
There was a problem hiding this comment.
Since you are already checking the type, there's no need to cast it explicitly:
| getCurrentFragment()?.apply { | |
| if (this is TextFragment) { | |
| (this as TextFragment).getNotesView().isEnabled = !mCurrentNote.isReadOnly | |
| } | |
| } | |
| getCurrentFragment()?.apply { | |
| if (this is TextFragment) { | |
| getNotesView().isEnabled = !mCurrentNote.isReadOnly | |
| } | |
| } |
or using the safe cast operator:
| getCurrentFragment()?.apply { | |
| if (this is TextFragment) { | |
| (this as TextFragment).getNotesView().isEnabled = !mCurrentNote.isReadOnly | |
| } | |
| } | |
| (getCurrentFragment() as? TextFragment) | |
| ?.getNotesView()?.isEnabled = !mCurrentNote.isReadOnly |
| getCurrentFragment()?.apply { | ||
| if (this is TextFragment) { | ||
| (this as TextFragment).getNotesView().isEnabled = !mCurrentNote.isReadOnly | ||
| } | ||
| } |
There was a problem hiding this comment.
You could replace this duplicated code with a call to checkReadOnlyState():
| getCurrentFragment()?.apply { | |
| if (this is TextFragment) { | |
| (this as TextFragment).getNotesView().isEnabled = !mCurrentNote.isReadOnly | |
| } | |
| } | |
| checkReadOnlyState() |
| if (note.isReadOnly) { | ||
| Handler(Looper.getMainLooper()).post { | ||
| callback?.invoke(noteId) | ||
| } | ||
| } else { | ||
| Handler(Looper.getMainLooper()).post { | ||
| callback?.invoke(noteId) | ||
| } |
There was a problem hiding this comment.
This change is redundant. Both branches here contain identical code.
app/src/main/res/values/strings.xml
Outdated
| <string name="read_only">Note read only</string> | ||
| <string name="read_only_disable">Note read only disable</string> |
There was a problem hiding this comment.
These strings aren't very descriptive. Let's replace them with:
- "Switch to preview mode"
- "Switch to edit mode"
The icon for "Switch to edit mode" should be a pencil (the drawable's already in the app so you just have to reference it with @drawable/ic_edit_vector)
|
Hey, I knew you would persevere ;) The feature itself seems to be working fine, I left some comments above regarding the code. Let me know if you run into any issues implementing the suggestions. I think it would be better to replace the 'read only' terminology with 'preview mode' as suggested in #103 (comment). Thanks! |
| private fun checkReadOnlyState() { | ||
| getCurrentFragment()?.apply { | ||
| if (this is TextFragment) { | ||
| (this as TextFragment).getNotesView().isEnabled = !mCurrentNote.isReadOnly |
There was a problem hiding this comment.
This is probably not the best way to disable the text input. Disabling the view disables a lot of things, not just the input.
I think one should be able to select and copy the text when preview/read-only mode is enabled.
There was a problem hiding this comment.
Yes, that's true. But I haven't found another way to do it. I tried to do it by modifying the properties of EditText to block writing, but it didn't work.
|
It doesn't seem to work correctly. Some bugs I've encountered:
Generally, it looks like instead of doing real read-only mode, you're only hiding a virtual keyboard. |
|
Thank you for your feedback and for taking the time to review my work. I will continue my work based on the remarks you left me. I haven’t really found how to implement a true read-only mode or where to modify it, but I will keep working on my side to find a better way to implement it. |
|
Great! Just some pointers: 1 and 2 are probably the result of using You should be able to fix point 3 and 4 by updating the view's read only state when TextFragment's is resumed. Right now it's only updated in MainActivity. |
What is it?
Description of the changes in your PR
Before/After Screenshots/Screen Record
after.mp4
Fixes the following issue(s)
Acknowledgement