forked from upstream-mirrors/OpenTracks
Clean up code + add pace.
This commit is contained in:
@@ -180,7 +180,7 @@ limitations under the License.
|
|||||||
<action android:name="com.google.android.apps.mytracks.TRACK_UPDATED" />
|
<action android:name="com.google.android.apps.mytracks.TRACK_UPDATED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<meta-data android:name="android.appwidget.provider"
|
<meta-data android:name="android.appwidget.provider"
|
||||||
android:resource="@xml/appwidget_info" />
|
android:resource="@xml/track_widget_info" />
|
||||||
</receiver>
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|||||||
@@ -48,18 +48,11 @@ limitations under the License.
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/appwidget_distance_text"
|
style="@style/WidgetText.Register"
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/appwidget_distance_text" />
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:textColor="@color/appwidget_text"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:width="110px" />
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
style="@style/WidgetText"
|
||||||
android:layout_width="wrap_content"
|
android:text="@string/total_distance_label" />
|
||||||
android:text="@string/total_distance_label"
|
|
||||||
android:textColor="@color/appwidget_text"
|
|
||||||
android:textSize="14sp" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
@@ -71,18 +64,11 @@ limitations under the License.
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingBottom="2px">
|
android:paddingBottom="2px">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/appwidget_time_text"
|
style="@style/WidgetText.Register"
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/appwidget_time_text" />
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:textColor="@color/appwidget_text"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:width="110px" />
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
style="@style/WidgetText"
|
||||||
android:layout_width="wrap_content"
|
android:text="@string/moving_time_label" />
|
||||||
android:text="@string/moving_time_label"
|
|
||||||
android:textColor="@color/appwidget_text"
|
|
||||||
android:textSize="14sp" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
@@ -93,18 +79,11 @@ limitations under the License.
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/appwidget_speed_text"
|
style="@style/WidgetText.Register"
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/appwidget_speed_text" />
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:textColor="@color/appwidget_text"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:width="110px" />
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
style="@style/WidgetText"
|
||||||
android:layout_width="wrap_content"
|
android:text="@string/speed" />
|
||||||
android:text="@string/average_moving_speed_label"
|
|
||||||
android:textColor="@color/appwidget_text"
|
|
||||||
android:textSize="14sp" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -74,4 +74,15 @@ limitations under the License.
|
|||||||
<item name="android:layout_height">3dip</item>
|
<item name="android:layout_height">3dip</item>
|
||||||
<item name="android:layout_width">fill_parent</item>
|
<item name="android:layout_width">fill_parent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- The style for the track widget. -->
|
||||||
|
<style name="WidgetText" parent="@android:Widget.TextView">
|
||||||
|
<item name="android:layout_height">wrap_content</item>
|
||||||
|
<item name="android:layout_width">wrap_content</item>
|
||||||
|
<item name="android:textColor">@color/appwidget_text</item>
|
||||||
|
<item name="android:textSize">14sp</item>
|
||||||
|
</style>
|
||||||
|
<style name="WidgetText.Register">
|
||||||
|
<item name="android:width">160px</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -16,7 +16,7 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
<appwidget-provider
|
<appwidget-provider
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:initialLayout="@layout/appwidget"
|
android:initialLayout="@layout/track_widget"
|
||||||
android:minHeight="72dp"
|
android:minHeight="72dp"
|
||||||
android:minWidth="294dp"
|
android:minWidth="294dp"
|
||||||
android:updatePeriodMillis="0" />
|
android:updatePeriodMillis="0" />
|
||||||
@@ -70,8 +70,10 @@ public class TrackWidgetProvider
|
|||||||
private String unknown;
|
private String unknown;
|
||||||
private String distance;
|
private String distance;
|
||||||
private String speed;
|
private String speed;
|
||||||
|
private String pace;
|
||||||
private TrackObserver trackObserver;
|
private TrackObserver trackObserver;
|
||||||
private boolean isMetric;
|
private boolean isMetric;
|
||||||
|
private boolean reportSpeed;
|
||||||
private long selectedTrackId;
|
private long selectedTrackId;
|
||||||
private SharedPreferences sharedPreferences;
|
private SharedPreferences sharedPreferences;
|
||||||
private String TRACK_STARTED_ACTION;
|
private String TRACK_STARTED_ACTION;
|
||||||
@@ -141,7 +143,7 @@ public class TrackWidgetProvider
|
|||||||
|
|
||||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||||
ComponentName widget = new ComponentName(context, TrackWidgetProvider.class);
|
ComponentName widget = new ComponentName(context, TrackWidgetProvider.class);
|
||||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget);
|
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.track_widget);
|
||||||
|
|
||||||
// Make all of the stats open the mytracks activity.
|
// Make all of the stats open the mytracks activity.
|
||||||
Intent intent = new Intent(context, MyTracks.class);
|
Intent intent = new Intent(context, MyTracks.class);
|
||||||
@@ -237,7 +239,12 @@ public class TrackWidgetProvider
|
|||||||
if (!isMetric) {
|
if (!isMetric) {
|
||||||
displaySpeed *= UnitConversions.KMH_TO_MPH;
|
displaySpeed *= UnitConversions.KMH_TO_MPH;
|
||||||
}
|
}
|
||||||
speed = StringUtils.formatSingleDecimalPlace(displaySpeed) + " " + this.speed;
|
if (reportSpeed) {
|
||||||
|
speed = StringUtils.formatSingleDecimalPlace(displaySpeed) + " " + this.speed;
|
||||||
|
} else {
|
||||||
|
long displayPace = (long) (3600000.0 / displaySpeed);
|
||||||
|
speed = StringUtils.formatTime(displayPace) + " " + pace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
views.setTextViewText(R.id.appwidget_distance_text, distance);
|
views.setTextViewText(R.id.appwidget_distance_text, distance);
|
||||||
@@ -252,7 +259,14 @@ public class TrackWidgetProvider
|
|||||||
isMetric = prefs.getBoolean(metricUnitsKey, true);
|
isMetric = prefs.getBoolean(metricUnitsKey, true);
|
||||||
distance = context.getString(isMetric ? R.string.kilometer : R.string.mile);
|
distance = context.getString(isMetric ? R.string.kilometer : R.string.mile);
|
||||||
speed = context.getString(isMetric ? R.string.kilometer_per_hour : R.string.mile_per_hour);
|
speed = context.getString(isMetric ? R.string.kilometer_per_hour : R.string.mile_per_hour);
|
||||||
|
pace = context.getString(isMetric ? R.string.min_per_kilometer : R.string.min_per_mile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String reportSpeedKey = context.getString(R.string.report_speed_key);
|
||||||
|
if (key == null || key.equals(reportSpeedKey)) {
|
||||||
|
reportSpeed = prefs.getBoolean(reportSpeedKey, true);
|
||||||
|
}
|
||||||
|
|
||||||
String selectedTrackKey = context.getString(R.string.selected_track_key);
|
String selectedTrackKey = context.getString(R.string.selected_track_key);
|
||||||
if (key == null || key.equals(selectedTrackKey)) {
|
if (key == null || key.equals(selectedTrackKey)) {
|
||||||
selectedTrackId = prefs.getLong(selectedTrackKey, -1);
|
selectedTrackId = prefs.getLong(selectedTrackKey, -1);
|
||||||
|
|||||||
Reference in New Issue
Block a user