4242import org .mozilla .vrbrowser .ui .views .NavigationURLBar ;
4343import org .mozilla .vrbrowser .ui .views .UIButton ;
4444import org .mozilla .vrbrowser .ui .views .UITextButton ;
45+ import org .mozilla .vrbrowser .ui .widgets .NotificationManager .Notification .NotificationPosition ;
4546import org .mozilla .vrbrowser .ui .widgets .dialogs .SelectionActionWidget ;
4647import org .mozilla .vrbrowser .ui .widgets .dialogs .SendTabDialogWidget ;
4748import org .mozilla .vrbrowser .ui .widgets .dialogs .VoiceSearchWidget ;
@@ -377,7 +378,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
377378
378379 @ Override
379380 public void detachFromWindow () {
380- hideNotification ();
381+ hideAllNotifications ();
381382
382383 if (mAttachedWindow != null && mAttachedWindow .isResizing ()) {
383384 exitResizeMode (ResizeAction .RESTORE_SIZE );
@@ -585,7 +586,7 @@ private void enterResizeMode() {
585586 }
586587 }
587588
588- hideNotifications ();
589+ hideAllNotifications ();
589590
590591 // Update preset styles
591592 }
@@ -1030,7 +1031,10 @@ public void showPopUpsBlockedNotification() {
10301031 final int currentCount = mBlockedCount ;
10311032 postDelayed (() -> {
10321033 if (currentCount == mBlockedCount ) {
1033- showNotification (POPUP_NOTIFICATION_ID , mBinding .navigationBarNavigation .urlBar .getPopUpButton (), R .string .popup_tooltip );
1034+ showNotification (POPUP_NOTIFICATION_ID ,
1035+ mBinding .navigationBarNavigation .urlBar .getPopUpButton (),
1036+ NotificationManager .Notification .TOP ,
1037+ R .string .popup_tooltip );
10341038 }
10351039 }, POP_UP_NOTIFICATION_DELAY );
10361040 }
@@ -1040,48 +1044,54 @@ public void hidePopUpsBlockedNotification() {
10401044 final int currentCount = mBlockedCount ;
10411045 post (() -> {
10421046 if (currentCount == mBlockedCount ) {
1043- hideNotification ();
1047+ hideNotification (POPUP_NOTIFICATION_ID );
10441048 }
10451049 });
10461050 }
10471051
1048- public void hideNotifications () {
1049- hidePopUpsBlockedNotification ();
1050- }
1051-
10521052 public void showTabAddedNotification () {
1053- showNotification (TAB_ADDED_NOTIFICATION_ID , R .string .tab_added_notification );
1053+ showNotification (TAB_ADDED_NOTIFICATION_ID ,
1054+ NotificationManager .Notification .BOTTOM ,
1055+ R .string .tab_added_notification );
10541056 }
10551057
10561058 public void showTabSentNotification () {
1057- showNotification (TAB_SENT_NOTIFICATION_ID , R .string .tab_sent_notification );
1059+ showNotification (TAB_SENT_NOTIFICATION_ID ,
1060+ NotificationManager .Notification .BOTTOM ,
1061+ R .string .tab_sent_notification );
10581062 }
10591063
10601064 public void showBookmarkAddedNotification () {
1061- showNotification (BOOKMARK_ADDED_NOTIFICATION_ID , R .string .bookmarks_saved_notification );
1065+ showNotification (BOOKMARK_ADDED_NOTIFICATION_ID ,
1066+ NotificationManager .Notification .BOTTOM ,
1067+ R .string .bookmarks_saved_notification );
10621068 }
10631069
1064- private void showNotification (int notificationId , UIButton button , int stringRes ) {
1070+ private void showNotification (int notificationId , UIButton button , @ NotificationPosition int position , int stringRes ) {
10651071 NotificationManager .Notification notification = new NotificationManager .Builder (this )
10661072 .withView (button )
10671073 .withString (stringRes )
1068- .withPosition (NotificationManager . Notification . BOTTOM )
1074+ .withPosition (position )
10691075 .withMargin (20.0f ).build ();
10701076 NotificationManager .show (notificationId , notification );
10711077 }
10721078
1073- private void showNotification (int notificationId , int stringRes ) {
1079+ private void showNotification (int notificationId , @ NotificationPosition int position , int stringRes ) {
10741080 NotificationManager .Notification notification = new NotificationManager .Builder (this )
10751081 .withString (stringRes )
1076- .withPosition (NotificationManager . Notification . BOTTOM )
1082+ .withPosition (position )
10771083 .withMargin (20.0f ).build ();
10781084 NotificationManager .show (notificationId , notification );
10791085 }
10801086
1081- private void hideNotification () {
1087+ public void hideAllNotifications () {
10821088 NotificationManager .hideAll ();
10831089 }
10841090
1091+ private void hideNotification (int notificationId ) {
1092+ NotificationManager .hide (notificationId );
1093+ }
1094+
10851095 private ConnectivityReceiver .Delegate mConnectivityDelegate = connected -> {
10861096 if (mMediaControlsWidget != null ) {
10871097 mMediaControlsWidget .setVisible (connected && mMediaControlsWidget .isVisible ());
0 commit comments