Shortcuts/share to ankidroid should not crash the app when the file permissions are missing
How to reproduce:
- install ankidroid from a source that is not the playstore. If you build ankidroid yourself, you can use the full variant.
- open ankidroid, give permission to access file
- open the settings, go to apps > Special app access> all files access> ankidroid> toggle off "allow access to manage all files" (Or, you can wait a few months, android remove permissions to apps that are not used)
- Then, either:
- long tap ankidroid, and open the shortcut for study, add or card browser
- select some text, and share it with ankidroid, with note editor or instant note editor ( ping @criticalAY )
- select an image, and share it to ankidroid > Add Image
Actual result:
- You'll see a snackbar "Missinq required storage permission. Please grant storage permission then r..."
Expected result:
- same as when you open ankidroid directly, open a downloaded deck, or when you share an image to AnkiDroid > Image Occlusion, that is, opens a page that state
Ankidroid needs some permission to work.
This is a very low priority bug, because it can only occurs to people who:
- don't use the play store version,
- have spent months without using ankidroid, have manually removed a permission, or try to share to ankidroid before opening ankidroid a first time normally
- have created shortcuts or decides to share images or text to ankidroid.
This probably happened to some of our users, but I expect this to be quite rare
I was the one who implemented this functionality earlier it used crash but sure we can improvise it, I will take it on later. And @Arthur-Milchior it is not crashing as I said it did earlier but it's a toast that we show on purpose if no permission is granted
Sorry, you're right, crashing was not the proper word. Still, there is an issue, as the toast does not even show the entire message, and is not enough for the user to know how to solve it. At this point, even "Open AnkiDroid normally" would be more helpful, given that it would lead to an actual screen which invite the user to grant permission.
@Arthur-Milchior my suggestion is why not use snackbar to show full message because changing string will also effect different situation where this string is used
@Arthur-Milchior also assign this to me
We don't need a snackbar here, see the working of the other screen mentioned by Arthur
@criticalAY I see we need to show the permission screen if permission is turned off, is that what you are saying???
@MinusMallard You don't need to ask for permission. If you know how to solve it, just add a note saying you're working on it, open a PR, and that's it.
At worst, if someone else want to work on it and after a week or two you have no update, we'll decide what to do. But by default, you don't need our permission.
On the other paw, yeah, it's great you asked what need to be done. And it seems you perfectly understood, we need to show the permission screen
Any news @MinusMallard ?
@Arthur-Milchior, Yeah, I'm sorry I forgot to give an update. I actually looked at the text, file, and image intent handlers; they all are very similar in terms of how they manage intents from external sources, so I was not able to track down a specific reason for why this is happening.
Hello 👋, this issue has been opened for more than 3 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically
Hello 👋, this issue has been opened for more than 3 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically