diff --git a/core/src/main/java/com/agifans/agile/GameScreen.java b/core/src/main/java/com/agifans/agile/GameScreen.java index 6c833e7..f6d0362 100644 --- a/core/src/main/java/com/agifans/agile/GameScreen.java +++ b/core/src/main/java/com/agifans/agile/GameScreen.java @@ -280,7 +280,7 @@ private void draw(float delta) { batch.enableBlending(); batch.begin(); - if (keyboardType.isRendered()) { + if (keyboardType.isRendered() || viewportManager.isPortrait()) { batch.setColor(c.r, c.g, c.b, keyboardType.getOpacity()); batch.draw(keyboardType.getTexture(), 0, keyboardType.getRenderOffset()); } @@ -290,26 +290,13 @@ private void draw(float delta) { batch.setColor(c.r, c.g, c.b, 0.5f); if (viewportManager.isPortrait()) { batch.draw(joystickIcon, 0, 0); - if (Gdx.app.getType().equals(ApplicationType.Android)) { - // Main AGI keyboard on the left. - batch.draw(keyboardIcon, viewportManager.getWidth() - 145, 0); - // Mobile keyboard for debug purpose. Wouldn't normally make this available. - batch.setColor(c.r, c.g, c.b, 0.15f); - batch.draw(keyboardIcon, viewportManager.getWidth() - viewportManager.getWidth() / 2 - 70, 0); - - } else { - // Desktop puts keyboard button in the middle. - batch.draw(keyboardIcon, viewportManager.getWidth() - viewportManager.getWidth() / 2 - 70, 0); - // and the back button on the right. - batch.draw(backIcon, viewportManager.getWidth() - 145, 0); - } - + batch.draw(fullScreenIcon, viewportManager.getWidth() - viewportManager.getWidth() / 2 - 70, 0); + batch.draw(backIcon, viewportManager.getWidth() - 145, 0); } else { batch.draw(joystickIcon, 0, viewportManager.getHeight() - 140); batch.draw(fullScreenIcon, viewportManager.getWidth() - 150, viewportManager.getHeight() - 140); batch.draw(backIcon, viewportManager.getWidth() - 150, 0); batch.draw(keyboardIcon, 0, 0); - } batch.end(); diff --git a/core/src/main/java/com/agifans/agile/ui/GameScreenInputProcessor.java b/core/src/main/java/com/agifans/agile/ui/GameScreenInputProcessor.java index 343b34c..cb31c16 100644 --- a/core/src/main/java/com/agifans/agile/ui/GameScreenInputProcessor.java +++ b/core/src/main/java/com/agifans/agile/ui/GameScreenInputProcessor.java @@ -309,13 +309,6 @@ public boolean touchUp(int screenX, int screenY, int pointer, int button) { if (keycode != null) { processVirtualKeyboardKeyUp(keycode); } - } else if (keyboardType.equals(KeyboardType.MOBILE_ON_SCREEN)) { - // If the onscreen keyboard is being shown then if we receive a tap event, it - // won't be on the virtual keyboard but must therefore be outside it. So we - // hide the keyboard. - Gdx.input.setOnscreenKeyboardVisible(false); - keyboardType = KeyboardType.OFF; - } // TODO: Need to handle the magic numbers in this block in a better way. @@ -329,24 +322,12 @@ public boolean touchUp(int screenX, int screenY, int pointer, int button) { if (touchXY.y < 130) { if (touchXY.x < 140) { joystickClicked = true; - } else if (touchXY.x > (viewportManager.getWidth() - 145)) { - // If not Android, then right area is Back button. - if (Gdx.app.getType().equals(ApplicationType.Android)) { - keyboardClicked = true; - } else { - backArrowClicked = true; - } + backArrowClicked = true; } else { - // Mobile soft keyboard is only available in portrait mode (debug only) int midWidth = (int) (viewportManager.getWidth() - viewportManager.getWidth() / 2); if ((touchXY.x > (midWidth - 70)) && (touchXY.y < (midWidth + 70))) { - if (Gdx.app.getType().equals(ApplicationType.Android)) { - Gdx.input.setOnscreenKeyboardVisible(true); - keyboardType = KeyboardType.MOBILE_ON_SCREEN; - } else { - keyboardClicked = true; - } + fullScreenClicked = true; } } } @@ -473,15 +454,22 @@ public boolean touchDragged(int screenX, int screenY, int pointer) { } /** - * Invokes by its MachineScreen when the screen has resized. + * Invokes by its GameScreen when the screen has resized. * * @param width The new screen width. * @param height The new screen height. */ public void resize(int width, int height) { - if (keyboardType.isRendered()) { - // Switch keyboard layout based on the orientation. - keyboardType = (height > width ? KeyboardType.PORTRAIT_LOWER_CASE : KeyboardType.LANDSCAPE_LOWER_CASE); + if (height > width) { + // Change to portrait if it is not already a portrait keyboard. + if (!keyboardType.isPortrait()) { + keyboardType = KeyboardType.PORTRAIT_LOWER_CASE; + } + } else if (keyboardType.isRendered()) { + // Change to landscape if it is not already a landscape keyboard. + if (!keyboardType.isLandscape()) { + keyboardType = KeyboardType.LANDSCAPE_LOWER_CASE; + } } } diff --git a/core/src/main/java/com/agifans/agile/ui/KeyboardType.java b/core/src/main/java/com/agifans/agile/ui/KeyboardType.java index 85a26c5..7a70aef 100644 --- a/core/src/main/java/com/agifans/agile/ui/KeyboardType.java +++ b/core/src/main/java/com/agifans/agile/ui/KeyboardType.java @@ -283,6 +283,24 @@ public float getOpacity() { public boolean isRendered() { return (texture != null); } + + /** + * @return true if this KeyboardType is a landscape keyboard, otherwise false. + */ + public boolean isLandscape() { + return (equals(LANDSCAPE_LOWER_CASE) || + equals(LANDSCAPE_UPPER_CASE) || + equals(LANDSCAPE_PUNC_NUMBERS)); + } + + /** + * @return true if this KeyboardType is a portrait keyboard, otherwise false. + */ + public boolean isPortrait() { + return (equals(PORTRAIT_LOWER_CASE) || + equals(PORTRAIT_UPPER_CASE) || + equals(PORTRAIT_PUNC_NUMBERS)); + } /** * @return Offset from the bottom of the screen that the keyboard is rendered