Merge pull request #1088 from Bars107/master
All tracks updated on dashboard and my places
This commit is contained in:
commit
23804a4fb6
14 changed files with 237 additions and 298 deletions
|
@ -34,6 +34,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/card_bg"
|
android:background="?attr/card_bg"
|
||||||
|
android:visibility="gone"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -17,6 +17,27 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/check_local_index"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:focusable="false"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginLeft="@dimen/local_index_check_right_margin"
|
||||||
|
android:layout_marginTop="@dimen/favorites_icon_top_margin"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:src="@drawable/ic_gpx_track"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginLeft="@dimen/list_content_padding"
|
||||||
|
android:layout_marginTop="@dimen/favorites_icon_top_margin"
|
||||||
|
android:focusable="false"/>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -36,6 +57,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/read_section"
|
||||||
|
android:visibility="visible"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -43,25 +66,28 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginRight="@dimen/gpx_small_icon_margin"
|
||||||
android:src="@drawable/ic_small_point"/>
|
android:src="@drawable/ic_small_point"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/points_count"
|
android:id="@+id/points_count"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/gpx_small_text_margin"
|
||||||
android:textColor="@color/icon_color_light"/>
|
android:textColor="@color/icon_color_light"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/distance_icon"
|
android:id="@+id/distance_icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/gpx_small_icon_margin"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="@dimen/dashPluginMargin"
|
|
||||||
android:src="@drawable/ic_small_distance"/>
|
android:src="@drawable/ic_small_distance"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/distance"
|
android:id="@+id/distance"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/gpx_small_text_margin"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/icon_color_light"/>
|
android:textColor="@color/icon_color_light"/>
|
||||||
|
|
||||||
|
@ -70,37 +96,73 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginRight="@dimen/gpx_small_icon_margin"
|
||||||
android:src="@drawable/ic_small_time"/>
|
android:src="@drawable/ic_small_time"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/time"
|
android:id="@+id/time"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/gpx_small_text_margin"
|
||||||
android:textColor="@color/icon_color_light"/>
|
android:textColor="@color/icon_color_light"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/unknown_section"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/date_and_size_details"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/icon_color_light"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?android:textColorPrimary"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/stop"
|
android:id="@+id/stop"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_width="@dimen/dashListItemHeight"
|
android:layout_width="@dimen/dashListItemHeight"
|
||||||
android:layout_height="@dimen/dashListItemHeight"
|
android:layout_height="@dimen/dashListItemHeight"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||||
android:background="?attr/options_button_background"
|
android:background="?attr/options_button_background"
|
||||||
android:src="@drawable/ic_action_rec_stop"
|
android:src="@drawable/ic_action_rec_stop"
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/show_on_map"
|
android:id="@+id/show_on_map"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_width="@dimen/dashListItemHeight"
|
android:layout_width="@dimen/dashListItemHeight"
|
||||||
android:layout_height="@dimen/dashListItemHeight"
|
android:layout_height="@dimen/dashListItemHeight"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="?attr/options_button_background"
|
android:background="?attr/options_button_background"
|
||||||
android:src="@drawable/ic_action_gsave_dark"/>
|
android:src="@drawable/ic_action_gsave_dark"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/options"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="@dimen/list_item_height"
|
||||||
|
android:layout_height="@dimen/list_item_height"
|
||||||
|
android:background="?attr/options_button_background"
|
||||||
|
android:focusable="false"
|
||||||
|
android:src="?attr/list_settings_icon"/>
|
||||||
|
|
||||||
|
<!--
|
||||||
<include layout="@layout/check_item_rel" />
|
<include layout="@layout/check_item_rel" />
|
||||||
|
-->
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
android:src="@drawable/ic_sdcard"
|
android:src="@drawable/ic_gpx_track"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||||
|
|
|
@ -20,6 +20,6 @@
|
||||||
android:id="@+id/bottomControls"
|
android:id="@+id/bottomControls"
|
||||||
android:background="?attr/bottomToolBarColor"
|
android:background="?attr/bottomToolBarColor"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="@dimen/bottom_tool_bar_size"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -40,6 +40,8 @@
|
||||||
<dimen name="dialog_content_bottom_margin">16dp</dimen>
|
<dimen name="dialog_content_bottom_margin">16dp</dimen>
|
||||||
<dimen name="local_size_height">34dp</dimen>
|
<dimen name="local_size_height">34dp</dimen>
|
||||||
<dimen name="favorite_icon_size">24dp</dimen>
|
<dimen name="favorite_icon_size">24dp</dimen>
|
||||||
|
<dimen name="gpx_small_icon_margin">3dp</dimen>
|
||||||
|
<dimen name="gpx_small_text_margin">14dp</dimen>
|
||||||
|
|
||||||
<!-- TextSizes -->
|
<!-- TextSizes -->
|
||||||
<dimen name="list_header_text_size">14sp</dimen>
|
<dimen name="list_header_text_size">14sp</dimen>
|
||||||
|
|
|
@ -207,19 +207,6 @@ public class GPXUtilities {
|
||||||
return maxElevation != -100;
|
return maxElevation != -100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTimeHours(long time) {
|
|
||||||
return (int) ((time / 1000) / 3600);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getTimeSeconds(long time) {
|
|
||||||
return (int) ((time / 1000) % 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTimeMinutes(long time) {
|
|
||||||
return (int) (((time / 1000) / 60) % 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSpeedSpecified() {
|
public boolean isSpeedSpecified() {
|
||||||
return avgSpeed > 0;
|
return avgSpeed > 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,6 +401,7 @@ public class GpxSelectionHelper {
|
||||||
private boolean showCurrentTrack;
|
private boolean showCurrentTrack;
|
||||||
private GPXFile gpxFile;
|
private GPXFile gpxFile;
|
||||||
private int color;
|
private int color;
|
||||||
|
private GPXTrackAnalysis trackAnalysis;
|
||||||
private List<List<WptPt>> processedPointsToDisplay = new ArrayList<List<WptPt>>();
|
private List<List<WptPt>> processedPointsToDisplay = new ArrayList<List<WptPt>>();
|
||||||
private List<GpxDisplayGroup> displayGroups = null;
|
private List<GpxDisplayGroup> displayGroups = null;
|
||||||
private boolean routePoints;
|
private boolean routePoints;
|
||||||
|
@ -410,9 +411,14 @@ public class GpxSelectionHelper {
|
||||||
if(gpxFile.tracks.size() > 0) {
|
if(gpxFile.tracks.size() > 0) {
|
||||||
this.color = gpxFile.tracks.get(0).getColor(0);
|
this.color = gpxFile.tracks.get(0).getColor(0);
|
||||||
}
|
}
|
||||||
|
trackAnalysis = gpxFile.getAnalysis(new File(gpxFile.path).lastModified());
|
||||||
processPoints();
|
processPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GPXTrackAnalysis getTrackAnalysis() {
|
||||||
|
return trackAnalysis;
|
||||||
|
}
|
||||||
|
|
||||||
public void processPoints() {
|
public void processPoints() {
|
||||||
this.processedPointsToDisplay = gpxFile.proccessPoints();
|
this.processedPointsToDisplay = gpxFile.proccessPoints();
|
||||||
if(this.processedPointsToDisplay.isEmpty()) {
|
if(this.processedPointsToDisplay.isEmpty()) {
|
||||||
|
|
|
@ -2,9 +2,11 @@ package net.osmand.plus.activities;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,6 +22,7 @@ import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
@ -84,14 +87,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
private LoadGpxTask asyncLoader;
|
private LoadGpxTask asyncLoader;
|
||||||
private GpxIndexesAdapter allGpxAdapter;
|
private GpxIndexesAdapter allGpxAdapter;
|
||||||
private ShowedOnMapAdapter showOnMapGpxAdapter;
|
private static MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
|
||||||
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
|
|
||||||
private LoadLocalIndexDescriptionTask descriptionLoader;
|
private LoadLocalIndexDescriptionTask descriptionLoader;
|
||||||
private ContextMenuAdapter optionsMenuAdapter;
|
private ContextMenuAdapter optionsMenuAdapter;
|
||||||
private AsyncTask<GpxInfo, ?, ?> operationTask;
|
private AsyncTask<GpxInfo, ?, ?> operationTask;
|
||||||
private GpxSelectionHelper selectedGpxHelper;
|
private GpxSelectionHelper selectedGpxHelper;
|
||||||
private SavingTrackHelper savingTrackHelper;
|
private SavingTrackHelper savingTrackHelper;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
private Drawable gpxNormal;
|
||||||
|
private Drawable gpxOnMap;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -122,17 +126,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
updateCurrentTrack(getView());
|
updateCurrentTrack(getView());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createShowedOnMapsView(View v) {
|
|
||||||
ListView onMap = (ListView) v.findViewById(R.id.gpx_on_map);
|
|
||||||
showOnMapGpxAdapter = new ShowedOnMapAdapter(getActivity(), R.layout.dash_gpx_track_item);
|
|
||||||
onMap.setAdapter(showOnMapGpxAdapter);
|
|
||||||
v.findViewById(R.id.turn_off_all).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
showOnMapGpxAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
|
@ -142,20 +135,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShowedOnMapVisibility(boolean visibility) {
|
|
||||||
View v = getView();
|
|
||||||
if (v == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//temporary hiding this view
|
|
||||||
v.findViewById(R.id.show_on_map).setVisibility(View.GONE);
|
|
||||||
/* if (visibility) {
|
|
||||||
v.findViewById(R.id.on_map_layout).setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
v.findViewById(R.id.on_map_layout).setVisibility(View.GONE);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateCurrentTrack(View v) {
|
private void updateCurrentTrack(View v) {
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -195,8 +174,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
gpxNormal = getResources().getDrawable(R.drawable.ic_gpx_track).mutate();
|
||||||
|
gpxOnMap = getResources().getDrawable(R.drawable.ic_gpx_track).mutate();
|
||||||
|
gpxOnMap.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||||
|
if (getMyApplication().getSettings().isLightContent()) {
|
||||||
|
gpxNormal.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
|
||||||
|
}
|
||||||
|
|
||||||
createShowedOnMapsView(v);
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +189,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
icon.mutate();
|
icon.mutate();
|
||||||
boolean light = app.getSettings().isLightContent();
|
boolean light = app.getSettings().isLightContent();
|
||||||
if (light) {
|
if (light) {
|
||||||
icon.setColorFilter(0xff727272, PorterDuff.Mode.MULTIPLY);
|
icon.setColorFilter(app.getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
|
||||||
}
|
}
|
||||||
ImageButton stop = ((ImageButton) v.findViewById(R.id.stop));
|
ImageButton stop = ((ImageButton) v.findViewById(R.id.stop));
|
||||||
stop.setImageDrawable(icon);
|
stop.setImageDrawable(icon);
|
||||||
|
@ -227,7 +211,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
icon = app.getResources().getDrawable(R.drawable.ic_action_gsave_dark);
|
icon = app.getResources().getDrawable(R.drawable.ic_action_gsave_dark);
|
||||||
icon.mutate();
|
icon.mutate();
|
||||||
if (light) {
|
if (light) {
|
||||||
icon.setColorFilter(0xff727272, PorterDuff.Mode.MULTIPLY);
|
icon.setColorFilter(app.getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
|
||||||
}
|
}
|
||||||
ImageButton save = ((ImageButton) v.findViewById(R.id.show_on_map));
|
ImageButton save = ((ImageButton) v.findViewById(R.id.show_on_map));
|
||||||
save.setOnClickListener(new View.OnClickListener() {
|
save.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -442,7 +426,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyActionMode(ActionMode mode) {
|
public void onDestroyActionMode(ActionMode mode) {
|
||||||
enableSelectionMode(false);
|
enableSelectionMode(false);
|
||||||
getView().findViewById(R.id.memory_size).setVisibility(View.GONE);
|
|
||||||
runSelection(false);
|
runSelection(false);
|
||||||
allGpxAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -504,16 +487,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyActionMode(ActionMode mode) {
|
public void onDestroyActionMode(ActionMode mode) {
|
||||||
enableSelectionMode(false);
|
enableSelectionMode(false);
|
||||||
getView().findViewById(R.id.memory_size).setVisibility(View.GONE);
|
|
||||||
allGpxAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (R.string.local_index_mi_upload_gpx == actionResId) {
|
|
||||||
((TextView) getView().findViewById(R.id.memory_size)).setText(R.string.local_index_upload_gpx_description);
|
|
||||||
((TextView) getView().findViewById(R.id.memory_size)).setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
allGpxAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,68 +529,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void basicFileOperation(final GpxInfo info, ContextMenuAdapter adapter) {
|
|
||||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
|
||||||
@Override
|
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
|
|
||||||
if (resId == R.string.local_index_mi_rename) {
|
|
||||||
renameFile(info);
|
|
||||||
} else if (resId == R.string.local_index_unselect_gpx_file ||
|
|
||||||
resId == R.string.local_index_select_gpx_file) {
|
|
||||||
if (info.gpx == null) {
|
|
||||||
loadGpxAsync(info, resId == R.string.local_index_select_gpx_file);
|
|
||||||
} else {
|
|
||||||
getMyApplication().getSelectedGpxHelper().selectGpxFile(info.gpx, resId == R.string.local_index_select_gpx_file, true);
|
|
||||||
showOnMapGpxAdapter.addGpxInfo(info);
|
|
||||||
|
|
||||||
allGpxAdapter.notifyDataSetChanged();
|
|
||||||
selectedGpxHelper.runUiListeners();
|
|
||||||
}
|
|
||||||
} else if (resId == R.string.local_index_mi_delete) {
|
|
||||||
Builder confirm = new AlertDialog.Builder(getActivity());
|
|
||||||
confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
new DeleteGpxTask().execute(info);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
confirm.setNegativeButton(R.string.default_buttons_no, null);
|
|
||||||
confirm.setMessage(getString(R.string.delete_confirmation_msg, info.file.getName()));
|
|
||||||
confirm.show();
|
|
||||||
} else if (resId == R.string.local_index_mi_export) {
|
|
||||||
final Uri fileUri = Uri.fromFile(info.file);
|
|
||||||
final Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
|
||||||
sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
|
||||||
sendIntent.setType("application/gpx+xml");
|
|
||||||
startActivity(sendIntent);
|
|
||||||
} else if (resId == R.string.show_gpx_route) {
|
|
||||||
showGpxOnMap(info);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (info.gpx != null && info.file == null) {
|
|
||||||
GpxSelectionHelper.SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedCurrentRecordingTrack();
|
|
||||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() == info.gpx) {
|
|
||||||
adapter.item(R.string.local_index_unselect_gpx_file).listen(listener).reg();
|
|
||||||
} else {
|
|
||||||
adapter.item(R.string.local_index_select_gpx_file).listen(listener).reg();
|
|
||||||
}
|
|
||||||
} else if (info.file != null) {
|
|
||||||
if (getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(info.file.getAbsolutePath()) == null) {
|
|
||||||
adapter.item(R.string.local_index_select_gpx_file).listen(listener).reg();
|
|
||||||
} else {
|
|
||||||
adapter.item(R.string.local_index_unselect_gpx_file).listen(listener).reg();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
adapter.item(R.string.show_gpx_route).listen(listener).reg();
|
|
||||||
if (info.file != null) {
|
|
||||||
adapter.item(R.string.local_index_mi_rename).listen(listener).reg();
|
|
||||||
adapter.item(R.string.local_index_mi_delete).listen(listener).reg();
|
|
||||||
adapter.item(R.string.local_index_mi_export).listen(listener).reg();
|
|
||||||
}
|
|
||||||
OsmandPlugin.onContextMenuActivity(getActivity(), this, info, adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showGpxOnMap(GpxInfo info) {
|
private void showGpxOnMap(GpxInfo info) {
|
||||||
info.updateGpxInfo(getMyApplication());
|
info.updateGpxInfo(getMyApplication());
|
||||||
|
@ -626,10 +541,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
e = false;
|
e = false;
|
||||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
|
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
if (showOnMapGpxAdapter.getCount() == 0) {
|
|
||||||
setShowedOnMapVisibility(true);
|
|
||||||
}
|
|
||||||
showOnMapGpxAdapter.addGpxInfo(info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e) {
|
if (e) {
|
||||||
|
@ -660,36 +571,24 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true);
|
((ActionBarActivity) getActivity()).setSupportProgressBarIndeterminateVisibility(true);
|
||||||
allGpxAdapter.clear();
|
allGpxAdapter.clear();
|
||||||
if (showOnMapGpxAdapter != null) {
|
|
||||||
showOnMapGpxAdapter.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(GpxInfo... values) {
|
protected void onProgressUpdate(GpxInfo... values) {
|
||||||
for (GpxInfo v : values) {
|
for (GpxInfo v : values) {
|
||||||
allGpxAdapter.addLocalIndexInfo(v);
|
allGpxAdapter.addLocalIndexInfo(v);
|
||||||
if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null) {
|
|
||||||
showOnMapGpxAdapter.addGpxInfo(v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
showOnMapGpxAdapter.notifyDataSetChanged();
|
|
||||||
allGpxAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResult(List<GpxInfo> result) {
|
public void setResult(List<GpxInfo> result) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
allGpxAdapter.clear();
|
allGpxAdapter.clear();
|
||||||
showOnMapGpxAdapter.clear();
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
for (GpxInfo v : result) {
|
for (GpxInfo v : result) {
|
||||||
allGpxAdapter.addLocalIndexInfo(v);
|
allGpxAdapter.addLocalIndexInfo(v);
|
||||||
if (selectedGpxHelper.getSelectedFileByName(v.getFileName()) != null) {
|
|
||||||
showOnMapGpxAdapter.addGpxInfo(v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
allGpxAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
showOnMapGpxAdapter.notifyDataSetChanged();
|
|
||||||
onPostExecute(result);
|
onPostExecute(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -703,12 +602,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
if (allGpxAdapter.getGroupCount() > 0) {
|
if (allGpxAdapter.getGroupCount() > 0) {
|
||||||
getExpandableListView().expandGroup(0);
|
getExpandableListView().expandGroup(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showOnMapGpxAdapter.getCount() > 0) {
|
|
||||||
setShowedOnMapVisibility(true);
|
|
||||||
} else {
|
|
||||||
setShowedOnMapVisibility(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private File[] listFilesSorted(File dir) {
|
private File[] listFilesSorted(File dir) {
|
||||||
|
@ -763,7 +656,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
Map<String, List<GpxInfo>> data = new LinkedHashMap<>();
|
Map<String, List<GpxInfo>> data = new LinkedHashMap<>();
|
||||||
List<String> category = new ArrayList<>();
|
List<String> category = new ArrayList<>();
|
||||||
int warningColor;
|
int warningColor;
|
||||||
int okColor;
|
|
||||||
int defaultColor;
|
int defaultColor;
|
||||||
int corruptedColor;
|
int corruptedColor;
|
||||||
private SearchFilter filter;
|
private SearchFilter filter;
|
||||||
|
@ -771,7 +663,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
public GpxIndexesAdapter(Context ctx) {
|
public GpxIndexesAdapter(Context ctx) {
|
||||||
warningColor = ctx.getResources().getColor(R.color.color_warning);
|
warningColor = ctx.getResources().getColor(R.color.color_warning);
|
||||||
okColor = ctx.getResources().getColor(R.color.color_ok);
|
|
||||||
TypedArray ta = ctx.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary});
|
TypedArray ta = ctx.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary});
|
||||||
defaultColor = ta.getColor(0, ctx.getResources().getColor(R.color.color_unknown));
|
defaultColor = ta.getColor(0, ctx.getResources().getColor(R.color.color_unknown));
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
|
@ -849,42 +740,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
final GpxInfo child = getChild(groupPosition, childPosition);
|
final GpxInfo child = getChild(groupPosition, childPosition);
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
v = inflater.inflate(R.layout.dash_gpx_track_item, parent, false);
|
||||||
}
|
|
||||||
TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
|
|
||||||
viewName.setText(child.getName());
|
|
||||||
|
|
||||||
if (child.isCorrupted()) {
|
|
||||||
viewName.setTextColor(corruptedColor);
|
|
||||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
|
||||||
} else if (selectedGpxHelper.getSelectedFileByName(child.getFileName()) != null) {
|
|
||||||
viewName.setTextColor(okColor);
|
|
||||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
|
||||||
} else {
|
|
||||||
viewName.setTextColor(defaultColor);
|
|
||||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
|
||||||
}
|
|
||||||
TextView sizeText = (TextView) v.findViewById(R.id.local_index_size);
|
|
||||||
if (child.getSize() >= 0) {
|
|
||||||
String size;
|
|
||||||
if (child.getSize() > 100) {
|
|
||||||
size = formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)});
|
|
||||||
} else {
|
|
||||||
size = child.getSize() + " kB";
|
|
||||||
}
|
|
||||||
sizeText.setText(size);
|
|
||||||
} else {
|
|
||||||
sizeText.setText("");
|
|
||||||
}
|
|
||||||
TextView descr = ((TextView) v.findViewById(R.id.local_index_descr));
|
|
||||||
if (child.isExpanded()) {
|
|
||||||
descr.setVisibility(View.VISIBLE);
|
|
||||||
descr.setText(child.getHtmlDescription());
|
|
||||||
sizeText.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
descr.setVisibility(View.GONE);
|
|
||||||
sizeText.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
udpateGpxInfoView(v, child, app, gpxNormal, gpxOnMap, false);
|
||||||
|
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||||
ImageButton options = (ImageButton) v.findViewById(R.id.options);
|
ImageButton options = (ImageButton) v.findViewById(R.id.options);
|
||||||
options.setOnClickListener(new View.OnClickListener() {
|
options.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -892,9 +751,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
openPopUpMenu(v, child);
|
openPopUpMenu(v, child);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
|
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
|
||||||
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
|
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
|
||||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
checkbox.setChecked(selectedItems.contains(child));
|
checkbox.setChecked(selectedItems.contains(child));
|
||||||
checkbox.setOnClickListener(new View.OnClickListener() {
|
checkbox.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -926,6 +786,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
|
@ -1020,8 +881,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||||
Drawable showIcon = getResources().getDrawable(R.drawable.ic_show_on_map);
|
Drawable showIcon = getResources().getDrawable(R.drawable.ic_show_on_map);
|
||||||
if (light) {
|
if (light) {
|
||||||
showIcon.mutate();
|
showIcon.mutate().setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
|
||||||
showIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
|
|
||||||
}
|
}
|
||||||
MenuItem item = optionsMenu.getMenu().add(R.string.show_gpx_route)
|
MenuItem item = optionsMenu.getMenu().add(R.string.show_gpx_route)
|
||||||
.setIcon(showIcon);
|
.setIcon(showIcon);
|
||||||
|
@ -1042,6 +902,19 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
item = optionsMenu.getMenu().add(R.string.share_fav)
|
||||||
|
.setIcon(light ? R.drawable.ic_action_gshare_light : R.drawable.ic_action_gshare_dark);
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
final Uri fileUri = Uri.fromFile(gpxInfo.file);
|
||||||
|
final Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||||
|
sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
||||||
|
sendIntent.setType("application/gpx+xml");
|
||||||
|
startActivity(sendIntent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
final OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
|
final OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
|
||||||
if (osmEditingPlugin != null && osmEditingPlugin.isActive()) {
|
if (osmEditingPlugin != null && osmEditingPlugin.isActive()) {
|
||||||
|
@ -1271,15 +1144,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
if (results.values != null) {
|
if (results.values != null) {
|
||||||
synchronized (allGpxAdapter) {
|
synchronized (allGpxAdapter) {
|
||||||
allGpxAdapter.clear();
|
allGpxAdapter.clear();
|
||||||
showOnMapGpxAdapter.clear();
|
|
||||||
for (GpxInfo i : ((List<GpxInfo>) results.values)) {
|
for (GpxInfo i : ((List<GpxInfo>) results.values)) {
|
||||||
allGpxAdapter.addLocalIndexInfo(i);
|
allGpxAdapter.addLocalIndexInfo(i);
|
||||||
if (selectedGpxHelper.getSelectedFileByName(i.getFileName()) != null) {
|
|
||||||
showOnMapGpxAdapter.addGpxInfo(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showOnMapGpxAdapter.notifyDataSetChanged();
|
|
||||||
allGpxAdapter.notifyDataSetChanged();
|
allGpxAdapter.notifyDataSetChanged();
|
||||||
if (constraint != null && constraint.length() > 3) {
|
if (constraint != null && constraint.length() > 3) {
|
||||||
collapseTrees(10);
|
collapseTrees(10);
|
||||||
|
@ -1334,6 +1202,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
private boolean corrupted;
|
private boolean corrupted;
|
||||||
private boolean expanded;
|
private boolean expanded;
|
||||||
private Spanned htmlDescription;
|
private Spanned htmlDescription;
|
||||||
|
private GPXUtilities.GPXTrackAnalysis analysis;
|
||||||
|
|
||||||
public GpxInfo() {
|
public GpxInfo() {
|
||||||
}
|
}
|
||||||
|
@ -1387,6 +1256,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getFileDate() {
|
||||||
|
return file.lastModified();
|
||||||
|
}
|
||||||
|
|
||||||
public Spanned getHtmlDescription() {
|
public Spanned getHtmlDescription() {
|
||||||
if (htmlDescription != null) {
|
if (htmlDescription != null) {
|
||||||
return htmlDescription;
|
return htmlDescription;
|
||||||
|
@ -1395,6 +1268,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
return htmlDescription;
|
return htmlDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GPXUtilities.GPXTrackAnalysis getAnalysis() {
|
||||||
|
return analysis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnalysis(GPXUtilities.GPXTrackAnalysis analysis) {
|
||||||
|
this.analysis = analysis;
|
||||||
|
}
|
||||||
|
|
||||||
public void setGpx(GPXFile gpx) {
|
public void setGpx(GPXFile gpx) {
|
||||||
this.gpx = gpx;
|
this.gpx = gpx;
|
||||||
|
@ -1407,9 +1287,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
if (gpx.warning != null) {
|
if (gpx.warning != null) {
|
||||||
corrupted = true;
|
corrupted = true;
|
||||||
description = gpx.warning;
|
description = gpx.warning;
|
||||||
|
analysis = null;
|
||||||
} else {
|
} else {
|
||||||
// 'Long-press for options' message
|
// 'Long-press for options' message
|
||||||
description = GpxUiHelper.getDescription(app, gpx, file, true);
|
analysis = gpx.getAnalysis(file.lastModified());
|
||||||
|
description = GpxUiHelper.getDescription(app, analysis, true);
|
||||||
}
|
}
|
||||||
htmlDescription = null;
|
htmlDescription = null;
|
||||||
getHtmlDescription();
|
getHtmlDescription();
|
||||||
|
@ -1436,79 +1318,86 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
getView().findViewById(R.id.gpx_on_map).setLayoutParams(params);
|
getView().findViewById(R.id.gpx_on_map).setLayoutParams(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ShowedOnMapAdapter extends ArrayAdapter<GpxInfo> {
|
|
||||||
|
|
||||||
public void addGpxInfo(GpxInfo info) {
|
public static void udpateGpxInfoView(View v, GpxInfo child, OsmandApplication app,
|
||||||
boolean contains = false;
|
Drawable gpxNormal, Drawable gpxOnMap,
|
||||||
for (int i = 0; i < getCount(); i++) {
|
boolean isDashItem) {
|
||||||
if (getItem(i).equals(info)) {
|
TextView viewName = ((TextView) v.findViewById(R.id.name));
|
||||||
contains = true;
|
if(!isDashItem) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (contains) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
add(info);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
|
|
||||||
//if there's too many items, we need to set size of listview
|
|
||||||
if (getCount() == 4) {
|
|
||||||
adjustShowOnMapListViewSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShowedOnMapAdapter(Context context, int resource) {
|
|
||||||
super(context, resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
View v = convertView;
|
|
||||||
if (v == null) {
|
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
|
||||||
v = inflater.inflate(R.layout.dash_gpx_track_item, parent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
final GpxInfo gpxInfo = getItem(position);
|
|
||||||
|
|
||||||
TextView viewName = ((TextView) v.findViewById(R.id.name));
|
|
||||||
viewName.setText(gpxInfo.getName());
|
|
||||||
|
|
||||||
v.findViewById(R.id.show_on_map).setVisibility(View.GONE);
|
|
||||||
v.findViewById(R.id.stop).setVisibility(View.GONE);
|
|
||||||
v.findViewById(R.id.divider).setVisibility(View.GONE);
|
v.findViewById(R.id.divider).setVisibility(View.GONE);
|
||||||
if (gpxInfo.gpx != null) {
|
} else {
|
||||||
String description = GpxUiHelper.getDescription(getMyApplication(), gpxInfo.gpx, gpxInfo.file, true);
|
v.findViewById(R.id.divider).setVisibility(View.VISIBLE);
|
||||||
int startindex = description.indexOf(">");
|
}
|
||||||
int endindex = description.indexOf("</font>");
|
|
||||||
String distnace = description.substring(startindex + 1, endindex);
|
|
||||||
((TextView) v.findViewById(R.id.distance)).
|
|
||||||
setText(distnace);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
final CompoundButton check = (CompoundButton) v.findViewById(R.id.check_item);
|
viewName.setText(child.getName());
|
||||||
check.setVisibility(View.VISIBLE);
|
GpxSelectionHelper selectedGpxHelper = app.getSelectedGpxHelper();
|
||||||
if (selectedGpxHelper.getSelectedFileByName(gpxInfo.getFileName()) != null) {
|
|
||||||
check.setChecked(true);
|
//ImageView icon = (ImageView) v.findViewById(!isDashItem? R.id.icon : R.id.show_on_map);
|
||||||
} else {
|
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||||
check.setChecked(false);
|
icon.setVisibility(View.VISIBLE);
|
||||||
}
|
icon.setImageDrawable(gpxNormal);
|
||||||
check.setOnClickListener(new View.OnClickListener() {
|
if (child.isCorrupted()) {
|
||||||
@Override
|
viewName.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
||||||
public void onClick(View v) {
|
} else {
|
||||||
if (gpxInfo.gpx == null) {
|
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||||
loadGpxAsync(gpxInfo, check.isChecked());
|
}
|
||||||
} else {
|
if (selectedGpxHelper.getSelectedFileByName(child.getFileName()) != null) {
|
||||||
selectedGpxHelper.selectGpxFile(gpxInfo.gpx, check.isChecked(), true);
|
icon.setImageDrawable(gpxOnMap);
|
||||||
}
|
}
|
||||||
allGpxAdapter.notifyDataSetChanged();
|
boolean sectionRead = child.getAnalysis() == null;
|
||||||
|
if(sectionRead) {
|
||||||
|
v.findViewById(R.id.read_section).setVisibility(View.GONE);
|
||||||
|
v.findViewById(R.id.unknown_section).setVisibility(View.VISIBLE);
|
||||||
|
String date = "";
|
||||||
|
String size = "";
|
||||||
|
if (child.getSize() >= 0) {
|
||||||
|
if (child.getSize() > 100) {
|
||||||
|
size = formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)});
|
||||||
|
} else {
|
||||||
|
size = child.getSize() + " kB";
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
return v;
|
DateFormat df = app.getResourceManager().getDateFormat();
|
||||||
|
long fd = child.getFileDate();
|
||||||
|
if(fd > 0) {
|
||||||
|
date = (df.format(new Date(fd)));
|
||||||
|
}
|
||||||
|
TextView sizeText = (TextView) v.findViewById(R.id.date_and_size_details);
|
||||||
|
sizeText.setText(date + " \u2022 " + size);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
v.findViewById(R.id.read_section).setVisibility(View.VISIBLE);
|
||||||
|
v.findViewById(R.id.unknown_section).setVisibility(View.GONE);
|
||||||
|
TextView time = (TextView) v.findViewById(R.id.time);
|
||||||
|
TextView distance = (TextView) v.findViewById(R.id.distance);
|
||||||
|
TextView pointsCount= (TextView) v.findViewById(R.id.points_count);
|
||||||
|
GPXUtilities.GPXTrackAnalysis analysis = child.getAnalysis();
|
||||||
|
pointsCount.setText(analysis.wptPoints +"");
|
||||||
|
if(analysis.totalDistanceMoving != 0) {
|
||||||
|
distance.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistanceMoving, app));
|
||||||
|
} else {
|
||||||
|
distance.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(analysis.isTimeSpecified()) {
|
||||||
|
if(analysis.isTimeMoving()) {
|
||||||
|
time.setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000))+"");
|
||||||
|
} else {
|
||||||
|
time.setText(Algorithms.formatDuration((int) (analysis.timeSpan/ 1000))+"");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
time.setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView descr = ((TextView) v.findViewById(R.id.description));
|
||||||
|
if (child.isExpanded()) {
|
||||||
|
descr.setVisibility(View.VISIBLE);
|
||||||
|
descr.setText(child.getHtmlDescription());
|
||||||
|
} else {
|
||||||
|
descr.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class OsmandActionBarActivity extends ActionBarActivity {
|
||||||
//should be called after set content view
|
//should be called after set content view
|
||||||
protected void setupHomeButton(){
|
protected void setupHomeButton(){
|
||||||
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
|
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
|
||||||
back.setColorFilter(0xffffffff, PorterDuff.Mode.MULTIPLY);
|
back.setColorFilter(getResources().getColor(R.color.color_white), PorterDuff.Mode.MULTIPLY);
|
||||||
getSupportActionBar().setHomeButtonEnabled(true);
|
getSupportActionBar().setHomeButtonEnabled(true);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setHomeAsUpIndicator(back);
|
getSupportActionBar().setHomeAsUpIndicator(back);
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class SettingsActivity extends SettingsBaseActivity {
|
||||||
Toolbar tb = new Toolbar(this);
|
Toolbar tb = new Toolbar(this);
|
||||||
tb.setClickable(true);
|
tb.setClickable(true);
|
||||||
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
|
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
|
||||||
back.setColorFilter(0xffffffff, PorterDuff.Mode.MULTIPLY);
|
back.setColorFilter(app.getResources().getColor(R.color.color_white), PorterDuff.Mode.MULTIPLY);
|
||||||
tb.setNavigationIcon(back);
|
tb.setNavigationIcon(back);
|
||||||
tb.setTitle(R.string.about_settings);
|
tb.setTitle(R.string.about_settings);
|
||||||
tb.setBackgroundColor(getResources().getColor( getResIdFromAttribute(this, R.attr.pstsTabBackground)));
|
tb.setBackgroundColor(getResources().getColor( getResIdFromAttribute(this, R.attr.pstsTabBackground)));
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class SearchAddressFragment extends Fragment {
|
||||||
});
|
});
|
||||||
menuItem = menu.add(0, ONLINE_SEARCH, 0, R.string.search_online_address);
|
menuItem = menu.add(0, ONLINE_SEARCH, 0, R.string.search_online_address);
|
||||||
MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
menuItem = menuItem.setIcon(R.drawable.ic_action_gnext_dark);
|
menuItem = menuItem.setIcon(R.drawable.ic_world_globe_dark);
|
||||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class SearchAddressOnlineFragment extends Fragment implements SearchActiv
|
||||||
if (getActivity() instanceof SearchActivity) {
|
if (getActivity() instanceof SearchActivity) {
|
||||||
menuItem = menu.add(0, 0, 0, R.string.search_offline_address);
|
menuItem = menu.add(0, 0, 0, R.string.search_offline_address);
|
||||||
MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
menuItem = menuItem.setIcon(R.drawable.ic_action_gnext_dark);
|
menuItem = menuItem.setIcon(R.drawable.ic_sdcard);
|
||||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
backup = getActivity().getResources().getDrawable(R.drawable.ic_type_archive);
|
backup = getActivity().getResources().getDrawable(R.drawable.ic_type_archive);
|
||||||
backup.mutate();
|
backup.mutate();
|
||||||
if (light) {
|
if (light) {
|
||||||
backup.setColorFilter(0xff727272, PorterDuff.Mode.MULTIPLY);
|
backup.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
|
||||||
}
|
}
|
||||||
sdcard = getActivity().getResources().getDrawable(R.drawable.ic_sdcard);
|
sdcard = getActivity().getResources().getDrawable(R.drawable.ic_sdcard);
|
||||||
sdcard.mutate();
|
sdcard.mutate();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.monitoring;
|
package net.osmand.plus.monitoring;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
@ -8,6 +9,7 @@ import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.OsmAndAppCustomization;
|
import net.osmand.plus.OsmAndAppCustomization;
|
||||||
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -40,6 +42,10 @@ import android.widget.Toast;
|
||||||
*/
|
*/
|
||||||
public class DashTrackFragment extends DashBaseFragment {
|
public class DashTrackFragment extends DashBaseFragment {
|
||||||
|
|
||||||
|
private Drawable gpxOnMap;
|
||||||
|
private Drawable gpxNormal;
|
||||||
|
private java.text.DateFormat format;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
|
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
|
||||||
|
@ -47,7 +53,16 @@ public class DashTrackFragment extends DashBaseFragment {
|
||||||
TextView header = (TextView) view.findViewById(R.id.fav_text);
|
TextView header = (TextView) view.findViewById(R.id.fav_text);
|
||||||
header.setTypeface(typeface);
|
header.setTypeface(typeface);
|
||||||
header.setText(R.string.tracks);
|
header.setText(R.string.tracks);
|
||||||
|
gpxNormal = getResources().getDrawable(R.drawable.ic_gpx_track).mutate();
|
||||||
|
gpxOnMap = getResources().getDrawable(R.drawable.ic_gpx_track).mutate();
|
||||||
|
gpxOnMap.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||||
|
if (getMyApplication().getSettings().isLightContent()) {
|
||||||
|
gpxNormal.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
|
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
|
||||||
|
format = getMyApplication().getResourceManager().getDateFormat();
|
||||||
|
|
||||||
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,7 +105,7 @@ public class DashTrackFragment extends DashBaseFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OsmandApplication app = getMyApplication();
|
final OsmandApplication app = getMyApplication();
|
||||||
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
|
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
|
||||||
if (app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
if (app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
||||||
list.remove(2);
|
list.remove(2);
|
||||||
|
@ -99,61 +114,38 @@ public class DashTrackFragment extends DashBaseFragment {
|
||||||
|
|
||||||
AvailableGPXFragment.createCurrentTrackView(view, app);
|
AvailableGPXFragment.createCurrentTrackView(view, app);
|
||||||
|
|
||||||
|
|
||||||
GpxSelectionHelper.SelectedGpxFile currentTrack = savingTrackHelper.getCurrentTrack();
|
GpxSelectionHelper.SelectedGpxFile currentTrack = savingTrackHelper.getCurrentTrack();
|
||||||
((TextView)view.findViewById(R.id.name)).setText(R.string.currently_recording_track);
|
((TextView)view.findViewById(R.id.name)).setText(R.string.currently_recording_track);
|
||||||
String description = GpxUiHelper.getDescription(getMyApplication(), currentTrack.getGpxFile(), null, true);
|
|
||||||
int startindex = description.indexOf(">");
|
|
||||||
int endindex = description.indexOf("</font>");
|
|
||||||
String distance = description.substring(startindex + 1, endindex);
|
|
||||||
String points = String.valueOf(currentTrack.getGpxFile().points.size());
|
String points = String.valueOf(currentTrack.getGpxFile().points.size());
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.points_count)).setText(points);
|
((TextView) view.findViewById(R.id.points_count)).setText(points);
|
||||||
((TextView)view.findViewById(R.id.distance)).setText(distance);
|
((TextView)view.findViewById(R.id.distance)).setText(
|
||||||
|
OsmAndFormatter.getFormattedDistance(savingTrackHelper.getDistance(), app));
|
||||||
tracks.addView(view);
|
tracks.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String filename : list) {
|
for (String filename : list) {
|
||||||
final File f = new File(dir, filename);
|
final File f = new File(dir, filename);
|
||||||
final GPXUtilities.GPXFile res = GPXUtilities.loadGPXFile(getMyApplication(), f);
|
boolean haveInfo = false;
|
||||||
|
GpxSelectionHelper.SelectedGpxFile selectedGpxFile =
|
||||||
|
app.getSelectedGpxHelper().getSelectedFileByPath(f.getAbsolutePath());
|
||||||
|
GPXUtilities.GPXTrackAnalysis trackAnalysis = null;
|
||||||
|
if(selectedGpxFile != null) {
|
||||||
|
trackAnalysis = selectedGpxFile.getTrackAnalysis();
|
||||||
|
}
|
||||||
|
AvailableGPXFragment.GpxInfo info = new AvailableGPXFragment.GpxInfo();
|
||||||
|
info.subfolder = "";
|
||||||
|
info.setAnalysis(trackAnalysis);
|
||||||
|
info.file = f;
|
||||||
|
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
|
View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
|
||||||
((TextView) view.findViewById(R.id.name)).setText(filename);
|
AvailableGPXFragment.udpateGpxInfoView(view, info, app, gpxNormal, gpxOnMap, true);
|
||||||
((TextView) view.findViewById(R.id.points_count)).
|
|
||||||
setText(res.points.size() + " " + getActivity().getString(R.string.points));
|
|
||||||
String description = GpxUiHelper.getDescription(getMyApplication(), res, f, true);
|
|
||||||
int startindex = description.indexOf(">");
|
|
||||||
int endindex = description.indexOf("</font>");
|
|
||||||
String distnace = description.substring(startindex + 1, endindex);
|
|
||||||
((TextView) view.findViewById(R.id.distance)).
|
|
||||||
setText(distnace);
|
|
||||||
view.findViewById(R.id.time_icon).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
boolean light = getMyApplication().getSettings().isLightContent();
|
|
||||||
Drawable icon = getResources().getDrawable(R.drawable.ic_show_on_map);
|
|
||||||
GpxSelectionHelper gpxSelectionHelper = getMyApplication().getSelectedGpxHelper();
|
|
||||||
boolean isShowingOnMap = gpxSelectionHelper.getSelectedFileByName(filename) != null;
|
|
||||||
//setting proper icon color
|
|
||||||
if (isShowingOnMap) {
|
|
||||||
icon.mutate();
|
|
||||||
if (light) {
|
|
||||||
icon.setColorFilter(getResources().getColor(R.color.dashboard_gpx_on_map), PorterDuff.Mode.MULTIPLY);
|
|
||||||
} else {
|
|
||||||
icon.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
|
||||||
}
|
|
||||||
} else if (light) {
|
|
||||||
icon.mutate();
|
|
||||||
icon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
|
|
||||||
|
|
||||||
}
|
|
||||||
final ImageButton showOnMap = (ImageButton) view.findViewById(R.id.show_on_map);
|
|
||||||
showOnMap.setImageDrawable(icon);
|
|
||||||
showOnMap.setVisibility(View.VISIBLE);
|
|
||||||
//view.findViewById(R.id.distance_icon).setVisibility(View.GONE);
|
|
||||||
view.findViewById(R.id.stop).setVisibility(View.GONE);
|
|
||||||
view.setOnClickListener(new View.OnClickListener() {
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
showOnMap(res);
|
showOnMap(GPXUtilities.loadGPXFile(app, f));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tracks.addView(view);
|
tracks.addView(view);
|
||||||
|
|
Loading…
Reference in a new issue