Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flip board switch #168

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
android:versionCode="200"
android:versionName="9.4.2">
android:versionCode="201"
android:versionName="9.5.0">

<application
android:name="android.app.Application"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract public class ChessBoardActivity extends BaseActivity implements GameLis
protected ArrayList<Integer> highlightedPositions = new ArrayList<Integer>();
protected ArrayList<Integer> moveToPositions = new ArrayList<Integer>();
protected int soundTickTock, soundCheck, soundMove, soundCapture, soundNewGame;
protected boolean skipReturn = true, showMoves = false;
protected boolean skipReturn = true, showMoves = false, flipBoard = false;
private String keyboardBuffer = "";

public boolean requestMove(final int from, final int to) {
Expand Down
23 changes: 20 additions & 3 deletions app/src/main/java/jwtc/android/chess/play/PlayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ public class PlayActivity extends ChessBoardActivity implements SeekBar.OnSeekBa
private ProgressBar progressBarEngine;
private ImageButton playButton;
private boolean vsCPU = true;
private boolean flipBoard = false;
private int myTurn = 1, requestMoveFrom = -1, requestMoveTo = -1;
private ChessPiecesStackView topPieces;
private ChessPiecesStackView bottomPieces;
private ViewSwitcher switchTurnMe, switchTurnOpp;
private TextView textViewOpponent, textViewMe, textViewOpponentClock, textViewMyClock, textViewEngineValue, textViewEcoValue;
private TableLayout layoutBoardTop, layoutBoardBottom;
private SwitchMaterial switchSound, switchBlindfold;
private SwitchMaterial switchSound, switchBlindfold, switchFlip;

@Override
public boolean requestMove(final int from, final int to) {
Expand Down Expand Up @@ -224,6 +225,14 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});

switchFlip = findViewById(R.id.SwitchFlip);
switchFlip.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
flipBoard = switchFlip.isChecked();
updateBoardRotation();
}
});

}

@Override
Expand Down Expand Up @@ -357,11 +366,11 @@ protected void onPause() {
editor.putString("game_pgn", gameApi.exportFullPGN());
editor.putString("FEN", null); //


editor.putLong("clockWhiteMillies", localClock.getWhiteRemaining());
editor.putLong("clockBlackMillies", localClock.getBlackRemaining());
editor.putLong("clockStartTime", localClock.getLastMeasureTime());

editor.putBoolean("flipBoard", flipBoard);
// if (_uriNotification == null)
// editor.putString("NotificationUri", null);
// else
Expand Down Expand Up @@ -721,6 +730,10 @@ protected void updateForNewGame() {
resetSelectedSquares();
}

protected void updateBoardRotation() {
chessBoardView.setRotated(myTurn == BoardConstants.BLACK && !flipBoard || myTurn == BoardConstants.WHITE && flipBoard);
}

protected void updateGameSettingsByPrefs() {
SharedPreferences prefs = getPrefs();

Expand All @@ -741,7 +754,11 @@ protected void updateGameSettingsByPrefs() {

myEngine.setQuiescentSearchOn(prefs.getBoolean("quiescentSearchOn", true));

chessBoardView.setRotated(myTurn == BoardConstants.BLACK);
flipBoard = prefs.getBoolean("flipBoard", false);

switchFlip.setChecked(flipBoard);

updateBoardRotation();

playIfEngineMove();
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout-land/play.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@
android:checked="true"
android:nextFocusDown="@id/ButtonNext"
></com.google.android.material.switchmaterial.SwitchMaterial>
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/SwitchFlip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@string/menu_flip"
android:checked="true"
></com.google.android.material.switchmaterial.SwitchMaterial>
</TableRow>
</TableLayout>

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/play.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@
android:text="@string/pref_sound"
android:checked="true"
></com.google.android.material.switchmaterial.SwitchMaterial>
<com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/SwitchFlip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@string/menu_flip"
android:checked="true"
></com.google.android.material.switchmaterial.SwitchMaterial>
</TableRow>
</TableLayout>

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<string name="menu_pgn_tool">PGN Werkzeug</string>
<string name="menu_about">Über</string>
<string name="menu_exit">Beenden</string>
<string name="menu_flip">Brett drehen</string>
<string name="menu_flip">Drehen</string>
<string name="menu_more">Mehr…</string>
<string name="menu_setup">Brett Einstellungen</string>
<string name="menu_from_qrcode">Von QR-code</string>
Expand All @@ -174,7 +174,7 @@
<string name="pref_show_captured">Geschlagenene Figuren</string>
<string name="pref_show_annotate">Kommentiere Zug</string>
<string name="menu_subview_guess">Rate den Zug</string>
<string name="pref_show_blindfold">Blindschach Modus</string>
<string name="pref_show_blindfold">Blindschach</string>

<string name="options_play_human">Spieler gegen Spieler</string>
<string name="options_play_android">Spieler gegen Android</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
<string name="pref_show_captured">Piezas capturadas</string>
<string name="pref_show_annotate">Anota movimiento</string>
<string name="menu_subview_guess">Adivina movimiento</string>
<string name="pref_show_blindfold">Modo venda</string>
<string name="pref_show_blindfold">Venda</string>

<string name="options_play_human">Humano contra Humano</string>
<string name="options_play_android">Human contra Android</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<string name="menu_pgn_tool">Outil PGN</string>
<string name="menu_about">A propos</string>
<string name="menu_exit">Quitter</string>
<string name="menu_flip">Inverser l\'échiquier</string>
<string name="menu_flip">Inverser</string>
<string name="menu_more">Plus…</string>
<string name="menu_setup">Configuration de l\'échiquier</string>
<string name="menu_from_qrcode">Depuis un QR-code</string>
Expand All @@ -185,7 +185,7 @@
<string name="pref_show_captured">Pièces capturées</string>
<string name="pref_show_annotate">Coups annotés</string>
<string name="menu_subview_guess">Evaluer le coup</string>
<string name="pref_show_blindfold">Mode aveugle</string>
<string name="pref_show_blindfold">Aveugle</string>

<string name="options_play_human">Humain contre humain</string>
<string name="options_play_android">Humain contre Android</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<string name="menu_pgn_tool">Strumento PGN</string>
<string name="menu_about">Informazioni</string>
<string name="menu_exit">Esci</string>
<string name="menu_flip">Inverti la scacchiera</string>
<string name="menu_flip">Inverti</string>
<string name="menu_more">Altro&#8230;</string>
<string name="menu_setup">Disponi la scacchiera</string>
<string name="menu_from_qrcode">Da QR Code</string>
Expand All @@ -176,7 +176,7 @@
<string name="pref_show_captured">Pezzi catturati</string>
<string name="pref_show_annotate">Annota mossa</string>
<string name="menu_subview_guess">Indovina la mossa</string>
<string name="pref_show_blindfold">Modalità alla cieca</string>
<string name="pref_show_blindfold">Benda</string>

<string name="options_play_human">Umano contro Umano</string>
<string name="options_play_android">Umano contro Android</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<string name="menu_pgn_tool">FerramentaPGN</string>
<string name="menu_about">Cerca de</string>
<string name="menu_exit">Saír</string>
<string name="menu_flip">Virar tabuleiro</string>
<string name="menu_flip">Virar</string>
<string name="menu_more">Mais…</string>
<string name="menu_setup">Configurar tabuleiro</string>
<string name="menu_from_qrcode">Desde código-QR</string>
Expand All @@ -176,7 +176,7 @@
<string name="pref_show_captured">Peças capturadas</string>
<string name="pref_show_annotate">Annotar jogada</string>
<string name="menu_subview_guess">Adivinhar jogada</string>
<string name="pref_show_blindfold">Modo venda</string>
<string name="pref_show_blindfold">Venda</string>

<string name="options_play_human">Humano contra Human</string>
<string name="options_play_android">Humano contra Android</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<string name="menu_pgn_tool">Инструмент PGN</string>
<string name="menu_about">О приложении</string>
<string name="menu_exit">Выход</string>
<string name="menu_flip">Перевернуть доску</string>
<string name="menu_flip">вращать</string>
<string name="menu_more">Ещё…</string>
<string name="menu_setup">Расстановка доски</string>
<string name="menu_from_qrcode">Из QR-кода</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<string name="menu_pgn_tool">PGN 工具</string>
<string name="menu_about">关于</string>
<string name="menu_exit">退出</string>
<string name="menu_flip">旋转棋盘</string>
<string name="menu_flip">旋转</string>
<string name="menu_more">更多…</string>
<string name="menu_setup">棋盘设置</string>
<string name="menu_from_qrcode">来自二维码</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
<string name="menu_pgn_tool">PGN tool</string>
<string name="menu_about">About</string>
<string name="menu_exit">Exit</string>
<string name="menu_flip">Flip board</string>
<string name="menu_flip">Rotate</string>
<string name="menu_more">More…</string>
<string name="menu_setup">Setup board</string>
<string name="menu_from_qrcode">From QR-code</string>
Expand All @@ -186,7 +186,7 @@
<string name="pref_show_captured">Captured pieces</string>
<string name="pref_show_annotate">Annotate move</string>
<string name="menu_subview_guess">Guess the move</string>
<string name="pref_show_blindfold">Blindfold mode</string>
<string name="pref_show_blindfold">Blindfold</string>

<string name="options_play_human">Human vs Human</string>
<string name="options_play_android">Human vs Android</string>
Expand Down