forked from upstream-mirrors/OpenTracks
Improve stats layout
This commit is contained in:
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
|
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
<!-- Row 1: distance and speed -->
|
<!-- Row 1: distance and calorie -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent" >
|
android:layout_width="match_parent" >
|
||||||
@@ -24,10 +24,10 @@ limitations under the License.
|
|||||||
layout="@layout/stats_large_item" />
|
layout="@layout/stats_large_item" />
|
||||||
<View style="@style/StatsVerticalSpacer" />
|
<View style="@style/StatsVerticalSpacer" />
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stats_speed"
|
android:id="@+id/stats_calorie"
|
||||||
layout="@layout/stats_large_item" />
|
layout="@layout/stats_large_item" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- Row 2: total time and average speed -->
|
<!-- Row 2: total time and moving time -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent" >
|
android:layout_width="match_parent" >
|
||||||
@@ -36,32 +36,34 @@ limitations under the License.
|
|||||||
layout="@layout/stats_large_item" />
|
layout="@layout/stats_large_item" />
|
||||||
<View style="@style/StatsVerticalSpacer" />
|
<View style="@style/StatsVerticalSpacer" />
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stats_average_speed"
|
android:id="@+id/stats_moving_time"
|
||||||
layout="@layout/stats_large_item" />
|
layout="@layout/stats_large_item" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- Row 3: horizontal line -->
|
<!-- Row 3: horizontal line -->
|
||||||
<View style="@style/StatsHorizontalLine" />
|
<View style="@style/StatsHorizontalLine" />
|
||||||
<!-- Row 3: moving time and average moving speed -->
|
<!-- Row 3: speed and average speed -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent" >
|
android:layout_width="match_parent" >
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stats_moving_time"
|
android:id="@+id/stats_speed"
|
||||||
layout="@layout/stats_small_item" />
|
layout="@layout/stats_small_item" />
|
||||||
<View style="@style/StatsVerticalSpacer" />
|
<View style="@style/StatsVerticalSpacer" />
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stats_average_moving_time"
|
android:id="@+id/stats_average_speed"
|
||||||
layout="@layout/stats_small_item" />
|
layout="@layout/stats_small_item" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- Row 4: empty and max speed -->
|
<!-- Row 4: max speed and average moving speed -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent" >
|
android:layout_width="match_parent" >
|
||||||
<LinearLayout style="@style/StatsSmallItemContainer" />
|
|
||||||
<View style="@style/StatsVerticalSpacer" />
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stats_max_speed"
|
android:id="@+id/stats_max_speed"
|
||||||
layout="@layout/stats_small_item" />
|
layout="@layout/stats_small_item" />
|
||||||
|
<View style="@style/StatsVerticalSpacer" />
|
||||||
|
<include
|
||||||
|
android:id="@+id/stats_average_moving_speed"
|
||||||
|
layout="@layout/stats_small_item" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- Row 5: horizontal line -->
|
<!-- Row 5: horizontal line -->
|
||||||
<View
|
<View
|
||||||
@@ -78,14 +80,19 @@ limitations under the License.
|
|||||||
<TextView
|
<TextView
|
||||||
android:text="@string/stats_grade"
|
android:text="@string/stats_grade"
|
||||||
style="@style/StatsSmallLabel" />
|
style="@style/StatsSmallLabel" />
|
||||||
<!-- Grade min -->
|
<TableLayout
|
||||||
<include
|
android:layout_gravity="center"
|
||||||
android:id="@+id/stats_grade_min"
|
android:layout_height="wrap_content"
|
||||||
layout="@layout/stats_small_item_1line" />
|
android:layout_width="wrap_content" >
|
||||||
<!-- Grade max -->
|
<!-- Grade min -->
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stats_grade_max"
|
android:id="@+id/stats_grade_min"
|
||||||
layout="@layout/stats_small_item_1line" />
|
layout="@layout/stats_small_item_1line" />
|
||||||
|
<!-- Grade max -->
|
||||||
|
<include
|
||||||
|
android:id="@+id/stats_grade_max"
|
||||||
|
layout="@layout/stats_small_item_1line" />
|
||||||
|
</TableLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<View style="@style/StatsVerticalSpacer" />
|
<View style="@style/StatsVerticalSpacer" />
|
||||||
<!-- Elevation -->
|
<!-- Elevation -->
|
||||||
@@ -94,22 +101,27 @@ limitations under the License.
|
|||||||
<TextView
|
<TextView
|
||||||
android:text="@string/stats_elevation"
|
android:text="@string/stats_elevation"
|
||||||
style="@style/StatsSmallLabel" />
|
style="@style/StatsSmallLabel" />
|
||||||
<!-- Elevation -->
|
<TableLayout
|
||||||
<include
|
android:layout_gravity="center"
|
||||||
android:id="@+id/stats_elevation"
|
android:layout_height="wrap_content"
|
||||||
layout="@layout/stats_small_item_1line" />
|
android:layout_width="wrap_content" >
|
||||||
<!-- Elevation gain -->
|
<!-- Elevation -->
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stats_elevation_gain"
|
android:id="@+id/stats_elevation"
|
||||||
layout="@layout/stats_small_item_1line" />
|
layout="@layout/stats_small_item_1line" />
|
||||||
<!-- Elevation min -->
|
<!-- Elevation gain -->
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stats_elevation_min"
|
android:id="@+id/stats_elevation_gain"
|
||||||
layout="@layout/stats_small_item_1line" />
|
layout="@layout/stats_small_item_1line" />
|
||||||
<!-- Elevation max -->
|
<!-- Elevation min -->
|
||||||
<include
|
<include
|
||||||
android:id="@+id/stats_elevation_max"
|
android:id="@+id/stats_elevation_min"
|
||||||
layout="@layout/stats_small_item_1line" />
|
layout="@layout/stats_small_item_1line" />
|
||||||
|
<!-- Elevation max -->
|
||||||
|
<include
|
||||||
|
android:id="@+id/stats_elevation_max"
|
||||||
|
layout="@layout/stats_small_item_1line" />
|
||||||
|
</TableLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- Row 6: horizontal line -->
|
<!-- Row 6: horizontal line -->
|
||||||
@@ -129,25 +141,4 @@ limitations under the License.
|
|||||||
android:id="@+id/stats_longitude"
|
android:id="@+id/stats_longitude"
|
||||||
layout="@layout/stats_small_item" />
|
layout="@layout/stats_small_item" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!-- Row 7: calorie horizontal line -->
|
|
||||||
<View
|
|
||||||
android:id="@+id/stats_calorie_horizontal_line"
|
|
||||||
style="@style/StatsHorizontalLine" />
|
|
||||||
<!-- Row 7: calorie -->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/stats_calorie_container"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent" >
|
|
||||||
<!-- calorie value -->
|
|
||||||
<include
|
|
||||||
android:id="@+id/stats_calorie"
|
|
||||||
layout="@layout/stats_small_item" />
|
|
||||||
<!-- Setup activity type-->
|
|
||||||
<Button
|
|
||||||
android:id="@+id/stats_calorie_setup"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:text="@string/stats_calorie_setup" />
|
|
||||||
</LinearLayout>
|
|
||||||
</merge>
|
</merge>
|
||||||
@@ -14,18 +14,28 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/stats_small_1line_id"
|
android:layout_height="wrap_content"
|
||||||
style="@style/StatsSmallValueContainer" >
|
android:layout_width="wrap_content" >
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:id="@+id/stats_value"
|
android:layout_gravity="right|bottom"
|
||||||
style="@style/StatsSmallValue" />
|
style="@style/StatsSmallValueContainer" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/stats_unit"
|
android:id="@+id/stats_value"
|
||||||
style="@style/StatsUnit" />
|
android:layout_alignParentBottom="true"
|
||||||
<TextView
|
style="@style/StatsSmallValue" />
|
||||||
android:id="@+id/stats_label"
|
<TextView
|
||||||
android:layout_gravity="bottom"
|
android:id="@+id/stats_unit"
|
||||||
android:paddingLeft="8dp"
|
android:layout_alignParentBottom="true"
|
||||||
style="@style/StatsSmallLabel" />
|
android:layout_toRightOf="@id/stats_value"
|
||||||
</LinearLayout>
|
style="@style/StatsUnit" />
|
||||||
|
</RelativeLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_gravity="left|bottom"
|
||||||
|
style="@style/StatsSmallValueContainer" >
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/stats_label"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
style="@style/StatsSmallLabel" />
|
||||||
|
</LinearLayout>
|
||||||
|
</TableRow>
|
||||||
@@ -18,16 +18,14 @@ limitations under the License.
|
|||||||
<!-- The style for choose activity text -->
|
<!-- The style for choose activity text -->
|
||||||
<style name="StatsSmallLabel" parent="@style/TextSmall">
|
<style name="StatsSmallLabel" parent="@style/TextSmall">
|
||||||
<!-- same as StatsSmallLabel in values/styles.xml except adding textAllCaps -->
|
<!-- same as StatsSmallLabel in values/styles.xml except adding textAllCaps -->
|
||||||
<item name="android:gravity">right</item>
|
<item name="android:layout_gravity">center</item>
|
||||||
<item name="android:layout_gravity">right</item>
|
|
||||||
<item name="android:singleLine">false</item>
|
<item name="android:singleLine">false</item>
|
||||||
<item name="android:textAllCaps">true</item>
|
<item name="android:textAllCaps">true</item>
|
||||||
<item name="android:textStyle">bold</item>
|
<item name="android:textStyle">bold</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="StatsLargeLabel" parent="@style/TextSmall">
|
<style name="StatsLargeLabel" parent="@style/TextSmall">
|
||||||
<!-- same as StatsLargeLabel in values/styles.xml except adding textAllCaps -->
|
<!-- same as StatsLargeLabel in values/styles.xml except adding textAllCaps -->
|
||||||
<item name="android:gravity">right</item>
|
<item name="android:layout_gravity">center</item>
|
||||||
<item name="android:layout_gravity">right</item>
|
|
||||||
<item name="android:singleLine">false</item>
|
<item name="android:singleLine">false</item>
|
||||||
<item name="android:textAllCaps">true</item>
|
<item name="android:textAllCaps">true</item>
|
||||||
<item name="android:textColor">@color/stats_large_label</item>
|
<item name="android:textColor">@color/stats_large_label</item>
|
||||||
|
|||||||
@@ -149,8 +149,7 @@ limitations under the License.
|
|||||||
</style>
|
</style>
|
||||||
<!-- stats large label -->
|
<!-- stats large label -->
|
||||||
<style name="StatsLargeLabel" parent="@style/TextSmall">
|
<style name="StatsLargeLabel" parent="@style/TextSmall">
|
||||||
<item name="android:gravity">right</item>
|
<item name="android:layout_gravity">center</item>
|
||||||
<item name="android:layout_gravity">right</item>
|
|
||||||
<item name="android:singleLine">false</item>
|
<item name="android:singleLine">false</item>
|
||||||
<item name="android:textColor">@color/stats_large_label</item>
|
<item name="android:textColor">@color/stats_large_label</item>
|
||||||
<item name="android:textStyle">bold</item>
|
<item name="android:textStyle">bold</item>
|
||||||
@@ -166,7 +165,7 @@ limitations under the License.
|
|||||||
</style>
|
</style>
|
||||||
<!-- stats large value container -->
|
<!-- stats large value container -->
|
||||||
<style name="StatsLargeValueContainer">
|
<style name="StatsLargeValueContainer">
|
||||||
<item name="android:layout_gravity">right</item>
|
<item name="android:layout_gravity">center</item>
|
||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
<item name="android:layout_marginTop">-4dp</item>
|
<item name="android:layout_marginTop">-4dp</item>
|
||||||
<item name="android:layout_width">wrap_content</item>
|
<item name="android:layout_width">wrap_content</item>
|
||||||
@@ -181,8 +180,7 @@ limitations under the License.
|
|||||||
</style>
|
</style>
|
||||||
<!-- stats small label -->
|
<!-- stats small label -->
|
||||||
<style name="StatsSmallLabel" parent="@style/TextSmall">
|
<style name="StatsSmallLabel" parent="@style/TextSmall">
|
||||||
<item name="android:gravity">right</item>
|
<item name="android:layout_gravity">center</item>
|
||||||
<item name="android:layout_gravity">right</item>
|
|
||||||
<item name="android:singleLine">false</item>
|
<item name="android:singleLine">false</item>
|
||||||
<item name="android:textStyle">bold</item>
|
<item name="android:textStyle">bold</item>
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.google.android.apps.mytracks;
|
|||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
|
||||||
import com.google.android.apps.mytracks.util.StatsUtils;
|
import com.google.android.apps.mytracks.util.StatsUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
@@ -37,8 +36,7 @@ public class AggregatedStatsActivity extends AbstractMyTracksActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
StatsUtils.setTripStatisticsValues(
|
StatsUtils.setTripStatisticsValues(this, this, null, getTripStatistics());
|
||||||
this, this, null, getTripStatistics(), PreferencesUtils.RECORDING_TRACK_ID_DEFAULT);
|
|
||||||
StatsUtils.setLocationValues(this, this, null, null, false);
|
StatsUtils.setLocationValues(this, this, null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import com.google.android.apps.mytracks.content.Waypoint;
|
|||||||
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
||||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||||
import com.google.android.apps.mytracks.util.PhotoUtils;
|
import com.google.android.apps.mytracks.util.PhotoUtils;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
|
||||||
import com.google.android.apps.mytracks.util.StatsUtils;
|
import com.google.android.apps.mytracks.util.StatsUtils;
|
||||||
import com.google.android.apps.mytracks.util.StringUtils;
|
import com.google.android.apps.mytracks.util.StringUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
@@ -277,8 +276,8 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
TextView name = (TextView) getView().findViewById(R.id.marker_detail_statistics_name);
|
TextView name = (TextView) getView().findViewById(R.id.marker_detail_statistics_name);
|
||||||
setTextView(name, waypoint.getName());
|
setTextView(name, waypoint.getName());
|
||||||
|
|
||||||
StatsUtils.setTripStatisticsValues(getActivity(), null, getView(),
|
StatsUtils.setTripStatisticsValues(
|
||||||
waypoint.getTripStatistics(), PreferencesUtils.RECORDING_TRACK_ID_DEFAULT);
|
getActivity(), null, getView(), waypoint.getTripStatistics());
|
||||||
StatsUtils.setLocationValues(getActivity(), null, getView(), waypoint.getLocation(), false);
|
StatsUtils.setLocationValues(getActivity(), null, getView(), waypoint.getLocation(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,9 +260,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
* Updates the UI.
|
* Updates the UI.
|
||||||
*/
|
*/
|
||||||
private void updateUi(FragmentActivity activity) {
|
private void updateUi(FragmentActivity activity) {
|
||||||
StatsUtils.setTripStatisticsValues(activity, activity, null, lastTripStatistics,
|
StatsUtils.setTripStatisticsValues(activity, activity, null, lastTripStatistics);
|
||||||
trackDataHub == null ? PreferencesUtils.RECORDING_TRACK_ID_DEFAULT
|
|
||||||
: trackDataHub.getSelectedTrackId());
|
|
||||||
StatsUtils.setLocationValues(
|
StatsUtils.setLocationValues(
|
||||||
activity, activity, null, lastLocation, isSelectedTrackRecording());
|
activity, activity, null, lastLocation, isSelectedTrackRecording());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,15 +16,15 @@
|
|||||||
|
|
||||||
package com.google.android.apps.mytracks.util;
|
package com.google.android.apps.mytracks.util;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType;
|
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
import android.text.SpannableStringBuilder;
|
||||||
|
import android.text.Spanned;
|
||||||
|
import android.text.style.SuperscriptSpan;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -63,10 +63,16 @@ public class StatsUtils {
|
|||||||
boolean reportSpeed = PreferencesUtils.isReportSpeed(context);
|
boolean reportSpeed = PreferencesUtils.isReportSpeed(context);
|
||||||
|
|
||||||
// Set speed/pace
|
// Set speed/pace
|
||||||
double speed = isRecording && location != null && location.hasSpeed() ? location.getSpeed()
|
View speed = getView(activity, view, R.id.stats_speed);
|
||||||
: Double.NaN;
|
if (isRecording) {
|
||||||
setSpeed(context, getView(activity, view, R.id.stats_speed), R.string.stats_speed,
|
double value = isRecording && location != null && location.hasSpeed() ? location.getSpeed()
|
||||||
R.string.stats_pace, speed, metricUnits, reportSpeed);
|
: Double.NaN;
|
||||||
|
speed.setVisibility(View.VISIBLE);
|
||||||
|
setSpeed(context, speed, R.string.stats_speed, R.string.stats_pace, value, metricUnits,
|
||||||
|
reportSpeed);
|
||||||
|
} else {
|
||||||
|
speed.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
// Set elevation
|
// Set elevation
|
||||||
boolean showGradeElevation = PreferencesUtils.getBoolean(context,
|
boolean showGradeElevation = PreferencesUtils.getBoolean(context,
|
||||||
@@ -124,12 +130,9 @@ public class StatsUtils {
|
|||||||
* @param view the containing view for finding views. If null, the activity
|
* @param view the containing view for finding views. If null, the activity
|
||||||
* cannot be null
|
* cannot be null
|
||||||
* @param tripStatistics the trip statistics
|
* @param tripStatistics the trip statistics
|
||||||
* @param trackId the id of track, which is used to set calorie value. Does
|
|
||||||
* not handle the calorie If the value is
|
|
||||||
* {@link PreferencesUtils#RECORDING_TRACK_ID_DEFAULT}
|
|
||||||
*/
|
*/
|
||||||
public static void setTripStatisticsValues(
|
public static void setTripStatisticsValues(
|
||||||
Context context, Activity activity, View view, TripStatistics tripStatistics, long trackId) {
|
Context context, Activity activity, View view, TripStatistics tripStatistics) {
|
||||||
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||||
boolean reportSpeed = PreferencesUtils.isReportSpeed(context);
|
boolean reportSpeed = PreferencesUtils.isReportSpeed(context);
|
||||||
|
|
||||||
@@ -138,31 +141,35 @@ public class StatsUtils {
|
|||||||
setDistanceValue(
|
setDistanceValue(
|
||||||
context, getView(activity, view, R.id.stats_distance), totalDistance, metricUnits);
|
context, getView(activity, view, R.id.stats_distance), totalDistance, metricUnits);
|
||||||
|
|
||||||
|
// Set calorie
|
||||||
|
double calorie = tripStatistics == null ? Double.NaN : tripStatistics.getCalorie();
|
||||||
|
setCalorie(context, getView(activity, view, R.id.stats_calorie), calorie);
|
||||||
|
|
||||||
// Set total time
|
// Set total time
|
||||||
setTimeValue(context, getView(activity, view, R.id.stats_total_time), R.string.stats_total_time,
|
setTimeValue(context, getView(activity, view, R.id.stats_total_time), R.string.stats_total_time,
|
||||||
tripStatistics != null ? tripStatistics.getTotalTime() : -1L);
|
tripStatistics != null ? tripStatistics.getTotalTime() : -1L);
|
||||||
|
|
||||||
|
// Set moving time
|
||||||
|
setTimeValue(context, getView(activity, view, R.id.stats_moving_time),
|
||||||
|
R.string.stats_moving_time, tripStatistics != null ? tripStatistics.getMovingTime() : -1L);
|
||||||
|
|
||||||
// Set average speed/pace
|
// Set average speed/pace
|
||||||
double averageSpeed = tripStatistics != null ? tripStatistics.getAverageSpeed() : Double.NaN;
|
double averageSpeed = tripStatistics != null ? tripStatistics.getAverageSpeed() : Double.NaN;
|
||||||
setSpeed(context, getView(activity, view, R.id.stats_average_speed),
|
setSpeed(context, getView(activity, view, R.id.stats_average_speed),
|
||||||
R.string.stats_average_speed, R.string.stats_average_pace, averageSpeed, metricUnits,
|
R.string.stats_average_speed, R.string.stats_average_pace, averageSpeed, metricUnits,
|
||||||
reportSpeed);
|
reportSpeed);
|
||||||
|
|
||||||
// Set moving time
|
|
||||||
setTimeValue(context, getView(activity, view, R.id.stats_moving_time),
|
|
||||||
R.string.stats_moving_time, tripStatistics != null ? tripStatistics.getMovingTime() : -1L);
|
|
||||||
|
|
||||||
// Set average moving speed/pace
|
|
||||||
double averageMovingSpeed = tripStatistics != null ? tripStatistics.getAverageMovingSpeed()
|
|
||||||
: Double.NaN;
|
|
||||||
setSpeed(context, getView(activity, view, R.id.stats_average_moving_time),
|
|
||||||
R.string.stats_average_moving_speed, R.string.stats_average_moving_pace, averageMovingSpeed,
|
|
||||||
metricUnits, reportSpeed);
|
|
||||||
|
|
||||||
// Set max speed/pace
|
// Set max speed/pace
|
||||||
double maxSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getMaxSpeed();
|
double maxSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getMaxSpeed();
|
||||||
setSpeed(context, getView(activity, view, R.id.stats_max_speed), R.string.stats_max_speed,
|
setSpeed(context, getView(activity, view, R.id.stats_max_speed), R.string.stats_max_speed,
|
||||||
R.string.stats_fastest_pace, maxSpeed, metricUnits, reportSpeed);
|
R.string.stats_fastest_pace, maxSpeed, metricUnits, reportSpeed);
|
||||||
|
|
||||||
|
// Set average moving speed/pace
|
||||||
|
double averageMovingSpeed = tripStatistics != null ? tripStatistics.getAverageMovingSpeed()
|
||||||
|
: Double.NaN;
|
||||||
|
setSpeed(context, getView(activity, view, R.id.stats_average_moving_speed),
|
||||||
|
R.string.stats_average_moving_speed, R.string.stats_average_moving_pace, averageMovingSpeed,
|
||||||
|
metricUnits, reportSpeed);
|
||||||
|
|
||||||
// Set grade/elevation
|
// Set grade/elevation
|
||||||
boolean showGradeElevation = PreferencesUtils.getBoolean(context,
|
boolean showGradeElevation = PreferencesUtils.getBoolean(context,
|
||||||
@@ -198,30 +205,6 @@ public class StatsUtils {
|
|||||||
gradeElevationHorizontalLine.setVisibility(View.GONE);
|
gradeElevationHorizontalLine.setVisibility(View.GONE);
|
||||||
gradeElevationContainer.setVisibility(View.GONE);
|
gradeElevationContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT) {
|
|
||||||
// Set calories
|
|
||||||
boolean showCalorie = PreferencesUtils.getBoolean(
|
|
||||||
context, R.string.stats_show_calorie_key, PreferencesUtils.STATS_SHOW_CALORIE_DEFAULT);
|
|
||||||
View calorieHorizontalLine = getView(activity, view, R.id.stats_calorie_horizontal_line);
|
|
||||||
View calorieContainer = getView(activity, view, R.id.stats_calorie_container);
|
|
||||||
if (showCalorie) {
|
|
||||||
calorieHorizontalLine.setVisibility(View.VISIBLE);
|
|
||||||
calorieContainer.setVisibility(View.VISIBLE);
|
|
||||||
double calories = Double.NaN;
|
|
||||||
if (tripStatistics != null) {
|
|
||||||
calories = tripStatistics.getCalorie();
|
|
||||||
}
|
|
||||||
MyTracksProviderUtils myTracksProviderUtils = MyTracksProviderUtils.Factory.get(context);
|
|
||||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
|
||||||
ActivityType activityType = track == null ? ActivityType.INVALID
|
|
||||||
: CalorieUtils.getActivityType(context, track.getCategory());
|
|
||||||
setCalorie(context, getView(activity, view, R.id.stats_calorie), activityType, calories);
|
|
||||||
} else {
|
|
||||||
calorieHorizontalLine.setVisibility(View.GONE);
|
|
||||||
calorieContainer.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -241,6 +224,19 @@ public class StatsUtils {
|
|||||||
setItem(context, view, reportSpeed ? speedLabelId : paceLabelId, parts[0], parts[1]);
|
setItem(context, view, reportSpeed ? speedLabelId : paceLabelId, parts[0], parts[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets calorie.
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
* @param view the containing view
|
||||||
|
* @param calorie the value of calorie
|
||||||
|
*/
|
||||||
|
private static void setCalorie(Context context, View view, double calorie) {
|
||||||
|
String value = calorie == Double.NaN ? null
|
||||||
|
: String.format(Locale.getDefault(), CALORIES_FORMAT, calorie);
|
||||||
|
setItem(context, view, R.string.stats_calorie, value, context.getString(R.string.unit_calorie));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets distance value.
|
* Sets distance value.
|
||||||
*
|
*
|
||||||
@@ -322,28 +318,10 @@ public class StatsUtils {
|
|||||||
private static void setCoordinateValue(
|
private static void setCoordinateValue(
|
||||||
Context context, View view, int labelId, double coordinate) {
|
Context context, View view, int labelId, double coordinate) {
|
||||||
String value = Double.isNaN(coordinate) || Double.isInfinite(coordinate) ? null
|
String value = Double.isNaN(coordinate) || Double.isInfinite(coordinate) ? null
|
||||||
: Location.convert(coordinate, Location.FORMAT_DEGREES);
|
: Location.convert(coordinate, Location.FORMAT_DEGREES);
|
||||||
setItem(context, view, labelId, value, COORDINATE_DEGREE);
|
SpannableStringBuilder unit = new SpannableStringBuilder(COORDINATE_DEGREE);
|
||||||
}
|
unit.setSpan(new SuperscriptSpan(), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
setItem(context, view, labelId, value, unit);
|
||||||
/**
|
|
||||||
* Sets calorie.
|
|
||||||
*
|
|
||||||
* @param context the context
|
|
||||||
* @param view the containing view
|
|
||||||
* @param activityType the activity type
|
|
||||||
* @param calorie the value of calorie
|
|
||||||
*/
|
|
||||||
private static void setCalorie(
|
|
||||||
Context context, View view, ActivityType activityType, double calorie) {
|
|
||||||
if (activityType == ActivityType.INVALID) {
|
|
||||||
view.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
view.setVisibility(View.VISIBLE);
|
|
||||||
setItem(context, view, R.string.stats_calorie,
|
|
||||||
String.format(Locale.getDefault(), CALORIES_FORMAT, calorie),
|
|
||||||
context.getString(R.string.unit_calorie));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -355,7 +333,8 @@ public class StatsUtils {
|
|||||||
* @param value the value, can be null
|
* @param value the value, can be null
|
||||||
* @param unit the unit. Null to hide the unit
|
* @param unit the unit. Null to hide the unit
|
||||||
*/
|
*/
|
||||||
private static void setItem(Context context, View view, int labelId, String value, String unit) {
|
private static void setItem(
|
||||||
|
Context context, View view, int labelId, CharSequence value, CharSequence unit) {
|
||||||
TextView labelTextView = (TextView) view.findViewById(R.id.stats_label);
|
TextView labelTextView = (TextView) view.findViewById(R.id.stats_label);
|
||||||
TextView valueTextView = (TextView) view.findViewById(R.id.stats_value);
|
TextView valueTextView = (TextView) view.findViewById(R.id.stats_value);
|
||||||
TextView unitTextView = (TextView) view.findViewById(R.id.stats_unit);
|
TextView unitTextView = (TextView) view.findViewById(R.id.stats_unit);
|
||||||
|
|||||||
Reference in New Issue
Block a user