mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-18 11:42:17 +01:00
DroidFish: Use Locale.US for all text formatting.
This commit is contained in:
@@ -859,7 +859,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
}
|
||||
|
||||
private final int getIntSetting(String settingName, int defaultValue) {
|
||||
String tmp = settings.getString(settingName, String.format("%d", defaultValue));
|
||||
String tmp = settings.getString(settingName, String.format(Locale.US, "%d", defaultValue));
|
||||
int value = Integer.parseInt(tmp);
|
||||
return value;
|
||||
}
|
||||
@@ -1085,7 +1085,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
R.string.stockfish_engine);
|
||||
boolean analysis = (ctrl != null) && ctrl.analysisMode();
|
||||
if ((strength < 1000) && !analysis) {
|
||||
engineTitleText.setText(String.format("%s: %d%%", eName, strength / 10));
|
||||
engineTitleText.setText(String.format(Locale.US, "%s: %d%%", eName, strength / 10));
|
||||
} else {
|
||||
engineTitleText.setText(eName);
|
||||
}
|
||||
@@ -3107,7 +3107,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
|
||||
@Override
|
||||
public void reportInvalidMove(Move m) {
|
||||
String msg = String.format("%s %s-%s",
|
||||
String msg = String.format(Locale.US, "%s %s-%s",
|
||||
getString(R.string.invalid_move),
|
||||
TextIO.squareToString(m.from), TextIO.squareToString(m.to));
|
||||
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
|
||||
@@ -3115,14 +3115,14 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
|
||||
@Override
|
||||
public void reportEngineName(String engine) {
|
||||
String msg = String.format("%s: %s",
|
||||
String msg = String.format(Locale.US, "%s: %s",
|
||||
getString(R.string.engine), engine);
|
||||
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportEngineError(String errMsg) {
|
||||
String msg = String.format("%s: %s",
|
||||
String msg = String.format(Locale.US, "%s: %s",
|
||||
getString(R.string.engine_error), errMsg);
|
||||
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.petero.droidfish.activities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.petero.droidfish.ChessBoard;
|
||||
import org.petero.droidfish.DroidFish;
|
||||
@@ -549,8 +550,8 @@ public class EditBoard extends Activity {
|
||||
builder.setTitle(R.string.edit_move_counters);
|
||||
final EditText halfMoveClock = (EditText)content.findViewById(R.id.ed_cnt_halfmove);
|
||||
final EditText fullMoveCounter = (EditText)content.findViewById(R.id.ed_cnt_fullmove);
|
||||
halfMoveClock.setText(String.format("%d", cb.pos.halfMoveClock));
|
||||
fullMoveCounter.setText(String.format("%d", cb.pos.fullMoveCounter));
|
||||
halfMoveClock.setText(String.format(Locale.US, "%d", cb.pos.halfMoveClock));
|
||||
fullMoveCounter.setText(String.format(Locale.US, "%d", cb.pos.fullMoveCounter));
|
||||
final Runnable setCounters = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.petero.droidfish.activities;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.petero.droidfish.ColorTheme;
|
||||
import org.petero.droidfish.R;
|
||||
@@ -382,7 +383,7 @@ public class EditPGN extends ListActivity {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.delete_file_question);
|
||||
String name = new File(pgnFile.getName()).getName();
|
||||
String msg = String.format(getString(R.string.delete_named_file), name);
|
||||
String msg = String.format(Locale.US, getString(R.string.delete_named_file), name);
|
||||
builder.setMessage(msg);
|
||||
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
||||
@@ -555,13 +555,13 @@ public class DroidComputerPlayer {
|
||||
if (sr.wTime < 1) sr.wTime = 1;
|
||||
if (sr.bTime < 1) sr.bTime = 1;
|
||||
StringBuilder goStr = new StringBuilder(96);
|
||||
goStr.append(String.format("go wtime %d btime %d", sr.wTime, sr.bTime));
|
||||
goStr.append(String.format(Locale.US, "go wtime %d btime %d", sr.wTime, sr.bTime));
|
||||
if (sr.wInc > 0)
|
||||
goStr.append(String.format(" winc %d", sr.wInc));
|
||||
goStr.append(String.format(Locale.US, " winc %d", sr.wInc));
|
||||
if (sr.bInc > 0)
|
||||
goStr.append(String.format(" binc %d", sr.bInc));
|
||||
goStr.append(String.format(Locale.US, " binc %d", sr.bInc));
|
||||
if (sr.movesToGo > 0)
|
||||
goStr.append(String.format(" movestogo %d", sr.movesToGo));
|
||||
goStr.append(String.format(Locale.US, " movestogo %d", sr.movesToGo));
|
||||
if (sr.ponderMove != null)
|
||||
goStr.append(" ponder");
|
||||
if (sr.searchMoves != null) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.petero.droidfish.engine;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Locale;
|
||||
|
||||
/** Implements line-based text communication between threads. */
|
||||
public class LocalPipe {
|
||||
@@ -9,13 +10,13 @@ public class LocalPipe {
|
||||
|
||||
/** Write a line to the pipe. */
|
||||
public final synchronized void printLine(String format) {
|
||||
String s = String.format(format, new Object[]{});
|
||||
String s = String.format(Locale.US, format, new Object[]{});
|
||||
addLine(s);
|
||||
}
|
||||
|
||||
/** Write a line to the pipe. */
|
||||
public final synchronized void printLine(String format, Object ... args) {
|
||||
String s = String.format(format, args);
|
||||
String s = String.format(Locale.US, format, args);
|
||||
addLine(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ public abstract class UCIEngineBase implements UCIEngine {
|
||||
|
||||
@Override
|
||||
public void setOption(String name, int value) {
|
||||
setOption(name, String.format("%d", value));
|
||||
setOption(name, String.format(Locale.US, "%d", value));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,7 +127,7 @@ public abstract class UCIEngineBase implements UCIEngine {
|
||||
String currVal = currOptions.get(lcName);
|
||||
if (value.equals(currVal))
|
||||
return;
|
||||
writeLineToEngine(String.format("setoption name %s value %s", name, value));
|
||||
writeLineToEngine(String.format(Locale.US, "setoption name %s value %s", name, value));
|
||||
currOptions.put(lcName, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ public class DroidChessController {
|
||||
continue;
|
||||
if (i > 0)
|
||||
buf.append('\n');
|
||||
buf.append(String.format("[%d] ", pvi.depth));
|
||||
buf.append(String.format(Locale.US, "[%d] ", pvi.depth));
|
||||
boolean negateScore = !whiteMove && gui.whiteBasedScores();
|
||||
if (pvi.upperBound || pvi.lowerBound) {
|
||||
boolean upper = pvi.upperBound ^ negateScore;
|
||||
@@ -636,9 +636,9 @@ public class DroidChessController {
|
||||
}
|
||||
int score = negateScore ? -pvi.score : pvi.score;
|
||||
if (pvi.isMate) {
|
||||
buf.append(String.format("m%d", score));
|
||||
buf.append(String.format(Locale.US, "m%d", score));
|
||||
} else {
|
||||
buf.append(String.format("%.2f", score / 100.0));
|
||||
buf.append(String.format(Locale.US, "%.2f", score / 100.0));
|
||||
}
|
||||
|
||||
buf.append(pvi.pvStr);
|
||||
@@ -715,7 +715,7 @@ public class DroidChessController {
|
||||
UndoInfo ui = new UndoInfo();
|
||||
if (ponderMove != null) {
|
||||
String moveStr = TextIO.moveToString(tmpPos, ponderMove, false, localPt());
|
||||
buf.append(String.format(" [%s]", moveStr));
|
||||
buf.append(String.format(Locale.US, " [%s]", moveStr));
|
||||
tmpPos.makeMove(ponderMove, ui);
|
||||
}
|
||||
for (Move m : pv.pv) {
|
||||
@@ -724,7 +724,7 @@ public class DroidChessController {
|
||||
if (!TextIO.isValid(tmpPos, m))
|
||||
break;
|
||||
String moveStr = TextIO.moveToString(tmpPos, m, false, localPt());
|
||||
buf.append(String.format(" %s", moveStr));
|
||||
buf.append(String.format(Locale.US, " %s", moveStr));
|
||||
tmpPos.makeMove(m, ui);
|
||||
}
|
||||
pv.pvStr = buf.toString();
|
||||
@@ -897,7 +897,7 @@ public class DroidChessController {
|
||||
if (computerPlayer != null) {
|
||||
engine = computerPlayer.getEngineName();
|
||||
if (strength < 1000)
|
||||
engine += String.format(" (%.1f%%)", strength * 0.1);
|
||||
engine += String.format(Locale.US, " (%.1f%%)", strength * 0.1);
|
||||
}
|
||||
String player = gui.playerName();
|
||||
String white = gameMode.playerWhite() ? player : engine;
|
||||
@@ -909,7 +909,7 @@ public class DroidChessController {
|
||||
private final synchronized void updatePlayerNames(String engineName) {
|
||||
if (game != null) {
|
||||
if (strength < 1000)
|
||||
engineName += String.format(" (%.1f%%)", strength * 0.1);
|
||||
engineName += String.format(Locale.US, " (%.1f%%)", strength * 0.1);
|
||||
String white = gameMode.playerWhite() ? game.tree.white : engineName;
|
||||
String black = gameMode.playerBlack() ? game.tree.black : engineName;
|
||||
game.tree.setPlayerNames(white, black);
|
||||
|
||||
@@ -83,7 +83,7 @@ public class GameTree {
|
||||
int year = now.get(Calendar.YEAR);
|
||||
int month = now.get(Calendar.MONTH) + 1;
|
||||
int day = now.get(Calendar.DAY_OF_MONTH);
|
||||
date = String.format("%04d.%02d.%02d", year, month, day);
|
||||
date = String.format(Locale.US, "%04d.%02d.%02d", year, month, day);
|
||||
}
|
||||
round = "?";
|
||||
white = "?";
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.petero.droidfish.gamelogic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.petero.droidfish.PGNOptions;
|
||||
import org.petero.droidfish.R;
|
||||
@@ -703,7 +704,7 @@ public class TextIO {
|
||||
*/
|
||||
public static final String asciiBoard(Position pos) {
|
||||
StringBuilder ret = new StringBuilder(400);
|
||||
String nl = String.format("%n");
|
||||
String nl = String.format(Locale.US, "%n");
|
||||
ret.append(" +----+----+----+----+----+----+----+----+"); ret.append(nl);
|
||||
for (int y = 7; y >= 0; y--) {
|
||||
ret.append(" |");
|
||||
|
||||
Reference in New Issue
Block a user