Added show on map checkbox to points fragment

This commit is contained in:
Alexey Kulish 2018-05-30 21:56:46 +03:00
parent 9ccc7d4b5f
commit b8bef71db7
6 changed files with 63 additions and 18 deletions

View file

@ -180,4 +180,14 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/bottom_divider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<include layout="@layout/list_item_divider"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -244,7 +244,10 @@ public class GpxSelectionHelper {
return dg; return dg;
} }
private static void processGroupTrack(OsmandApplication app, GpxDisplayGroup group) { private static void processGroupTrack(@NonNull OsmandApplication app, @NonNull GpxDisplayGroup group) {
if (group.track == null) {
return;
}
List<GpxDisplayItem> list = group.getModifiableList(); List<GpxDisplayItem> list = group.getModifiableList();
String timeSpanClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_time_span_color)); String timeSpanClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_time_span_color));
String speedClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_speed)); String speedClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_speed));
@ -252,7 +255,6 @@ public class GpxSelectionHelper {
String descClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_altitude_desc)); String descClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_altitude_desc));
String distanceClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_distance_color)); String distanceClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_distance_color));
final float eleThreshold = 3; final float eleThreshold = 3;
// int t = 1;
for (TrkSegment r : group.track.segments) { for (TrkSegment r : group.track.segments) {
if (r.points.size() == 0) { if (r.points.size() == 0) {
continue; continue;

View file

@ -34,6 +34,7 @@ import net.osmand.plus.R;
import net.osmand.plus.measurementtool.NewGpxData; import net.osmand.plus.measurementtool.NewGpxData;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.myplaces.SplitSegmentDialogFragment; import net.osmand.plus.myplaces.SplitSegmentDialogFragment;
import net.osmand.plus.myplaces.TrackActivityFragmentAdapter;
import net.osmand.plus.myplaces.TrackBitmapDrawer; import net.osmand.plus.myplaces.TrackBitmapDrawer;
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
import net.osmand.plus.myplaces.TrackPointFragment; import net.osmand.plus.myplaces.TrackPointFragment;
@ -321,6 +322,19 @@ public class TrackActivity extends TabActivity {
} }
} }
public void updateHeader(Fragment sender) {
for (WeakReference<Fragment> f : fragList) {
Fragment frag = f.get();
if (frag != sender) {
if (frag instanceof TrackSegmentFragment) {
((TrackSegmentFragment) frag).updateHeader();
} else if (frag instanceof TrackPointFragment) {
((TrackPointFragment) frag).updateHeader();
}
}
}
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (openTracksList) { if (openTracksList) {

View file

@ -276,13 +276,14 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
final View splitIntervalView = headerView.findViewById(R.id.split_interval_view); final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
final View colorView = headerView.findViewById(R.id.color_view); final View colorView = headerView.findViewById(R.id.color_view);
vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle); vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle);
final View bottomDivider = headerView.findViewById(R.id.bottom_divider);
GPXFile gpxFile = getGpx(); GPXFile gpxFile = getGpx();
boolean gpxFileSelected = isGpxFileSelected(gpxFile); boolean gpxFileSelected = isGpxFileSelected(gpxFile);
boolean hasPath = gpxFile != null && (gpxFile.tracks.size() > 0 || gpxFile.routes.size() > 0); boolean hasPath = gpxFile != null && (gpxFile.tracks.size() > 0 || gpxFile.routes.size() > 0);
TrackActivity activity = getTrackActivity(); TrackActivity activity = getTrackActivity();
TrackBitmapDrawer trackDrawer = getTrackBitmapDrawer(); TrackBitmapDrawer trackDrawer = getTrackBitmapDrawer();
if (activity != null && trackDrawer!= null) { if (activity != null && trackDrawer != null) {
if (trackDrawer.isNonInitialized()) { if (trackDrawer.isNonInitialized()) {
if (trackDrawer.initAndDraw()) { if (trackDrawer.initAndDraw()) {
imageView.setVisibility(View.VISIBLE); imageView.setVisibility(View.VISIBLE);
@ -294,21 +295,33 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
} }
} }
if (showMapOnly) { vis.setChecked(gpxFileSelected);
headerView.findViewById(R.id.track_settings_view).setVisibility(View.GONE); vis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
} else { @Override
vis.setChecked(gpxFileSelected); public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
vis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { if (!isChecked) {
@Override selectedSplitInterval = 0;
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { }
if (!isChecked) { setTrackVisibilityOnMap(vis.isChecked());
selectedSplitInterval = 0; if (!showMapOnly) {
}
setTrackVisibilityOnMap(vis.isChecked());
updateSplitIntervalView(splitIntervalView); updateSplitIntervalView(splitIntervalView);
updateColorView(colorView); updateColorView(colorView);
} }
}); TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null) {
trackActivity.updateHeader(fragment);
}
}
});
if (showMapOnly) {
splitIntervalView.setVisibility(View.GONE);
splitColorView.setVisibility(View.GONE);
divider.setVisibility(View.GONE);
bottomDivider.setVisibility(View.VISIBLE);
} else {
bottomDivider.setVisibility(View.GONE);
updateColorView(colorView); updateColorView(colorView);
colorView.setOnClickListener(new View.OnClickListener() { colorView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -411,8 +424,8 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
private boolean isGpxFileSelected(GPXFile gpxFile) { private boolean isGpxFileSelected(GPXFile gpxFile) {
return gpxFile != null && return gpxFile != null &&
((gpxFile.showCurrentTrack && app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null) || ((gpxFile.showCurrentTrack && app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null) ||
(gpxFile.path != null && app.getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path) != null)); (gpxFile.path != null && app.getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path) != null));
} }
private void setTrackVisibilityOnMap(boolean visible) { private void setTrackVisibilityOnMap(boolean visible) {

View file

@ -675,6 +675,12 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
} }
} }
public void updateHeader() {
if (fragmentAdapter != null) {
fragmentAdapter.updateHeader(0);
}
}
class PointGPXAdapter extends OsmandBaseExpandableListAdapter implements Filterable { class PointGPXAdapter extends OsmandBaseExpandableListAdapter implements Filterable {
Map<GpxDisplayGroup, List<GpxDisplayItem>> itemGroups = new LinkedHashMap<>(); Map<GpxDisplayGroup, List<GpxDisplayItem>> itemGroups = new LinkedHashMap<>();

View file

@ -253,7 +253,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
} }
} }
private void updateHeader() { public void updateHeader() {
if (fragmentAdapter != null) { if (fragmentAdapter != null) {
fragmentAdapter.updateHeader(adapter.getCount()); fragmentAdapter.updateHeader(adapter.getCount());
} }