Skip to content

Read only feature #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

Read only feature #123

wants to merge 30 commits into from

Conversation

vbernier02
Copy link

What is it?

  • Bugfix
  • 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:
after_read_only.mp4

Fixes the following issue(s)

Acknowledgement

@vbernier02 vbernier02 closed this May 6, 2025
@naveensingh
Copy link
Member

@vbernier02 everything okay? :)

@vbernier02 vbernier02 reopened this May 6, 2025
@vbernier02
Copy link
Author

@vbernier02 everything okay? :)

Yes, just a little fix with the import

@vbernier02
Copy link
Author

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

@naveensingh
Copy link
Member

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 naveensingh self-assigned this May 26, 2025
Copy link
Member

@naveensingh naveensingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found some issues:

  1. The read-only state is still lost on app restart. I think we can remove persistence for now and keep it session-based. It'll be a simpler implementation and probably less confusing for most users.
  2. Spell check should be disabled in read-only mode. Right now, I can modify the note by tapping highlighted words or phrases (check out this)
  3. The keyboard should be hidden automatically when read-only mode is activated (use hideKeyboard extension)
  4. The undo button now appears automatically on startup, even when there are no edits.

@naveensingh naveensingh added the waiting for author If the author does not respond, the issue will be closed. Otherwise, the label will be removed. label Jun 8, 2025
@vbernier02
Copy link
Author

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 ?

@naveensingh
Copy link
Member

naveensingh commented Jun 12, 2025

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 naveensingh removed their assignment Jun 12, 2025
@vbernier02
Copy link
Author

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

@naveensingh
Copy link
Member

I think this should fix the spell check and keyboard issue

Yep, those seem to be fixed now 🎉

@naveensingh
Copy link
Member

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 naveensingh added waiting for author If the author does not respond, the issue will be closed. Otherwise, the label will be removed. and removed waiting for author If the author does not respond, the issue will be closed. Otherwise, the label will be removed. labels Jun 19, 2025
@vbernier02
Copy link
Author

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.

@naveensingh
Copy link
Member

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.

@vbernier02
Copy link
Author

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 ?

@naveensingh
Copy link
Member

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.

@fossifybot
Copy link
Contributor

fossifybot bot commented Jul 3, 2025

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 fossifybot bot removed the waiting for author If the author does not respond, the issue will be closed. Otherwise, the label will be removed. label Jul 3, 2025
@fossifybot fossifybot bot closed this Jul 3, 2025
@naveensingh
Copy link
Member

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

@vbernier02
Copy link
Author

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.

@naveensingh naveensingh reopened this Jul 4, 2025
@naveensingh naveensingh self-assigned this Jul 4, 2025
@naveensingh
Copy link
Member

Okay. Thanks for working on this!

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.

[fr] read only
2 participants