-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Store category sorting for recent, favorites and uncategorized per account #1218
base: main
Are you sure you want to change the base?
Conversation
I'm still working on deleting meta category when deleting an account. |
|
There's stiil a problem that I don't know how to test the modified code, so I check the keys mannually to make sure they are the same. |
Yeah, we don't have that much tests (yet). I am working from time to time on the coverage, but that's a huge load of work, given that we started with 0 tests... I have added a very basic unit test for the delete method of the |
Thank you very much for your hard work and feedback! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did an early review, and i guess you are overthinking it a bit, especially in the modifyCategoryOrder
method... I don't really understand why you additionally call putString()
and place some hard coded strings in the SharedPreferences
...?
Also: A migration is missing to migrate the existing SharedPreferences
to the account-specific ones. You can orientate on Migration_21_22.java
for that.
app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java
Outdated
Show resolved
Hide resolved
app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java
Outdated
Show resolved
Hide resolved
app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java
Outdated
Show resolved
Hide resolved
app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java
Outdated
Show resolved
Hide resolved
I’ve modified the code according to the above suggestions and passed the latest added tests. 😄 |
I don't know exactly what to do in the migration. Should I refresh the sharedPreferences? Or should I uses the refreshed sharedPreferences to update the database using execSQL? |
You basically need to read all account IDs from the database, migrate sharedPreferences as described here and then remove the old sharedPreferences which were not account specific |
How can I know the structure of the table of database? Without knowing it I could not make a query. |
We are using the Room library as ORM. The entities are defined in Everything you need is to fetch the set of all account IDs and iterate it to add sharedPrefs for each of them. Don't forget to increment the database version, otherwise your migration will not be applied (i forgot it a few times myself and was frustrated because it didn't work 😉 ) |
I think I've finished with that. Please check whether there is a problem. |
Do I need to add the modified sharedPreferences to the database? I've finished the |
No. But you are removing the keys too early. This way it will only work for one set up account, not in a multi accoubt scenario. Also please use always hardcoded strings in Migrations (instead of |
If I hardcoded the string, for example |
This version satisfy all the requirements above.😄 |
You are absolutely right, what a pity that we use localized strings a keys. We should move away from them during this migration and i unfortunately can not see any other option then gathering a list of all available translated values (see As a new key you can use something meaningful like
You can either store those new keys as public static final String XYZ = "category_sorting_"; or alternatively in the <string name="XYZ" translatable="false">category_sorting_</string> Actually what you have found here is a bug from my point of view, because if one changes the language of his Android device, the sorting of the meta categories won't work. Some extra miles to go, but worth it. |
So actually what I need to do is to defined three untranslatable meta categories, and migrate the old one to the new one. Because the newly defined one is staticlly stored in sharedPreferences, we don't have to worry about internationalization. |
Yes, it can be considered being a bug to use translated values as keys (which we currently do). Therefore we should replace them with static values while we are migrating them anyway. |
I guess now we don't have to worry about hardcoded strings in Migrations. I added four elements to |
@stefan-niedermann Do I have to resolve the conflicts shown below? Is there anything I can do anymore? |
I did not forget you, i am just quite busy with my work and my private life at the moment - sorrs for the delay. |
Thank you for your attention. I am also very busy these days and I hope the repair of the issue will not be delayed. |
Store category sorting for recent, favorites and uncategorized per account.