diff --git a/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java b/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java index 54ab8b8..e31e930 100644 --- a/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java +++ b/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java @@ -36,6 +36,7 @@ import android.view.Window; import android.widget.Button; import android.widget.CheckBox; +import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; @@ -57,10 +58,12 @@ public class BouncyActivity extends Activity { View buttonPanel; View highScorePanel; + View selectTableRow; + ImageButton nextTableButton; + ImageButton previousTableButton; Button startGameButton; Button resumeGameButton; Button endGameButton; - Button switchTableButton; Button aboutButton; Button preferencesButton; Button showHighScoreButton; @@ -153,11 +156,13 @@ public class BouncyActivity extends Activity { scoreView.setHighScores(highScores); buttonPanel = findViewById(R.id.buttonPanel); + selectTableRow = findViewById(R.id.selectTableRow); highScorePanel = findViewById(R.id.highScorePanel); + nextTableButton = findViewById(R.id.nextTableButton); + previousTableButton = findViewById(R.id.previousTableButton); startGameButton = findViewById(R.id.startGameButton); resumeGameButton = findViewById(R.id.resumeGameButton); endGameButton = findViewById(R.id.endGameButton); - switchTableButton = findViewById(R.id.switchTableButton); aboutButton = findViewById(R.id.aboutButton); preferencesButton = findViewById(R.id.preferencesButton); unlimitedBallsToggle = findViewById(R.id.unlimitedBallsToggle); @@ -177,7 +182,7 @@ public class BouncyActivity extends Activity { // (after checking that the event was within the button bounds). This is likely // fragile but seems to be working ok. List allButtons = Arrays.asList( - startGameButton, resumeGameButton, endGameButton, switchTableButton, + nextTableButton, previousTableButton, startGameButton, resumeGameButton, endGameButton, aboutButton, preferencesButton, unlimitedBallsToggle, showHighScoreButton, hideHighScoreButton); for (View button : allButtons) { button.setOnTouchListener((view, motionEvent) -> { @@ -275,6 +280,19 @@ public void receivedOrientationValues(float azimuth, float pitch, float roll) { return true; } } + // When showing the main menu, switch tables with the flipper buttons. + if (!field.getGameState().isGameInProgress() && buttonPanel.getVisibility() == View.VISIBLE) { + if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) { + doPreviousTable(null); + startGameButton.requestFocus(); + return true; + } + if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { + doNextTable(null); + startGameButton.requestFocus(); + return true; + } + } return super.onKeyDown(keyCode, event); } @@ -315,11 +333,11 @@ void updateButtons() { } else { buttonPanel.setVisibility(View.VISIBLE); + selectTableRow.setVisibility(View.GONE); + unlimitedBallsToggle.setVisibility(View.GONE); startGameButton.setVisibility(View.GONE); resumeGameButton.setVisibility(View.VISIBLE); endGameButton.setVisibility(View.VISIBLE); - switchTableButton.setVisibility(View.GONE); - unlimitedBallsToggle.setVisibility(View.GONE); resumeGameButton.requestFocus(); } } @@ -334,11 +352,11 @@ else if (highScorePanel.getVisibility() == View.VISIBLE) { } else { buttonPanel.setVisibility(View.VISIBLE); + selectTableRow.setVisibility(View.VISIBLE); + unlimitedBallsToggle.setVisibility(View.VISIBLE); startGameButton.setVisibility(View.VISIBLE); resumeGameButton.setVisibility(View.GONE); endGameButton.setVisibility(View.GONE); - switchTableButton.setVisibility(View.VISIBLE); - unlimitedBallsToggle.setVisibility(View.VISIBLE); startGameButton.requestFocus(); } } @@ -592,8 +610,8 @@ public void scoreViewClicked(View view) { } } - public void doSwitchTable(View view) { - currentLevel = (currentLevel == numberOfLevels) ? 1 : currentLevel + 1; + void switchToTable(int tableNum) { + this.currentLevel = tableNum; synchronized (field) { resetFieldForCurrentLevel(); } @@ -604,6 +622,20 @@ public void doSwitchTable(View view) { fieldDriver.resetFrameRate(); } + public void doSwitchTable(View view) { + doNextTable(view); + } + + public void doNextTable(View view) { + int nextTableNum = (currentLevel == numberOfLevels) ? 1 : currentLevel + 1; + switchToTable(nextTableNum); + } + + public void doPreviousTable(View view) { + int prevTableNum = (currentLevel == 1) ? numberOfLevels : currentLevel - 1; + switchToTable(prevTableNum); + } + void resetFieldForCurrentLevel() { field.resetForLayoutMap(FieldLayoutReader.layoutMapForLevel(this, currentLevel)); } diff --git a/app/src/main/res/drawable-anydpi-v21/ic_baseline_arrow_left_60.xml b/app/src/main/res/drawable-anydpi-v21/ic_baseline_arrow_left_60.xml new file mode 100644 index 0000000..a68f25a --- /dev/null +++ b/app/src/main/res/drawable-anydpi-v21/ic_baseline_arrow_left_60.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable-anydpi-v21/ic_baseline_arrow_right_60.xml b/app/src/main/res/drawable-anydpi-v21/ic_baseline_arrow_right_60.xml new file mode 100644 index 0000000..5f86214 --- /dev/null +++ b/app/src/main/res/drawable-anydpi-v21/ic_baseline_arrow_right_60.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable-hdpi/ic_baseline_arrow_left_60.png b/app/src/main/res/drawable-hdpi/ic_baseline_arrow_left_60.png new file mode 100644 index 0000000..7e1cb60 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_baseline_arrow_left_60.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_baseline_arrow_right_60.png b/app/src/main/res/drawable-hdpi/ic_baseline_arrow_right_60.png new file mode 100644 index 0000000..49f8722 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_baseline_arrow_right_60.png differ diff --git a/app/src/main/res/drawable-ldpi/ic_baseline_arrow_left_60.png b/app/src/main/res/drawable-ldpi/ic_baseline_arrow_left_60.png new file mode 100644 index 0000000..8569d9c Binary files /dev/null and b/app/src/main/res/drawable-ldpi/ic_baseline_arrow_left_60.png differ diff --git a/app/src/main/res/drawable-ldpi/ic_baseline_arrow_right_60.png b/app/src/main/res/drawable-ldpi/ic_baseline_arrow_right_60.png new file mode 100644 index 0000000..93ccf78 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/ic_baseline_arrow_right_60.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_baseline_arrow_left_60.png b/app/src/main/res/drawable-mdpi/ic_baseline_arrow_left_60.png new file mode 100644 index 0000000..d250c17 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_baseline_arrow_left_60.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_baseline_arrow_right_60.png b/app/src/main/res/drawable-mdpi/ic_baseline_arrow_right_60.png new file mode 100644 index 0000000..4f3bbe1 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_baseline_arrow_right_60.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_baseline_arrow_left_60.png b/app/src/main/res/drawable-xhdpi/ic_baseline_arrow_left_60.png new file mode 100644 index 0000000..76706f0 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_baseline_arrow_left_60.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_baseline_arrow_right_60.png b/app/src/main/res/drawable-xhdpi/ic_baseline_arrow_right_60.png new file mode 100644 index 0000000..2cae486 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_baseline_arrow_right_60.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_baseline_arrow_left_60.png b/app/src/main/res/drawable-xxhdpi/ic_baseline_arrow_left_60.png new file mode 100644 index 0000000..6bb3afc Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_baseline_arrow_left_60.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_baseline_arrow_right_60.png b/app/src/main/res/drawable-xxhdpi/ic_baseline_arrow_right_60.png new file mode 100644 index 0000000..ce409ec Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_baseline_arrow_right_60.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_baseline_arrow_left_60.png b/app/src/main/res/drawable-xxxhdpi/ic_baseline_arrow_left_60.png new file mode 100644 index 0000000..f99b31f Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_baseline_arrow_left_60.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_baseline_arrow_right_60.png b/app/src/main/res/drawable-xxxhdpi/ic_baseline_arrow_right_60.png new file mode 100644 index 0000000..5356f06 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_baseline_arrow_right_60.png differ diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml index b18f928..c0353a0 100644 --- a/app/src/main/res/layout/main.xml +++ b/app/src/main/res/layout/main.xml @@ -29,97 +29,131 @@ android:layout_height="fill_parent" android:visibility="gone" /> - - -