Skip to content

Conversation

@mpaulmier
Copy link

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 getMaxShortcutCountPerActivity which 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.

Copy link
Member

@TheLastProject TheLastProject left a 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.

Copy link
Member

@TheLastProject TheLastProject left a 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);
Copy link
Member

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);
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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"

Suggested change
* 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Shortcuts not updated after archiving card

2 participants