Skip to content
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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
32369d5
Remove markdown syntax from title.
AlpAcA0072 May 10, 2021
970f4ab
Remove markdown syntax "# " from title. A simple version.
AlpAcA0072 May 11, 2021
60023e4
Remove markdown syntax "# " from title. A simple version.
AlpAcA0072 May 11, 2021
05c51c9
Remove markdown syntax "# " from title. A simple version.
AlpAcA0072 May 11, 2021
29e398c
Merge branch 'master' into master
AlpAcA0072 May 12, 2021
f33b67a
Remove markdown syntax "# " from title up to 6 times. A simple version.
AlpAcA0072 May 12, 2021
551aa3c
Merge remote-tracking branch 'origin/master'
AlpAcA0072 May 12, 2021
62d9863
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 15, 2021
2f53701
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 15, 2021
869f783
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 16, 2021
ac6e07c
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 16, 2021
7593f81
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 16, 2021
acf797b
Merge branch 'master' into master
AlpAcA0072 May 16, 2021
995ae3a
Merge branch 'master' into master
AlpAcA0072 May 16, 2021
9e15412
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 16, 2021
fea5839
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 16, 2021
b5c8b4c
Merge branch 'master' into master
AlpAcA0072 May 16, 2021
c8f37eb
Merge branch 'master' into master
AlpAcA0072 May 17, 2021
b3fcd8e
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 18, 2021
63a0110
Merge remote-tracking branch 'origin/master'
AlpAcA0072 May 18, 2021
5d8b44b
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 18, 2021
9d626fa
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 18, 2021
11bc09b
[Store category sorting for recent, favorites and uncategorized per a…
AlpAcA0072 May 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ public List<Account> getAccounts() {
public void deleteAccount(@NonNull Account account) {
try {
ApiProvider.invalidateAPICache(AccountImporter.getSingleSignOnAccount(context, account.getAccountName()));
executor.submit(() -> {
AlpAcA0072 marked this conversation as resolved.
Show resolved Hide resolved
final Context ctx = context.getApplicationContext();
AlpAcA0072 marked this conversation as resolved.
Show resolved Hide resolved
final SharedPreferences.Editor sp = PreferenceManager.getDefaultSharedPreferences(ctx).edit();
final String keyRecentCategory = ENavigationCategoryType.RECENT.toString().concat(String.valueOf(account.getId()));
final String keyUncategorizedCategory = ENavigationCategoryType.UNCATEGORIZED.toString().concat(String.valueOf(account.getId()));
final String keyFavoritesCategory = ENavigationCategoryType.FAVORITES.toString().concat(String.valueOf(account.getId()));
sp.remove(keyRecentCategory);
sp.remove(keyUncategorizedCategory);
sp.remove(keyFavoritesCategory);
AlpAcA0072 marked this conversation as resolved.
Show resolved Hide resolved
sp.remove(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.label_favorites) + account.getId());
sp.remove(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.action_uncategorized) + account.getId());
sp.remove(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.label_all_notes) + account.getId());
sp.apply();
});
} catch (NextcloudFilesAppAccountNotFoundException e) {
e.printStackTrace();
ApiProvider.invalidateAPICache();
Expand Down Expand Up @@ -608,18 +622,22 @@ public void modifyCategoryOrder(long accountId, @NonNull NavigationCategory sele
final Context ctx = context.getApplicationContext();
final SharedPreferences.Editor sp = PreferenceManager.getDefaultSharedPreferences(ctx).edit();
int orderIndex = sortingMethod.getId();

final String categoryType = selectedCategory.getType().toString();
final String keyMetaCategory = categoryType.concat(String.valueOf(accountId));
switch (selectedCategory.getType()) {
case FAVORITES: {
sp.putInt(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.label_favorites), orderIndex);
sp.putInt(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.label_favorites) + accountId, orderIndex);
sp.putString(keyMetaCategory, "modified");
AlpAcA0072 marked this conversation as resolved.
Show resolved Hide resolved
break;
}
case UNCATEGORIZED: {
sp.putInt(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.action_uncategorized), orderIndex);
sp.putInt(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.action_uncategorized) + accountId, orderIndex);
sp.putString(keyMetaCategory, "lexicographically");
break;
}
case RECENT: {
sp.putInt(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.label_all_notes), orderIndex);
sp.putInt(ctx.getString(R.string.action_sorting_method) + ' ' + ctx.getString(R.string.label_all_notes) + accountId, orderIndex);
sp.putString(keyMetaCategory, "modified");
break;
}
case DEFAULT_CATEGORY:
Expand Down Expand Up @@ -661,19 +679,19 @@ public void modifyCategoryOrder(long accountId, @NonNull NavigationCategory sele
public LiveData<CategorySortingMethod> getCategoryOrder(@NonNull NavigationCategory selectedCategory) {
final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
String prefKey;

final String accountId = String.valueOf(selectedCategory.getAccountId());
switch (selectedCategory.getType()) {
// TODO make this account specific
case RECENT: {
prefKey = context.getString(R.string.action_sorting_method) + ' ' + context.getString(R.string.label_all_notes);
prefKey = context.getString(R.string.action_sorting_method) + ' ' + context.getString(R.string.label_all_notes) + accountId;
break;
}
case FAVORITES: {
prefKey = context.getString(R.string.action_sorting_method) + ' ' + context.getString(R.string.label_favorites);
prefKey = context.getString(R.string.action_sorting_method) + ' ' + context.getString(R.string.label_favorites) + accountId;
break;
}
case UNCATEGORIZED: {
prefKey = context.getString(R.string.action_sorting_method) + ' ' + context.getString(R.string.action_uncategorized);
prefKey = context.getString(R.string.action_sorting_method) + ' ' + context.getString(R.string.action_uncategorized) + accountId;
break;
}
case DEFAULT_CATEGORY:
Expand Down