-
-
Notifications
You must be signed in to change notification settings - Fork 224
Improve ShortcuHelper.updateShortcuts to take all actions into account #2919
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
base: main
Are you sure you want to change the base?
Conversation
TheLastProject
left a comment
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 feel the general refactor feels correct, nice that it fixes 2 issues at once. Haven't tested yet, so just commenting on the general code.
TheLastProject
left a comment
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.
Few small things
| DBHelper.updateLoyaltyCardArchiveStatus(database, loyaltyCardId, 1); | ||
| Toast.makeText(LoyaltyCardViewActivity.this, R.string.archived, Toast.LENGTH_LONG).show(); | ||
|
|
||
| ShortcutHelper.removeShortcut(LoyaltyCardViewActivity.this, loyaltyCardId); |
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.
Shouldn't this still call update at least?
|
|
||
| DBHelper.deleteLoyaltyCard(database, LoyaltyCardViewActivity.this, loyaltyCardId); | ||
|
|
||
| ShortcutHelper.removeShortcut(LoyaltyCardViewActivity.this, loyaltyCardId); |
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.
Same here, shouldn't this call update to ensure it disappears?
|
|
||
| DBHelper.deleteLoyaltyCard(mDatabase, this@MainActivity, loyaltyCard.id) | ||
|
|
||
| ShortcutHelper.removeShortcut(this@MainActivity, loyaltyCard.id) |
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.
And here
| for (loyaltyCard in mAdapter.getSelectedItems()) { | ||
| Log.d(TAG, "Archiving card: " + loyaltyCard.id) | ||
| DBHelper.updateLoyaltyCardArchiveStatus(mDatabase, loyaltyCard.id, 1) | ||
| ShortcutHelper.removeShortcut(this@MainActivity, loyaltyCard.id) |
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.
And here
| * manually modified. We use -1 here as a default value to check if | ||
| * the value has been set either manually by the test scenario or | ||
| * automatically in the `updateShortcuts` function. | ||
| * It's actual value will be set based on the maximum amount of shortcuts |
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.
Not a native speaker but I believe this should be "Its"
| * It's actual value will be set based on the maximum amount of shortcuts | |
| * Its actual value will be set based on the maximum amount of shortcuts |
Hello, following our discussion on #2810 here is a PR for the changes, let me know what you think.
This actually fixes #2810 and #2811.
The function now updates the shortcuts list by searching the database for the most recently used items.
Fetching this data from the database via the existing cursor function had the side effect of getting favorite/starred items first. Which is why I also tackled #2811 in this PR as well.
The maximum number of shortcuts is now dependant on the launcher's maximum possible shortcuts and is editable during testing. This needs to be tested on actual hardware, the emulator reported 16 available slots when calling
getMaxShortcutCountPerActivitywhich sounds a bit much to me.I added 2 tests for the ShortcutHelper class for this new behavior. Hopefully these are useful, this part of the code wasn't tested.