merge heads

This commit is contained in:
Jimmy Shih
2011-12-16 15:04:32 -08:00
parent f973ab8ac2
commit 4ce0809948
96 changed files with 2689 additions and 13446 deletions
+2 -1
View File
@@ -21,7 +21,8 @@ limitations under the License.
<TableLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingBottom="2dp"
android:padding="2dp"
android:shrinkColumns="0"
android:stretchColumns="1">
<TableRow style="@style/AboutTableRow">
<ImageView
+57 -129
View File
@@ -14,139 +14,67 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_width="fill_parent">
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical">
<ScrollView
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="fill_parent">
<LinearLayout
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent">
android:layout_width="fill_parent"
android:orientation="vertical">
<TableLayout
android:layout_height="wrap_content"
android:stretchColumns="1,4"
android:layout_width="fill_parent">
<!-- Layout the sensor state on one line. -->
<TableRow>
<TextView
android:layout_span="5"
android:text="@string/menu_sensor_state" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
android:id="@+id/sensor_state_register"
android:layout_column="1"
android:layout_span="5"
style="@style/StatsRegister" />
</TableRow>
<!-- Layout the sensor data age on one line. -->
<TableRow>
<TextView
android:layout_span="5"
android:text="@string/sensor_state_last_sensor_time" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
android:id="@+id/sensor_data_time_register"
android:layout_column="1"
android:layout_span="5"
style="@style/StatsRegister" />
</TableRow>
<!-- Power meter -->
<TableRow
android:padding="1dip">
<TextView
android:layout_column="1"
android:layout_span="3"
android:text="@string/sensor_state_power" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
style="@style/StatsRegister.Big"
android:id="@+id/power_state_register"
android:layout_column="1"
android:layout_span="4" />
<TextView
style="@style/StatsUnitSolo" />
android:layout_column="5"
android:text="@string/watts" />
</TableRow>
<!-- Cadence -->
<TableRow
android:padding="1dip">
<TextView
android:layout_column="1"
android:layout_span="3"
android:text="@string/sensor_state_cadence" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
style="@style/StatsRegister.Big"
android:id="@+id/cadence_state_register"
android:layout_column="4" />
<TextView
style="@style/StatsUnitSolo" />
android:layout_column="2"
android:text="@string/revolutions_per_minute" />
</TableRow>
<!-- Heart Rate -->
<TableRow
android:padding="1dip">
<TextView
android:layout_column="1"
android:layout_span="3"
android:text="@string/sensor_state_heart_rate" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
style="@style/StatsRegister.Big"
android:id="@+id/heart_rate_register"
android:layout_column="1"
android:layout_span="4" />
<TextView
style="@style/StatsUnitSolo"
android:layout_column="5"
android:text="@string/unit_beat_per_minute" />
</TableRow>
<!-- Battery Level -->
<TableRow
android:padding="1dip">
<TextView
android:layout_column="1"
android:layout_span="3"
android:text="@string/sensor_state_battery" />
</TableRow>
<TableRow
android:background="@color/stat_label_background">
<TextView
style="@style/StatsRegister.Big"
android:id="@+id/battery_level_register"
android:layout_column="1"
android:layout_span="4" />
<TextView
style="@style/StatsUnitSolo"
android:layout_column="5"
android:text="@string/unit_percent" />
</TableRow>
</TableLayout>
<!-- Sensor state -->
<TextView
android:text="@string/menu_sensor_state"
style="@style/SensorStateLabel"/>
<TextView
android:id="@+id/sensor_state"
style="@style/SensorStateValue"/>
<!-- Last sensor time -->
<TextView
android:text="@string/sensor_state_last_sensor_time"
style="@style/SensorStateLabel"/>
<TextView
android:id="@+id/sensor_state_last_sensor_time"
style="@style/SensorStateValue"/>
<!-- Power -->
<TextView
android:text="@string/sensor_state_power"
style="@style/SensorStateLabel"/>
<TextView
android:id="@+id/sensor_state_power"
style="@style/SensorStateValue"/>
<!-- Cadence -->
<TextView
android:text="@string/sensor_state_cadence"
style="@style/SensorStateLabel"/>
<TextView
android:id="@+id/sensor_state_cadence"
style="@style/SensorStateValue"/>
<!-- Heart rate -->
<TextView
android:text="@string/sensor_state_heart_rate"
style="@style/SensorStateLabel"/>
<TextView
android:id="@+id/sensor_state_heart_rate"
style="@style/SensorStateValue"/>
<!-- Battery level -->
<TextView
android:text="@string/sensor_state_battery"
style="@style/SensorStateLabel"/>
<TextView
android:id="@+id/sensor_state_battery"
style="@style/SensorStateValue"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
</LinearLayout>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-1
View File
@@ -49,6 +49,5 @@ limitations under the License.
<string name="track_action_end">com.google.android.apps.mytracks.END_CURRENT_TRACK</string>
<string name="track_action_save">android.intent.action.SAVE</string>
<string name="track_action_start">com.google.android.apps.mytracks.START_NEW_TRACK</string>
<string name="unit_percent">%</string>
<string name="value_unknown">-</string>
</resources>
+100 -55
View File
@@ -472,42 +472,68 @@ limitations under the License.
Screenshot: eula.png">
Decline
</string>
<string name="eula_message"
translation_description="The message for the 'Terms of service' dialog.
<string name="eula_message_body"
translation_description="The body in the Google mobile terms of service. See
http://m.google.com/toscountry.">
By using Google\'s mobile products and services ("Services"), you:
</string>
<string name="eula_message_date"
translation_description="The date in the Google mobile terms of service. See
http://m.google.com/toscountry.">
December 1, 2010
</string>
<string name="eula_message_footer"
translation_description="The footer in the Google mobile terms of service. See
http://m.google.com/toscountry.
Google Mobile Terms of Service. Already translated at http://m.google.com/toscountry. Please
cut and paste the translations from the web site.">
December 1, 2010\n
\n
Mobile Terms of Service\n
\n
By using Google\'s mobile products and services ("Services"), you:\n
\n
1. Agree to be bound by these terms and a) the YouTube Terms of Use (m.google.com/tos_youtube)
for YouTube-related Services, b) the Google Maps Terms and Conditions (m.google.com/tos_maps)
for mapping, local and location-based Services, c) the Google Buzz Terms and Conditions for
Google Buzz-related Services (m.google.com/tos_buzz), d) the Google Books Terms of Service
(m.google.com/tos_books) for Books-related Services, and e) the Google Terms of Service
(m.google.com/utos) for all other Services, as updated from time to time. You may use the
Services only as set forth in these agreements. Do not manipulate while driving.\n
\n
2. Acknowledge and agree that third parties may offer Services, and that you may be subject to
third party terms and that third parties may enforce terms against you. Google is not
responsible for third party changes to the Services.\n
\n
3. Consent to the collection, use, sharing, and onward transfer of your data, including but not
limited to voice and location data, as outlined in the Mobile Privacy Policy
(m.google.com/privacy). Location data may be from mixed sources and may not be accurate. Use at
your own risk.\n
\n
4. Acknowledge that certain Services require phone service, data access or text messaging
capability. Except as otherwise noted, Google does not charge for the Services, but carrier
rates for phone, data and text messaging may apply.\n
\n
%1$s: host name, 'm.google.com'">
The Services may contain third party content. Any required attribution or notice for the third
party content may be found at m.google.com/legalnotices.\n
\n
©2011\n
party content may be found at %1$s/legalnotices.
</string>
<string name="eula_message_header"
translation_description="The header in the Google mobile terms of service. See
http://m.google.com/toscountry.">
Mobile Terms of Service
</string>
<string name="eula_message_item1"
translation_description="The first item in the Google mobile terms of service. See
http://m.google.com/toscountry.
%1$s: host name, 'm.google.com'
%2$s: host name, 'm.google.com'
%3$s: host name, 'm.google.com'
%4$s: host name, 'm.google.com'
%5$s: host name, 'm.google.com'">
Agree to be bound by these terms and a) the YouTube Terms of Use (%1$s/tos_youtube) for
YouTube-related Services, b) the Google Maps Terms and Conditions (%2$s/tos_maps) for mapping,
local and location-based Services, c) the Google Buzz Terms and Conditions for Google
Buzz-related Services (%3$s/tos_buzz), d) the Google Books Terms of Service (%4$s/tos_books) for
Books-related Services, and e) the Google Terms of Service (%5$s/utos) for all other Services,
as updated from time to time. You may use the Services only as set forth in these agreements. Do
not manipulate while driving.
</string>
<string name="eula_message_item2"
translation_description="The second item in the Google mobile terms of service. See
http://m.google.com/toscountry.">
Acknowledge and agree that third parties may offer Services, and that you may be subject to
third party terms and that third parties may enforce terms against you. Google is not
responsible for third party changes to the Services.
</string>
<string name="eula_message_item3"
translation_description="The third item in the Google mobile terms of service. See
http://m.google.com/toscountry.
%1$s: host name, 'm.google.com'">
Consent to the collection, use, sharing, and onward transfer of your data, including but not
limited to voice and location data, as outlined in the Mobile Privacy Policy (%1$s/privacy).
Location data may be from mixed sources and may not be accurate. Use at your own risk.
</string>
<string name="eula_message_item4"
translation_description="The fourth item in the Google mobile terms of service. See
http://m.google.com/toscountry.">
Acknowledge that certain Services require phone service, data access or text messaging
capability. Except as otherwise noted, Google does not charge for the Services, but carrier
rates for phone, data and text messaging may apply.
</string>
<string name="eula_title"
translation_description="The title for the 'Terms of service' dialog, asking the user to accept
@@ -1214,6 +1240,14 @@ limitations under the License.
Screenshot: sensor_state_none.png">
Battery level
</string>
<string name="sensor_state_battery_value"
translation_description="In the 'Sensor state' page, the value for the 'Battery level'. E.g,
'Battery level: 50 %'.
%1$d: a number. E.g., '50'.
%%: escape sequence for the '%' character.">
%1$d %%
</string>
<string name="sensor_state_cadence"
translation_description="In the 'Sensor state' page, the label for the cadence on the bike
sensor. Cadence is the number of revolutions of the crank per minute. E.g.,
@@ -1222,6 +1256,13 @@ limitations under the License.
Screenshot: sensor_state_none.png">
Cadence
</string>
<string name="sensor_state_cadence_value"
translation_description="In the 'Sensor state' page, the value for the 'Cadence'. Cadence is the
number of revolutions of the crank per minute. E.g., 'Cadence: 80 rpm'.
%1$d: a number. E.g., '80'.">
%1$d rpm
</string>
<string name="sensor_state_connected"
translation_description="In the 'Sensor state' page, the 'Sensor state' value when the sensor
has connected.
@@ -1250,6 +1291,13 @@ limitations under the License.
Screenshot: sensor_state_none.png">
Heart rate
</string>
<string name="sensor_state_heart_rate_value"
translation_description="In the 'Sensor state' page, the value for the 'Heart rate'. E.g.,
'Hear rate: 100 bpm'.
%1$d: a number. E.g., '100'.">
%1$d bpm
</string>
<string name="sensor_state_last_sensor_time"
translation_description="In the 'Sensor state' page, the label for the last time the sensor has
sent a data. E.g., 'Last sensor time: 10:05 am'.
@@ -1264,6 +1312,13 @@ limitations under the License.
Screenshot: sensor_state_none.png">
Power
</string>
<string name="sensor_state_power_value"
translation_description="In the 'Sensor state' page, the value for the 'Power'. Power is the
power output of the rider. E.g., 'Power: 50 W'.
%1$d: a number. E.g., '50'.">
%1$d W
</string>
<string name="sensor_state_sending"
translation_description="In the 'Sensor state' page, the 'Sensor state' value when the sensor is
sending data.
@@ -1732,7 +1787,7 @@ limitations under the License.
</string>
<string name="settings_sensor_ant_options"
translation_description="In the 'Sensor' settings, the section header to configure the ANT+
options.
options. Note that ANT+ is a radio standard.
Character limit: ~40 (1 line)
Screenshot: settings_sensor.png">
@@ -1795,7 +1850,7 @@ limitations under the License.
</string>
<string name="settings_sensor_type_ant"
translation_description="In the 'Sensor' settings, for the 'Sensor type' dropdown, the option to
connect to an ANT+ heart rate sensor.
connect to an ANT+ heart rate sensor. Note that ANT+ is a radio standard.
Character limit: ~21 (1 line)
Screenshot: settings_sensor_type.png">
@@ -1811,7 +1866,8 @@ limitations under the License.
</string>
<string name="settings_sensor_type_polar"
translation_description="In the 'Sensor' settings, for the 'Sensor type' dropdown, the option to
connect to a Polar bluetooth sensor.
connect to a Polar bluetooth sensor. Do not translate Polar, the company name, but can
translate Bluetooth, the radio standard.
Character limit: ~21 (1 line)
Screenshot: settings_sensor_type.png">
@@ -1819,7 +1875,8 @@ limitations under the License.
</string>
<string name="settings_sensor_type_srm"
translation_description="In the 'Sensor' settings, for the 'Sensor type' dropdown, the option to
connect to a SRM ANT+ bridge.
connect to a SRM ANT+ bridge. Do not trasnlate SRM, the company name, but can translate
ANT+, the radio standard, and bridge (network bridge).
Character limit: ~21 (1 line)
Screenshot: settings_sensor_type.png">
@@ -1834,7 +1891,8 @@ limitations under the License.
</string>
<string name="settings_sensor_type_zephyr"
translation_description="In the 'Sensor' settings, for the 'Sensor type' dropdown, the option to
connect to a Zephyr bluetooth sensor.
connect to a Zephyr bluetooth sensor. Do not translate Zephyr, the company name, but can
translate Bluetooth, the radio standard.
Character limit: ~21 (1 line)
Screenshot: settings_sensor_type.png">
@@ -1842,7 +1900,7 @@ limitations under the License.
</string>
<string name="settings_sensor_unpair_ant"
translation_description="In the 'Sensor' settings, under the 'ANT+ options' configurations, the
option to unpair an ANT+ heart rate sensor.
option to unpair an ANT+ heart rate sensor. Note that ANT+ is a radio standard.
Character limit: ~26 (1 line)
Screenshot: settings_sensor.png">
@@ -1850,7 +1908,8 @@ limitations under the License.
</string>
<string name="settings_sensor_unpair_srm"
translation_description="In the 'Sensor' settings, under the 'ANT+ options' configurations, the
option to unpair a SRM ANT+ bridge.
option to unpair a SRM ANT+ bridge. Do not trasnlate SRM, the company name, but can translate
ANT+, the radio standard, and bridge (network bridge).
Character limit: ~26 (1 line)
Screenshot: settings_sensor.png">
@@ -2291,11 +2350,6 @@ limitations under the License.
</string>
<!-- Unit -->
<string name="unit_beat_per_minute"
translation_description="Abbreviation for beats per minute, unit for heart rate. E.g.,
'Heart rate: 80 bpm'.">
bpm
</string>
<string name="unit_feet"
translation_description="Abbreviation for feet. E.g., '2 ft'.">
ft
@@ -2336,15 +2390,6 @@ limitations under the License.
translation_description="Abbreviation for minutes per mile. E.g, '5 min/mi'.">
min/mi
</string>
<string name="unit_revolution_per_minute"
translation_description="Abbreviation for revolutions per minute, unit for cadence. E.g.,
'Cadence: 80 rpm'.">
rpm
</string>
<string name="unit_watt"
translation_description="Abbreviation for watts, unit for power. E.g., 'Power: 80 W'.">
W
</string>
<!-- Value -->
<string name="value_adapt_accuracy"
+18
View File
@@ -71,6 +71,24 @@ limitations under the License.
<item name="android:visibility">gone</item>
</style>
<style name="SensorStateLabel">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
</style>
<style name="SensorStateValue">
<item name="android:background">@color/stat_label_background</item>
<item name="android:gravity">right</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
<item name="android:textColor">@color/stat_label_text</item>
<item name="android:textSize">40sp</item>
</style>
<!-- The style for a view which divides the numerator and denominator of the units on the statistics activity. -->
<style name="StatsDivider" parent="@android:Widget.TextView">
<item name="android:background">@color/black</item>
@@ -266,7 +266,7 @@ public class MyTracks extends TabActivity implements OnTouchListener {
case DIALOG_EULA_ID:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.eula_title);
builder.setMessage(R.string.eula_message);
builder.setMessage(EulaUtil.getEulaMessage(this));
builder.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@@ -80,7 +80,7 @@ public class SensorStateActivity extends Activity {
/**
* A temporary sensor manager, when none is available.
*/
SensorManager tempSensorManager = null;
private SensorManager tempSensorManager = null;
/**
* A state flag set to true when the activity is active/visible,
@@ -91,7 +91,7 @@ public class SensorStateActivity extends Activity {
* it could cause the {@link #tempSensorManager} to be recreated, after it
* is destroyed at the pause event.
*/
boolean isVisible = false;
private boolean isVisible = false;
public SensorStateActivity() {
utils = new StatsUtilities(this);
@@ -139,7 +139,7 @@ public class SensorStateActivity extends Activity {
super.onDestroy();
}
protected void updateState() {
private void updateState() {
Log.d(TAG, "Updating SensorStateActivity");
ITrackRecordingService service = serviceConnection.getServiceIfBound();
@@ -162,8 +162,7 @@ public class SensorStateActivity extends Activity {
}
}
private void updateFromTempSensorManager()
{
private void updateFromTempSensorManager() {
// Use variables to hold the sensor state and data set.
Sensor.SensorState currentState = null;
Sensor.SensorDataSet currentDataSet = null;
@@ -186,8 +185,7 @@ public class SensorStateActivity extends Activity {
updateSensorStateAndData(currentState, currentDataSet);
}
private void updateFromSysSensorManager()
{
private void updateFromSysSensorManager() {
// Use variables to hold the sensor state and data set.
Sensor.SensorState currentState = null;
Sensor.SensorDataSet currentDataSet = null;
@@ -228,91 +226,115 @@ public class SensorStateActivity extends Activity {
/**
* Stops the temporary sensor manager, if one exists.
*/
private void stopTempSensorManager()
{
private void stopTempSensorManager() {
if (tempSensorManager != null) {
tempSensorManager.shutdown();
tempSensorManager = null;
}
}
private void updateSensorStateAndData(Sensor.SensorState state, Sensor.SensorDataSet dataSet)
{
private void updateSensorStateAndData(Sensor.SensorState state, Sensor.SensorDataSet dataSet) {
updateSensorState(state == null ? Sensor.SensorState.NONE : state);
updateSensorData(dataSet);
}
private void updateSensorState(Sensor.SensorState state) {
TextView sensorTime =
((TextView) findViewById(R.id.sensor_state_register));
sensorTime.setText(SensorUtils.getStateAsString(state, this));
((TextView) findViewById(R.id.sensor_state)).setText(SensorUtils.getStateAsString(state, this));
}
protected void updateSensorData(Sensor.SensorDataSet sds) {
private void updateSensorData(Sensor.SensorDataSet sds) {
if (sds == null) {
utils.setUnknown(R.id.sensor_data_time_register);
utils.setUnknown(R.id.cadence_state_register);
utils.setUnknown(R.id.power_state_register);
utils.setUnknown(R.id.heart_rate_register);
utils.setUnknown(R.id.battery_level_register);
return;
utils.setUnknown(R.id.sensor_state_last_sensor_time);
utils.setUnknown(R.id.sensor_state_power);
utils.setUnknown(R.id.sensor_state_cadence);
utils.setUnknown(R.id.sensor_state_battery);
} else {
((TextView) findViewById(R.id.sensor_state_last_sensor_time)).setText(getLastSensorTime(sds));
((TextView) findViewById(R.id.sensor_state_power)).setText(getPower(sds));
((TextView) findViewById(R.id.sensor_state_cadence)).setText(getCadence(sds));
((TextView) findViewById(R.id.sensor_state_heart_rate)).setText(getHeartRate(sds));
((TextView) findViewById(R.id.sensor_state_battery)).setText(getBattery(sds));
}
}
TextView sensorTime =
((TextView) findViewById(R.id.sensor_data_time_register));
sensorTime.setText(
TIMESTAMP_FORMAT.format(new Date(sds.getCreationTime())));
/**
* Gets the last sensor time.
*
* @param sds sensor data set
*/
private String getLastSensorTime(Sensor.SensorDataSet sds) {
return TIMESTAMP_FORMAT.format(new Date(sds.getCreationTime()));
}
/**
* Gets the power.
*
* @param sds sensor data set
*/
private String getPower(Sensor.SensorDataSet sds) {
String value;
if (sds.hasPower() && sds.getPower().hasValue()
&& sds.getPower().getState() == Sensor.SensorState.SENDING) {
utils.setText(R.id.power_state_register,
Integer.toString(sds.getPower().getValue()));
String format = getString(R.string.sensor_state_power_value);
value = String.format(format, sds.getPower().getValue());
} else {
utils.setText(R.id.power_state_register,
SensorUtils.getStateAsString(
sds.hasPower()
? sds.getPower().getState()
: Sensor.SensorState.NONE,
this));
value = SensorUtils.getStateAsString(
sds.hasPower() ? sds.getPower().getState() : Sensor.SensorState.NONE, this);
}
return value;
}
/**
* Gets the cadence.
*
* @param sds sensor data set
*/
private String getCadence(Sensor.SensorDataSet sds) {
String value;
if (sds.hasCadence() && sds.getCadence().hasValue()
&& sds.getCadence().getState() == Sensor.SensorState.SENDING) {
utils.setText(R.id.cadence_state_register,
Integer.toString(sds.getCadence().getValue()));
String format = getString(R.string.sensor_state_cadence_value);
value = String.format(format, sds.getCadence().getValue());
} else {
utils.setText(R.id.cadence_state_register,
SensorUtils.getStateAsString(
sds.hasCadence()
? sds.getCadence().getState()
: Sensor.SensorState.NONE,
this));
value = SensorUtils.getStateAsString(
sds.hasCadence() ? sds.getCadence().getState() : Sensor.SensorState.NONE, this);
}
return value;
}
/**
* Gets the heart rate.
*
* @param sds sensor data set
*/
private String getHeartRate(Sensor.SensorDataSet sds) {
String value;
if (sds.hasHeartRate() && sds.getHeartRate().hasValue()
&& sds.getHeartRate().getState() == Sensor.SensorState.SENDING) {
utils.setText(R.id.heart_rate_register,
Integer.toString(sds.getHeartRate().getValue()));
String format = getString(R.string.sensor_state_heart_rate_value);
value = String.format(format, sds.getHeartRate().getValue());
} else {
utils.setText(R.id.heart_rate_register,
SensorUtils.getStateAsString(
sds.hasHeartRate()
? sds.getHeartRate().getState()
: Sensor.SensorState.NONE,
this));
value = SensorUtils.getStateAsString(
sds.hasHeartRate() ? sds.getHeartRate().getState() : Sensor.SensorState.NONE, this);
}
return value;
}
/**
* Gets the battery.
*
* @param sds sensor data set
*/
private String getBattery(Sensor.SensorDataSet sds) {
String value;
if (sds.hasBatteryLevel() && sds.getBatteryLevel().hasValue()
&& sds.getBatteryLevel().getState() == Sensor.SensorState.SENDING) {
utils.setText(R.id.battery_level_register,
Integer.toString(sds.getBatteryLevel().getValue()));
String format = getString(R.string.sensor_state_battery_value);
value = String.format(format, sds.getBatteryLevel().getValue());
} else {
utils.setText(R.id.battery_level_register,
SensorUtils.getStateAsString(
sds.hasBatteryLevel()
? sds.getBatteryLevel().getState()
: Sensor.SensorState.NONE,
this));
value = SensorUtils.getStateAsString(
sds.hasBatteryLevel() ? sds.getBatteryLevel().getState() : Sensor.SensorState.NONE, this);
}
return value;
}
}
}
@@ -310,7 +310,7 @@ public class TrackList extends ListActivity
TextView textView = (TextView) view;
if (columnIndex == startTimeIdx) {
long time = cursor.getLong(startTimeIdx);
textView.setText(String.format("%tc", time));
textView.setText(StringUtils.formatDateTime(time));
} else if (columnIndex == totalDistanceIdx) {
double length = cursor.getDouble(totalDistanceIdx);
String lengthUnit = null;
@@ -265,9 +265,13 @@ public class WaypointsList extends ListActivity
if (columnIndex == timeIdx) {
long time = cursor.getLong(timeIdx);
TextView textView = (TextView) view;
textView.setText(String.format("%tc", time));
textView.setVisibility(
textView.getText().length() < 1 ? View.GONE : View.VISIBLE);
if (time == 0) {
textView.setVisibility(View.GONE);
} else {
textView.setText(StringUtils.formatDateTime(time));
textView.setVisibility(View.VISIBLE);
}
} else if (columnIndex == typeIdx) {
int type = cursor.getInt(typeIdx);
ImageView imageView = (ImageView) view;
@@ -15,6 +15,7 @@
*/
package com.google.android.apps.mytracks;
import com.google.android.apps.mytracks.util.EulaUtil;
import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.maps.mytracks.R;
@@ -77,7 +78,7 @@ public class WelcomeActivity extends Activity {
case DIALOG_EULA_ID:
builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.eula_title);
builder.setMessage(R.string.eula_message);
builder.setMessage(EulaUtil.getEulaMessage(this));
builder.setPositiveButton(R.string.generic_ok, null);
builder.setCancelable(true);
return builder.create();
@@ -18,6 +18,7 @@ package com.google.android.apps.mytracks.io.backup;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracks;
import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
@@ -32,7 +33,6 @@ import android.util.Log;
import android.widget.Toast;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
@@ -46,10 +46,6 @@ import java.util.Date;
*/
public class BackupActivityHelper {
// Since the user sees this format, we use the local timezone
private static final DateFormat DISPLAY_BACKUP_FORMAT = DateFormat.getDateTimeInstance(
DateFormat.SHORT, DateFormat.SHORT);
private static final Comparator<Date> REVERSE_DATE_ORDER =
new Comparator<Date>() {
@Override
@@ -160,7 +156,7 @@ public class BackupActivityHelper {
// Make a user-visible version of the backup filenames
final String backupDateStrs[] = new String[backupDates.length];
for (int i = 0; i < backupDates.length; i++) {
backupDateStrs[i] = DISPLAY_BACKUP_FORMAT.format(backupDates[i]);
backupDateStrs[i] = StringUtils.formatDateTime(backupDates[i].getTime());
}
// Show a dialog for the user to pick which backup to restore
@@ -44,8 +44,6 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.util.Date;
import java.util.concurrent.atomic.AtomicReference;
/**
@@ -290,7 +288,7 @@ public class DocsHelper {
DocsTagBuilder tagBuilder = new DocsTagBuilder(metricUnits)
.append("name", track.getName())
.append("description", track.getDescription())
.append("date", getDisplayDate(stats.getStartTime()))
.append("date", StringUtils.formatDateTime(stats.getStartTime()))
.append("totaltime", StringUtils.formatTimeAlwaysShowingHours(
stats.getTotalTime()))
.append("movingtime", StringUtils.formatTimeAlwaysShowingHours(
@@ -330,19 +328,6 @@ public class DocsHelper {
Log.i(Constants.TAG, "Post finished.");
}
/**
* Gets the display string for a time.
*
* @param time the time
* @return the display string of the time
*/
private String getDisplayDate(long time) {
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
Date startTime = new Date(time);
String dateString = format.format(startTime);
return dateString;
}
/**
* Writes spreadsheet row data to the indicated worksheet.
*
@@ -16,14 +16,12 @@
package com.google.android.apps.mytracks.services;
import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.content.SharedPreferences;
import java.text.DateFormat;
import java.util.Date;
/**
* Creates a default track name based on the current default track name policy.
*
@@ -46,8 +44,7 @@ class DefaultTrackNameFactory {
*/
String newTrackName(long trackId, long startTime) {
if (useTimestampTrackName()) {
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
return formatter.format(new Date(startTime));
return StringUtils.formatDateTime(startTime);
} else {
return String.format(context.getString(R.string.track_name_format), trackId);
}
@@ -99,7 +99,7 @@ public class SensorUtils {
public static String getStateAsString(Sensor.SensorState state, Context c) {
switch (state) {
case NONE:
return c.getString(R.string.sensor_type_value_none);
return c.getString(R.string.settings_sensor_type_none);
case CONNECTING:
return c.getString(R.string.sensor_state_connecting);
case CONNECTED:
@@ -15,19 +15,24 @@
*/
package com.google.android.apps.mytracks.util;
import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
/**
* Utilities for the EULA preference value.
* Utilities for EULA.
*/
public class EulaUtil {
private static final String EULA_PREFERENCE_FILE = "eula";
// Accepting Google mobile terms of service
private static final String EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
private static final String COPYRIGHT = "©2011";
private static final String HOST_NAME = "m.google.com";
private EulaUtil() {}
public static boolean getEulaValue(Context context) {
@@ -43,4 +48,29 @@ public class EulaUtil {
editor.putBoolean(EULA_PREFERENCE_KEY, true);
ApiFeatures.getInstance().getApiAdapter().applyPreferenceChanges(editor);
}
public static String getEulaMessage(Context context) {
String item1 = String.format(context.getString(R.string.eula_message_item1), HOST_NAME,
HOST_NAME, HOST_NAME, HOST_NAME, HOST_NAME);
String item3 = String.format(context.getString(R.string.eula_message_item3), HOST_NAME);
String footer = String.format(context.getString(R.string.eula_message_footer), HOST_NAME);
return context.getString(R.string.eula_message_date)
+ "\n\n"
+ context.getString(R.string.eula_message_header)
+ "\n\n"
+ context.getString(R.string.eula_message_body)
+ "\n\n"
+ "1. " + item1
+ "\n\n"
+ "2. " + context.getString(R.string.eula_message_item2)
+ "\n\n"
+ "3. " + item3
+ "\n\n"
+ "4. " + context.getString(R.string.eula_message_item4)
+ "\n\n"
+ footer
+ "\n\n"
+ COPYRIGHT;
}
}
@@ -25,6 +25,7 @@ import com.google.android.maps.mytracks.R;
import android.content.Context;
import android.content.SharedPreferences;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
@@ -44,6 +45,16 @@ public class StringUtils implements DescriptionGenerator {
private final Context context;
/**
* Formats the time based on user locale.
*
* @param time time
*/
public static String formatDateTime(long time) {
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
return formatter.format(new Date(time));
}
/**
* Formats a number of milliseconds as a string.
*
@@ -303,7 +314,7 @@ public class StringUtils implements DescriptionGenerator {
+ "%s: %d %s (%d %s)<br>"
+ "%s: %d %%<br>"
+ "%s: %d %%<br>"
+ "%s: %tc<br>"
+ "%s: %s<br>"
+ "%s: %s<br>"
+ "<img border=\"0\" src=\"%s\"/>",
@@ -349,7 +360,7 @@ public class StringUtils implements DescriptionGenerator {
// Line 11
context.getString(R.string.send_google_recorded),
new Date(trackStats.getStartTime()),
StringUtils.formatDateTime(trackStats.getStartTime()),
// Line 12
context.getString(R.string.track_detail_activity_type_hint), category,
@@ -18,6 +18,7 @@ package com.google.android.apps.mytracks.io.docs;
import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.io.AuthManager;
import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
import com.google.android.testing.mocking.AndroidMock;
import com.google.android.testing.mocking.UsesMocks;
@@ -28,8 +29,6 @@ import android.test.mock.MockContext;
import android.test.mock.MockResources;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
import junit.framework.TestCase;
@@ -40,9 +39,7 @@ import junit.framework.TestCase;
*/
public class DocsHelper_AddTrackRowTest extends TestCase {
private static final long TIME = 1288721514000L;
private static final DateFormat DATE_FORMAT = DateFormat.getDateTimeInstance(
DateFormat.SHORT, DateFormat.SHORT);
private static class StringWritingDocsHelper extends DocsHelper {
String writtenSheetUri = null;
String writtenData = null;
@@ -64,7 +61,7 @@ public class DocsHelper_AddTrackRowTest extends TestCase {
+ "xmlns:gsx='http://schemas.google.com/spreadsheets/2006/extended'>"
+ "<gsx:name><![CDATA[trackName]]></gsx:name>"
+ "<gsx:description><![CDATA[trackDescription]]></gsx:description>"
+ "<gsx:date><![CDATA[" + DATE_FORMAT.format(new Date(TIME)) + "]]></gsx:date>"
+ "<gsx:date><![CDATA[" + StringUtils.formatDateTime(TIME) + "]]></gsx:date>"
+ "<gsx:totaltime><![CDATA[0:00:05]]></gsx:totaltime>"
+ "<gsx:movingtime><![CDATA[0:00:04]]></gsx:movingtime>"
+ "<gsx:distance><![CDATA[12.43]]></gsx:distance>"
@@ -15,12 +15,11 @@
*/
package com.google.android.apps.mytracks.services;
import com.google.android.apps.mytracks.util.StringUtils;
import android.content.Context;
import android.test.AndroidTestCase;
import java.text.DateFormat;
import java.util.Date;
/**
* Tests {@link DefaultTrackNameFactory}
*
@@ -52,9 +51,7 @@ public class DefaultTrackNameFactoryTest extends AndroidTestCase {
DefaultTrackNameFactory factory =
new MockDefaultTrackNameFactory(getContext(), true);
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
assertEquals(formatter.format(new Date(TIMESTAMP)),
factory.newTrackName(1, TIMESTAMP));
assertEquals(StringUtils.formatDateTime(TIMESTAMP), factory.newTrackName(1, TIMESTAMP));
}
public void testIncrementingTrackName() {