Yanndroid / NotiNotes

A Notes app living in your notification panel
https://play.google.com/store/apps/details?id=de.dlyt.yanndroid.notinotes
MIT License
61 stars 7 forks source link

Deleting/Editing a note sometimes does not work #6

Closed Garbaz closed 2 years ago

Garbaz commented 2 years ago

Sometimes, when I press the "edit" or the "delete" button inside the notification, nothing happens, no matter if I re-open the detailed view of the notification, or pull the notification area back up and back down. However, if I open the dialogue to create a new note once, and exit it again, then "edit" and "delete" work again.

Unfortunately, I can't seem to find some clear steps to reproduce this reliably. Even if I "Force Stop" the app, the edit/delete buttons still work. I just create a new note, wait for a while, and then I can no longer edit or delete it. Though once that happens, I can reliably get it to work again by opening the creation dialog briefly.

Garbaz commented 2 years ago

Looking through the code a bit, other than the possibility of the Dialog constructor somehow messing up, what appears as a potential origin to me might be the if (requestPermission()) return at the beginning of all dialogues, since requestPermission() appears to return false if Settings.canDrawOverlays(context) returns true. I.e., we don't start the dialogue if the permission has been granted? Is this intended?

Of course this wouldn't explain why the normal create dialog works perfectly fine for me, and only the dialogues started from the notification do not.

Speculation 2: Does it make sense to use this, i.e. the TileService as the context, even if we start the dialogue not from the actual TileService? Wouldn't getApplicationContext() be more sensible there?

Yanndroid commented 2 years ago

I'm aware of this issue and the problem is that sometimes the service isn't running and therefore interacting with the notification does nothing. I've also updated the playstore description recently, mentioning this exact issue:

- There is a bug which prevents the user from interacting with the notification (edit, delete, etc.). It will be fixed in the next update. In the meantime you have to add the tile in the first row (i.e. the tile has to be visible when interacting).

I have a plan for an update that should fix this and also other stuff regarding android 12, but I'm very busy lately. I hope I can make the update by the end of next week.

Yanndroid commented 2 years ago

What I need to do is make the BroadcastReceiver mBroadcastReceiver independent from the service and register it directly in manifest. But this will cause a lot of other problems, I'll also have to fix. That's why it might take some time.

Garbaz commented 2 years ago

Alright, no hurry, I'm very happy with the app either way. Now that I have figured out a way to reliably be able to edit/delete notes, it's not much of a bother.

I'd love to contribute some code, but as evident by my gross misdiagnosis, I don't know much about Android development.

Yanndroid commented 2 years ago

Thanks, I wouldn't blame your diagnosis though. requestPermission() does in fact return false if Settings.canDrawOverlays(context) is true. My method name is a bit misleading, because it not only requests the permission but also returns if the permission had to be requested. if (requestPermission()) return will then interrupt the code and not show an overlay. Another thing to mention is that this is my first app in kotlin and thus allowed me to learn the language, so the code might not be very clean and optimized. Contribution is always welcome and I think even if you don't have a lot of experience in android development, what your doing right now is the way to go. By analyzing app source codes and trying to understand why something might not work is how you understand how the rest works imo. So keep it up and you'll be making awesome android apps soon.👌

Yanndroid commented 2 years ago

Fixed in v1.3.3