-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Sync separate #17417
Sync separate #17417
Conversation
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.
One question, nothing blocking I feel, presuming this is tested
fun updateSyncIconFromState(menu: Menu) { | ||
val state = syncMenuState | ||
if (state == null) { | ||
return | ||
} | ||
val menuItem = menu.findItem(R.id.action_sync) | ||
val provider = MenuItemCompat.getActionProvider(menuItem) as? SyncActionProvider | ||
?: return | ||
val tooltipText = when (state.syncIcon) { | ||
SyncIconState.Normal, SyncIconState.PendingChanges -> R.string.button_sync | ||
SyncIconState.OneWay -> R.string.sync_menu_title_one_way_sync | ||
SyncIconState.NotLoggedIn -> R.string.sync_menu_title_no_account | ||
} | ||
provider.setTooltipText(activity.getString(tooltipText)) | ||
when (state.syncIcon) { | ||
SyncIconState.Normal -> { | ||
BadgeDrawableBuilder.removeBadge(provider) | ||
} | ||
SyncIconState.PendingChanges -> { | ||
BadgeDrawableBuilder(activity) | ||
.withColor(activity.getColor(R.color.badge_warning)) | ||
.replaceBadge(provider) | ||
} | ||
SyncIconState.OneWay, SyncIconState.NotLoggedIn -> { | ||
BadgeDrawableBuilder(activity) | ||
.withText('!') | ||
.withColor(activity.getColor(R.color.badge_error)) | ||
.replaceBadge(provider) | ||
} | ||
} |
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.
Isn't this DeckPicker specific?
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.
Currently, it is specific to the deck picker.
One of the point I mentioned in the full PR is that I don't know whether I'd want the badge to appear in the reviewer or not. I'd expect the "full sync needed" icon to be very important. The normal sync, as it will appear after the first review, it may be too much of a distraction.
I'd argue that, even if we decide to let it be used in the deck picker only, it's still nice to have the code in Sync, because the DeckPicker is already very big
This class deals with the entire Sync part of the deck picker.
Ensuring there is no typo when using deck id in a reviewer intent
The enum was used only in one function. Adding an intermediary step does not add clarity to the code. Each method were also only used once. I think the resulting code is easier to read, thanks to less layer of abstractions.
040f71c
to
db07e78
Compare
Closing it, because I was able to deal with both reviewer, and had to do change to this system |
This PR is a preamble for #17399. It contains everything related to cleaning the sync code and separating it from the DeckPicker.
I moved most of the code in a single file, that can be reused by the reviewer. I remove SyncStatus which added extra abstraction layer without , I believe, adding any clarity to the code. And replaced a literal by a constant