diff --git a/project/src/main/java/com/shurik/droidzebra/GameState.java b/project/src/main/java/com/shurik/droidzebra/GameState.java index df91da5..2dae2b7 100644 --- a/project/src/main/java/com/shurik/droidzebra/GameState.java +++ b/project/src/main/java/com/shurik/droidzebra/GameState.java @@ -19,7 +19,7 @@ public class GameState { private int lastMove; private int nextMove; - private int reachedDepth; + private String reachedDepth = "0"; private ByteBoard byteBoard; private GameStateListener handler = new GameStateListener() { }; @@ -133,8 +133,8 @@ void setOpening(String opening) { handler.onBoard(this); } - void setReachedDepth(int reachedDepth) { - if(reachedDepth != this.reachedDepth) { + void setReachedDepth(String reachedDepth) { + if(!Objects.equals(reachedDepth, this.reachedDepth)) { this.reachedDepth = reachedDepth; handler.onBoard(this); } @@ -144,7 +144,7 @@ public String getOpening() { return opening; } - public int getReachedDepth() { + public String getReachedDepth() { return reachedDepth; } diff --git a/project/src/main/java/com/shurik/droidzebra/ZebraEngine.java b/project/src/main/java/com/shurik/droidzebra/ZebraEngine.java index 075ab16..581df61 100644 --- a/project/src/main/java/com/shurik/droidzebra/ZebraEngine.java +++ b/project/src/main/java/com/shurik/droidzebra/ZebraEngine.java @@ -722,9 +722,7 @@ private JSONObject Callback(int msgcode, JSONObject data) { String reachedDepth = split[1]; ZebraEngine.this.onDebugListener.onDebug("Depth: " + reachedDepth); try { - - int newDepth = Integer.parseInt(reachedDepth); - currentGameState.setReachedDepth(newDepth); + currentGameState.setReachedDepth(reachedDepth); } catch (NumberFormatException e) { Log.e("Status", e.toString(), e); } diff --git a/project/src/main/java/de/earthlingz/oerszebra/DroidZebra.java b/project/src/main/java/de/earthlingz/oerszebra/DroidZebra.java index f12262c..4e7dd19 100644 --- a/project/src/main/java/de/earthlingz/oerszebra/DroidZebra.java +++ b/project/src/main/java/de/earthlingz/oerszebra/DroidZebra.java @@ -298,51 +298,56 @@ public void onDebug(String message) { Log.i("Intent", type + " " + action); engine.setOnErrorListener(this); //TODO don't forget to remove later to avoid memory leak - - - - engine.onReady(() -> { - setContentView(R.layout.board_layout); - showActionBar(); - getState().reset(); - mBoardView = findViewById(R.id.board); - mBoardView.setBoardViewModel(getState()); - mBoardView.setOnMakeMoveListener(this); - mBoardView.requestFocus(); - - //https://developer.android.com/develop/ui/views/layout/edge-to-edge?hl=de#java - ViewCompat.setOnApplyWindowInsetsListener(mBoardView, (v, windowInsets) -> { - Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); - // Apply the insets as a margin to the view. This solution sets only the - // bottom, left, and right dimensions, but you can apply whichever insets are - // appropriate to your layout. You can also update the view padding if that's - // more appropriate. - ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); - mlp.topMargin = insets.top; - mlp.leftMargin = insets.left; - mlp.bottomMargin = insets.bottom; - mlp.rightMargin = insets.right; - v.setLayoutParams(mlp); - - // Return CONSUMED if you don't want want the window insets to keep passing - // down to descendant views. - return WindowInsetsCompat.CONSUMED; + if(engine.getState() != ZebraEngine.ENGINE_STATE.ES_INITIAL) { + onReady(savedInstanceState, action, type, intent); + } else { + engine.onReady(() -> { + onReady(savedInstanceState, action, type, intent); }); + } + } - resetStatusView(); + private void onReady(Bundle savedInstanceState, String action, String type, Intent intent) { + setContentView(R.layout.board_layout); + showActionBar(); + getState().reset(); + mBoardView = findViewById(R.id.board); + mBoardView.setBoardViewModel(getState()); + mBoardView.setOnMakeMoveListener(this); + mBoardView.requestFocus(); + + //https://developer.android.com/develop/ui/views/layout/edge-to-edge?hl=de#java + ViewCompat.setOnApplyWindowInsetsListener(mBoardView, (v, windowInsets) -> { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + // Apply the insets as a margin to the view. This solution sets only the + // bottom, left, and right dimensions, but you can apply whichever insets are + // appropriate to your layout. You can also update the view padding if that's + // more appropriate. + ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); + mlp.topMargin = insets.top; + mlp.leftMargin = insets.left; + mlp.bottomMargin = insets.bottom; + mlp.rightMargin = insets.right; + v.setLayoutParams(mlp); + + // Return CONSUMED if you don't want want the window insets to keep passing + // down to descendant views. + return WindowInsetsCompat.CONSUMED; + }); - if (Intent.ACTION_SEND.equals(action) && type != null) { - handleIntent(intent); - } else if (savedInstanceState != null - && savedInstanceState.containsKey("moves_played_count") - && savedInstanceState.getInt("moves_played_count") > 0) { - startNewGameAndResetUI(savedInstanceState.getInt("moves_played_count"), savedInstanceState.getByteArray("moves_played")); - } else { - startNewGameAndResetUI(); - } + resetStatusView(); - mIsInitCompleted = true; - }); + if (Intent.ACTION_SEND.equals(action) && type != null) { + handleIntent(intent); + } else if (savedInstanceState != null + && savedInstanceState.containsKey("moves_played_count") + && savedInstanceState.getInt("moves_played_count") > 0) { + startNewGameAndResetUI(savedInstanceState.getInt("moves_played_count"), savedInstanceState.getByteArray("moves_played")); + } else { + startNewGameAndResetUI(); + } + + mIsInitCompleted = true; } private void startNewGameAndResetUI(LinkedList moves) { @@ -426,7 +431,7 @@ private void setStatus() { if(viewById != null) { int depth = settingsProvider.getSettingZebraDepth(); int depthExact = settingsProvider.getSettingZebraDepthExact(); - int reachedDepth = 0; + String reachedDepth = "0"; int moveNumber = 1; if(gameState != null) { reachedDepth = gameState.getReachedDepth(); diff --git a/project/src/main/java/de/earthlingz/oerszebra/guessmove/GuessMoveActivity.java b/project/src/main/java/de/earthlingz/oerszebra/guessmove/GuessMoveActivity.java index 5aa0b73..b85691e 100644 --- a/project/src/main/java/de/earthlingz/oerszebra/guessmove/GuessMoveActivity.java +++ b/project/src/main/java/de/earthlingz/oerszebra/guessmove/GuessMoveActivity.java @@ -6,10 +6,15 @@ import android.graphics.Color; import android.os.Bundle; import android.view.MenuItem; +import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; + import com.innovattic.rangeseekbar.RangeSeekBar; import com.shurik.droidzebra.EngineConfig; import com.shurik.droidzebra.InvalidMove; @@ -46,6 +51,26 @@ protected void onCreate(Bundle savedInstanceState) { boardView = findViewById(R.id.guess_move_board); boardViewModel = manager; boardView.setBoardViewModel(boardViewModel); + + //https://developer.android.com/develop/ui/views/layout/edge-to-edge?hl=de#java + ViewCompat.setOnApplyWindowInsetsListener(boardView, (v, windowInsets) -> { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + // Apply the insets as a margin to the view. This solution sets only the + // bottom, left, and right dimensions, but you can apply whichever insets are + // appropriate to your layout. You can also update the view padding if that's + // more appropriate. + ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); + mlp.topMargin = insets.top; + mlp.leftMargin = insets.left; + mlp.bottomMargin = insets.bottom; + mlp.rightMargin = insets.right; + v.setLayoutParams(mlp); + + // Return CONSUMED if you don't want want the window insets to keep passing + // down to descendant views. + return WindowInsetsCompat.CONSUMED; + }); + boardView.requestFocus(); sideToMoveCircle = findViewById(R.id.side_to_move_circle); hintText = findViewById(R.id.guess_move_text); diff --git a/project/src/main/res/values-de/strings.xml b/project/src/main/res/values-de/strings.xml index e568f99..1c16498 100644 --- a/project/src/main/res/values-de/strings.xml +++ b/project/src/main/res/values-de/strings.xml @@ -8,7 +8,7 @@ Du musst aussetzen Abbrechen Bist du sicher? - Move %4$d%nState: %5$s (%3$d)%nMid: %1$d Exact: %2$d + Move %4$d%nState: %5$s (%3$s)%nMid: %1$d Exact: %2$d Brett anzeigen Senden/Teilen Neues Spiel diff --git a/project/src/main/res/values-fr/strings.xml b/project/src/main/res/values-fr/strings.xml index a89b736..3627b09 100644 --- a/project/src/main/res/values-fr/strings.xml +++ b/project/src/main/res/values-fr/strings.xml @@ -60,7 +60,7 @@ OK Envoyer/Partager (ceci peut prendre du temps) - Move %4$d%nState: %5$s (%3$d)%nMid: %1$d Exact: %2$d + Move %4$d%nState: %5$s (%3$s)%nMid: %1$d Exact: %2$d Paramètres Généré par Reversatile (https://play.google.com/store/apps/details?id=de.earthlingz.oerszebra) Date: diff --git a/project/src/main/res/values-ja/strings.xml b/project/src/main/res/values-ja/strings.xml index 4c0cc89..28335dd 100644 --- a/project/src/main/res/values-ja/strings.xml +++ b/project/src/main/res/values-ja/strings.xml @@ -62,7 +62,7 @@ OK 送信/共有 (しばらくお待ちください) - Move %4$d%nState: %5$s (%3$d)%nMid: %1$d Exact: %2$d + Move %4$d%nState: %5$s (%3$s)%nMid: %1$d Exact: %2$d 設定 作成:DroidZebra (https://play.google.com/store/apps/details?id=de.earthlingz.oerszebra) 日付: diff --git a/project/src/main/res/values-ko/strings.xml b/project/src/main/res/values-ko/strings.xml index 2de17c7..78ced46 100644 --- a/project/src/main/res/values-ko/strings.xml +++ b/project/src/main/res/values-ko/strings.xml @@ -62,7 +62,7 @@ 보내기/공유 잠시만 기다려주십시오 - Move %4$d%nState: %5$s (%3$d)%nMid: %1$d Exact: %2$d + Move %4$d%nState: %5$s (%3$s)%nMid: %1$d Exact: %2$d 환경설정 드로이드제브라에 의해 생성됨 (https://play.google.com/store/apps/details?id=de.earthlingz.oerszebra) 날짜: diff --git a/project/src/main/res/values-ru/strings.xml b/project/src/main/res/values-ru/strings.xml index eecc711..3bbef7d 100644 --- a/project/src/main/res/values-ru/strings.xml +++ b/project/src/main/res/values-ru/strings.xml @@ -62,7 +62,7 @@ OK Отправить (это займет немного времени) - Move %4$d%nState: %5$s (%3$d)%nMid: %1$d Exact: %2$d + Move %4$d%nState: %5$s (%3$s)%nMid: %1$d Exact: %2$d Настройки Сгенерировано с помощью Reversatile (https://play.google.com/store/apps/details?id=de.earthlingz.oerszebra) Дата: diff --git a/project/src/main/res/values/strings.xml b/project/src/main/res/values/strings.xml index 11fd7fc..1fb0e1b 100644 --- a/project/src/main/res/values/strings.xml +++ b/project/src/main/res/values/strings.xml @@ -69,7 +69,7 @@ Cancel share/send (this may take a few moments) - Move %4$d%nState: %5$s (%3$d)%nMid: %1$d Exact: %2$d + Move %4$d%nState: %5$s (%3$s)%nMid: %1$d Exact: %2$d Settings Generated by Reversatile (https://play.google.com/store/apps/details?id=de.earthlingz.oerszebra)