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

Commit d5a1f66

Browse files
committed
Debounce popup block notification when blocking popups caused by back button
1 parent a0ec4bd commit d5a1f66

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,11 +1190,31 @@ public void onPopUpAvailable() {
11901190
@Override
11911191
public void onPopUpsCleared() {
11921192
mURLBar.setIsPopUpAvailable(false);
1193+
hidePopUpsBlockedNotification();
11931194
}
11941195
};
11951196

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

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

0 commit comments

Comments
 (0)