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 (#2126)
  • Loading branch information
bluemarvin authored Nov 1, 2019
1 parent fd432cc commit 6725754
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public class NavigationBarWidget extends UIWidget implements GeckoSession.Naviga
private HamburgerMenuWidget mHamburgerMenu;
private SendTabDialogWidget mSendTabDialog;
private TooltipWidget mPopUpNotification;
private int mBlockedCount;

public NavigationBarWidget(Context aContext) {
super(aContext);
Expand Down Expand Up @@ -1190,11 +1191,29 @@ public void onPopUpAvailable() {
@Override
public void onPopUpsCleared() {
mURLBar.setIsPopUpAvailable(false);
hidePopUpsBlockedNotification();
}
};

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 6725754

Please sign in to comment.