Added show on map checkbox to points fragment
This commit is contained in:
parent
abbc0fe2ee
commit
624380773b
6 changed files with 63 additions and 18 deletions
|
@ -180,4 +180,14 @@
|
|||
|
||||
</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>
|
|
@ -244,7 +244,10 @@ public class GpxSelectionHelper {
|
|||
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();
|
||||
String timeSpanClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_time_span_color));
|
||||
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 distanceClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_distance_color));
|
||||
final float eleThreshold = 3;
|
||||
// int t = 1;
|
||||
for (TrkSegment r : group.track.segments) {
|
||||
if (r.points.size() == 0) {
|
||||
continue;
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.measurementtool.NewGpxData;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.myplaces.SplitSegmentDialogFragment;
|
||||
import net.osmand.plus.myplaces.TrackActivityFragmentAdapter;
|
||||
import net.osmand.plus.myplaces.TrackBitmapDrawer;
|
||||
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
||||
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
|
||||
public void onBackPressed() {
|
||||
if (openTracksList) {
|
||||
|
|
|
@ -276,13 +276,14 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
|
||||
final View colorView = headerView.findViewById(R.id.color_view);
|
||||
vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle);
|
||||
final View bottomDivider = headerView.findViewById(R.id.bottom_divider);
|
||||
GPXFile gpxFile = getGpx();
|
||||
boolean gpxFileSelected = isGpxFileSelected(gpxFile);
|
||||
|
||||
boolean hasPath = gpxFile != null && (gpxFile.tracks.size() > 0 || gpxFile.routes.size() > 0);
|
||||
TrackActivity activity = getTrackActivity();
|
||||
TrackBitmapDrawer trackDrawer = getTrackBitmapDrawer();
|
||||
if (activity != null && trackDrawer!= null) {
|
||||
if (activity != null && trackDrawer != null) {
|
||||
if (trackDrawer.isNonInitialized()) {
|
||||
if (trackDrawer.initAndDraw()) {
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
|
@ -294,21 +295,33 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (showMapOnly) {
|
||||
headerView.findViewById(R.id.track_settings_view).setVisibility(View.GONE);
|
||||
} else {
|
||||
vis.setChecked(gpxFileSelected);
|
||||
vis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (!isChecked) {
|
||||
selectedSplitInterval = 0;
|
||||
}
|
||||
setTrackVisibilityOnMap(vis.isChecked());
|
||||
vis.setChecked(gpxFileSelected);
|
||||
vis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (!isChecked) {
|
||||
selectedSplitInterval = 0;
|
||||
}
|
||||
setTrackVisibilityOnMap(vis.isChecked());
|
||||
if (!showMapOnly) {
|
||||
updateSplitIntervalView(splitIntervalView);
|
||||
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);
|
||||
colorView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -411,8 +424,8 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
|
||||
private boolean isGpxFileSelected(GPXFile gpxFile) {
|
||||
return gpxFile != null &&
|
||||
((gpxFile.showCurrentTrack && app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null) ||
|
||||
(gpxFile.path != null && app.getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path) != null));
|
||||
((gpxFile.showCurrentTrack && app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null) ||
|
||||
(gpxFile.path != null && app.getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path) != null));
|
||||
}
|
||||
|
||||
private void setTrackVisibilityOnMap(boolean visible) {
|
||||
|
|
|
@ -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 {
|
||||
|
||||
Map<GpxDisplayGroup, List<GpxDisplayItem>> itemGroups = new LinkedHashMap<>();
|
||||
|
|
|
@ -253,7 +253,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
|||
}
|
||||
}
|
||||
|
||||
private void updateHeader() {
|
||||
public void updateHeader() {
|
||||
if (fragmentAdapter != null) {
|
||||
fragmentAdapter.updateHeader(adapter.getCount());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue