Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Debounce popup block notification when blocking popups caused by back…
Browse files Browse the repository at this point in the history
… button
  • Loading branch information
bluemarvin committed Nov 1, 2019
1 parent a0ec4bd commit d5a1f66
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1190,11 +1190,31 @@ public void onPopUpAvailable() {
@Override
public void onPopUpsCleared() {
mURLBar.setIsPopUpAvailable(false);
hidePopUpsBlockedNotification();
}
};

private int mBlockedCount;

public void showPopUpsBlockedNotification() {
post(() -> showNotification(mURLBar.getPopUpButton(), R.string.popup_tooltip));
final int POP_UP_NOTIFICATION_DELAY = 800;
mBlockedCount++;
final int currentCount = mBlockedCount;
postDelayed(() -> {
if (currentCount == mBlockedCount) {
showNotification(mURLBar.getPopUpButton(), R.string.popup_tooltip);
}
}, POP_UP_NOTIFICATION_DELAY);
}

public void hidePopUpsBlockedNotification() {
mBlockedCount++;
final int currentCount = mBlockedCount;
post(() -> {
if (currentCount == mBlockedCount) {
hideNotification(mURLBar.getPopUpButton());
}
});
}

private void showNotification(UIButton button, int stringRes) {
Expand Down

0 comments on commit d5a1f66

Please sign in to comment.