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

Debounce popup block notification when blocking popups caused by back button #2126

Merged
merged 1 commit into from
Nov 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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