mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-20 04:32:17 +01:00
DroidFish: Fixed lint warnings about locale-dependent string formatting.
This commit is contained in:
@@ -33,6 +33,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.petero.droidfish.ChessBoard.SquareDecoration;
|
||||
@@ -1262,7 +1263,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
/** Set new game mode. */
|
||||
private final void newGameMode(int gameModeType) {
|
||||
Editor editor = settings.edit();
|
||||
String gameModeStr = String.format("%d", gameModeType);
|
||||
String gameModeStr = String.format(Locale.US, "%d", gameModeType);
|
||||
editor.putString("gameMode", gameModeStr);
|
||||
editor.commit();
|
||||
gameMode = new GameMode(gameModeType);
|
||||
@@ -1285,8 +1286,8 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
private final int nameMatchScore(String name, String match) {
|
||||
if (name == null)
|
||||
return 0;
|
||||
String lName = name.toLowerCase();
|
||||
String lMatch = match.toLowerCase();
|
||||
String lName = name.toLowerCase(Locale.US);
|
||||
String lMatch = match.toLowerCase(Locale.US);
|
||||
if (name.equals(match))
|
||||
return 6;
|
||||
if (lName.equals(lMatch))
|
||||
@@ -1561,7 +1562,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
if (type != 2) {
|
||||
int gameModeType = (type == 0) ? GameMode.PLAYER_WHITE : GameMode.PLAYER_BLACK;
|
||||
Editor editor = settings.edit();
|
||||
String gameModeStr = String.format("%d", gameModeType);
|
||||
String gameModeStr = String.format(Locale.US, "%d", gameModeType);
|
||||
editor.putString("gameMode", gameModeStr);
|
||||
editor.commit();
|
||||
gameMode = new GameMode(gameModeType);
|
||||
@@ -2119,7 +2120,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
dialog.dismiss();
|
||||
if (gameModeType >= 0) {
|
||||
Editor editor = settings.edit();
|
||||
String gameModeStr = String.format("%d", gameModeType);
|
||||
String gameModeStr = String.format(Locale.US, "%d", gameModeType);
|
||||
editor.putString("gameMode", gameModeStr);
|
||||
editor.commit();
|
||||
gameMode = new GameMode(gameModeType);
|
||||
@@ -2225,7 +2226,7 @@ public class DroidFish extends Activity implements GUIInterface {
|
||||
moveView.setText(commInfo.move);
|
||||
String nagStr = Node.nagStr(commInfo.nag).trim();
|
||||
if ((nagStr.length() == 0) && (commInfo.nag > 0))
|
||||
nagStr = String.format("%d", commInfo.nag);
|
||||
nagStr = String.format(Locale.US, "%d", commInfo.nag);
|
||||
nag.setText(nagStr);
|
||||
|
||||
builder.setNegativeButton(R.string.cancel, null);
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package org.petero.droidfish;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
@@ -173,7 +175,7 @@ public class SeekBarPreference extends Preference
|
||||
}
|
||||
|
||||
private final String valToString() {
|
||||
return String.format("%.1f%%", currVal*0.1);
|
||||
return String.format(Locale.US, "%.1f%%", currVal*0.1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package org.petero.droidfish.activities;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.petero.droidfish.ColorTheme;
|
||||
@@ -286,7 +287,7 @@ public class LoadScid extends ListActivity {
|
||||
String scidFileName = fileName.substring(0, fileName.indexOf("."));
|
||||
String[] proj = new String[]{"pgn"};
|
||||
try {
|
||||
String uri = String.format("content://org.scid.database.scidprovider/games/%d", gameId);
|
||||
String uri = String.format(Locale.US, "content://org.scid.database.scidprovider/games/%d", gameId);
|
||||
Cursor cursor = managedQuery(Uri.parse(uri),
|
||||
proj, scidFileName, null, null);
|
||||
return cursor;
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.petero.droidfish.EngineOptions;
|
||||
import org.petero.droidfish.book.BookOptions;
|
||||
@@ -735,7 +736,7 @@ public class DroidComputerPlayer {
|
||||
listener.notifyEngineName(engineName);
|
||||
}
|
||||
} else if (tokens.length > 2) {
|
||||
String optName = tokens[2].toLowerCase();
|
||||
String optName = tokens[2].toLowerCase(Locale.US);
|
||||
uci.registerOption(optName);
|
||||
if (optName.equals("multipv")) {
|
||||
try {
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.petero.droidfish.EngineOptions;
|
||||
import org.petero.droidfish.engine.cuckoochess.CuckooChessEngine;
|
||||
@@ -120,7 +121,7 @@ public abstract class UCIEngineBase implements UCIEngine {
|
||||
|
||||
@Override
|
||||
public void setOption(String name, String value) {
|
||||
String lcName = name.toLowerCase();
|
||||
String lcName = name.toLowerCase(Locale.US);
|
||||
if (!allOptions.contains(lcName))
|
||||
return;
|
||||
String currVal = currOptions.get(lcName);
|
||||
|
||||
@@ -24,6 +24,7 @@ import chess.Move;
|
||||
import chess.Position;
|
||||
import chess.TextIO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.petero.droidfish.EngineOptions;
|
||||
import org.petero.droidfish.engine.LocalPipe;
|
||||
@@ -146,12 +147,12 @@ public class CuckooChessEngine extends UCIEngineBase {
|
||||
if (tokens[1].endsWith("name")) {
|
||||
int idx = 2;
|
||||
while ((idx < tokens.length) && !tokens[idx].equals("value")) {
|
||||
optionName.append(tokens[idx++].toLowerCase());
|
||||
optionName.append(tokens[idx++].toLowerCase(Locale.US));
|
||||
optionName.append(' ');
|
||||
}
|
||||
if ((idx < tokens.length) && tokens[idx++].equals("value")) {
|
||||
while ((idx < tokens.length)) {
|
||||
optionValue.append(tokens[idx++].toLowerCase());
|
||||
optionValue.append(tokens[idx++].toLowerCase(Locale.US));
|
||||
optionValue.append(' ');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.petero.droidfish.gamelogic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.petero.droidfish.EngineOptions;
|
||||
@@ -676,7 +677,7 @@ public class DroidChessController {
|
||||
nps /= 1000;
|
||||
npsPrefix = "k";
|
||||
}
|
||||
statStrTmp = String.format("d:%d %d:%s t:%.2f n:%d%s nps:%d%s", currDepth, currMoveNr, currMoveStr,
|
||||
statStrTmp = String.format(Locale.US, "d:%d %d:%s t:%.2f n:%d%s nps:%d%s", currDepth, currMoveNr, currMoveStr,
|
||||
currTime / 1000.0, nodes, nodesPrefix, nps, npsPrefix);
|
||||
}
|
||||
final String statStr = statStrTmp;
|
||||
|
||||
Reference in New Issue
Block a user