From 7f55d7ec67f02f2ae42c3a4402c6c5c55d105c4f Mon Sep 17 00:00:00 2001 From: ThisIsPIRI Date: Thu, 30 Jan 2020 04:14:46 +0900 Subject: [PATCH] Translate showOrder, more finals --- app/build.gradle | 4 +-- .../java/com/thisispiri/mnk/andr/Board.java | 10 +++---- .../com/thisispiri/mnk/andr/DebugBoard.java | 16 +++++----- .../com/thisispiri/mnk/andr/MainActivity.java | 29 ++++++++++--------- app/src/main/res/values-ko/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/preferences.xml | 2 +- 7 files changed, 33 insertions(+), 30 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4d0177e..7294bc0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.thisispiri.mnk" minSdkVersion 14 targetSdkVersion 28 - versionCode 33 - versionName "1.13.2" + versionCode 34 + versionName "1.14.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/java/com/thisispiri/mnk/andr/Board.java b/app/src/main/java/com/thisispiri/mnk/andr/Board.java index ac8a8dc..dcbf991 100644 --- a/app/src/main/java/com/thisispiri/mnk/andr/Board.java +++ b/app/src/main/java/com/thisispiri/mnk/andr/Board.java @@ -24,11 +24,11 @@ public enum Line { protected Line lineType; protected MnkGame game; private final RectF ovalData = new RectF(); - public Board(android.content.Context context, android.util.AttributeSet attr) { + public Board(final android.content.Context context, final android.util.AttributeSet attr) { super(context, attr); background = new Paint(); line = new Paint(); oPaint = new Paint(); xPaint = new Paint(); } - @Override protected void onDraw(Canvas canvas) { + @Override protected void onDraw(final Canvas canvas) { //draw background canvas.drawRect(0, 0, sideLength, sideLength, background); //draw lines @@ -105,7 +105,7 @@ else if(game.array[i][j] == Shape.X) { //draw X } } } - public void updateValues(int bgColor, int lineColor, int oColor, int xColor, Symbol ox, Line line) { + public void updateValues(final int bgColor, final int lineColor, final int oColor, final int xColor, final Symbol ox, final Line line) { background.setColor(bgColor); this.line.setColor(lineColor); //this.line.setStrokeWidth(lineWidth); @@ -115,14 +115,14 @@ public void updateValues(int bgColor, int lineColor, int oColor, int xColor, Sym lineType = line; } /**Assigns an {@link MnkGame} to be used in the object. Call this every time the board size is changed since it caches the values.*/ - public void setGame(MnkGame g) { + public void setGame(final MnkGame g) { game = g; horSize = game.getHorSize(); verSize = game.getVerSize(); horUnit = sideLength / horSize; verUnit = sideLength / verSize; } - public void setSideLength(int length) { + public void setSideLength(final int length) { sideLength = length; horUnit = length / horSize; verUnit = length / verSize; diff --git a/app/src/main/java/com/thisispiri/mnk/andr/DebugBoard.java b/app/src/main/java/com/thisispiri/mnk/andr/DebugBoard.java index 168de2e..4096a95 100644 --- a/app/src/main/java/com/thisispiri/mnk/andr/DebugBoard.java +++ b/app/src/main/java/com/thisispiri/mnk/andr/DebugBoard.java @@ -24,14 +24,14 @@ public class DebugBoard extends Board { * This shouldn't be used with {@link Symbol#XS_AND_OS}.*/ public boolean showOrder = false; private Move[] dummyArray = new Move[0]; - public DebugBoard(android.content.Context context, android.util.AttributeSet attr) { + public DebugBoard(final android.content.Context context, final android.util.AttributeSet attr) { super(context, attr); aiPaint.setTextSize(getResources().getDisplayMetrics().scaledDensity * 9); for(Paint p : orderPaints) { p.setTextAlign(Paint.Align.CENTER); } } - @Override protected void onDraw(Canvas canvas) { + @Override protected void onDraw(final Canvas canvas) { super.onDraw(canvas); if(showOrder) { Move[] moves = game.history.toArray(dummyArray); @@ -49,34 +49,34 @@ public DebugBoard(android.content.Context context, android.util.AttributeSet att } /**Manually change the turn numbers' colors. This will persist until the next {@link DebugBoard#updateValues}. * @param colors ARGB ColorInt vararg. First one for the first player and second one for the second. Do not pass more than two.*/ - public void setOrderColors(int... colors) { + public void setOrderColors(final int... colors) { for(int i = 0; i < orderPaints.length; i++) { orderPaints[i].setColor(colors[i]); } } /**The Strings will be drawn on lower left corner of their respective cells if {@code internals}' size matches that of the game's array. * Pass null to disable it.*/ - public void setAiInternals(String[][] internals) { + public void setAiInternals(final String[][] internals) { this.aiInternals = internals; } - @Override public void updateValues(int bgColor, int lineColor, int oColor, int xColor, Symbol ox, Line line) { + @Override public void updateValues(final int bgColor, final int lineColor, final int oColor, final int xColor, final Symbol ox, final Line line) { super.updateValues(bgColor, lineColor, oColor, xColor, ox, line); orderPaints[0].setColor(invertColor(xPaint.getColor())); orderPaints[1].setColor(invertColor(oPaint.getColor())); } - @Override public void setGame(MnkGame game) { + @Override public void setGame(final MnkGame game) { super.setGame(game); for(Paint p : orderPaints) { p.setTextSize(sideLength / Math.max(horSize, verSize) / 2); } } - @Override public void setSideLength(int length) { + @Override public void setSideLength(final int length) { super.setSideLength(length); for(Paint p : orderPaints) { p.setTextSize(sideLength / Math.max(horSize, verSize) / 2); } } - private int invertColor(@ColorInt int color) { + private int invertColor(final @ColorInt int color) { return argb(alpha(color), 0xFF - red(color), 0xFF - green(color), 0xFF - blue(color)); } } diff --git a/app/src/main/java/com/thisispiri/mnk/andr/MainActivity.java b/app/src/main/java/com/thisispiri/mnk/andr/MainActivity.java index cf1c83a..4dfdb50 100644 --- a/app/src/main/java/com/thisispiri/mnk/andr/MainActivity.java +++ b/app/src/main/java/com/thisispiri/mnk/andr/MainActivity.java @@ -357,7 +357,7 @@ else if(game.history.size() == game.getHorSize() * game.getVerSize()) { //if the } return null; } - private void aiTurn(boolean highlight) { + private void aiTurn(final boolean highlight) { MnkAiDecision decision = ai.playTurnJustify(game); if(showAiInternals) board.setAiInternals(decision.values); @@ -404,8 +404,9 @@ else if(game.getNextIndexAt(-1) == myIndex) { } return true; } - @Override public void updateRemaining(long time) { - winText.setText(String.format(Locale.getDefault(), "%02d : %02d : %03d", TimeUnit.MILLISECONDS.toMinutes(time), TimeUnit.MILLISECONDS.toSeconds(time) % 60, time % 1000)); + @Override public void updateRemaining(final long time) { + winText.setText(String.format(Locale.getDefault(), "%02d : %02d : %03d", + TimeUnit.MILLISECONDS.toMinutes(time), TimeUnit.MILLISECONDS.toSeconds(time) % 60, time % 1000)); } @Override public void timerFinished() { if(!enableTimeLimit) return; @@ -416,7 +417,7 @@ else if(game.getNextIndexAt(-1) == myIndex) { else limitTimer.start(); } - @Override public void togglePlaying(boolean allow) { + @Override public void togglePlaying(final boolean allow) { preventPlaying = !allow; if(preventPlaying) winText.setText(R.string.waitDelay); } @@ -467,7 +468,7 @@ private class BunStr { /**Shows a {@code DecisionDialogFragment} asking the user to confirm something. * Adds {@link MainActivity#DECISION_TAG} to the arguments as tagInBundle. * The positive and negative buttons will read {@code positive} and {@code negative}, respectively.*/ - private void requestConfirm(Bundle arguments, String message, String positive, String negative) { + private void requestConfirm(final Bundle arguments, final String message, final String positive, final String negative) { if(activityRunning) { arguments.putString(getString(R.string.i_tagInBundle), DECISION_TAG); DecisionDialogFragment decisionDialog = new DecisionDialogFragment(); @@ -486,7 +487,7 @@ private void requestConfirm(Bundle arguments, String message, String positive, S } /**@see MainActivity#requestConfirm(Bundle, String, String, String). * The Dialog class's default text will be used for the buttons.*/ - private void requestConfirm(Bundle arguments, String message) { + private void requestConfirm(final Bundle arguments, final String message) { requestConfirm(arguments, message, null, null); } /**Shows an {@code EditTextDialogFragment} with the supplied tag, message and hint.*/ @@ -501,7 +502,7 @@ private void showBluetoothDialog() { fragment.setArguments(bundleWith(getString(R.string.i_tagInBundle), BLUETOOTH_TAG)); fragment.show(getSupportFragmentManager(), BLUETOOTH_TAG, getString(R.string.app_name)); } - private void showChecksDialog(String message, int[] questions) { + private void showChecksDialog(final String message, final int[] questions) { ChecksDialogFragment checks = new ChecksDialogFragment(); checks.setArguments(bundleWith(getString(R.string.i_tagInBundle), CHECKS_TAG)); checks.show(getSupportFragmentManager(), CHECKS_TAG, message, questions); @@ -599,7 +600,7 @@ private void showChecksDialog(String message, int[] questions) { //SECTION: Communication /**Clicks the {@code RadioButton} without alerting {@code rLis}.*/ - private void hiddenClick(RadioButton button) { + private void hiddenClick(final RadioButton button) { AndrUtil.hiddenClick(rGroup, button, rLis, true); } /**Listens for changes in the playing mode(local or Bluetooth)*/ @@ -652,7 +653,7 @@ private void configureUI(final boolean toBluetooth) { /**Sets up the time limit if {@code limit} is greater than 0. Disables it otherwise. * Cancels the timer if the limit was changed from the last value. * @param limit If greater than 0, time limit is enabled and set to it. Otherwise, time limit is disabled.*/ - @Override public void setTimeLimit(int limit) { + @Override public void setTimeLimit(final int limit) { enableTimeLimit = limit > 0; timeLimit = limit; if(timeLimit != previousTimeLimit) { @@ -677,7 +678,7 @@ private void configureUI(final boolean toBluetooth) { } /**Stops Bluetooth communications but doesn't set radioLocal to true. * @param informOpponent If true, informs the opponent that we terminated the connection.*/ - private void stopBluetooth(boolean informOpponent) { + private void stopBluetooth(final boolean informOpponent) { try { if(bluetoothThread != null) { if(informOpponent) bluetoothThread.write(new byte[]{ORDER_HEADER, ORDER_CANCEL_CONNECTION}); @@ -690,14 +691,14 @@ private void stopBluetooth(boolean informOpponent) { showToast(this, R.string.problemWhileClosing); } } - @Override public void requestToUser(byte action) { + @Override public void requestToUser(final byte action) { requestToUser(action, null); } /**Informs that the opponent requested the {@code action} and lets the user choose whether to allow it or not. * If the requested {@code action} is {@link IoThread#REQUEST_RESTART}, displays the changed rules. * @param action The action the opponent requested. * @param details Currently used to show changed rules(int[]) to the user.*/ - @Override public void requestToUser(byte action, T details) { + @Override public void requestToUser(final byte action, final T details) { int actionStringID; switch(action) { case REQUEST_RESTART: actionStringID = R.string.restart; break; @@ -714,7 +715,7 @@ private void stopBluetooth(boolean informOpponent) { } requestConfirm(bundle, shownString); } - private String stringifyRules(int[] rules) { + private String stringifyRules(final int[] rules) { StringBuilder builder = new StringBuilder(); final String[] names = {getString(R.string.horSize), getString(R.string.verSize), getString(R.string.winCondition), getString(R.string.timeLimit), getString(R.string.gravity), getString(R.string.exactOnly), getString(R.string.myIndex)}; @@ -788,7 +789,7 @@ private void loadGame(final String fileName) { //SECTION: Fun private static class FillHandler extends Handler{ final WeakReference activity; - FillHandler(MainActivity a) {activity = new WeakReference<>(a);} + FillHandler(final MainActivity a) {activity = new WeakReference<>(a);} @Override public void handleMessage(final Message m) { if(m.getData().getString("result") != null) activity.get().winText.setText(m.getData().getString("result")); activity.get().board.invalidate(); diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 6bf89da..7112309 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -95,4 +95,5 @@ 예) 오목에서 육목을 만들면 인정x 돌 모양을 바둑돌로 바꾸고 쓰세요 도우미 + 돌 순서 보이기 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6b71b47..bbed095 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -94,4 +94,5 @@ Discounts 6-lines in gomoku and such. Helpers Use with go stones symbol + Show order of moves diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index c6d3338..2745573 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -57,7 +57,7 @@ android:title="@string/helpers">