|
41 | 41 | import com.codename1.ui.events.ActionEvent; |
42 | 42 | import com.codename1.ui.events.ActionListener; |
43 | 43 | import com.codename1.ui.geom.Dimension; |
| 44 | +import com.codename1.ui.geom.Rectangle; |
44 | 45 | import com.codename1.ui.layouts.BorderLayout; |
45 | 46 | import com.codename1.ui.plaf.Style; |
46 | 47 | import com.codename1.ui.plaf.UIManager; |
@@ -713,7 +714,6 @@ public ToastBarComponent() { |
713 | 714 | this.getAllStyles().setBgColor(0x0); |
714 | 715 | this.getAllStyles().setBackgroundType(Style.BACKGROUND_NONE); |
715 | 716 | this.getAllStyles().setBgTransparency(128); |
716 | | - setSafeArea(true); |
717 | 717 | setVisible(false); |
718 | 718 | label = new TextArea(); |
719 | 719 | label.setUIID(defaultMessageUIID); |
@@ -835,18 +835,33 @@ private ToastBarComponent getToastBarComponent(boolean create) { |
835 | 835 | c.hidden = true; |
836 | 836 | f.putClientProperty("ToastBarComponent", c); |
837 | 837 | Container layered = getLayeredPane(); |
838 | | - // Mark the ToastBar overlay container as a safe area so it respects |
839 | | - // device notches/system bars (e.g. Android navigation, iPhone notch). |
840 | | - layered.setSafeArea(true); |
841 | 838 | layered.setLayout(new BorderLayout()); |
842 | 839 | layered.addComponent(position==Component.TOP ? BorderLayout.NORTH : BorderLayout.SOUTH, c); |
843 | 840 | updateStatus(); |
844 | 841 | } |
845 | | - if(position == Component.BOTTOM && f.getInvisibleAreaUnderVKB() > 0) { |
846 | | - Style s = c.getAllStyles(); |
847 | | - s.setMarginUnit(Style.UNIT_TYPE_PIXELS); |
848 | | - s.setMarginBottom(f.getInvisibleAreaUnderVKB()); |
| 842 | + Rectangle safeArea = Display.getInstance().getDisplaySafeArea(new Rectangle(0, 0, 0, 0)); |
| 843 | + if(position == Component.BOTTOM) { |
| 844 | + if (f.getInvisibleAreaUnderVKB() > 0) { |
| 845 | + Style s = c.getAllStyles(); |
| 846 | + s.setMarginUnit(Style.UNIT_TYPE_PIXELS); |
| 847 | + s.setMarginBottom(f.getInvisibleAreaUnderVKB()); |
| 848 | + } |
| 849 | + int safeBottomMargin = Display.getInstance().getDisplayHeight() |
| 850 | + - safeArea.getY() |
| 851 | + - safeArea.getHeight(); |
| 852 | + if (0 < safeBottomMargin) { |
| 853 | + Style s = c.getAllStyles(); |
| 854 | + s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); |
| 855 | + s.setPaddingBottom(safeBottomMargin); |
| 856 | + } |
| 857 | + } else if (position == Component.TOP) { |
| 858 | + if (safeArea.getY() > 0) { |
| 859 | + Style s = c.getAllStyles(); |
| 860 | + s.setPaddingUnit(Style.UNIT_TYPE_PIXELS); |
| 861 | + s.setPaddingTop(safeArea.getY()); |
| 862 | + } |
849 | 863 | } |
| 864 | + |
850 | 865 | return c; |
851 | 866 | } |
852 | 867 | return null; |
|
0 commit comments