forked from upstream-mirrors/OpenTracks
Clean up all usages of String.format to support i18n.
This commit is contained in:
@@ -47,8 +47,7 @@ public class AntPreference extends Preference {
|
||||
if (sensorId == 0) {
|
||||
setSummary(R.string.settings_sensor_ant_not_paired);
|
||||
} else {
|
||||
setSummary(
|
||||
String.format(getContext().getString(R.string.settings_sensor_ant_paired), sensorId));
|
||||
setSummary(getContext().getString(R.string.settings_sensor_ant_paired, sensorId));
|
||||
}
|
||||
|
||||
// Add actions to allow repairing.
|
||||
|
||||
@@ -233,8 +233,7 @@ public class SensorStateActivity extends AbstractMyTracksActivity {
|
||||
String value;
|
||||
if (sensorDataSet.hasPower() && sensorDataSet.getPower().hasValue()
|
||||
&& sensorDataSet.getPower().getState() == Sensor.SensorState.SENDING) {
|
||||
String format = getString(R.string.sensor_state_power_value);
|
||||
value = String.format(format, sensorDataSet.getPower().getValue());
|
||||
value = getString(R.string.sensor_state_power_value, sensorDataSet.getPower().getValue());
|
||||
} else {
|
||||
value = SensorUtils.getStateAsString(
|
||||
sensorDataSet.hasPower() ? sensorDataSet.getPower().getState() : Sensor.SensorState.NONE,
|
||||
@@ -252,8 +251,7 @@ public class SensorStateActivity extends AbstractMyTracksActivity {
|
||||
String value;
|
||||
if (sensorDataSet.hasCadence() && sensorDataSet.getCadence().hasValue()
|
||||
&& sensorDataSet.getCadence().getState() == Sensor.SensorState.SENDING) {
|
||||
String format = getString(R.string.sensor_state_cadence_value);
|
||||
value = String.format(format, sensorDataSet.getCadence().getValue());
|
||||
value = getString(R.string.sensor_state_cadence_value, sensorDataSet.getCadence().getValue());
|
||||
} else {
|
||||
value = SensorUtils.getStateAsString(
|
||||
sensorDataSet.hasCadence() ? sensorDataSet.getCadence().getState()
|
||||
@@ -271,8 +269,8 @@ public class SensorStateActivity extends AbstractMyTracksActivity {
|
||||
String value;
|
||||
if (sensorDataSet.hasHeartRate() && sensorDataSet.getHeartRate().hasValue()
|
||||
&& sensorDataSet.getHeartRate().getState() == Sensor.SensorState.SENDING) {
|
||||
String format = getString(R.string.sensor_state_heart_rate_value);
|
||||
value = String.format(format, sensorDataSet.getHeartRate().getValue());
|
||||
value = getString(
|
||||
R.string.sensor_state_heart_rate_value, sensorDataSet.getHeartRate().getValue());
|
||||
} else {
|
||||
value = SensorUtils.getStateAsString(
|
||||
sensorDataSet.hasHeartRate() ? sensorDataSet.getHeartRate().getState()
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.net.Uri;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Database importer which reads values written by {@link DatabaseDumper}.
|
||||
@@ -179,7 +180,7 @@ public class DatabaseImporter {
|
||||
byte[] blob = new byte[blobLength];
|
||||
int readBytes = reader.read(blob, 0, blobLength);
|
||||
if (readBytes != blobLength) {
|
||||
throw new IOException(String.format(
|
||||
throw new IOException(String.format(Locale.US,
|
||||
"Short read on column %s; expected %d bytes, read %d",
|
||||
name, blobLength, readBytes));
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class SendDocsUtils {
|
||||
throws IOException, ParseException, HttpException {
|
||||
GDataParser gDataParser = null;
|
||||
try {
|
||||
String uri = String.format(GET_SPREADSHEET_BY_TITLE_URI, URLEncoder.encode(title));
|
||||
String uri = String.format(Locale.US, GET_SPREADSHEET_BY_TITLE_URI, URLEncoder.encode(title));
|
||||
gDataParser = documentsClient.getParserForFeed(Entry.class, uri, authToken);
|
||||
gDataParser.init();
|
||||
|
||||
@@ -222,7 +222,7 @@ public class SendDocsUtils {
|
||||
throws IOException, AuthenticationException, ParseException {
|
||||
GDataParser gDataParser = null;
|
||||
try {
|
||||
String uri = String.format(GET_WORKSHEETS_URI, spreadsheetId);
|
||||
String uri = String.format(Locale.US, GET_WORKSHEETS_URI, spreadsheetId);
|
||||
gDataParser = spreadsheetClient.getParserForWorksheetsFeed(uri, authToken);
|
||||
gDataParser.init();
|
||||
if (!gDataParser.hasMoreData()) {
|
||||
@@ -269,7 +269,7 @@ public class SendDocsUtils {
|
||||
public static void addTrackInfo(
|
||||
Track track, String spreadsheetId, String worksheetId, String authToken, Context context)
|
||||
throws IOException {
|
||||
String worksheetUri = String.format(GET_WORKSHEET_URI, spreadsheetId, worksheetId);
|
||||
String worksheetUri = String.format(Locale.US, GET_WORKSHEET_URI, spreadsheetId, worksheetId);
|
||||
boolean metricUnits = PreferencesUtils.getBoolean(
|
||||
context, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
|
||||
addRow(worksheetUri, getRowContent(track, metricUnits, context), authToken);
|
||||
@@ -312,8 +312,8 @@ public class SendDocsUtils {
|
||||
appendTag(builder, "elevationunit", elevationUnit);
|
||||
|
||||
if (track.getMapId().length() > 0) {
|
||||
appendTag(builder, "map",
|
||||
String.format("%s?msa=0&msid=%s", Constants.MAPSHOP_BASE_URL, track.getMapId()));
|
||||
appendTag(builder, "map", String.format(
|
||||
Locale.US, "%s?msa=0&msid=%s", Constants.MAPSHOP_BASE_URL, track.getMapId()));
|
||||
}
|
||||
|
||||
builder.append("</entry>");
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.google.wireless.gdata.client.GDataServiceClient;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Client to talk to Google Maps via GData.
|
||||
*/
|
||||
@@ -93,9 +95,8 @@ public class MapsClient extends GDataServiceClient {
|
||||
|
||||
public static String getVersionFeed(String versionUserId,
|
||||
String versionClient, String currentVersion) {
|
||||
return String.format(MAPS_VERSION_FEED_PATH_FORMAT,
|
||||
MAPS_BASE_FEED_URL, versionUserId,
|
||||
versionClient, currentVersion);
|
||||
return String.format(Locale.US, MAPS_VERSION_FEED_PATH_FORMAT, MAPS_BASE_FEED_URL,
|
||||
versionUserId, versionClient, currentVersion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ import android.os.PowerManager.WakeLock;
|
||||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -777,9 +778,9 @@ public class TrackRecordingService extends Service {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, String.format(
|
||||
"Not recording. Distance to last recorded point (%f m) is less than"
|
||||
+ " %d m.", distanceToLastRecorded, minRecordingDistance));
|
||||
Log.d(TAG, String.format(Locale.US,
|
||||
"Not recording. Distance to last recorded point (%f m) is less than %d m.",
|
||||
distanceToLastRecorded, minRecordingDistance));
|
||||
// Return here so that the location is NOT recorded as the last location.
|
||||
return;
|
||||
}
|
||||
|
||||
+4
-2
@@ -33,6 +33,8 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* This is the common superclass for ANT-based sensors. It handles tasks which
|
||||
* apply to the ANT framework as a whole, such as framework initialization and
|
||||
@@ -279,7 +281,7 @@ public abstract class AntSensorManager extends SensorManager {
|
||||
*/
|
||||
protected boolean handleMessage(byte messageId, byte[] messageData) {
|
||||
if (messageId == AntMesg.MESG_STARTUP_MESG_ID) {
|
||||
Log.d(TAG, String.format(
|
||||
Log.d(TAG, String.format(Locale.US,
|
||||
"Received startup message (reason %02x); initializing channel",
|
||||
new AntStartupMessage(messageData).getMessage()));
|
||||
setupAntSensorChannels();
|
||||
@@ -376,7 +378,7 @@ public abstract class AntSensorManager extends SensorManager {
|
||||
private String messageToString(byte[] message) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (byte b : message) {
|
||||
out.append(String.format("%s%02x", (out.length() == 0 ? "" : " "), b));
|
||||
out.append(String.format(Locale.US, "%s%02x", (out.length() == 0 ? "" : " "), b));
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
||||
speed = context.getResources().getQuantityString(speedId, getQuantityCount(s), s);
|
||||
} else {
|
||||
int paceId = metricUnits ? R.string.voice_pace_per_kilometer : R.string.voice_pace_per_mile;
|
||||
speed = String.format(context.getString(paceId), getAnnounceTime((long) s));
|
||||
speed = context.getString(paceId, getAnnounceTime((long) s));
|
||||
}
|
||||
|
||||
int totalDistanceId = metricUnits ? R.plurals.voiceTotalDistanceKilometers
|
||||
|
||||
+2
-4
@@ -911,15 +911,13 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
String selection;
|
||||
String[] selectionArgs;
|
||||
if (minWaypointId > 0) {
|
||||
selection = String.format("%s = ? AND %s >= ?",
|
||||
WaypointsColumns.TRACKID,
|
||||
WaypointsColumns._ID);
|
||||
selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns._ID + ">=?";
|
||||
selectionArgs = new String[] {
|
||||
Long.toString(trackId),
|
||||
Long.toString(minWaypointId)
|
||||
};
|
||||
} else {
|
||||
selection = String.format("%s=?", WaypointsColumns.TRACKID);
|
||||
selection = WaypointsColumns.TRACKID + "=?";
|
||||
selectionArgs = new String[] { Long.toString(trackId) };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user