Notes icon indicating copy to clipboard operation
Notes copied to clipboard

Read only feature

Open vbernier02 opened this issue 7 months ago • 17 comments

What is it?

  • [ ] Bugfix
  • [x] Feature
  • [ ] Codebase improvement

Description of the changes in your PR

  • Added read-only functionality which blocks a note if activated
  • Adding a boolean to the class Note to to identify if readonly true or false
  • Added read-only status check function in MainActivity and TextFragment
  • Added 2 buttons for read only option

Before/After Screenshots/Screen Record

  • Before: before2

  • After:

https://github.com/user-attachments/assets/978aded2-edf1-42b3-830e-822c5b13b74f

Fixes the following issue(s)

  • Fixes #69

Acknowledgement

vbernier02 avatar May 06 '25 13:05 vbernier02

@vbernier02 everything okay? :)

naveensingh avatar May 06 '25 15:05 naveensingh

@vbernier02 everything okay? :)

Yes, just a little fix with the import

vbernier02 avatar May 06 '25 15:05 vbernier02

I don't know what to do about NotesDatabase.kt:90:59: This expression contains a magic number. Consider defining it as a well-named constant. [MagicNumber]. There was no error like this in my last pull request, and I haven't changed the file since

vbernier02 avatar May 07 '25 16:05 vbernier02

Hey, don't worry about it for now. Some checks are failing on master as well. I'll be soon updating the contribution guidelines regarding this.

naveensingh avatar May 07 '25 16:05 naveensingh

Thanks for your feedback and the suggestions, I'll try to fix the issues when I have time.

Regarding the loss of the read-only state that’s strange. When I test it, the note retains its read-only state, so I'm not sure how to fix it

I also wanted your opinion on the read-only button icon. Currently, it shows the icon of the mode the note will switch to after clicking it. Currently Read-only disabled: ic_visibility_vector Read-only enabled: edit_24dp_000000_FILL0_wght400_GRAD0_opsz24

Do you think it would be better if the button showed the current mode of the note instead ?

An about the workflow failures should I ignore them ?

vbernier02 avatar Jun 11 '25 15:06 vbernier02

When I test it, the note retains its read-only state, so I'm not sure how to fix it

Ok, I'll check that myself later during review. You may focus on points 2, 3, and 4

Currently, it shows the icon of the mode the note will switch to after clicking it.

This is the expected behavior. Icons in buttons represent the action that will be performed. Not the current state.

(Check this app for example)

An about the workflow failures should I ignore them ?

Yes, ignore detekt and android-lint.

naveensingh avatar Jun 12 '25 05:06 naveensingh

I think this should fix the spell check and keyboard issue. I haven't looked at the undo button yet.

vbernier02 avatar Jun 17 '25 16:06 vbernier02

I think this should fix the spell check and keyboard issue

Yep, those seem to be fixed now :tada:

naveensingh avatar Jun 19 '25 05:06 naveensingh

But it looks like your latest commit broke selection in read-only mode. Now I also get a crash on long press:

Process: org.fossify.notes, PID: 31839
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.Editor$SelectionModifierCursorController.getMinTouchOffset()' on a null object reference
    at android.widget.Editor.touchPositionIsInSelection(Editor.java:1386)
    at android.widget.Editor.performLongClick(Editor.java:1477)
    at android.widget.TextView.performLongClick(TextView.java:13025)
    at android.view.View.performLongClick(View.java:7656)
    at android.view.View$CheckForLongPress.run(View.java:30144)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:211)
    at android.os.Looper.loop(Looper.java:300)
    at android.app.ActivityThread.main(ActivityThread.java:8503)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)

naveensingh avatar Jun 19 '25 05:06 naveensingh

But it looks like your latest commit broke selection in read-only mode. Now I also get a crash on long press:

I haven't been able to reproduce the crash but I think it has to do with the fact that I deleted some lines which during my last tests no longer seem to influence the code. So I think I was wrong.

vbernier02 avatar Jun 19 '25 13:06 vbernier02

I haven't been able to reproduce the crash but I think it has to do with the fact that I deleted some lines

Yes, that was it. No crashes now.

naveensingh avatar Jun 19 '25 14:06 naveensingh

Nice, thank and sorry for making you test it once more. To debug, I use my phone or the Android Studio emulator, but I often feel like it keeps some old code during my tests like the crash you reported, which doesn’t happen on my side possibly. Do you know what might cause that ? Maybe a setting to change in Android Studio or a clear of data/cache ?

vbernier02 avatar Jun 19 '25 16:06 vbernier02

To debug, I use my phone or the Android Studio emulator, but I often feel like it keeps some old code during my tests like the crash you reported, which doesn’t happen on my side possibly. Do you know what might cause that ? Maybe a setting to change in Android Studio or a clear of data/cache ?

It's usually not the build, and some issues only manifest under specific conditions, but here are some options to get a clean slate:

  • Android Studio ➜ Build ➜ Clean project (or run ./gradlew clean in the terminal)
  • Clear data or uninstall the app. You can install ADB Idea plugin from the marketplace if you find yourself doing this often.

naveensingh avatar Jun 20 '25 03:06 naveensingh

This pull request was automatically closed due to inactivity and/or lack of response from the author. If you have further updates or additional information, please comment or reopen the PR to continue.

fossifybot[bot] avatar Jul 03 '25 12:07 fossifybot[bot]

Hey, still working on this? I'm happy to take it from here if you aren't free.

naveensingh avatar Jul 03 '25 14:07 naveensingh

Hey, still working on this? I'm happy to take it from here if you aren't free.

Sorry, I've been pretty busy lately and probably will be for a while longer. No problem, you can continue the feature if you want.

vbernier02 avatar Jul 04 '25 12:07 vbernier02

Okay. Thanks for working on this!

naveensingh avatar Jul 04 '25 13:07 naveensingh