diff --git a/MyTracks/AndroidManifest.xml b/MyTracks/AndroidManifest.xml
index c0ee2d7c6..a584d2ae2 100755
--- a/MyTracks/AndroidManifest.xml
+++ b/MyTracks/AndroidManifest.xml
@@ -19,7 +19,6 @@ limitations under the License.
android:versionCode="56"
android:versionName="2.0.2"
package="com.google.android.maps.mytracks" >
-
@@ -79,7 +78,6 @@ limitations under the License.
android:name="com.google.android.apps.mytracks.WRITE_TRACK_DATA"
android:permissionGroup="android.permission-group.LOCATION"
android:protectionLevel="dangerous" />
-
@@ -115,22 +113,19 @@ limitations under the License.
-
-
-
-
+
-
-
@@ -158,8 +150,7 @@ limitations under the License.
-
+
-
@@ -181,15 +171,12 @@ limitations under the License.
android:label="@string/menu_sensor_state"
android:name="com.google.android.apps.mytracks.SensorStateActivity" />
-
+
-
-
@@ -215,6 +202,13 @@ limitations under the License.
+
+
+
+
+
-
-
\ No newline at end of file
diff --git a/MyTracks/res/layout-v14/bottom_buttons.xml b/MyTracks/res/layout-v14/bottom_buttons.xml
new file mode 100644
index 000000000..18a88de6d
--- /dev/null
+++ b/MyTracks/res/layout-v14/bottom_buttons.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MyTracks/res/layout/bottom_buttons.xml b/MyTracks/res/layout/bottom_buttons.xml
new file mode 100644
index 000000000..c6d36ee61
--- /dev/null
+++ b/MyTracks/res/layout/bottom_buttons.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MyTracks/res/layout/track_controller.xml b/MyTracks/res/layout/track_controller.xml
index fb2ab6171..923a638e4 100644
--- a/MyTracks/res/layout/track_controller.xml
+++ b/MyTracks/res/layout/track_controller.xml
@@ -52,7 +52,7 @@ limitations under the License.
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:singleLine="true"
- style="@style/TextTiny" />
+ style="@style/TextMicro" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MyTracks/res/layout/track_widget_large.xml b/MyTracks/res/layout/track_widget_large.xml
index 7163b92c0..9927051be 100644
--- a/MyTracks/res/layout/track_widget_large.xml
+++ b/MyTracks/res/layout/track_widget_large.xml
@@ -20,106 +20,117 @@ limitations under the License.
android:layout_width="fill_parent"
android:padding="@dimen/widget_margin" >
-
-
-
-
-
+ android:orientation="vertical" >
+
+
+
+
+ android:id="@+id/track_widget_item1_label"
+ style="@style/TrackWidgetLabel" />
+
+
+
+
+
+
+
+
+
+
+
+
+ android:id="@+id/track_widget_item3_label"
+ style="@style/TrackWidgetLabel" />
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ android:id="@+id/track_widget_item2_label"
+ style="@style/TrackWidgetLabel" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MyTracks/res/layout/track_widget_small.xml b/MyTracks/res/layout/track_widget_small.xml
index c93ddf065..bb09a15e8 100644
--- a/MyTracks/res/layout/track_widget_small.xml
+++ b/MyTracks/res/layout/track_widget_small.xml
@@ -45,13 +45,17 @@ limitations under the License.
android:layout_weight="1"
android:layout_width="fill_parent"
android:orientation="vertical" >
+
+
@@ -60,15 +64,16 @@ limitations under the License.
android:layout_weight="1"
android:layout_width="fill_parent"
android:orientation="vertical" >
+
diff --git a/MyTracks/res/values/keys.xml b/MyTracks/res/values/keys.xml
index a7675bedb..dcfab95d4 100644
--- a/MyTracks/res/values/keys.xml
+++ b/MyTracks/res/values/keys.xml
@@ -54,8 +54,12 @@ limitations under the License.
trackColorModeSlow
trackColorMode
trackName
+ trackWidgetItem1
+ trackWidgetItem2
+ trackWidgetItem3
+ trackWidgetItem4
voiceFrequency
-
+
autoResumeTrackCurrentRetry
recordingTrackId
diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml
index 06e138026..ca0f1b872 100644
--- a/MyTracks/res/values/strings.xml
+++ b/MyTracks/res/values/strings.xml
@@ -2293,6 +2293,12 @@ limitations under the License.
Recording your track…
+
+
+ Configure Widget Items
+
+
diff --git a/MyTracks/res/values/styles.xml b/MyTracks/res/values/styles.xml
index 219246495..f0517e8bc 100644
--- a/MyTracks/res/values/styles.xml
+++ b/MyTracks/res/values/styles.xml
@@ -192,11 +192,11 @@ limitations under the License.
- wrap_content
- 14sp
-
-
@@ -212,6 +212,26 @@ limitations under the License.
- center_vertical
- fitXY
+
+
+
+
+
+
-
-
-
diff --git a/MyTracks/res/xml/track_widget_info.xml b/MyTracks/res/xml/track_widget_info.xml
index c8bba9e4e..ddd60d3ff 100644
--- a/MyTracks/res/xml/track_widget_info.xml
+++ b/MyTracks/res/xml/track_widget_info.xml
@@ -15,6 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
list = new ArrayList();
+ addItem(list, R.string.stats_total_distance);
+ addItem(list, R.string.stats_total_time);
+ addItem(list, reportSpeed ? R.string.stats_average_speed : R.string.stats_average_pace);
+ addItem(list, R.string.stats_moving_time);
+ addItem(list,
+ reportSpeed ? R.string.stats_average_moving_speed : R.string.stats_average_moving_pace);
+
+ configSpinner(item1, list, PreferencesUtils.getInt(
+ this, R.string.track_widget_item1, PreferencesUtils.TRACK_WIDGET_ITEM1_DEFAULT));
+ configSpinner(item2, list, PreferencesUtils.getInt(
+ this, R.string.track_widget_item2, PreferencesUtils.TRACK_WIDGET_ITEM2_DEFAULT));
+ configSpinner(item3, list, PreferencesUtils.getInt(
+ this, R.string.track_widget_item3, PreferencesUtils.TRACK_WIDGET_ITEM3_DEFAULT));
+ configSpinner(item4, list, PreferencesUtils.getInt(
+ this, R.string.track_widget_item4, PreferencesUtils.TRACK_WIDGET_ITEM4_DEFAULT));
+
+ findViewById(R.id.bottom_buttons_add).setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ // Push widget update to surface with newly set prefix
+ AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(
+ TrackWidgetConfigActivity.this);
+ TrackWidgetProvider.updateAppWidget(
+ TrackWidgetConfigActivity.this, appWidgetManager, appWidgetId);
+ PreferencesUtils.setInt(TrackWidgetConfigActivity.this, R.string.track_widget_item1,
+ item1.getSelectedItemPosition());
+ PreferencesUtils.setInt(TrackWidgetConfigActivity.this, R.string.track_widget_item2,
+ item2.getSelectedItemPosition());
+ PreferencesUtils.setInt(TrackWidgetConfigActivity.this, R.string.track_widget_item3,
+ item3.getSelectedItemPosition());
+ PreferencesUtils.setInt(TrackWidgetConfigActivity.this, R.string.track_widget_item4,
+ item4.getSelectedItemPosition());
+
+ // Make sure we pass back the original appWidgetId
+ Intent resultValue = new Intent();
+ resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ setResult(RESULT_OK, resultValue);
+ finish();
+ }
+ });
+ findViewById(R.id.bottom_buttons_cancel).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ });
+
+ // Find the app widget id from the intent.
+ Intent intent = getIntent();
+ Bundle extras = intent.getExtras();
+ appWidgetId = extras != null ? extras.getInt(
+ AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
+ : AppWidgetManager.INVALID_APPWIDGET_ID;
+
+ // If they gave us an intent without the widget id, just bail.
+ if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
+ finish();
+ }
+ }
+
+ private void addItem(List list, int id) {
+ list.add(getString(id).toUpperCase());
+ }
+
+ private void configSpinner(Spinner spinner, List list, int position) {
+ ArrayAdapter adapter = new ArrayAdapter(
+ this, android.R.layout.simple_spinner_item, list);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ spinner.setAdapter(adapter);
+ spinner.setSelection(position);
+ }
+}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java b/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
index 7323e1273..aa6b52753 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
@@ -37,6 +37,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.TaskStackBuilder;
import android.util.SparseBooleanArray;
+import android.view.View;
import android.widget.RemoteViews;
/**
@@ -57,8 +58,7 @@ public class TrackWidgetProvider extends AppWidgetProvider {
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
String action = intent.getAction();
- if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)
- || context.getString(R.string.track_paused_broadcast_action).equals(action)
+ if (context.getString(R.string.track_paused_broadcast_action).equals(action)
|| context.getString(R.string.track_resumed_broadcast_action).equals(action)
|| context.getString(R.string.track_started_broadcast_action).equals(action)
|| context.getString(R.string.track_stopped_broadcast_action).equals(action)
@@ -69,7 +69,8 @@ public class TrackWidgetProvider extends AppWidgetProvider {
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
new ComponentName(context, TrackWidgetProvider.class));
for (int appWidgetId : appWidgetIds) {
- RemoteViews remoteViews = getRemoteViews(context, trackId, useLargeSize.get(appWidgetId));
+ RemoteViews remoteViews = getRemoteViews(
+ context, trackId, useLargeSize.get(appWidgetId, true));
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
}
@@ -87,13 +88,26 @@ public class TrackWidgetProvider extends AppWidgetProvider {
}
/**
- * Updates the widget.
+ * Updates an app widget.
+ *
+ * @param context the context
+ * @param appWidgetManager the app widget manager
+ * @param appWidgetId the app widget id
+ */
+ public static void updateAppWidget(
+ Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
+ RemoteViews remoteViews = getRemoteViews(context, -1L, useLargeSize.get(appWidgetId, true));
+ appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
+ }
+
+ /**
+ * Gets the remote views.
*
* @param context the context
* @param trackId the track id
* @param large true to use the large layout
*/
- private RemoteViews getRemoteViews(Context context, long trackId, boolean large) {
+ private static RemoteViews getRemoteViews(Context context, long trackId, boolean large) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
large ? R.layout.track_widget_large : R.layout.track_widget_small);
@@ -104,6 +118,12 @@ public class TrackWidgetProvider extends AppWidgetProvider {
R.string.recording_track_paused_key, PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
boolean metricUnits = PreferencesUtils.getBoolean(
context, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
+ boolean reportSpeed = PreferencesUtils.getBoolean(
+ context, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
+ int item1 = PreferencesUtils.getInt(
+ context, R.string.track_widget_item1, PreferencesUtils.TRACK_WIDGET_ITEM1_DEFAULT);
+ int item2 = PreferencesUtils.getInt(
+ context, R.string.track_widget_item2, PreferencesUtils.TRACK_WIDGET_ITEM2_DEFAULT);
// Get track and trip statistics
MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
@@ -115,20 +135,66 @@ public class TrackWidgetProvider extends AppWidgetProvider {
TripStatistics tripStatistics = track == null ? null : track.getTripStatistics();
updateStatisticsContainer(context, remoteViews, track);
- updateMovingTime(context, remoteViews, tripStatistics);
- updateTotalDistance(context, remoteViews, tripStatistics, metricUnits);
+ setItem(context, remoteViews, R.id.track_widget_item1_label, R.id.track_widget_item1_value,
+ R.id.track_widget_item1_unit, item1, tripStatistics, metricUnits, reportSpeed);
+ setItem(context, remoteViews, R.id.track_widget_item2_label, R.id.track_widget_item2_value,
+ R.id.track_widget_item2_unit, item2, tripStatistics, metricUnits, reportSpeed);
+
updateRecordButton(context, remoteViews, isRecording, recordingTrackPaused);
updateStopButton(context, remoteViews, isRecording);
if (large) {
- boolean reportSpeed = PreferencesUtils.getBoolean(
- context, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
- updateAverageMovingSpeed(context, remoteViews, tripStatistics, metricUnits, reportSpeed);
- updateAverageSpeed(context, remoteViews, tripStatistics, metricUnits, reportSpeed);
+ int item3 = PreferencesUtils.getInt(
+ context, R.string.track_widget_item3, PreferencesUtils.TRACK_WIDGET_ITEM3_DEFAULT);
+ int item4 = PreferencesUtils.getInt(
+ context, R.string.track_widget_item4, PreferencesUtils.TRACK_WIDGET_ITEM4_DEFAULT);
+ setItem(context, remoteViews, R.id.track_widget_item3_label, R.id.track_widget_item3_value,
+ R.id.track_widget_item3_unit, item3, tripStatistics, metricUnits, reportSpeed);
+ setItem(context, remoteViews, R.id.track_widget_item4_label, R.id.track_widget_item4_value,
+ R.id.track_widget_item4_unit, item4, tripStatistics, metricUnits, reportSpeed);
updateRecordStatus(context, remoteViews, isRecording, recordingTrackPaused);
}
return remoteViews;
}
+ /**
+ * Sets a widget item.
+ *
+ * @param context the context
+ * @param remoteViews the remote view
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
+ * @param itemValue the item value
+ * @param tripStatistics the trip statistics
+ * @param metricUnits true to use metric units
+ * @param reportSpeed try to report speed
+ */
+ private static void setItem(Context context, RemoteViews remoteViews, int labelId, int valueId,
+ int unitId, int itemValue, TripStatistics tripStatistics, boolean metricUnits,
+ boolean reportSpeed) {
+ switch (itemValue) {
+ case 1:
+ updateTotalTime(context, remoteViews, labelId, valueId, unitId, tripStatistics);
+ break;
+ case 2:
+ updateAverageSpeed(context, remoteViews, labelId, valueId, unitId, tripStatistics,
+ metricUnits, reportSpeed);
+ break;
+ case 3:
+ updateMovingTime(context, remoteViews, labelId, valueId, unitId, tripStatistics);
+ break;
+ case 4:
+ updateAverageMovingSpeed(context, remoteViews, labelId, valueId, unitId, tripStatistics,
+ metricUnits, reportSpeed);
+ break;
+ case 0:
+ default:
+ updateTotalDistance(
+ context, remoteViews, labelId, valueId, unitId, tripStatistics, metricUnits);
+ break;
+ }
+ }
+
/**
* Updates the statistics container.
*
@@ -136,7 +202,8 @@ public class TrackWidgetProvider extends AppWidgetProvider {
* @param remoteViews the remote views
* @param track the track
*/
- private void updateStatisticsContainer(Context context, RemoteViews remoteViews, Track track) {
+ private static void updateStatisticsContainer(
+ Context context, RemoteViews remoteViews, Track track) {
Intent intent;
if (track != null) {
intent = IntentUtils.newIntent(context, TrackDetailActivity.class)
@@ -150,34 +217,112 @@ public class TrackWidgetProvider extends AppWidgetProvider {
remoteViews.setOnClickPendingIntent(R.id.track_widget_statistics, pendingIntent);
}
- /**
- * Updates moving time.
- *
- * @param context the context
- * @param remoteViews the remote views
- * @param tripStatistics the trip statistics
- */
- private void updateMovingTime(
- Context context, RemoteViews remoteViews, TripStatistics tripStatistics) {
- String movingTimeValue = tripStatistics == null ? context.getString(R.string.value_unknown)
- : StringUtils.formatElapsedTime(tripStatistics.getMovingTime());
- remoteViews.setTextViewText(R.id.track_widget_moving_time_value, movingTimeValue);
- }
-
/**
* Updates total distance.
*
* @param context the context
* @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
*/
- private void updateTotalDistance(Context context, RemoteViews remoteViews,
- TripStatistics tripStatistics, boolean metricUnits) {
- double distance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
- String[] distanceParts = StringUtils.getDistanceParts(context, distance, metricUnits);
- remoteViews.setTextViewText(R.id.track_widget_total_distance_value, distanceParts[0]);
- remoteViews.setTextViewText(R.id.track_widget_total_distance_unit, distanceParts[1]);
+ private static void updateTotalDistance(Context context, RemoteViews remoteViews, int labelId,
+ int valueId, int unitId, TripStatistics tripStatistics, boolean metricUnits) {
+ double totalDistance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
+ String[] totalDistanceParts = StringUtils.getDistanceParts(context, totalDistance, metricUnits);
+ remoteViews.setTextViewText(labelId, context.getString(R.string.stats_total_distance));
+ remoteViews.setTextViewText(valueId, totalDistanceParts[0]);
+ remoteViews.setTextViewText(unitId, totalDistanceParts[1]);
+ }
+
+ /**
+ * Updates total time.
+ *
+ * @param context the context
+ * @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
+ * @param tripStatistics the trip statistics
+ */
+ private static void updateTotalTime(Context context, RemoteViews remoteViews, int labelId,
+ int valueId, int unitId, TripStatistics tripStatistics) {
+ String totalTime = tripStatistics == null ? context.getString(R.string.value_unknown)
+ : StringUtils.formatElapsedTime(tripStatistics.getTotalTime());
+ remoteViews.setTextViewText(labelId, context.getString(R.string.stats_total_time));
+ remoteViews.setTextViewText(valueId, totalTime);
+ remoteViews.setViewVisibility(unitId, View.GONE);
+ }
+
+ /**
+ * Updates average speed.
+ *
+ * @param context the context
+ * @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
+ * @param tripStatistics the trip statistics
+ * @param metricUnits true to use metric units
+ * @param reportSpeed true to report speed
+ */
+ private static void updateAverageSpeed(Context context, RemoteViews remoteViews, int labelId,
+ int valueId, int unitId, TripStatistics tripStatistics, boolean metricUnits,
+ boolean reportSpeed) {
+ String averageSpeedLabel = context.getString(
+ reportSpeed ? R.string.stats_average_speed : R.string.stats_average_pace);
+ remoteViews.setTextViewText(labelId, averageSpeedLabel);
+
+ Double speed = tripStatistics == null ? Double.NaN : tripStatistics.getAverageSpeed();
+ String[] speedParts = StringUtils.getSpeedParts(context, speed, metricUnits, reportSpeed);
+ remoteViews.setTextViewText(valueId, speedParts[0]);
+ remoteViews.setTextViewText(unitId, speedParts[1]);
+ }
+
+ /**
+ * Updates moving time.
+ *
+ * @param context the context
+ * @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
+ * @param tripStatistics the trip statistics
+ */
+ private static void updateMovingTime(Context context, RemoteViews remoteViews, int labelId,
+ int valueId, int unitId, TripStatistics tripStatistics) {
+ String movingTime = tripStatistics == null ? context.getString(R.string.value_unknown)
+ : StringUtils.formatElapsedTime(tripStatistics.getMovingTime());
+ remoteViews.setTextViewText(labelId, context.getString(R.string.stats_moving_time));
+ remoteViews.setTextViewText(valueId, movingTime);
+ remoteViews.setViewVisibility(unitId, View.GONE);
+ }
+
+ /**
+ * Updates average moving speed.
+ *
+ * @param context the context
+ * @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
+ * @param tripStatistics the trip statistics
+ * @param metricUnits true to use metric units
+ * @param reportSpeed true to report speed
+ */
+ private static void updateAverageMovingSpeed(Context context, RemoteViews remoteViews,
+ int labelId, int valueId, int unitId, TripStatistics tripStatistics, boolean metricUnits,
+ boolean reportSpeed) {
+ String averageMovingSpeedLabel = context.getString(
+ reportSpeed ? R.string.stats_average_moving_speed : R.string.stats_average_moving_pace);
+ remoteViews.setTextViewText(labelId, averageMovingSpeedLabel);
+
+ Double speed = tripStatistics == null ? Double.NaN : tripStatistics.getAverageMovingSpeed();
+ String[] speedParts = StringUtils.getSpeedParts(context, speed, metricUnits, reportSpeed);
+ remoteViews.setTextViewText(valueId, speedParts[0]);
+ remoteViews.setTextViewText(unitId, speedParts[1]);
}
/**
@@ -188,7 +333,7 @@ public class TrackWidgetProvider extends AppWidgetProvider {
* @param isRecording true if recording
* @param recordingTrackPaused true if recording track is paused
*/
- private void updateRecordButton(
+ private static void updateRecordButton(
Context context, RemoteViews remoteViews, boolean isRecording, boolean recordingTrackPaused) {
remoteViews.setImageViewResource(R.id.track_widget_record_button,
isRecording && !recordingTrackPaused ? R.drawable.btn_pause : R.drawable.btn_record);
@@ -213,7 +358,8 @@ public class TrackWidgetProvider extends AppWidgetProvider {
* @param remoteViews the remote views
* @param isRecording true if recording
*/
- private void updateStopButton(Context context, RemoteViews remoteViews, boolean isRecording) {
+ private static void updateStopButton(
+ Context context, RemoteViews remoteViews, boolean isRecording) {
remoteViews.setImageViewResource(
R.id.track_widget_stop_button, isRecording ? R.drawable.btn_stop_1 : R.drawable.btn_stop_0);
remoteViews.setBoolean(R.id.track_widget_stop_button, "setEnabled", isRecording);
@@ -226,49 +372,6 @@ public class TrackWidgetProvider extends AppWidgetProvider {
}
}
- /**
- * Updates average moving speed.
- *
- * @param context the context
- * @param remoteViews the remote views
- * @param tripStatistics the trip statistics
- * @param metricUnits true to use metric units
- * @param reportSpeed true to report speed
- */
- private void updateAverageMovingSpeed(Context context, RemoteViews remoteViews,
- TripStatistics tripStatistics, boolean metricUnits, boolean reportSpeed) {
- String averageMovingSpeedLabel = context.getString(
- reportSpeed ? R.string.stats_average_moving_speed : R.string.stats_average_moving_pace);
- remoteViews.setTextViewText(
- R.id.track_widget_average_moving_speed_label, averageMovingSpeedLabel);
-
- Double speed = tripStatistics == null ? Double.NaN : tripStatistics.getAverageMovingSpeed();
- String[] speedParts = StringUtils.getSpeedParts(context, speed, metricUnits, reportSpeed);
- remoteViews.setTextViewText(R.id.track_widget_average_moving_speed_value, speedParts[0]);
- remoteViews.setTextViewText(R.id.track_widget_average_moving_speed_unit, speedParts[1]);
- }
-
- /**
- * Updates average speed.
- *
- * @param context the context
- * @param remoteViews the remote views
- * @param tripStatistics the trip statistics
- * @param metricUnits true to use metric units
- * @param reportSpeed true to report speed
- */
- private void updateAverageSpeed(Context context, RemoteViews remoteViews,
- TripStatistics tripStatistics, boolean metricUnits, boolean reportSpeed) {
- String averageSpeedLabel = context.getString(
- reportSpeed ? R.string.stats_average_speed : R.string.stats_average_pace);
- remoteViews.setTextViewText(R.id.track_widget_average_speed_label, averageSpeedLabel);
-
- Double speed = tripStatistics == null ? Double.NaN : tripStatistics.getAverageSpeed();
- String[] speedParts = StringUtils.getSpeedParts(context, speed, metricUnits, reportSpeed);
- remoteViews.setTextViewText(R.id.track_widget_average_speed_value, speedParts[0]);
- remoteViews.setTextViewText(R.id.track_widget_average_speed_unit, speedParts[1]);
- }
-
/**
* Updates recording status.
*
@@ -277,7 +380,7 @@ public class TrackWidgetProvider extends AppWidgetProvider {
* @param isRecording true if recording
* @param recordingTrackPaused true if recording track is paused
*/
- private void updateRecordStatus(
+ private static void updateRecordStatus(
Context context, RemoteViews remoteViews, boolean isRecording, boolean recordingTrackPaused) {
String status;
int colorId;