add static graphs
This commit is contained in:
parent
3bcf8d4e3b
commit
913e125968
10 changed files with 522 additions and 196 deletions
|
@ -273,6 +273,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/details_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
|
|
@ -291,6 +291,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/details_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
|
|
@ -275,6 +275,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/details_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/list_item_divider" />
|
||||
<include
|
||||
android:id="@+id/list_item_divider"
|
||||
layout="@layout/list_item_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -72,7 +72,13 @@
|
|||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/dialog_content_margin" />
|
||||
android:layout_marginBottom="@dimen/context_menu_padding_margin_small" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/segments_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/block_statistics"
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -30,7 +31,10 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -40,22 +44,34 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
||||
import net.osmand.plus.myplaces.GPXItemPagerAdapter;
|
||||
import net.osmand.plus.myplaces.SegmentActionsListener;
|
||||
import net.osmand.plus.myplaces.SegmentGPXAdapter;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.track.GpxBlockStatisticsBuilder;
|
||||
import net.osmand.plus.track.TrackAppearanceFragment;
|
||||
import net.osmand.plus.track.TrackDisplayHelper;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||
import net.osmand.plus.views.controls.WrapContentHeightViewPager;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.AndroidUtils.getSecondaryTextColorId;
|
||||
import static net.osmand.AndroidUtils.setPadding;
|
||||
import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL;
|
||||
import static net.osmand.plus.track.GpxBlockStatisticsBuilder.INIT_BLOCKS_ALTITUDE;
|
||||
import static net.osmand.plus.track.GpxBlockStatisticsBuilder.INIT_BLOCKS_GENERAL;
|
||||
import static net.osmand.plus.track.GpxBlockStatisticsBuilder.INIT_BLOCKS_SPEED;
|
||||
|
||||
public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment {
|
||||
public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment implements SegmentActionsListener {
|
||||
|
||||
public static final String TAG = TripRecordingBottomFragment.class.getSimpleName();
|
||||
private static final Log LOG = PlatformUtil.getLog(TripRecordingBottomFragment.class);
|
||||
|
@ -69,8 +85,13 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment {
|
|||
|
||||
private View statusContainer;
|
||||
private AppCompatImageView trackAppearanceIcon;
|
||||
private GpxBlockStatisticsBuilder blockStatisticsBuilder;
|
||||
private LinearLayout segmentsContainer;
|
||||
|
||||
private TrackDisplayHelper displayHelper;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
private GPXItemPagerAdapter graphsAdapter;
|
||||
|
||||
private GpxBlockStatisticsBuilder blockStatisticsBuilder;
|
||||
private SelectedGpxFile selectedGpxFile;
|
||||
private final Handler handler = new Handler();
|
||||
private Runnable updatingGPS;
|
||||
|
@ -111,6 +132,13 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment {
|
|||
LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode);
|
||||
final FragmentManager fragmentManager = getFragmentManager();
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
if (savedInstanceState.containsKey(SAVE_CURRENT_GPX_FILE)
|
||||
&& savedInstanceState.getBoolean(SAVE_CURRENT_GPX_FILE)) {
|
||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
}
|
||||
}
|
||||
|
||||
View itemView = inflater.inflate(R.layout.trip_recording_fragment, null, false);
|
||||
items.add(new BaseBottomSheetItem.Builder()
|
||||
.setCustomView(itemView)
|
||||
|
@ -119,18 +147,6 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment {
|
|||
statusContainer = itemView.findViewById(R.id.status_container);
|
||||
updateStatus();
|
||||
|
||||
RecyclerView statBlocks = itemView.findViewById(R.id.block_statistics);
|
||||
if (savedInstanceState != null) {
|
||||
if (savedInstanceState.containsKey(SAVE_CURRENT_GPX_FILE)
|
||||
&& savedInstanceState.getBoolean(SAVE_CURRENT_GPX_FILE)) {
|
||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
}
|
||||
}
|
||||
blockStatisticsBuilder = new GpxBlockStatisticsBuilder(app, selectedGpxFile);
|
||||
blockStatisticsBuilder.setBlocksView(statBlocks);
|
||||
blockStatisticsBuilder.setBlocksClickable(false);
|
||||
blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode);
|
||||
|
||||
LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map);
|
||||
trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon);
|
||||
createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon,
|
||||
|
@ -141,6 +157,17 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
});
|
||||
|
||||
segmentsContainer = itemView.findViewById(R.id.segments_container);
|
||||
createSegmentsTabs(segmentsContainer);
|
||||
|
||||
RecyclerView statBlocks = itemView.findViewById(R.id.block_statistics);
|
||||
blockStatisticsBuilder = new GpxBlockStatisticsBuilder(app, selectedGpxFile, nightMode);
|
||||
blockStatisticsBuilder.setBlocksView(statBlocks);
|
||||
blockStatisticsBuilder.setBlocksClickable(false);
|
||||
blockStatisticsBuilder.setInitBlocksKey(INIT_BLOCKS_GENERAL);
|
||||
blockStatisticsBuilder.initStatBlocks(null,
|
||||
ContextCompat.getColor(app, getActiveTextColorId(nightMode)));
|
||||
|
||||
CardView cardLeft = itemView.findViewById(R.id.button_left);
|
||||
createItem(cardLeft, ItemType.CANCEL);
|
||||
cardLeft.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -191,7 +218,6 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -253,6 +279,52 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment {
|
|||
handler.post(updatingGPS);
|
||||
}
|
||||
|
||||
private void recreateStatBlocks(String initBlocksKey) {
|
||||
blockStatisticsBuilder.stopUpdatingStatBlocks();
|
||||
blockStatisticsBuilder.setInitBlocksKey(initBlocksKey);
|
||||
blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded();
|
||||
}
|
||||
|
||||
private void setupDisplayHelper() {
|
||||
displayHelper = new TrackDisplayHelper(app);
|
||||
if (!selectedGpxFile.isShowCurrentTrack()) {
|
||||
File file = new File(getGPXFile().path);
|
||||
displayHelper.setFile(file);
|
||||
displayHelper.setGpxDataItem(app.getGpxDbHelper().getItem(file));
|
||||
}
|
||||
displayHelper.setGpx(getGPXFile());
|
||||
}
|
||||
|
||||
private void createSegmentsTabs(ViewGroup viewGroup) {
|
||||
viewGroup.removeAllViews();
|
||||
setupDisplayHelper();
|
||||
|
||||
View segmentView = SegmentGPXAdapter.createGpxTabsView(displayHelper, viewGroup, this, nightMode);
|
||||
AndroidUiHelper.setVisibility(View.GONE, segmentView.findViewById(R.id.list_item_divider));
|
||||
WrapContentHeightViewPager pager = segmentView.findViewById(R.id.pager);
|
||||
PagerSlidingTabStrip tabLayout = segmentView.findViewById(R.id.sliding_tabs);
|
||||
final String[] initBlocksKeys = new String[]{INIT_BLOCKS_GENERAL, INIT_BLOCKS_ALTITUDE, INIT_BLOCKS_SPEED};
|
||||
tabLayout.setOnTabReselectedListener(new PagerSlidingTabStrip.OnTabReselectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(int position) {
|
||||
recreateStatBlocks(initBlocksKeys[position]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(int position) {
|
||||
recreateStatBlocks(initBlocksKeys[position]);
|
||||
}
|
||||
});
|
||||
|
||||
graphsAdapter = new GPXItemPagerAdapter(app, GpxUiHelper.makeGpxDisplayItem(app,
|
||||
displayHelper.getGpx()), displayHelper, nightMode, this, true);
|
||||
|
||||
pager.setAdapter(graphsAdapter);
|
||||
tabLayout.setViewPager(pager);
|
||||
|
||||
viewGroup.addView(segmentView);
|
||||
}
|
||||
|
||||
private void updateStatus() {
|
||||
TextView statusTitle = statusContainer.findViewById(R.id.text_status);
|
||||
AppCompatImageView statusIcon = statusContainer.findViewById(R.id.icon_status);
|
||||
|
@ -478,6 +550,46 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPointSelected(TrkSegment segment, double lat, double lon) {
|
||||
if (trackChartPoints == null) {
|
||||
trackChartPoints = new TrackChartPoints();
|
||||
trackChartPoints.setGpx(displayHelper.getGpx());
|
||||
}
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
int segmentColor = segment != null ? segment.getColor(0) : 0;
|
||||
trackChartPoints.setSegmentColor(segmentColor);
|
||||
trackChartPoints.setHighlightedPoint(new LatLon(lat, lon));
|
||||
mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateContent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChartTouch() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollBy(int px) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openSplitInterval(GpxDisplayItem gpxItem, TrkSegment trkSegment) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showOptionsPopupMenu(View view, TrkSegment segment, boolean confirmDeletion, GpxDisplayItem gpxItem) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openAnalyzeOnMap(GpxDisplayItem gpxItem) {
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
public static int getActiveTextColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||
|
|
|
@ -79,18 +79,29 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
|||
|
||||
private boolean chartClicked;
|
||||
private boolean nightMode;
|
||||
|
||||
private boolean onlyGraphs;
|
||||
|
||||
public GPXItemPagerAdapter(@NonNull OsmandApplication app,
|
||||
@NonNull GpxDisplayItem gpxItem,
|
||||
@NonNull TrackDisplayHelper displayHelper,
|
||||
boolean nightMode, @NonNull SegmentActionsListener actionsListener) {
|
||||
boolean nightMode,
|
||||
@NonNull SegmentActionsListener actionsListener) {
|
||||
this(app, gpxItem, displayHelper, nightMode, actionsListener, false);
|
||||
}
|
||||
|
||||
public GPXItemPagerAdapter(@NonNull OsmandApplication app,
|
||||
@NonNull GpxDisplayItem gpxItem,
|
||||
@NonNull TrackDisplayHelper displayHelper,
|
||||
boolean nightMode,
|
||||
@NonNull SegmentActionsListener actionsListener,
|
||||
boolean onlyGraphs) {
|
||||
super();
|
||||
this.app = app;
|
||||
this.gpxItem = gpxItem;
|
||||
this.nightMode = nightMode;
|
||||
this.displayHelper = displayHelper;
|
||||
this.actionsListener = actionsListener;
|
||||
this.onlyGraphs = onlyGraphs;
|
||||
iconsCache = app.getUIUtilities();
|
||||
fetchTabTypes();
|
||||
}
|
||||
|
@ -217,15 +228,46 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
|||
|
||||
private View getViewForTab(@NonNull ViewGroup container, @NonNull GPXTabItemType tabType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(container.getContext());
|
||||
View view;
|
||||
switch (tabType) {
|
||||
case GPX_TAB_ITEM_ALTITUDE:
|
||||
return inflater.inflate(R.layout.gpx_item_altitude, container, false);
|
||||
view = inflater.inflate(R.layout.gpx_item_altitude, container, false);
|
||||
if (onlyGraphs) {
|
||||
AndroidUiHelper.setVisibility(View.GONE,
|
||||
view.findViewById(R.id.average_range),
|
||||
view.findViewById(R.id.ascent_descent)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case GPX_TAB_ITEM_SPEED:
|
||||
return inflater.inflate(R.layout.gpx_item_speed, container, false);
|
||||
view = inflater.inflate(R.layout.gpx_item_speed, container, false);
|
||||
if (onlyGraphs) {
|
||||
AndroidUiHelper.setVisibility(View.GONE,
|
||||
view.findViewById(R.id.average_max),
|
||||
view.findViewById(R.id.time_distance)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case GPX_TAB_ITEM_GENERAL:
|
||||
default:
|
||||
return inflater.inflate(R.layout.gpx_item_general, container, false);
|
||||
view = inflater.inflate(R.layout.gpx_item_general, container, false);
|
||||
if (onlyGraphs) {
|
||||
AndroidUiHelper.setVisibility(View.GONE,
|
||||
view.findViewById(R.id.distance_time_span),
|
||||
view.findViewById(R.id.start_end_time)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (onlyGraphs) {
|
||||
AndroidUiHelper.setVisibility(View.GONE,
|
||||
view.findViewById(R.id.gpx_join_gaps_container),
|
||||
view.findViewById(R.id.list_divider),
|
||||
view.findViewById(R.id.details_divider),
|
||||
view.findViewById(R.id.details_view)
|
||||
);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
private void setupSpeedTab(View view, LineChart chart, GPXTrackAnalysis analysis, GPXFile gpxFile, int position) {
|
||||
|
@ -238,51 +280,55 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
|||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
}
|
||||
((ImageView) view.findViewById(R.id.average_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_speed));
|
||||
((ImageView) view.findViewById(R.id.max_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_max_speed));
|
||||
((ImageView) view.findViewById(R.id.time_moving_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_span));
|
||||
((ImageView) view.findViewById(R.id.distance_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
if (!onlyGraphs) {
|
||||
((ImageView) view.findViewById(R.id.average_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_speed));
|
||||
((ImageView) view.findViewById(R.id.max_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_max_speed));
|
||||
((ImageView) view.findViewById(R.id.time_moving_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_span));
|
||||
((ImageView) view.findViewById(R.id.distance_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
|
||||
String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app);
|
||||
String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app);
|
||||
String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app);
|
||||
String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app);
|
||||
|
||||
((TextView) view.findViewById(R.id.average_text)).setText(avg);
|
||||
((TextView) view.findViewById(R.id.max_text)).setText(max);
|
||||
((TextView) view.findViewById(R.id.average_text)).setText(avg);
|
||||
((TextView) view.findViewById(R.id.max_text)).setText(max);
|
||||
|
||||
view.findViewById(R.id.gpx_join_gaps_container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (displayHelper.setJoinSegments(!displayHelper.isJoinSegments())) {
|
||||
actionsListener.updateContent();
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
View view = getViewAtPosition(i);
|
||||
updateJoinGapsInfo(view, i);
|
||||
view.findViewById(R.id.gpx_join_gaps_container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (displayHelper.setJoinSegments(!displayHelper.isJoinSegments())) {
|
||||
actionsListener.updateContent();
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
View view = getViewAtPosition(i);
|
||||
updateJoinGapsInfo(view, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
view.findViewById(R.id.average_max).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.list_divider).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.time_distance).setVisibility(View.GONE);
|
||||
}
|
||||
updateJoinGapsInfo(view, position);
|
||||
view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAnalyzeOnMap(GPXTabItemType.GPX_TAB_ITEM_SPEED);
|
||||
if (!onlyGraphs) {
|
||||
updateJoinGapsInfo(view, position);
|
||||
view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAnalyzeOnMap(GPXTabItemType.GPX_TAB_ITEM_SPEED);
|
||||
}
|
||||
});
|
||||
TextView overflowMenu = view.findViewById(R.id.overflow_menu);
|
||||
if (!gpxItem.group.getTrack().generalTrack) {
|
||||
setupOptionsPopupMenu(overflowMenu, false);
|
||||
} else {
|
||||
overflowMenu.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
TextView overflowMenu = view.findViewById(R.id.overflow_menu);
|
||||
if (!gpxItem.group.getTrack().generalTrack) {
|
||||
setupOptionsPopupMenu(overflowMenu, false);
|
||||
} else {
|
||||
overflowMenu.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,56 +352,60 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
|||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
}
|
||||
((ImageView) view.findViewById(R.id.average_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_altitude_average));
|
||||
((ImageView) view.findViewById(R.id.range_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_altitude_average));
|
||||
((ImageView) view.findViewById(R.id.ascent_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_altitude_ascent));
|
||||
((ImageView) view.findViewById(R.id.descent_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_altitude_descent));
|
||||
if (!onlyGraphs) {
|
||||
((ImageView) view.findViewById(R.id.average_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_altitude_average));
|
||||
((ImageView) view.findViewById(R.id.range_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_altitude_average));
|
||||
((ImageView) view.findViewById(R.id.ascent_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_altitude_ascent));
|
||||
((ImageView) view.findViewById(R.id.descent_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_altitude_descent));
|
||||
|
||||
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
|
||||
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
|
||||
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
|
||||
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
|
||||
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
|
||||
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
|
||||
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
|
||||
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
|
||||
|
||||
((TextView) view.findViewById(R.id.average_text))
|
||||
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
|
||||
((TextView) view.findViewById(R.id.range_text)).setText(String.format("%s - %s", min, max));
|
||||
((TextView) view.findViewById(R.id.ascent_text)).setText(asc);
|
||||
((TextView) view.findViewById(R.id.descent_text)).setText(desc);
|
||||
((TextView) view.findViewById(R.id.average_text))
|
||||
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
|
||||
((TextView) view.findViewById(R.id.range_text)).setText(String.format("%s - %s", min, max));
|
||||
((TextView) view.findViewById(R.id.ascent_text)).setText(asc);
|
||||
((TextView) view.findViewById(R.id.descent_text)).setText(desc);
|
||||
|
||||
view.findViewById(R.id.gpx_join_gaps_container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (displayHelper.setJoinSegments(!displayHelper.isJoinSegments())) {
|
||||
actionsListener.updateContent();
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
View view = getViewAtPosition(i);
|
||||
updateJoinGapsInfo(view, i);
|
||||
view.findViewById(R.id.gpx_join_gaps_container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (displayHelper.setJoinSegments(!displayHelper.isJoinSegments())) {
|
||||
actionsListener.updateContent();
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
View view = getViewAtPosition(i);
|
||||
updateJoinGapsInfo(view, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
view.findViewById(R.id.average_range).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.list_divider).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.ascent_descent).setVisibility(View.GONE);
|
||||
}
|
||||
updateJoinGapsInfo(view, position);
|
||||
view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAnalyzeOnMap(GPXTabItemType.GPX_TAB_ITEM_ALTITUDE);
|
||||
if (!onlyGraphs) {
|
||||
updateJoinGapsInfo(view, position);
|
||||
view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAnalyzeOnMap(GPXTabItemType.GPX_TAB_ITEM_ALTITUDE);
|
||||
}
|
||||
});
|
||||
TextView overflowMenu = view.findViewById(R.id.overflow_menu);
|
||||
if (!gpxItem.group.getTrack().generalTrack) {
|
||||
setupOptionsPopupMenu(overflowMenu, false);
|
||||
} else {
|
||||
overflowMenu.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
TextView overflowMenu = view.findViewById(R.id.overflow_menu);
|
||||
if (!gpxItem.group.getTrack().generalTrack) {
|
||||
setupOptionsPopupMenu(overflowMenu, false);
|
||||
} else {
|
||||
overflowMenu.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,41 +419,42 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
|||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
}
|
||||
if (!onlyGraphs) {
|
||||
((ImageView) view.findViewById(R.id.distance_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
((ImageView) view.findViewById(R.id.duration_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_span));
|
||||
((ImageView) view.findViewById(R.id.start_time_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_start));
|
||||
((ImageView) view.findViewById(R.id.end_time_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_end));
|
||||
|
||||
((ImageView) view.findViewById(R.id.distance_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
((ImageView) view.findViewById(R.id.duration_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_span));
|
||||
((ImageView) view.findViewById(R.id.start_time_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_start));
|
||||
((ImageView) view.findViewById(R.id.end_time_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_end));
|
||||
|
||||
view.findViewById(R.id.gpx_join_gaps_container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (displayHelper.setJoinSegments(!displayHelper.isJoinSegments())) {
|
||||
actionsListener.updateContent();
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
View view = getViewAtPosition(i);
|
||||
updateJoinGapsInfo(view, i);
|
||||
view.findViewById(R.id.gpx_join_gaps_container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (displayHelper.setJoinSegments(!displayHelper.isJoinSegments())) {
|
||||
actionsListener.updateContent();
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
View view = getViewAtPosition(i);
|
||||
updateJoinGapsInfo(view, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (analysis.timeSpan > 0) {
|
||||
DateFormat tf = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
|
||||
});
|
||||
if (analysis.timeSpan > 0) {
|
||||
DateFormat tf = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
|
||||
|
||||
Date start = new Date(analysis.startTime);
|
||||
((TextView) view.findViewById(R.id.start_time_text)).setText(tf.format(start));
|
||||
((TextView) view.findViewById(R.id.start_date_text)).setText(df.format(start));
|
||||
Date end = new Date(analysis.endTime);
|
||||
((TextView) view.findViewById(R.id.end_time_text)).setText(tf.format(end));
|
||||
((TextView) view.findViewById(R.id.end_date_text)).setText(df.format(end));
|
||||
} else {
|
||||
view.findViewById(R.id.list_divider).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.start_end_time).setVisibility(View.GONE);
|
||||
Date start = new Date(analysis.startTime);
|
||||
((TextView) view.findViewById(R.id.start_time_text)).setText(tf.format(start));
|
||||
((TextView) view.findViewById(R.id.start_date_text)).setText(df.format(start));
|
||||
Date end = new Date(analysis.endTime);
|
||||
((TextView) view.findViewById(R.id.end_time_text)).setText(tf.format(end));
|
||||
((TextView) view.findViewById(R.id.end_date_text)).setText(df.format(end));
|
||||
} else {
|
||||
view.findViewById(R.id.list_divider).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.start_end_time).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
|
@ -412,17 +463,19 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
|||
view.findViewById(R.id.start_end_time).setVisibility(View.GONE);
|
||||
}
|
||||
updateJoinGapsInfo(view, position);
|
||||
view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAnalyzeOnMap(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
||||
if (!onlyGraphs) {
|
||||
view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAnalyzeOnMap(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
||||
}
|
||||
});
|
||||
TextView overflowMenu = view.findViewById(R.id.overflow_menu);
|
||||
if (!gpxItem.group.getTrack().generalTrack) {
|
||||
setupOptionsPopupMenu(overflowMenu, true);
|
||||
} else {
|
||||
overflowMenu.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
TextView overflowMenu = view.findViewById(R.id.overflow_menu);
|
||||
if (!gpxItem.group.getTrack().generalTrack) {
|
||||
setupOptionsPopupMenu(overflowMenu, true);
|
||||
} else {
|
||||
overflowMenu.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -598,7 +651,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
|||
@Override
|
||||
public void tabStylesUpdated(View tabsContainer, int currentPosition) {
|
||||
ViewGroup.MarginLayoutParams params = (MarginLayoutParams) tabsContainer.getLayoutParams();
|
||||
params.height = app.getResources().getDimensionPixelSize(R.dimen.dialog_button_height);
|
||||
params.height = app.getResources().getDimensionPixelSize(!onlyGraphs ? R.dimen.dialog_button_height : R.dimen.context_menu_buttons_bottom_height);
|
||||
tabsContainer.setLayoutParams(params);
|
||||
UiUtilities.updateCustomRadioButtons(app, tabsContainer, nightMode, getCustomRadioButtonType(currentPosition));
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import androidx.annotation.DrawableRes;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
@ -35,30 +36,44 @@ import net.osmand.util.Algorithms;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.liveupdates.LiveUpdatesFragmentNew.getDefaultIconColorId;
|
||||
|
||||
public class GpxBlockStatisticsBuilder {
|
||||
|
||||
private static final Log log = PlatformUtil.getLog(GpxBlockStatisticsBuilder.class);
|
||||
private static final int GENERAL_UPDATE_INTERVAL = 1000;
|
||||
private static final Log LOG = PlatformUtil.getLog(GpxBlockStatisticsBuilder.class);
|
||||
private static final int BLOCKS_UPDATE_INTERVAL = 1000;
|
||||
public static final String INIT_BLOCKS_BASE = "init_blocks_base";
|
||||
public static final String INIT_BLOCKS_GENERAL = "init_blocks_general";
|
||||
public static final String INIT_BLOCKS_ALTITUDE = "init_blocks_altitude";
|
||||
public static final String INIT_BLOCKS_SPEED = "init_blocks_speed";
|
||||
|
||||
private final OsmandApplication app;
|
||||
private final boolean nightMode;
|
||||
|
||||
private RecyclerView blocksView;
|
||||
private final SelectedGpxFile selectedGpxFile;
|
||||
private GPXTrackAnalysis analysis;
|
||||
|
||||
private BlockStatisticsAdapter adapter;
|
||||
private final List<StatBlock> items = new ArrayList<>();
|
||||
private boolean blocksClickable = true;
|
||||
private String initBlocksKey = INIT_BLOCKS_BASE;
|
||||
|
||||
private final Handler handler = new Handler();
|
||||
private Runnable updatingItems;
|
||||
private boolean updateRunning = false;
|
||||
|
||||
public GpxBlockStatisticsBuilder(OsmandApplication app, SelectedGpxFile selectedGpxFile) {
|
||||
public GpxBlockStatisticsBuilder(OsmandApplication app, SelectedGpxFile selectedGpxFile, boolean nightMode) {
|
||||
this.app = app;
|
||||
this.selectedGpxFile = selectedGpxFile;
|
||||
this.nightMode = nightMode;
|
||||
}
|
||||
|
||||
public boolean isUpdateRunning() {
|
||||
|
@ -73,6 +88,10 @@ public class GpxBlockStatisticsBuilder {
|
|||
this.blocksView = blocksView;
|
||||
}
|
||||
|
||||
public void setInitBlocksKey(String initBlocksKey) {
|
||||
this.initBlocksKey = initBlocksKey;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GpxDisplayItem getDisplayItem(GPXFile gpxFile) {
|
||||
return gpxFile.tracks.size() > 0 ? GpxUiHelper.makeGpxDisplayItem(app, gpxFile) : null;
|
||||
|
@ -82,9 +101,9 @@ public class GpxBlockStatisticsBuilder {
|
|||
return selectedGpxFile.getGpxFile();
|
||||
}
|
||||
|
||||
public void initStatBlocks(@Nullable SegmentActionsListener actionsListener, @ColorInt int activeColor, boolean nightMode) {
|
||||
public void initStatBlocks(@Nullable SegmentActionsListener actionsListener, @ColorInt int activeColor) {
|
||||
initItems();
|
||||
adapter = new BlockStatisticsAdapter(getDisplayItem(getGPXFile()), actionsListener, activeColor, nightMode);
|
||||
adapter = new BlockStatisticsAdapter(getDisplayItem(getGPXFile()), actionsListener, activeColor);
|
||||
adapter.setItems(items);
|
||||
blocksView.setLayoutManager(new LinearLayoutManager(app, LinearLayoutManager.HORIZONTAL, false));
|
||||
blocksView.setAdapter(adapter);
|
||||
|
@ -107,7 +126,7 @@ public class GpxBlockStatisticsBuilder {
|
|||
}
|
||||
AndroidUiHelper.updateVisibility(blocksView, !Algorithms.isEmpty(items));
|
||||
int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get();
|
||||
updateRunning = handler.postDelayed(this, Math.max(GENERAL_UPDATE_INTERVAL, interval));
|
||||
updateRunning = handler.postDelayed(this, Math.max(BLOCKS_UPDATE_INTERVAL, interval));
|
||||
}
|
||||
};
|
||||
updateRunning = handler.post(updatingItems);
|
||||
|
@ -117,65 +136,187 @@ public class GpxBlockStatisticsBuilder {
|
|||
public void initItems() {
|
||||
GPXFile gpxFile = getGPXFile();
|
||||
GpxDisplayItem gpxDisplayItem = getDisplayItem(gpxFile);
|
||||
GPXTrackAnalysis analysis = null;
|
||||
boolean withoutGaps = true;
|
||||
if (gpxDisplayItem != null) {
|
||||
analysis = gpxDisplayItem.analysis;
|
||||
withoutGaps = !selectedGpxFile.isJoinSegments() && gpxDisplayItem.isGeneralTrack();
|
||||
}
|
||||
if (analysis != null) {
|
||||
float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance;
|
||||
float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan;
|
||||
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
|
||||
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
|
||||
String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app);
|
||||
String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app);
|
||||
|
||||
items.clear();
|
||||
prepareData(analysis, app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app),
|
||||
R.drawable.ic_action_track_16, R.color.icon_color_default_light, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED, ItemType.ITEM_DISTANCE);
|
||||
prepareData(analysis, app.getString(R.string.altitude_ascent), asc,
|
||||
R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red, GPXDataSetType.SLOPE, null, ItemType.ITEM_ALTITUDE);
|
||||
prepareData(analysis, app.getString(R.string.altitude_descent), desc,
|
||||
R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green, GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE, ItemType.ITEM_ALTITUDE);
|
||||
prepareData(analysis, app.getString(R.string.average_speed), avg,
|
||||
R.drawable.ic_action_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ItemType.ITEM_SPEED);
|
||||
prepareData(analysis, app.getString(R.string.max_speed), max,
|
||||
R.drawable.ic_action_max_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ItemType.ITEM_SPEED);
|
||||
prepareData(analysis, app.getString(R.string.shared_string_time_span),
|
||||
Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()),
|
||||
R.drawable.ic_action_time_span_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME);
|
||||
switch (initBlocksKey) {
|
||||
case INIT_BLOCKS_GENERAL: {
|
||||
float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance;
|
||||
float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan;
|
||||
Date start = new Date(analysis.startTime);
|
||||
Date end = new Date(analysis.endTime);
|
||||
prepareDataDistance(totalDistance);
|
||||
prepareDataTimeSpan(timeSpan);
|
||||
prepareDataStartTime(start);
|
||||
prepareDataEndTime(end);
|
||||
break;
|
||||
}
|
||||
case INIT_BLOCKS_ALTITUDE: {
|
||||
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
|
||||
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
|
||||
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
|
||||
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
|
||||
prepareDataAverageAltitude();
|
||||
prepareDataAltitudeRange(min, max);
|
||||
prepareDataAscent(asc);
|
||||
prepareDataDescent(desc);
|
||||
break;
|
||||
}
|
||||
case INIT_BLOCKS_SPEED: {
|
||||
String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app);
|
||||
String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app);
|
||||
long timeMoving = withoutGaps ? analysis.timeMovingWithoutGaps : analysis.timeMoving;
|
||||
float totalDistanceMoving = withoutGaps ? analysis.totalDistanceMovingWithoutGaps : analysis.totalDistanceMoving;
|
||||
prepareDataAverageSpeed(avg);
|
||||
prepareDataMaximumSpeed(max);
|
||||
prepareDataTimeMoving(timeMoving);
|
||||
prepareDataDistanceCorrected(totalDistanceMoving);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case INIT_BLOCKS_BASE: {
|
||||
float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance;
|
||||
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
|
||||
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
|
||||
String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app);
|
||||
String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app);
|
||||
float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan;
|
||||
prepareDataDistance(totalDistance);
|
||||
prepareDataAscent(asc);
|
||||
prepareDataDescent(desc);
|
||||
prepareDataAverageSpeed(avg);
|
||||
prepareDataMaximumSpeed(max);
|
||||
prepareDataTimeSpan(timeSpan);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void prepareData(GPXTrackAnalysis analysis, String title, String value,
|
||||
@DrawableRes int imageResId, @ColorRes int imageColorId,
|
||||
public void prepareDataDistance(float totalDistance) {
|
||||
prepareData(app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app),
|
||||
R.drawable.ic_action_track_16, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED, ItemType.ITEM_DISTANCE);
|
||||
}
|
||||
|
||||
public void prepareDataAverageAltitude() {
|
||||
prepareData(app.getString(R.string.average_altitude), OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app),
|
||||
R.drawable.ic_action_altitude_average_16, GPXDataSetType.ALTITUDE, null, ItemType.ITEM_ALTITUDE);
|
||||
}
|
||||
|
||||
public void prepareDataAltitudeRange(String min, String max) {
|
||||
String pattern = app.getString(R.string.ltr_or_rtl_combine_via_dash);
|
||||
prepareData(app.getString(R.string.altitude_range), String.format(pattern, min, max),
|
||||
R.drawable.ic_action_altitude_range_16, GPXDataSetType.ALTITUDE, null, ItemType.ITEM_ALTITUDE);
|
||||
}
|
||||
|
||||
public void prepareDataAscent(String asc) {
|
||||
prepareData(app.getString(R.string.altitude_ascent), asc,
|
||||
R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red,
|
||||
GPXDataSetType.SLOPE, null, ItemType.ITEM_ALTITUDE);
|
||||
}
|
||||
|
||||
public void prepareDataDescent(String desc) {
|
||||
prepareData(app.getString(R.string.altitude_descent), desc,
|
||||
R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green,
|
||||
GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE, ItemType.ITEM_ALTITUDE);
|
||||
}
|
||||
|
||||
public void prepareDataAverageSpeed(String avg) {
|
||||
prepareData(app.getString(R.string.average_speed), avg,
|
||||
R.drawable.ic_action_speed_16, GPXDataSetType.SPEED, null, ItemType.ITEM_SPEED);
|
||||
}
|
||||
|
||||
public void prepareDataMaximumSpeed(String max) {
|
||||
prepareData(app.getString(R.string.max_speed), max,
|
||||
R.drawable.ic_action_max_speed_16, GPXDataSetType.SPEED, null, ItemType.ITEM_SPEED);
|
||||
}
|
||||
|
||||
public void prepareDataTimeMoving(long timeMoving) {
|
||||
prepareData(app.getString(R.string.shared_string_time_moving),
|
||||
Algorithms.formatDuration((int) (timeMoving / 1000), app.accessibilityEnabled()),
|
||||
R.drawable.ic_action_time_span_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME_MOVING);
|
||||
}
|
||||
|
||||
public void prepareDataDistanceCorrected(float totalDistanceMoving) {
|
||||
prepareData(app.getString(R.string.distance_moving),
|
||||
OsmAndFormatter.getFormattedDistance(totalDistanceMoving, app),
|
||||
R.drawable.ic_action_polygom_dark, GPXDataSetType.SPEED, null, ItemType.ITEM_DISTANCE_MOVING);
|
||||
}
|
||||
|
||||
public void prepareDataTimeSpan(float timeSpan) {
|
||||
prepareData(app.getString(R.string.shared_string_time_span),
|
||||
Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()),
|
||||
R.drawable.ic_action_time_span_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME_SPAN);
|
||||
}
|
||||
|
||||
public void prepareDataStartTime(Date start) {
|
||||
DateFormat dtf = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
prepareData(app.getString(R.string.shared_string_start_time), dtf.format(start),
|
||||
R.drawable.ic_action_time_start_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME);
|
||||
}
|
||||
|
||||
public void prepareDataEndTime(Date end) {
|
||||
DateFormat dtf = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
prepareData(app.getString(R.string.shared_string_end_time), dtf.format(end),
|
||||
R.drawable.ic_action_time_end_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME);
|
||||
}
|
||||
|
||||
public void prepareData(String title, String value, @DrawableRes int imageResId,
|
||||
GPXDataSetType firstType, GPXDataSetType secondType, ItemType itemType) {
|
||||
StatBlock statBlock = new StatBlock(title, value, imageResId, imageColorId, firstType, secondType, itemType);
|
||||
switch (statBlock.itemType) {
|
||||
case ITEM_DISTANCE: {
|
||||
if (analysis.totalDistance != 0f) {
|
||||
items.add(statBlock);
|
||||
prepareData(title, value, imageResId, getDefaultIconColorId(nightMode), firstType, secondType, itemType);
|
||||
}
|
||||
|
||||
public void prepareData(String title, String value, @DrawableRes int imageResId, @ColorRes int imageColorId,
|
||||
GPXDataSetType firstType, GPXDataSetType secondType, ItemType itemType) {
|
||||
if (analysis != null) {
|
||||
StatBlock statBlock = new StatBlock(title, value, imageResId, imageColorId, firstType, secondType, itemType);
|
||||
switch (statBlock.itemType) {
|
||||
case ITEM_DISTANCE: {
|
||||
if (analysis.totalDistance != 0f) {
|
||||
items.add(statBlock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ITEM_ALTITUDE: {
|
||||
if (analysis.hasElevationData) {
|
||||
items.add(statBlock);
|
||||
case ITEM_DISTANCE_MOVING: {
|
||||
if (analysis.totalDistanceMoving != 0f) {
|
||||
items.add(statBlock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ITEM_SPEED: {
|
||||
if (analysis.isSpeedSpecified()) {
|
||||
items.add(statBlock);
|
||||
case ITEM_ALTITUDE: {
|
||||
if (analysis.hasElevationData) {
|
||||
items.add(statBlock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ITEM_TIME: {
|
||||
if (analysis.hasSpeedData) {
|
||||
items.add(statBlock);
|
||||
case ITEM_SPEED: {
|
||||
if (analysis.isSpeedSpecified()) {
|
||||
items.add(statBlock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ITEM_TIME: {
|
||||
if (analysis.timeSpan > 0) {
|
||||
items.add(statBlock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ITEM_TIME_SPAN: {
|
||||
if (analysis.hasSpeedData) {
|
||||
items.add(statBlock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ITEM_TIME_MOVING: {
|
||||
if (analysis.isTimeMoving()) {
|
||||
items.add(statBlock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,9 +344,12 @@ public class GpxBlockStatisticsBuilder {
|
|||
|
||||
public enum ItemType {
|
||||
ITEM_DISTANCE,
|
||||
ITEM_DISTANCE_MOVING,
|
||||
ITEM_ALTITUDE,
|
||||
ITEM_SPEED,
|
||||
ITEM_TIME;
|
||||
ITEM_TIME,
|
||||
ITEM_TIME_SPAN,
|
||||
ITEM_TIME_MOVING;
|
||||
}
|
||||
|
||||
private class BlockStatisticsAdapter extends RecyclerView.Adapter<BlockStatisticsViewHolder> {
|
||||
|
@ -215,17 +359,15 @@ public class GpxBlockStatisticsBuilder {
|
|||
private final SegmentActionsListener actionsListener;
|
||||
@ColorInt
|
||||
private final int activeColor;
|
||||
private final boolean nightMode;
|
||||
private final int minWidthPx;
|
||||
private final int maxWidthPx;
|
||||
private final int textSize;
|
||||
|
||||
public BlockStatisticsAdapter(GpxDisplayItem displayItem, SegmentActionsListener actionsListener,
|
||||
@ColorInt int activeColor, boolean nightMode) {
|
||||
@ColorInt int activeColor) {
|
||||
this.displayItem = displayItem;
|
||||
this.actionsListener = actionsListener;
|
||||
this.activeColor = activeColor;
|
||||
this.nightMode = nightMode;
|
||||
minWidthPx = AndroidUtils.dpToPx(app, 60f);
|
||||
maxWidthPx = AndroidUtils.dpToPx(app, 120f);
|
||||
textSize = app.getResources().getDimensionPixelSize(R.dimen.default_desc_text_size);
|
||||
|
@ -250,7 +392,7 @@ public class GpxBlockStatisticsBuilder {
|
|||
holder.valueText.setText(item.value);
|
||||
holder.valueText.setTextColor(activeColor);
|
||||
holder.titleText.setText(item.title);
|
||||
holder.titleText.setTextColor(app.getResources().getColor(R.color.text_color_secondary_light));
|
||||
holder.titleText.setTextColor(ContextCompat.getColor(app, R.color.text_color_secondary_light));
|
||||
float letterSpacing = 0.00f;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
letterSpacing = Math.max(holder.valueText.getLetterSpacing(), holder.titleText.getLetterSpacing());
|
||||
|
|
|
@ -51,7 +51,7 @@ public class OverviewCard extends BaseCard {
|
|||
super(mapActivity);
|
||||
this.actionsListener = actionsListener;
|
||||
this.selectedGpxFile = selectedGpxFile;
|
||||
blockStatisticsBuilder = new GpxBlockStatisticsBuilder(app, selectedGpxFile);
|
||||
blockStatisticsBuilder = new GpxBlockStatisticsBuilder(app, selectedGpxFile, nightMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,7 +80,7 @@ public class OverviewCard extends BaseCard {
|
|||
initEditButton(iconColorDef, iconColorPres);
|
||||
initDirectionsButton(iconColorDef, iconColorPres);
|
||||
}
|
||||
blockStatisticsBuilder.initStatBlocks(actionsListener, getActiveColor(), nightMode);
|
||||
blockStatisticsBuilder.initStatBlocks(actionsListener, getActiveColor());
|
||||
}
|
||||
|
||||
private GPXFile getGPXFile() {
|
||||
|
|
|
@ -66,12 +66,17 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
|
||||
public interface CustomTabProvider {
|
||||
public View getCustomTabView(@NonNull ViewGroup parent, int position);
|
||||
|
||||
public void select(View tab);
|
||||
|
||||
public void deselect(View tab);
|
||||
|
||||
public void tabStylesUpdated(View tabsContainer, int currentPosition);
|
||||
}
|
||||
|
||||
public interface OnTabReselectedListener {
|
||||
public void onTabSelected(int position);
|
||||
|
||||
public void onTabReselected(int position);
|
||||
}
|
||||
|
||||
|
@ -121,7 +126,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
private int underlineHeight = 0;
|
||||
@ColorInt
|
||||
private int underlineColor;
|
||||
|
||||
|
||||
|
||||
private int dividerWidth = 0;
|
||||
private int dividerPadding = 0;
|
||||
|
@ -197,7 +202,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
|
||||
//In case we have the padding they must be equal so we take the biggest
|
||||
padding = Math.max(paddingLeft, paddingRight);
|
||||
|
||||
|
||||
|
||||
// get custom attrs
|
||||
a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
|
||||
|
@ -221,7 +226,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.NORMAL);
|
||||
tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, HALF_TRANSP);
|
||||
tabTextSelectedAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextSelectedAlpha, OPAQUE);
|
||||
tabTypeface = FontCache.getRobotoMedium(context);
|
||||
tabTypeface = FontCache.getRobotoMedium(context);
|
||||
a.recycle();
|
||||
|
||||
setMarginBottomTabContainer();
|
||||
|
@ -326,6 +331,9 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
View tab = tabsContainer.getChildAt(pager.getCurrentItem());
|
||||
notSelected(tab);
|
||||
pager.setCurrentItem(position);
|
||||
if (tabReselectedListener != null) {
|
||||
tabReselectedListener.onTabSelected(position);
|
||||
}
|
||||
} else if (tabReselectedListener != null) {
|
||||
tabReselectedListener.onTabReselected(position);
|
||||
}
|
||||
|
@ -470,7 +478,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
// draw underline
|
||||
rectPaint.setColor(underlineColor); //underlineColor
|
||||
canvas.drawRect(padding, height - underlineHeight, tabsContainer.getWidth() + padding, height, rectPaint);
|
||||
|
||||
|
||||
// draw divider
|
||||
if (dividerWidth != 0) {
|
||||
dividerPaint.setStrokeWidth(dividerWidth);
|
||||
|
|
Loading…
Reference in a new issue