diff --git a/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java b/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java index 878489c..54ab8b8 100644 --- a/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java +++ b/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java @@ -309,8 +309,9 @@ public void unpauseGame() { void updateButtons() { GameState state = field.getGameState(); if (state.isPaused()) { - if (highScorePanel.getVisibility() == View.VISIBLE){ + if (highScorePanel.getVisibility() == View.VISIBLE) { buttonPanel.setVisibility(View.GONE); + hideHighScoreButton.requestFocus(); } else { buttonPanel.setVisibility(View.VISIBLE); @@ -327,8 +328,9 @@ void updateButtons() { buttonPanel.setVisibility(View.GONE); highScorePanel.setVisibility(View.GONE); } - else if (highScorePanel.getVisibility() == View.VISIBLE){ + else if (highScorePanel.getVisibility() == View.VISIBLE) { buttonPanel.setVisibility(View.GONE); + hideHighScoreButton.requestFocus(); } else { buttonPanel.setVisibility(View.VISIBLE); @@ -610,12 +612,14 @@ public void showHighScore(View view) { this.fillHighScoreAdapter(); this.buttonPanel.setVisibility(View.GONE); this.highScorePanel.setVisibility(View.VISIBLE); + updateButtons(); } public void hideHighScore(View view) { this.buttonPanel.setVisibility(View.VISIBLE); this.highScorePanel.setVisibility(View.GONE); this.highScoreListLayout.removeAllViews(); + updateButtons(); } private void fillHighScoreAdapter() { diff --git a/app/src/main/java/com/dozingcatsoftware/bouncy/FieldLayoutReader.java b/app/src/main/java/com/dozingcatsoftware/bouncy/FieldLayoutReader.java index 590a403..c201c80 100644 --- a/app/src/main/java/com/dozingcatsoftware/bouncy/FieldLayoutReader.java +++ b/app/src/main/java/com/dozingcatsoftware/bouncy/FieldLayoutReader.java @@ -17,9 +17,14 @@ public class FieldLayoutReader { public static int getNumberOfLevels(Context context) { try { - return (int) Arrays.stream(context.getAssets().list("tables")) - .filter(name -> name.matches("^table\\d+\\.json")) - .count(); + // This would be cleaner with Arrays.stream/filter/count, but that's not supported + // by Android's desugaring library so it breaks on older devices. + List tableFiles = Arrays.asList(context.getAssets().list("tables")); + int count = 0; + while (tableFiles.contains("table" + (count + 1) + ".json")) { + count++; + } + return count; } catch (IOException ex) { throw new RuntimeException(ex);