Search in sources :

Example 1 with InteractionDialog

use of com.codename1.components.InteractionDialog in project CodenameOne by codenameone.

the class TestComponent method getComponentAt_int_int_browsercomponent.

private void getComponentAt_int_int_browsercomponent() {
    int w = Display.getInstance().getDisplayWidth();
    int h = Display.getInstance().getDisplayHeight();
    Form mapDemo = new Form("Maps", new LayeredLayout());
    Toolbar.setOnTopSideMenu(true);
    Toolbar tb = new Toolbar();
    mapDemo.setToolbar(tb);
    mapDemo.setTitle("Maps");
    tb.addCommandToSideMenu(new Command("Test") {

        @Override
        public void actionPerformed(ActionEvent e) {
        // testNestedScrollingLabels();
        }
    });
    BrowserComponent mc = new BrowserComponent();
    mapDemo.add(mc);
    mapDemo.show();
    TestUtils.waitForFormTitle("Maps", 2000);
    Component middleComponent = mapDemo.getComponentAt(w / 2, h / 2);
    assertTrue(mc == middleComponent || mc.contains(middleComponent), "Wrong component found in middle. Expected " + mc + " but found " + middleComponent);
    tb.openSideMenu();
    // wait for side menu to open
    TestUtils.waitFor(500);
    Component res = null;
    res = tb.getComponentAt(10, h / 2);
    // System.out.println("tb size = "+tb.getAbsoluteX()+", "+tb.getAbsoluteY()+", "+tb.getWidth()+", "+tb.getHeight());
    // System.out.println("mb size = "+tb.getMenuBar().getAbsoluteX()+", "+tb.getMenuBar().getAbsoluteY()+", "+tb.getMenuBar().getWidth()+", "+tb.getMenuBar().getHeight());
    // System.out.println("res is "+res);
    res = mapDemo.getComponentAt(10, h / 2);
    // Let's find the interaction dialog on the form
    Component interactionDialog = $("*", mapDemo).filter(c -> {
        return c instanceof InteractionDialog;
    }).asComponent();
    assertTrue(((InteractionDialog) interactionDialog).contains(res), "Toolbar is open so getComponentAt() should return something on the toolbar.  But received " + res + ".  Toolbar is " + tb);
}
Also used : Util(com.codename1.io.Util) BoxLayout(com.codename1.ui.layouts.BoxLayout) ActionEvent(com.codename1.ui.events.ActionEvent) NetworkManager(com.codename1.io.NetworkManager) LayeredLayout(com.codename1.ui.layouts.LayeredLayout) NetworkEvent(com.codename1.io.NetworkEvent) ComponentSelector.$(com.codename1.ui.ComponentSelector.$) ConnectionRequest(com.codename1.io.ConnectionRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) AbstractTest(com.codename1.testing.AbstractTest) TestUtils(com.codename1.testing.TestUtils) SimpleDateFormat(com.codename1.l10n.SimpleDateFormat) Cookie(com.codename1.io.Cookie) FileSystemStorage(com.codename1.io.FileSystemStorage) IOException(java.io.IOException) ActionListener(com.codename1.ui.events.ActionListener) JSONParser(com.codename1.io.JSONParser) Log(com.codename1.io.Log) BorderLayout(com.codename1.ui.layouts.BorderLayout) InputStreamReader(java.io.InputStreamReader) Style(com.codename1.ui.plaf.Style) Coord(com.codename1.maps.Coord) ToastBar(com.codename1.components.ToastBar) InteractionDialog(com.codename1.components.InteractionDialog) InteractionDialog(com.codename1.components.InteractionDialog) ActionEvent(com.codename1.ui.events.ActionEvent) LayeredLayout(com.codename1.ui.layouts.LayeredLayout)

Example 2 with InteractionDialog

use of com.codename1.components.InteractionDialog in project CodenameOne by codenameone.

the class Toolbar method constructOnTopSideMenu.

private void constructOnTopSideMenu() {
    if (sidemenuDialog == null) {
        permanentSideMenuContainer = constructSideNavigationComponent();
        final Form parent = getComponentForm();
        parent.addPointerPressedListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                if (Display.getInstance().getImplementation().isScrollWheeling()) {
                    return;
                }
                if (sidemenuDialog.isShowing()) {
                    if (evt.getX() > sidemenuDialog.getWidth()) {
                        parent.putClientProperty("cn1$sidemenuCharged", Boolean.FALSE);
                        closeSideMenu();
                        evt.consume();
                    } else {
                        if (evt.getX() + Display.getInstance().convertToPixels(8) > sidemenuDialog.getWidth()) {
                            parent.putClientProperty("cn1$sidemenuCharged", Boolean.TRUE);
                        } else {
                            parent.putClientProperty("cn1$sidemenuCharged", Boolean.FALSE);
                        }
                        if (!isComponentInOnTopSidemenu(parent.getComponentAt(evt.getX(), evt.getY()))) {
                            evt.consume();
                        }
                    }
                } else {
                    int displayWidth = Display.getInstance().getDisplayWidth();
                    final int sensitiveSection = displayWidth / getUIManager().getThemeConstant("sideSwipeSensitiveInt", 10);
                    if (evt.getX() < sensitiveSection) {
                        parent.putClientProperty("cn1$sidemenuCharged", Boolean.TRUE);
                        evt.consume();
                    } else {
                        parent.putClientProperty("cn1$sidemenuCharged", Boolean.FALSE);
                        permanentSideMenuContainer.pointerPressed(evt.getX(), evt.getY());
                    }
                }
            }
        });
        parent.addPointerDraggedListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                if (Display.getInstance().getImplementation().isScrollWheeling()) {
                    return;
                }
                Boolean b = (Boolean) parent.getClientProperty("cn1$sidemenuCharged");
                if (b != null && b.booleanValue()) {
                    parent.putClientProperty("cn1$sidemenuActivated", Boolean.TRUE);
                    showOnTopSidemenu(evt.getX(), false);
                    evt.consume();
                } else {
                    if (sidemenuDialog.isShowing()) {
                        permanentSideMenuContainer.pointerDragged(evt.getX(), evt.getY());
                        evt.consume();
                    }
                }
            }
        });
        parent.addPointerReleasedListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                if (Display.getInstance().getImplementation().isScrollWheeling()) {
                    return;
                }
                Boolean b = (Boolean) parent.getClientProperty("cn1$sidemenuActivated");
                if (b != null && b.booleanValue()) {
                    parent.putClientProperty("cn1$sidemenuActivated", null);
                    if (evt.getX() < parent.getWidth() / 4) {
                        closeSideMenu();
                    } else {
                        showOnTopSidemenu(-1, true);
                    }
                    evt.consume();
                } else {
                    if (sidemenuDialog.isShowing()) {
                        if (!isComponentInOnTopSidemenu(parent.getComponentAt(evt.getX(), evt.getY()))) {
                            evt.consume();
                        }
                        permanentSideMenuContainer.pointerReleased(evt.getX(), evt.getY());
                    }
                }
            }
        });
        sidemenuDialog = new InteractionDialog(new BorderLayout());
        sidemenuDialog.setFormMode(true);
        sidemenuDialog.setUIID("Container");
        sidemenuDialog.setDialogUIID("Container");
        sidemenuDialog.getTitleComponent().remove();
        sidemenuDialog.add(BorderLayout.CENTER, permanentSideMenuContainer);
        if (sidemenuSouthComponent != null) {
            sidemenuDialog.add(BorderLayout.SOUTH, sidemenuSouthComponent);
        }
        float size = 4.5f;
        try {
            size = Float.parseFloat(getUIManager().getThemeConstant("menuImageSize", "4.5"));
        } catch (Throwable t) {
            Log.e(t);
        }
        if (!parent.getUIManager().isThemeConstant("hideLeftSideMenuBool", false)) {
            Image i = (Image) parent.getUIManager().getThemeImageConstant("sideMenuImage");
            if (i != null) {
                Command cmd = addCommandToLeftBar("", i, new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        if (sidemenuDialog.isShowing()) {
                            closeSideMenu();
                            return;
                        }
                        showOnTopSidemenu(-1, false);
                    }
                });
                Image p = (Image) parent.getUIManager().getThemeImageConstant("sideMenuPressImage");
                if (p != null) {
                    findCommandComponent(cmd).setPressedIcon(p);
                }
            } else {
                addMaterialCommandToLeftBar("", FontImage.MATERIAL_MENU, size, new ActionListener() {

                    public void actionPerformed(ActionEvent evt) {
                        if (sidemenuDialog.isShowing()) {
                            closeSideMenu();
                            return;
                        }
                        showOnTopSidemenu(-1, false);
                    }
                });
            }
        }
    }
}
Also used : InteractionDialog(com.codename1.components.InteractionDialog) ActionListener(com.codename1.ui.events.ActionListener) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionEvent(com.codename1.ui.events.ActionEvent)

Example 3 with InteractionDialog

use of com.codename1.components.InteractionDialog in project codenameone-google-maps by codenameone.

the class GoogleMapsTestApp method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Native Maps Test");
    hi.setLayout(new BorderLayout());
    final MapContainer cnt = new MapContainer(HTML_API_KEY);
    // final MapContainer cnt = new MapContainer();
    // this breaks the code //because the Google map is not loaded yet
    cnt.setCameraPosition(new Coord(-26.1486233, 28.67401229999996));
    cnt.addMapListener(new MapListener() {

        @Override
        public void mapPositionUpdated(Component source, int zoom, Coord center) {
            System.out.println("Map position updated: zoom=" + zoom + ", Center=" + center);
        }
    });
    cnt.addLongPressListener(e -> {
        System.out.println("Long press");
        ToastBar.showMessage("Received longPress at " + e.getX() + ", " + e.getY(), FontImage.MATERIAL_3D_ROTATION);
    });
    cnt.addTapListener(e -> {
        ToastBar.showMessage("Received tap at " + e.getX() + ", " + e.getY(), FontImage.MATERIAL_3D_ROTATION);
    });
    int maxZoom = cnt.getMaxZoom();
    System.out.println("Max zoom is " + maxZoom);
    Button btnMoveCamera = new Button("Move Camera");
    btnMoveCamera.addActionListener(e -> {
        cnt.setCameraPosition(new Coord(-33.867, 151.206));
    });
    Style s = new Style();
    s.setFgColor(0xff0000);
    s.setBgTransparency(0);
    FontImage markerImg = FontImage.createMaterial(FontImage.MATERIAL_PLACE, s, 3);
    Button btnAddMarker = new Button("Add Marker");
    btnAddMarker.addActionListener(e -> {
        cnt.setCameraPosition(new Coord(41.889, -87.622));
        cnt.addMarker(EncodedImage.createFromImage(markerImg, false), cnt.getCameraPosition(), "Hi marker", "Optional long description", new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                System.out.println("Bounding box is " + cnt.getBoundingBox());
                ToastBar.showMessage("You clicked the marker", FontImage.MATERIAL_PLACE);
            }
        });
    });
    Button btnAddPath = new Button("Add Path");
    btnAddPath.addActionListener(e -> {
        cnt.addPath(cnt.getCameraPosition(), // Sydney
        new Coord(-33.866, 151.195), // Fiji
        new Coord(-18.142, 178.431), // Hawaii
        new Coord(21.291, -157.821), // Mountain View
        new Coord(37.423, -122.091));
    });
    Button panTo = new Button("Pan To");
    panTo.addActionListener(e -> {
        // bounds.extend(new google.maps.LatLng('66.057878', '-22.579047')); // Iceland
        // bounds.extend(new google.maps.LatLng('37.961952', '43.878878')); // Turkey
        Coord c1 = new Coord(49.0986192, -122.6764454);
        Coord c2 = new Coord(49.2577142, -123.1941149);
        // Coord center = new Coord(c1.getLatitude()/2 +  c2.getLatitude() / 2, c1.getLongitude()/2 + c2.getLongitude()/2 );
        Coord center = new Coord(49.1110928, -122.9414646);
        float zoom = cnt.getZoom();
        boolean[] finished = new boolean[1];
        cnt.addMapListener(new MapListener() {

            @Override
            public void mapPositionUpdated(Component source, int zoom, Coord c) {
                if (Math.abs(c.getLatitude() - center.getLatitude()) > .001 || Math.abs(c.getLongitude() - center.getLongitude()) > .001) {
                    return;
                }
                finished[0] = true;
                synchronized (finished) {
                    final MapListener fthis = this;
                    Display.getInstance().callSerially(() -> {
                        cnt.removeMapListener(fthis);
                    });
                    finished.notify();
                }
            }
        });
        cnt.zoom(center, (int) zoom);
        while (!finished[0]) {
            Display.getInstance().invokeAndBlock(() -> {
                while (!finished[0]) {
                    Util.wait(finished, 100);
                }
            });
        }
        BoundingBox box = cnt.getBoundingBox();
        if (!box.contains(c1) || !box.contains(c2)) {
            while (!box.contains(c1) || !box.contains(c2)) {
                if (!box.contains(c1)) {
                    System.out.println("Box " + box + " doesn't contain " + c1);
                }
                if (!box.contains(c1)) {
                    System.out.println("Box " + box + " doesn't contain " + c2);
                }
                zoom -= 1;
                final boolean[] done = new boolean[1];
                final int fzoom = (int) zoom;
                cnt.addMapListener(new MapListener() {

                    @Override
                    public void mapPositionUpdated(Component source, int zm, Coord center) {
                        if (zm == fzoom) {
                            final MapListener fthis = this;
                            Display.getInstance().callSerially(() -> {
                                cnt.removeMapListener(fthis);
                            });
                            done[0] = true;
                            synchronized (done) {
                                done.notify();
                            }
                        }
                    }
                });
                cnt.zoom(center, (int) zoom);
                while (!done[0]) {
                    Display.getInstance().invokeAndBlock(() -> {
                        while (!done[0]) {
                            Util.wait(done, 100);
                        }
                    });
                }
                box = cnt.getBoundingBox();
                System.out.println("Zoom now " + zoom);
            }
        } else if (box.contains(c1) && box.contains(c2)) {
            while (box.contains(c1) && box.contains(c2)) {
                zoom += 1;
                final boolean[] done = new boolean[1];
                final int fzoom = (int) zoom;
                cnt.addMapListener(new MapListener() {

                    public void mapPositionUpdated(Component source, int zm, Coord center) {
                        if (zm == fzoom) {
                            final MapListener fthis = this;
                            Display.getInstance().callSerially(() -> {
                                cnt.removeMapListener(fthis);
                            });
                            done[0] = true;
                            synchronized (done) {
                                done.notify();
                            }
                        }
                    }
                });
                cnt.zoom(center, (int) zoom);
                while (!done[0]) {
                    Display.getInstance().invokeAndBlock(() -> {
                        while (!done[0]) {
                            Util.wait(done, 100);
                        }
                    });
                }
                box = cnt.getBoundingBox();
            }
            zoom -= 1;
            cnt.zoom(center, (int) zoom);
            cnt.addTapListener(null);
        }
    });
    Button testCoordPositions = $(new Button("Test Coords")).addActionListener(e -> {
        Coord topLeft = cnt.getCoordAtPosition(0, 0);
        System.out.println("Top Left is " + topLeft + " -> " + cnt.getScreenCoordinate(topLeft) + " Should be (0,0)");
        Coord bottomRight = cnt.getCoordAtPosition(cnt.getWidth(), cnt.getHeight());
        System.out.println("Bottom right is " + bottomRight + " -> " + cnt.getScreenCoordinate(bottomRight) + " Should be " + cnt.getWidth() + ", " + cnt.getHeight());
        Coord bottomLeft = cnt.getCoordAtPosition(0, cnt.getHeight());
        System.out.println("Bottom Left is " + bottomLeft + " -> " + cnt.getScreenCoordinate(bottomLeft) + " Should be 0, " + cnt.getHeight());
        Coord topRight = cnt.getCoordAtPosition(cnt.getWidth(), 0);
        System.out.println("Top right is " + topRight + " -> " + cnt.getScreenCoordinate(topRight) + " Should be " + cnt.getWidth() + ", 0");
        Coord center = cnt.getCoordAtPosition(cnt.getWidth() / 2, cnt.getHeight() / 2);
        System.out.println("Center is " + center + " -> " + cnt.getScreenCoordinate(center) + ", should be " + (cnt.getWidth() / 2) + ", " + (cnt.getHeight() / 2));
        EncodedImage encImg = EncodedImage.createFromImage(markerImg, false);
        cnt.addMarker(encImg, topLeft, "Top Left", "Top Left", null);
        cnt.addMarker(encImg, topRight, "Top Right", "Top Right", null);
        cnt.addMarker(encImg, bottomRight, "Bottom Right", "Bottom Right", null);
        cnt.addMarker(encImg, bottomLeft, "Bottom Left", "Bottom Left", null);
        cnt.addMarker(encImg, center, "Center", "Center", null);
    }).asComponent(Button.class);
    Button toggleTopMargin = $(new Button("Toggle Margin")).addActionListener(e -> {
        int marginTop = $(cnt).getStyle().getMarginTop();
        if (marginTop < Display.getInstance().getDisplayHeight() / 3) {
            $(cnt).selectAllStyles().setMargin(Display.getInstance().getDisplayHeight() / 3, 0, 0, 0);
        } else {
            $(cnt).selectAllStyles().setMargin(0, 0, 0, 0);
        }
        $(cnt).getComponentForm().revalidate();
    }).asComponent(Button.class);
    Button btnClearAll = new Button("Clear All");
    btnClearAll.addActionListener(e -> {
        cnt.clearMapLayers();
    });
    MapObject mo = cnt.addMarker(EncodedImage.createFromImage(markerImg, false), new Coord(-33.866, 151.195), "test", "test", e -> {
        System.out.println("Marker clicked");
        cnt.removeMapObject(sydney);
    });
    sydney = mo;
    System.out.println("MO is " + mo);
    mo = cnt.addMarker(EncodedImage.createFromImage(markerImg, false), new Coord(-18.142, 178.431), "test", "test", e -> {
        System.out.println("Marker clicked");
    });
    System.out.println("MO is " + mo);
    cnt.addTapListener(e -> {
        if (tapDisabled) {
            return;
        }
        tapDisabled = true;
        TextField enterName = new TextField();
        Container wrapper = BoxLayout.encloseY(new Label("Name:"), enterName);
        InteractionDialog dlg = new InteractionDialog("Add Marker");
        dlg.getContentPane().add(wrapper);
        enterName.setDoneListener(e2 -> {
            String txt = enterName.getText();
            cnt.addMarker(EncodedImage.createFromImage(markerImg, false), cnt.getCoordAtPosition(e.getX(), e.getY()), enterName.getText(), "", e3 -> {
                ToastBar.showMessage("You clicked " + txt, FontImage.MATERIAL_PLACE);
            });
            dlg.dispose();
            tapDisabled = false;
        });
        dlg.showPopupDialog(new Rectangle(e.getX(), e.getY(), 10, 10));
        enterName.startEditingAsync();
    });
    Button showNextForm = $(new Button("Next Form")).addActionListener(e -> {
        Form form = new Form("Hello World");
        Button b1 = $(new Button("B1")).addActionListener(e2 -> {
            ToastBar.showMessage("B1 was pressed", FontImage.MATERIAL_3D_ROTATION);
        }).asComponent(Button.class);
        Button back = $(new Button("Back")).addActionListener(e2 -> {
            hi.showBack();
        }).asComponent(Button.class);
        form.add(b1);
    }).asComponent(Button.class);
    FloatingActionButton nextForm = FloatingActionButton.createFAB(FontImage.MATERIAL_ACCESS_ALARM);
    nextForm.addActionListener(e -> {
        Form form = new Form("Hello World");
        Button b1 = $(new Button("B1")).addActionListener(e2 -> {
            ToastBar.showMessage("B1 was pressed", FontImage.MATERIAL_3D_ROTATION);
        }).asComponent(Button.class);
        Button back = $(new Button("Back")).addActionListener(e2 -> {
            hi.showBack();
        }).asComponent(Button.class);
        form.add(b1).add(back);
        form.show();
    });
    Container root = LayeredLayout.encloseIn(BorderLayout.center(nextForm.bindFabToContainer(cnt)), BorderLayout.south(FlowLayout.encloseBottom(panTo, testCoordPositions, toggleTopMargin, btnMoveCamera, btnAddMarker, btnAddPath, btnClearAll)));
    hi.add(BorderLayout.CENTER, root);
    hi.show();
}
Also used : Util(com.codename1.io.Util) BoxLayout(com.codename1.ui.layouts.BoxLayout) ActionEvent(com.codename1.ui.events.ActionEvent) LayeredLayout(com.codename1.ui.layouts.LayeredLayout) MapObject(com.codename1.googlemaps.MapContainer.MapObject) MapListener(com.codename1.maps.MapListener) Form(com.codename1.ui.Form) Container(com.codename1.ui.Container) BoundingBox(com.codename1.maps.BoundingBox) ComponentSelector.$(com.codename1.ui.ComponentSelector.$) TextField(com.codename1.ui.TextField) Display(com.codename1.ui.Display) FontImage(com.codename1.ui.FontImage) Button(com.codename1.ui.Button) Label(com.codename1.ui.Label) Component(com.codename1.ui.Component) Rectangle(com.codename1.ui.geom.Rectangle) EncodedImage(com.codename1.ui.EncodedImage) MapContainer(com.codename1.googlemaps.MapContainer) FlowLayout(com.codename1.ui.layouts.FlowLayout) Resources(com.codename1.ui.util.Resources) IOException(java.io.IOException) ActionListener(com.codename1.ui.events.ActionListener) BorderLayout(com.codename1.ui.layouts.BorderLayout) Style(com.codename1.ui.plaf.Style) Coord(com.codename1.maps.Coord) UIManager(com.codename1.ui.plaf.UIManager) ToastBar(com.codename1.components.ToastBar) FloatingActionButton(com.codename1.components.FloatingActionButton) SideMenuBar(com.codename1.ui.SideMenuBar) InteractionDialog(com.codename1.components.InteractionDialog) Form(com.codename1.ui.Form) ActionEvent(com.codename1.ui.events.ActionEvent) Label(com.codename1.ui.Label) Rectangle(com.codename1.ui.geom.Rectangle) MapContainer(com.codename1.googlemaps.MapContainer) InteractionDialog(com.codename1.components.InteractionDialog) Container(com.codename1.ui.Container) MapContainer(com.codename1.googlemaps.MapContainer) BorderLayout(com.codename1.ui.layouts.BorderLayout) Button(com.codename1.ui.Button) FloatingActionButton(com.codename1.components.FloatingActionButton) BoundingBox(com.codename1.maps.BoundingBox) Style(com.codename1.ui.plaf.Style) TextField(com.codename1.ui.TextField) FloatingActionButton(com.codename1.components.FloatingActionButton) Component(com.codename1.ui.Component) FontImage(com.codename1.ui.FontImage) MapObject(com.codename1.googlemaps.MapContainer.MapObject) EncodedImage(com.codename1.ui.EncodedImage) Coord(com.codename1.maps.Coord) ActionListener(com.codename1.ui.events.ActionListener) MapListener(com.codename1.maps.MapListener)

Example 4 with InteractionDialog

use of com.codename1.components.InteractionDialog in project codenameone-google-maps by codenameone.

the class MapInfoPanel method show.

public void show() {
    if (getParent() != null) {
        return;
    }
    Display disp = Display.getInstance();
    if (disp.isTablet()) {
        if (disp.isPortrait()) {
            markers.setLayout(new BoxLayout(BoxLayout.X_AXIS));
            for (Component marker : markers) {
                if (marker instanceof Button) {
                    Button btnMarker = (Button) marker;
                    btnMarker.setTextPosition(Label.BOTTOM);
                }
            }
            InteractionDialog dlg = new InteractionDialog("Map Info");
            dlg.setLayout(new BorderLayout());
            dlg.add(BorderLayout.CENTER, this);
            int dh = disp.getDisplayHeight();
            int dw = disp.getDisplayWidth();
            dlg.show(3 * dh / 4, 0, 0, 0);
            updateMapPosition();
        } else {
            markers.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
            for (Component marker : markers) {
                if (marker instanceof Button) {
                    Button btnMarker = (Button) marker;
                    btnMarker.setTextPosition(Label.RIGHT);
                }
            }
            InteractionDialog dlg = new InteractionDialog("Map Info");
            dlg.setLayout(new BorderLayout());
            dlg.add(BorderLayout.CENTER, this);
            int dh = disp.getDisplayHeight();
            int dw = disp.getDisplayWidth();
            // makeTransparent(dlg);
            dlg.getAllStyles().setBorder(Border.createEmpty());
            dlg.getAllStyles().setBgColor(0x0);
            dlg.getAllStyles().setBgTransparency(128);
            List<Component> dialogTitle = findByUIID("DialogTitle", dlg);
            for (Component c : dialogTitle) {
                c.getAllStyles().setFgColor(0xffffff);
            }
            List<Component> tabsContainer = findByUIID("TabsContainer", dlg);
            for (Component c : tabsContainer) {
                c.getAllStyles().setBgColor(0xEAEAEA);
                // c.getAllStyles().setBackgroundType(Style.BACKGROUND_NONE);
                c.getAllStyles().setBgTransparency(255);
            }
            ;
            dlg.show(0, 0, 0, dw * 3 / 4);
            updateMapPosition();
            System.out.println("Making transparent");
        // makeTransparent(dlg);
        }
    } else {
        if (disp.isPortrait()) {
            markers.setLayout(new BoxLayout(BoxLayout.X_AXIS));
            for (Component marker : markers) {
                if (marker instanceof Button) {
                    Button btnMarker = (Button) marker;
                    btnMarker.setTextPosition(Label.BOTTOM);
                }
            }
            InteractionDialog dlg = new InteractionDialog("Map Info");
            dlg.setLayout(new BorderLayout());
            dlg.add(BorderLayout.CENTER, this);
            int dh = disp.getDisplayHeight();
            int dw = disp.getDisplayWidth();
            dlg.show(dh / 2, 0, 0, 0);
            updateMapPosition();
        } else {
            markers.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
            for (Component marker : markers) {
                if (marker instanceof Button) {
                    Button btnMarker = (Button) marker;
                    btnMarker.setTextPosition(Label.RIGHT);
                }
            }
            InteractionDialog dlg = new InteractionDialog("Map Info");
            dlg.setLayout(new BorderLayout());
            dlg.add(BorderLayout.CENTER, this);
            int dh = disp.getDisplayHeight();
            int dw = disp.getDisplayWidth();
            dlg.show(0, dw / 2, 0, 0);
            updateMapPosition();
        }
    }
}
Also used : InteractionDialog(com.codename1.components.InteractionDialog) BorderLayout(com.codename1.ui.layouts.BorderLayout) Button(com.codename1.ui.Button) BoxLayout(com.codename1.ui.layouts.BoxLayout) Component(com.codename1.ui.Component) Display(com.codename1.ui.Display)

Aggregations

InteractionDialog (com.codename1.components.InteractionDialog)4 BorderLayout (com.codename1.ui.layouts.BorderLayout)4 ActionEvent (com.codename1.ui.events.ActionEvent)3 ActionListener (com.codename1.ui.events.ActionListener)3 BoxLayout (com.codename1.ui.layouts.BoxLayout)3 ToastBar (com.codename1.components.ToastBar)2 Util (com.codename1.io.Util)2 Coord (com.codename1.maps.Coord)2 Button (com.codename1.ui.Button)2 Component (com.codename1.ui.Component)2 ComponentSelector.$ (com.codename1.ui.ComponentSelector.$)2 Display (com.codename1.ui.Display)2 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)2 Style (com.codename1.ui.plaf.Style)2 IOException (java.io.IOException)2 FloatingActionButton (com.codename1.components.FloatingActionButton)1 MapContainer (com.codename1.googlemaps.MapContainer)1 MapObject (com.codename1.googlemaps.MapContainer.MapObject)1 ConnectionRequest (com.codename1.io.ConnectionRequest)1 Cookie (com.codename1.io.Cookie)1