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

Commit 6725754

Browse files
authored
Debounce popup block notification when blocking popups caused by back button (#2126)
1 parent fd432cc commit 6725754

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public class NavigationBarWidget extends UIWidget implements GeckoSession.Naviga
103103
private HamburgerMenuWidget mHamburgerMenu;
104104
private SendTabDialogWidget mSendTabDialog;
105105
private TooltipWidget mPopUpNotification;
106+
private int mBlockedCount;
106107

107108
public NavigationBarWidget(Context aContext) {
108109
super(aContext);
@@ -1190,11 +1191,29 @@ public void onPopUpAvailable() {
11901191
@Override
11911192
public void onPopUpsCleared() {
11921193
mURLBar.setIsPopUpAvailable(false);
1194+
hidePopUpsBlockedNotification();
11931195
}
11941196
};
11951197

11961198
public void showPopUpsBlockedNotification() {
1197-
post(() -> showNotification(mURLBar.getPopUpButton(), R.string.popup_tooltip));
1199+
final int POP_UP_NOTIFICATION_DELAY = 800;
1200+
mBlockedCount++;
1201+
final int currentCount = mBlockedCount;
1202+
postDelayed(() -> {
1203+
if (currentCount == mBlockedCount) {
1204+
showNotification(mURLBar.getPopUpButton(), R.string.popup_tooltip);
1205+
}
1206+
}, POP_UP_NOTIFICATION_DELAY);
1207+
}
1208+
1209+
public void hidePopUpsBlockedNotification() {
1210+
mBlockedCount++;
1211+
final int currentCount = mBlockedCount;
1212+
post(() -> {
1213+
if (currentCount == mBlockedCount) {
1214+
hideNotification(mURLBar.getPopUpButton());
1215+
}
1216+
});
11981217
}
11991218

12001219
private void showNotification(UIButton button, int stringRes) {

0 commit comments

Comments
 (0)