Skip to content

Commit

Permalink
Translate showOrder, more finals
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsPIRI committed Jan 29, 2020
1 parent 322e8fe commit 7f55d7e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 30 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/thisispiri/mnk/andr/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/com/thisispiri/mnk/andr/DebugBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}
}
29 changes: 15 additions & 14 deletions app/src/main/java/com/thisispiri/mnk/andr/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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();
Expand All @@ -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.*/
Expand All @@ -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);
Expand Down Expand Up @@ -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)*/
Expand Down Expand Up @@ -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) {
Expand All @@ -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});
Expand All @@ -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 <T> void requestToUser(byte action, T details) {
@Override public <T> void requestToUser(final byte action, final T details) {
int actionStringID;
switch(action) {
case REQUEST_RESTART: actionStringID = R.string.restart; break;
Expand All @@ -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)};
Expand Down Expand Up @@ -788,7 +789,7 @@ private void loadGame(final String fileName) {
//SECTION: Fun
private static class FillHandler extends Handler{
final WeakReference<MainActivity> 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();
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@
<string name="exactSummary">예) 오목에서 육목을 만들면 인정x</string>
<string name="showHistoryHint">돌 모양을 바둑돌로 바꾸고 쓰세요</string>
<string name="helpers">도우미</string>
<string name="showOrder">돌 순서 보이기</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,5 @@
<string name="exactSummary">Discounts 6-lines in gomoku and such.</string>
<string name="helpers">Helpers</string>
<string name="showHistoryHint">Use with go stones symbol</string>
<string name="showOrder">Show order of moves</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
android:title="@string/helpers">
<CheckBoxPreference
android:key="showHistory"
android:title="Show stone history"
android:title="@string/showOrder"
android:defaultValue="false"
android:summary="@string/showHistoryHint"/>
<CheckBoxPreference
Expand Down

0 comments on commit 7f55d7e

Please sign in to comment.