Track appearance fixes

This commit is contained in:
Vitaliy 2020-07-20 17:37:45 +03:00
parent 5be8902e02
commit de5e161095
51 changed files with 694 additions and 302 deletions

View file

@ -1559,6 +1559,10 @@ public class GPXUtilities {
getExtensionsToWrite().put("gradient_scale_type", gradientScaleType);
}
public void removeGradientScaleType() {
getExtensionsToWrite().remove("gradient_scale_type");
}
public String getSplitType() {
if (extensions != null) {
return extensions.get("split_type");

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/radio_button_selected_center_dark" android:state_checked="true" />
<item android:drawable="@drawable/radio_button_regular_center_dark" />
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/radio_button_selected_center_light" android:state_checked="true" />
<item android:drawable="@drawable/radio_button_regular_center_light" />
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/radio_button_selected_left_dark" android:state_checked="true" />
<item android:drawable="@drawable/radio_button_regular_left_dark" />
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/radio_button_selected_left_light" android:state_checked="true" />
<item android:drawable="@drawable/radio_button_regular_left_light" />
</selector>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/stroked_buttons_and_links_outline_dark" />
</shape>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/stroked_buttons_and_links_outline_light" />
</shape>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp" />
<stroke
android:width="1dp"
android:color="@color/stroked_buttons_and_links_outline_dark" />
</shape>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp" />
<stroke
android:width="1dp"
android:color="@color/stroked_buttons_and_links_outline_light" />
</shape>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="4dp"
android:topRightRadius="4dp" />
<stroke
android:width="1dp"
android:color="@color/stroked_buttons_and_links_outline_dark" />
</shape>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="4dp"
android:topRightRadius="4dp" />
<stroke
android:width="1dp"
android:color="@color/stroked_buttons_and_links_outline_light" />
</shape>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/radio_button_selected_right_dark" android:state_checked="true" />
<item android:drawable="@drawable/radio_button_regular_right_dark" />
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/radio_button_selected_right_light" android:state_checked="true" />
<item android:drawable="@drawable/radio_button_regular_right_light" />
</selector>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/switch_button_active_dark" />
<stroke
android:width="1dp"
android:color="@color/switch_button_active_stroke_dark" />
</shape>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/switch_button_active_light" />
<stroke
android:width="1dp"
android:color="@color/switch_button_active_stroke_light" />
</shape>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp" />
<solid android:color="@color/switch_button_active_dark" />
<stroke
android:width="1dp"
android:color="@color/switch_button_active_stroke_dark" />
</shape>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp" />
<solid android:color="@color/switch_button_active_light" />
<stroke
android:width="1dp"
android:color="@color/switch_button_active_stroke_light" />
</shape>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="4dp"
android:topRightRadius="4dp" />
<solid android:color="@color/switch_button_active_dark" />
<stroke
android:width="1dp"
android:color="@color/switch_button_active_stroke_dark" />
</shape>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="4dp"
android:topRightRadius="4dp" />
<solid android:color="@color/switch_button_active_light" />
<stroke
android:width="1dp"
android:color="@color/switch_button_active_stroke_light" />
</shape>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/active_color_primary_dark" android:state_checked="false" />
<item android:color="@color/text_color_primary_dark" android:state_checked="true" />
</selector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/active_color_primary_light" android:state_checked="false" />
<item android:color="@color/text_color_primary_light" android:state_checked="true" />
</selector>

View file

@ -22,37 +22,37 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/radio_button_left"
android:background="?attr/btn_radio_button_left"
android:button="@android:color/transparent"
android:checked="true"
android:foreground="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/shared_string_none"
android:textColor="@drawable/radio_flat_text_selector" />
android:textColor="@drawable/radio_flat_text_selector_light" />
<RadioButton
android:id="@+id/time_split"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/radio_button_center"
android:background="?attr/btn_radio_button_center"
android:button="@android:color/transparent"
android:foreground="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/shared_string_time"
android:textColor="@drawable/radio_flat_text_selector" />
android:textColor="@drawable/radio_flat_text_selector_light" />
<RadioButton
android:id="@+id/distance_split"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/radio_button_right"
android:background="?attr/btn_radio_button_right"
android:button="@android:color/transparent"
android:foreground="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/distance"
android:textColor="@drawable/radio_flat_text_selector"
android:textColor="@drawable/radio_flat_text_selector_light"
android:textSize="@dimen/default_desc_text_size" />
</RadioGroup>

View file

@ -3823,4 +3823,6 @@
<string name="set_working_days_to_continue">Необходимо указать рабочие дни для продолжения</string>
<string name="route_between_points">Маршрут между пунктами</string>
<string name="plan_a_route">План маршрута</string>
<string name="gpx_split_interval_none_descr">Выберите нужный вариант разбиения: по времени или по расстоянию.</string>
<string name="gpx_split_interval_descr">Выберите интервал с которым будут отображаться метки с расстоянием или временем на треке.</string>
</resources>

View file

@ -133,6 +133,9 @@
<attr name="profile_save_btn" format="reference"/>
<attr name="profile_cancel_btn" format="reference"/>
<attr name="btn_bg_border_inactive" format="reference"/>
<attr name="btn_radio_button_left" format="reference"/>
<attr name="btn_radio_button_right" format="reference"/>
<attr name="btn_radio_button_center" format="reference"/>
<attr name="bg_dash_line" format="reference"/>
</declare-styleable>

View file

@ -471,7 +471,8 @@
<color name="switch_button_active_light">#1A237BFF</color>
<color name="switch_button_active_dark">#1AD28521</color>
<color name="switch_button_active_stroke">#80237BFF</color>
<color name="switch_button_active_stroke_light">#80237BFF</color>
<color name="switch_button_active_stroke_dark">#80D28521</color>
<color name="empty_hint_bg">#80000000</color>
<color name="input_layout_bg_color">#4DCCCCCC</color>

View file

@ -11,6 +11,13 @@
Thx - Hardy
-->
<string name="track_coloring_solid">Solid</string>
<string name="gpx_direction_arrows">Direction arrows</string>
<string name="shared_string_custom">Custom</string>
<string name="gpx_split_interval_none_descr">Select the desired splitting option: by time or by distance.</string>
<string name="gpx_split_interval_descr">Select the interval at which marks with distance or time on the track will be displayed.</string>
<string name="select_track_width">Select width</string>
<string name="track_show_start_finish_icons">Show start finish icons</string>
<string name="add_to_a_track">Add to a Track</string>
<string name="plan_a_route">Plan a route</string>
<string name="route_between_points">Route between points</string>

View file

@ -297,6 +297,9 @@
<item name="android:toolbarStyle">@style/ToolbarStyle</item>
<item name="toolbarStyle">@style/ToolbarStyle</item>
<item name="bg_dash_line">@drawable/bg_dash_line_light</item>
<item name="btn_radio_button_left">@drawable/radio_button_left_light</item>
<item name="btn_radio_button_right">@drawable/radio_button_right_light</item>
<item name="btn_radio_button_center">@drawable/radio_button_center_light</item>
</style>
<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
@ -578,6 +581,9 @@
<item name="android:toolbarStyle">@style/ToolbarStyle</item>
<item name="toolbarStyle">@style/ToolbarStyle</item>
<item name="bg_dash_line">@drawable/bg_dash_line_dark</item>
<item name="btn_radio_button_left">@drawable/radio_button_left_dark</item>
<item name="btn_radio_button_right">@drawable/radio_button_right_dark</item>
<item name="btn_radio_button_center">@drawable/radio_button_center_dark</item>
</style>
<style name="FreeVersionBanner" parent="OsmandDarkTheme">

View file

@ -539,7 +539,7 @@ public class GPXDatabase {
return false;
}
public boolean updateGradientScaleType(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType) {
public boolean updateGradientScaleType(@NonNull GpxDataItem item, @Nullable GradientScaleType gradientScaleType) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
@ -547,7 +547,7 @@ public class GPXDatabase {
String fileDir = getFileDir(item.file);
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_GRADIENT_SCALE_TYPE + " = ? " +
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
new Object[] {gradientScaleType.name(), fileName, fileDir});
new Object[] {(gradientScaleType == null ? "" : gradientScaleType.name()), fileName, fileDir});
item.gradientScaleType = gradientScaleType;
} finally {
db.close();
@ -723,7 +723,7 @@ public class GPXDatabase {
} else {
color = Algorithms.colorToString(item.color);
}
String gradientScaleType = item.gradientScaleType != null ? item.gradientScaleType.name() : GradientScaleType.SOLID.name();
String gradientScaleType = item.gradientScaleType != null ? item.gradientScaleType.name() : null;
if (a != null) {
db.execSQL(
"INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
@ -891,7 +891,7 @@ public class GPXDatabase {
try {
item.gradientScaleType = Algorithms.isEmpty(gradientScaleType) ? null : GradientScaleType.valueOf(gradientScaleType);
} catch (IllegalArgumentException e) {
item.gradientScaleType = GradientScaleType.SOLID;
item.gradientScaleType = null;
}
return item;

View file

@ -85,7 +85,7 @@ public class GpxDbHelper {
return res;
}
public boolean updateGradientScaleType(@NonNull GpxDataItem item, @NonNull GradientScaleType gradientScaleType) {
public boolean updateGradientScaleType(@NonNull GpxDataItem item, @Nullable GradientScaleType gradientScaleType) {
boolean res = db.updateGradientScaleType(item, gradientScaleType);
putToCache(item);
return res;

View file

@ -528,16 +528,13 @@ public class GpxSelectionHelper {
}
}
if (obj.has(SHOW_ARROWS)) {
boolean showArrows = obj.optBoolean(SHOW_ARROWS, false);
gpx.setShowArrows(showArrows);
gpx.setShowArrows(obj.optBoolean(SHOW_ARROWS, false));
}
if (obj.has(GRADIENT_SCALE_TYPE)) {
String gradientScaleTypeName = obj.optString(GRADIENT_SCALE_TYPE);
gpx.setGradientScaleType(gradientScaleTypeName);
gpx.setGradientScaleType(obj.optString(GRADIENT_SCALE_TYPE));
}
if (obj.has(SHOW_START_FINISH)) {
boolean showStartFinish = obj.optBoolean(SHOW_START_FINISH, false);
gpx.setShowStartFinish(showStartFinish);
gpx.setShowStartFinish(obj.optBoolean(SHOW_START_FINISH, false));
}
if (obj.has(WIDTH)) {
gpx.setWidth(obj.getString(WIDTH));

View file

@ -178,7 +178,7 @@ public class TrackActivity extends TabActivity {
}
}
public List<GpxDisplayGroup> getGpxDisplayGroups(boolean useDisplayGroups) {
public List<GpxDisplayGroup> getGpxFile(boolean useDisplayGroups) {
if (gpxFile == null) {
return new ArrayList<>();
}

View file

@ -94,7 +94,7 @@ public class GpxAppearanceAdapter extends ArrayAdapter<GpxAppearanceAdapter.Appe
}
}
public void init() {
private void init() {
addAll(getAppearanceItems(app, adapterType));
}

View file

@ -26,8 +26,8 @@ import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
import net.osmand.plus.myplaces.SaveGpxAsyncTask;
import net.osmand.plus.myplaces.SaveGpxAsyncTask.SaveGpxListener;
import net.osmand.plus.track.SaveGpxAsyncTask;
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
import net.osmand.util.Algorithms;
import java.util.Map;

View file

@ -30,8 +30,8 @@ import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener;
import net.osmand.plus.myplaces.SaveGpxAsyncTask;
import net.osmand.plus.myplaces.SaveGpxAsyncTask.SaveGpxListener;
import net.osmand.plus.track.SaveGpxAsyncTask;
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
import net.osmand.util.Algorithms;
import java.util.List;

View file

@ -380,7 +380,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
List<GpxDisplayGroup> groups = new ArrayList<>();
if (getTrackActivity() != null) {
List<GpxDisplayGroup> result = getTrackActivity().getGpxDisplayGroups(useDisplayGroups);
List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(useDisplayGroups);
for (GpxDisplayGroup group : result) {
boolean add = hasFilterType(group.getType());
if (add) {
@ -397,7 +397,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
TrackActivity trackActivity = getTrackActivity();
List<GpxDisplayItem> splitSegments = new ArrayList<>();
if (trackActivity != null) {
List<GpxDisplayGroup> result = trackActivity.getGpxDisplayGroups(true);
List<GpxDisplayGroup> result = trackActivity.getGpxFile(true);
if (result != null && result.size() > 0 && trkSegment.points.size() > 0) {
for (GpxDisplayGroup group : result) {
splitSegments.addAll(collectDisplayItemsFromGroup(group));

View file

@ -54,7 +54,8 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.measurementtool.NewGpxData;
import net.osmand.plus.myplaces.SplitTrackAsyncTask.SplitTrackListener;
import net.osmand.plus.track.SplitTrackAsyncTask;
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.track.GpxSplitType;
@ -352,6 +353,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
showTemporaryObjectOnMap(getGpx());
}
});
appearanceView.setVisibility(View.VISIBLE);
splitColorView.setVisibility(View.VISIBLE);
divider.setVisibility(View.VISIBLE);
} else {
@ -368,7 +370,8 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
GPXFile gpx = getGpx();
WptPt pointToShow = gpx != null ? gpx.findPointToShow() : null;
if (activity != null && pointToShow != null) {
if (!isGpxFileSelected(gpx)) {
boolean gpxFileSelected = isGpxFileSelected(gpx);
if (!gpxFileSelected) {
Intent intent = activity.getIntent();
if (intent != null) {
intent.putExtra(TrackActivity.SHOW_TEMPORARILY, true);
@ -376,6 +379,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
}
setTrackVisibilityOnMap(true);
final OsmandSettings settings = app.getSettings();
String trackName;
if (gpx.showCurrentTrack) {
trackName = app.getString(R.string.shared_string_currently_recording_track);
@ -384,7 +388,6 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
} else {
trackName = gpx.path;
}
OsmandSettings settings = app.getSettings();
settings.setMapLocationToShow(pointToShow.getLatitude(), pointToShow.getLongitude(),
settings.getLastKnownMapZoom(),
new PointDescription(PointDescription.POINT_TYPE_WPT, trackName),
@ -394,6 +397,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
MapActivity.launchMapActivityMoveToTop(activity);
}
}
private ListPopupWindow createPopupWindow(Activity activity, View anchorView, ListAdapter adapter, OnItemClickListener itemClickListener) {
ListPopupWindow popupWindow = new ListPopupWindow(activity);
popupWindow.setAnchorView(anchorView);
@ -646,7 +650,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
List<GpxDisplayGroup> groups = new ArrayList<>();
TrackActivity activity = getTrackActivity();
if (activity != null) {
List<GpxDisplayGroup> result = activity.getGpxDisplayGroups(useDisplayGroups);
List<GpxDisplayGroup> result = activity.getGpxFile(useDisplayGroups);
for (GpxDisplayGroup group : result) {
boolean add = hasFilterType(group.getType());
if (add) {
@ -746,9 +750,9 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
}
private void updateSplit(@NonNull List<GpxDisplayGroup> groups, @Nullable final SelectedGpxFile selectedGpx) {
GPXFile gpxFile = getGpx();
TrackActivity activity = getTrackActivity();
GpxSplitType gpxSplitType = getGpxSplitType();
GPXFile gpxFile = getGpx();
if (activity != null && gpxSplitType != null && gpxFile != null) {
int timeSplit = 0;
double distanceSplit = 0;

View file

@ -68,7 +68,8 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
import net.osmand.plus.measurementtool.NewGpxData;
import net.osmand.plus.myplaces.SaveGpxAsyncTask.SaveGpxListener;
import net.osmand.plus.track.SaveGpxAsyncTask;
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.views.controls.PagerSlidingTabStrip;

View file

@ -0,0 +1,48 @@
package net.osmand.plus.track;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.TextView;
import androidx.annotation.NonNull;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
public class DirectionArrowsCard extends BaseCard {
private TrackDrawInfo trackDrawInfo;
public DirectionArrowsCard(@NonNull MapActivity mapActivity, @NonNull TrackDrawInfo trackDrawInfo) {
super(mapActivity);
this.trackDrawInfo = trackDrawInfo;
}
@Override
public int getCardLayoutId() {
return R.layout.bottom_sheet_item_with_switch;
}
@Override
protected void updateContent() {
AndroidUiHelper.updateVisibility(view.findViewById(R.id.icon), false);
TextView titleView = view.findViewById(R.id.title);
titleView.setText(R.string.gpx_direction_arrows);
final CompoundButton compoundButton = view.findViewById(R.id.compound_button);
compoundButton.setChecked(trackDrawInfo.isShowArrows());
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = !compoundButton.isChecked();
compoundButton.setChecked(checked);
trackDrawInfo.setShowArrows(checked);
mapActivity.refreshMap();
}
});
}
}

View file

@ -10,7 +10,6 @@ import net.osmand.plus.R;
public enum GradientScaleType {
SOLID("gradient_solid_color", R.string.track_coloring_solid, R.drawable.ic_action_circle),
SPEED("gradient_speed_color", R.string.map_widget_speed, R.drawable.ic_action_speed),
ALTITUDE("gradient_altitude_color", R.string.altitude, R.drawable.ic_action_altitude_average),
SLOPE("gradient_slope_color", R.string.shared_string_slope, R.drawable.ic_action_altitude_ascent);
@ -38,4 +37,4 @@ public enum GradientScaleType {
public String getHumanString(@NonNull Context ctx) {
return ctx.getString(resId);
}
}
}

View file

@ -0,0 +1,49 @@
package net.osmand.plus.track;
import android.os.AsyncTask;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import java.io.File;
public class SaveGpxAsyncTask extends AsyncTask<Void, Void, Exception> {
private final GPXFile gpx;
private final SaveGpxListener saveGpxListener;
public SaveGpxAsyncTask(@NonNull GPXFile gpx,
@Nullable SaveGpxListener saveGpxListener) {
this.gpx = gpx;
this.saveGpxListener = saveGpxListener;
}
@Override
protected void onPreExecute() {
if (saveGpxListener != null) {
saveGpxListener.gpxSavingStarted();
}
}
@Override
protected Exception doInBackground(Void... params) {
return GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
}
@Override
protected void onPostExecute(Exception errorMessage) {
if (saveGpxListener != null) {
saveGpxListener.gpxSavingFinished(errorMessage);
}
}
public interface SaveGpxListener {
void gpxSavingStarted();
void gpxSavingFinished(Exception errorMessage);
}
}

View file

@ -27,8 +27,7 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.myplaces.SplitTrackAsyncTask;
import net.osmand.plus.myplaces.SplitTrackAsyncTask.SplitTrackListener;
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
import org.apache.commons.logging.Log;

View file

@ -4,7 +4,6 @@ import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -13,13 +12,8 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
public class SplitIntervalCard extends BaseCard {
private TrackDrawInfo trackDrawInfo;
private Fragment targetFragment;
public SplitIntervalCard(@NonNull MapActivity mapActivity, TrackDrawInfo trackDrawInfo, Fragment targetFragment) {
public SplitIntervalCard(@NonNull MapActivity mapActivity) {
super(mapActivity);
this.trackDrawInfo = trackDrawInfo;
this.targetFragment = targetFragment;
}
@Override
@ -34,12 +28,13 @@ public class SplitIntervalCard extends BaseCard {
TextView titleView = view.findViewById(R.id.title);
titleView.setText(R.string.gpx_split_interval);
TextView descriptionView = view.findViewById(R.id.description);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo, targetFragment);
CardListener listener = getListener();
if (listener != null) {
listener.onCardPressed(SplitIntervalCard.this);
}
}
});
}

View file

@ -0,0 +1,75 @@
package net.osmand.plus.track;
import android.os.AsyncTask;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.OsmandApplication;
import java.util.List;
public class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {
private OsmandApplication app;
private GpxSplitType gpxSplitType;
private List<GpxDisplayGroup> groups;
private SplitTrackListener splitTrackListener;
private boolean joinSegments;
private int timeSplitInterval;
private double distanceSplitInterval;
public SplitTrackAsyncTask(@NonNull OsmandApplication app,
@NonNull GpxSplitType gpxSplitType,
@NonNull List<GpxDisplayGroup> groups,
@Nullable SplitTrackListener splitTrackListener,
boolean joinSegments,
int timeSplitInterval,
double distanceSplitInterval) {
this.app = app;
this.groups = groups;
this.gpxSplitType = gpxSplitType;
this.splitTrackListener = splitTrackListener;
this.joinSegments = joinSegments;
this.timeSplitInterval = timeSplitInterval;
this.distanceSplitInterval = distanceSplitInterval;
}
@Override
protected void onPreExecute() {
if (splitTrackListener != null) {
splitTrackListener.trackSplittingStarted();
}
}
@Override
protected Void doInBackground(Void... params) {
for (GpxSelectionHelper.GpxDisplayGroup model : groups) {
if (gpxSplitType == GpxSplitType.NO_SPLIT) {
model.noSplit(app);
} else if (gpxSplitType == GpxSplitType.DISTANCE && distanceSplitInterval > 0) {
model.splitByDistance(app, distanceSplitInterval, joinSegments);
} else if (gpxSplitType == GpxSplitType.TIME && timeSplitInterval > 0) {
model.splitByTime(app, timeSplitInterval, joinSegments);
}
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (splitTrackListener != null) {
splitTrackListener.trackSplittingFinished();
}
}
public interface SplitTrackListener {
void trackSplittingStarted();
void trackSplittingFinished();
}
}

View file

@ -27,11 +27,12 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.DialogButtonType;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.ContextMenuFragment;
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.myplaces.DirectionArrowsCard;
import net.osmand.plus.myplaces.SaveGpxAsyncTask;
import net.osmand.plus.myplaces.SplitTrackAsyncTask;
import net.osmand.plus.track.TrackDrawInfo.OnTrackAppearanceChangedListener;
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
@ -40,9 +41,10 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
import static net.osmand.plus.track.TrackDrawInfo.TRACK_FILE_PATH;
public class TrackAppearanceFragment extends ContextMenuFragment {
public class TrackAppearanceFragment extends ContextMenuFragment implements CardListener {
public static final String TAG = TrackAppearanceFragment.class.getName();
@ -60,15 +62,7 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
private int menuTitleHeight;
private long modifiedTime = -1;
private OnTrackAppearanceChangedListener trackAppearanceListener;
private TrackWidthCard trackWidthCard;
private SplitIntervalCard splitIntervalCard;
private void updateAppearanceIcon() {
Drawable icon = getPaintedContentIcon(R.drawable.ic_action_gpx_width_bold, trackDrawInfo.getColor());
appearanceIcon.setImageDrawable(icon);
}
@Override
public int getMainLayoutId() {
@ -115,8 +109,26 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
File file = new File(selectedGpxFile.getGpxFile().path);
gpxDataItem = app.getGpxDbHelper().getItem(file);
trackDrawInfo = new TrackDrawInfo(gpxDataItem);
updateTrackColor();
}
trackDrawInfo.setTrackAppearanceListener(getTrackAppearanceListener());
}
private void updateTrackColor() {
int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
GPXFile gpxFile = selectedGpxFile.getGpxFile();
if (color == 0 && gpxFile != null) {
if (gpxFile.showCurrentTrack) {
color = app.getSettings().CURRENT_TRACK_COLOR.get();
} else {
color = gpxFile.getColor(0);
}
}
if (color == 0) {
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
OsmandSettings.CommonPreference<String> prefColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
color = GpxAppearanceAdapter.parseTrackColor(renderer, prefColor.get());
}
trackDrawInfo.setColor(color);
}
@Override
@ -130,6 +142,7 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
}
updateCards();
updateButtons(view);
updateAppearanceIcon();
if (!isPortrait()) {
int widthNoShadow = getLandscapeNoShadowWidth();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -185,25 +198,60 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
trackDrawInfo.saveToBundle(outState);
}
private OnTrackAppearanceChangedListener getTrackAppearanceListener() {
if (trackAppearanceListener == null) {
trackAppearanceListener = new OnTrackAppearanceChangedListener() {
@Override
public void onTrackColorChanged() {
updateAppearanceIcon();
if (trackWidthCard != null) {
trackWidthCard.updateItems();
}
@Override
public int getStatusBarColorId() {
View view = getView();
if (view != null) {
boolean nightMode = isNightMode();
if (getViewY() <= getFullScreenTopPosY() || !isPortrait()) {
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
@Override
public void onTrackWidthChanged() {
return nightMode ? R.color.divider_color_dark : R.color.divider_color_light;
} else {
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
view.setSystemUiVisibility(view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
};
}
}
return trackAppearanceListener;
return -1;
}
private void updateStatusBarColor() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.updateStatusBarColor();
}
}
@Override
public void onCardLayoutNeeded(@NonNull BaseCard card) {
}
@Override
public void onCardPressed(@NonNull BaseCard card) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
if (card instanceof SplitIntervalCard) {
SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo, this);
} else if (card instanceof TrackColoringCard) {
updateAppearanceIcon();
if (trackWidthCard != null) {
trackWidthCard.updateItems();
}
}
}
}
@Override
public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) {
}
private void updateAppearanceIcon() {
Drawable icon = getPaintedContentIcon(R.drawable.ic_action_gpx_width_bold, trackDrawInfo.getColor());
appearanceIcon.setImageDrawable(icon);
}
private void updateCardsLayout() {
@ -256,7 +304,11 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
GPXFile gpxFile = selectedGpxFile.getGpxFile();
gpxFile.setWidth(trackDrawInfo.getWidth());
gpxFile.setGradientScaleType(trackDrawInfo.getGradientScaleType().name());
if (trackDrawInfo.getGradientScaleType() != null) {
gpxFile.setGradientScaleType(trackDrawInfo.getGradientScaleType().name());
} else {
gpxFile.removeGradientScaleType();
}
gpxFile.setColor(trackDrawInfo.getColor());
for (GpxSplitType gpxSplitType : GpxSplitType.values()) {
@ -282,32 +334,32 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
int timeSplit = (int) gpxDataItem.getSplitInterval();
double distanceSplit = gpxDataItem.getSplitInterval();
GpxSplitType splitType = null;
GpxSplitType splitType;
if (gpxDataItem.getSplitType() == GpxSplitType.DISTANCE.getType()) {
splitType = GpxSplitType.DISTANCE;
} else if (gpxDataItem.getSplitType() == GpxSplitType.TIME.getType()) {
splitType = GpxSplitType.TIME;
} else {
splitType = GpxSplitType.NO_SPLIT;
}
if (splitType != null) {
SplitTrackAsyncTask.SplitTrackListener splitTrackListener = new SplitTrackAsyncTask.SplitTrackListener() {
SplitTrackAsyncTask.SplitTrackListener splitTrackListener = new SplitTrackAsyncTask.SplitTrackListener() {
@Override
public void trackSplittingStarted() {
@Override
public void trackSplittingStarted() {
}
@Override
public void trackSplittingFinished() {
if (selectedGpxFile != null) {
List<GpxDisplayGroup> groups = getGpxDisplayGroups();
selectedGpxFile.setDisplayGroups(groups, app);
}
@Override
public void trackSplittingFinished() {
if (selectedGpxFile != null) {
List<GpxDisplayGroup> groups = getGpxDisplayGroups();
selectedGpxFile.setDisplayGroups(groups, app);
}
}
};
List<GpxDisplayGroup> groups = getGpxDisplayGroups();
new SplitTrackAsyncTask(app, splitType, groups, splitTrackListener, trackDrawInfo.isJoinSegments(),
timeSplit, distanceSplit).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
};
List<GpxDisplayGroup> groups = getGpxDisplayGroups();
new SplitTrackAsyncTask(app, splitType, groups, splitTrackListener, trackDrawInfo.isJoinSegments(),
timeSplit, distanceSplit).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
@ -333,13 +385,15 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
ViewGroup cardsContainer = getCardsContainer();
cardsContainer.removeAllViews();
splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo, this);
SplitIntervalCard splitIntervalCard = new SplitIntervalCard(mapActivity);
splitIntervalCard.setListener(this);
cardsContainer.addView(splitIntervalCard.build(mapActivity));
DirectionArrowsCard directionArrowsCard = new DirectionArrowsCard(mapActivity, trackDrawInfo);
cardsContainer.addView(directionArrowsCard.build(mapActivity));
TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, selectedGpxFile, trackDrawInfo);
TrackColoringCard trackColoringCard = new TrackColoringCard(mapActivity, trackDrawInfo);
trackColoringCard.setListener(this);
cardsContainer.addView(trackColoringCard.build(mapActivity));
trackWidthCard = new TrackWidthCard(mapActivity, trackDrawInfo);
@ -362,32 +416,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
return displayGroups;
}
private void updateStatusBarColor() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.updateStatusBarColor();
}
}
@Override
public int getStatusBarColorId() {
View view = getView();
if (view != null) {
boolean nightMode = isNightMode();
if (getViewY() <= getFullScreenTopPosY() || !isPortrait()) {
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
return nightMode ? R.color.divider_color_dark : R.color.divider_color_light;
} else {
if (Build.VERSION.SDK_INT >= 23 && !nightMode) {
view.setSystemUiVisibility(view.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}
}
return -1;
}
public void dismissImmediate() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {

View file

@ -0,0 +1,23 @@
package net.osmand.plus.track;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.plus.R;
public class TrackAppearanceViewHolder extends RecyclerView.ViewHolder {
final TextView title;
final ImageView icon;
final ImageView button;
TrackAppearanceViewHolder(View itemView) {
super(itemView);
title = itemView.findViewById(R.id.groupName);
icon = itemView.findViewById(R.id.groupIcon);
button = itemView.findViewById(R.id.outlineRect);
}
}

View file

@ -10,6 +10,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
@ -17,7 +18,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import net.osmand.AndroidUtils;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
@ -28,27 +28,24 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.widgets.FlowLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems;
public class TrackColoringCard extends BaseCard {
private TrackDrawInfo trackDrawInfo;
private SelectedGpxFile selectedGpxFile;
private final static String SOLID_COLOR = "solid_color";
private GradientScaleType selectedScaleType;
private TrackDrawInfo trackDrawInfo;
private TrackColoringAdapter coloringAdapter;
private TrackAppearanceItem selectedAppearanceItem;
private List<TrackAppearanceItem> appearanceItems;
@ColorInt
private int selectedColor;
public TrackColoringCard(MapActivity mapActivity, SelectedGpxFile selectedGpxFile, TrackDrawInfo trackDrawInfo) {
public TrackColoringCard(MapActivity mapActivity, TrackDrawInfo trackDrawInfo) {
super(mapActivity);
this.trackDrawInfo = trackDrawInfo;
this.selectedGpxFile = selectedGpxFile;
appearanceItems = getGradientAppearanceItems();
}
@Override
@ -62,7 +59,7 @@ public class TrackColoringCard extends BaseCard {
createColorSelector();
updateColorSelector();
coloringAdapter = new TrackColoringAdapter(Arrays.asList(GradientScaleType.values()));
coloringAdapter = new TrackColoringAdapter(appearanceItems);
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
groupRecyclerView.setAdapter(coloringAdapter);
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
@ -70,6 +67,17 @@ public class TrackColoringCard extends BaseCard {
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
}
private List<TrackAppearanceItem> getGradientAppearanceItems() {
List<TrackAppearanceItem> items = new ArrayList<>();
items.add(new TrackAppearanceItem(SOLID_COLOR, app.getString(R.string.track_coloring_solid), R.drawable.ic_action_circle));
// for (GradientScaleType scaleType : GradientScaleType.values()) {
// items.add(new TrackAppearanceItem(scaleType.name(), scaleType.getHumanString(app), scaleType.getIconId()));
// }
return items;
}
private void createColorSelector() {
FlowLayout selectColor = view.findViewById(R.id.select_color);
List<Integer> colors = new ArrayList<>();
@ -81,13 +89,7 @@ public class TrackColoringCard extends BaseCard {
for (int color : colors) {
selectColor.addView(createColorItemView(color, selectColor), new FlowLayout.LayoutParams(0, 0));
}
if (selectedGpxFile.isShowCurrentTrack()) {
selectedColor = app.getSettings().CURRENT_TRACK_COLOR.get();
} else {
selectedColor = selectedGpxFile.getGpxFile().getColor(0);
}
updateColorSelector(selectedColor, selectColor);
updateColorSelector(trackDrawInfo.getColor(), selectColor);
}
private View createColorItemView(@ColorInt final int color, final FlowLayout rootView) {
@ -106,6 +108,12 @@ public class TrackColoringCard extends BaseCard {
public void onClick(View v) {
updateColorSelector(color, rootView);
coloringAdapter.notifyDataSetChanged();
trackDrawInfo.setColor(color);
CardListener listener = getListener();
if (listener != null) {
listener.onCardPressed(TrackColoringCard.this);
}
}
});
colorItemView.setTag(color);
@ -113,7 +121,7 @@ public class TrackColoringCard extends BaseCard {
}
private void updateColorSelector(int color, View rootView) {
View oldColor = rootView.findViewWithTag(selectedColor);
View oldColor = rootView.findViewWithTag(trackDrawInfo.getColor());
if (oldColor != null) {
oldColor.findViewById(R.id.outline).setVisibility(View.INVISIBLE);
ImageView icon = oldColor.findViewById(R.id.icon);
@ -123,19 +131,21 @@ public class TrackColoringCard extends BaseCard {
if (newColor != null) {
newColor.findViewById(R.id.outline).setVisibility(View.VISIBLE);
}
selectedColor = color;
trackDrawInfo.setColor(color);
mapActivity.refreshMap();
}
private GradientScaleType getSelectedScaleType() {
if (selectedScaleType == null) {
selectedScaleType = trackDrawInfo.getGradientScaleType();
if (selectedScaleType == null) {
selectedScaleType = GradientScaleType.SOLID;
private TrackAppearanceItem getSelectedAppearanceItem() {
if (selectedAppearanceItem == null) {
GradientScaleType scaleType = trackDrawInfo.getGradientScaleType();
for (TrackAppearanceItem item : appearanceItems) {
if (scaleType == null && item.getAttrName().equals(SOLID_COLOR)
|| scaleType != null && scaleType.name().equals(item.getAttrName())) {
selectedAppearanceItem = item;
break;
}
}
}
return selectedScaleType;
return selectedAppearanceItem;
}
private void updateHeader() {
@ -145,31 +155,43 @@ public class TrackColoringCard extends BaseCard {
titleView.setText(R.string.select_color);
TextView descriptionView = view.findViewById(R.id.description);
descriptionView.setText(getSelectedScaleType().getHumanString(view.getContext()));
descriptionView.setText(getSelectedAppearanceItem().getLocalizedValue());
}
private void updateColorSelector() {
boolean visible = GradientScaleType.SOLID == getSelectedScaleType();
boolean visible = getSelectedAppearanceItem().getAttrName().equals(SOLID_COLOR);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.select_color), visible);
}
private class TrackColoringAdapter extends RecyclerView.Adapter<TrackColoringViewHolder> {
public void setGradientScaleType(TrackAppearanceItem item) {
if (item.getAttrName().equals(SOLID_COLOR)) {
trackDrawInfo.setGradientScaleType(null);
} else {
trackDrawInfo.setGradientScaleType(GradientScaleType.valueOf(item.getAttrName()));
}
mapActivity.refreshMap();
private List<GradientScaleType> items;
updateHeader();
updateColorSelector();
}
private TrackColoringAdapter(List<GradientScaleType> items) {
private class TrackColoringAdapter extends RecyclerView.Adapter<TrackAppearanceViewHolder> {
private List<TrackAppearanceItem> items;
private TrackColoringAdapter(List<TrackAppearanceItem> items) {
this.items = items;
}
@NonNull
@Override
public TrackColoringViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
public TrackAppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode);
View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false);
view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width);
view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height);
TrackColoringViewHolder holder = new TrackColoringViewHolder(view);
TrackAppearanceViewHolder holder = new TrackAppearanceViewHolder(view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, holder.button, nightMode, R.drawable.ripple_solid_light_6dp,
R.drawable.ripple_solid_dark_6dp);
@ -178,16 +200,16 @@ public class TrackColoringCard extends BaseCard {
}
@Override
public void onBindViewHolder(@NonNull final TrackColoringViewHolder holder, int position) {
GradientScaleType item = items.get(position);
holder.colorKey.setText(item.getHumanString(holder.itemView.getContext()));
public void onBindViewHolder(@NonNull final TrackAppearanceViewHolder holder, int position) {
TrackAppearanceItem item = items.get(position);
holder.title.setText(item.getLocalizedValue());
updateButtonBg(holder, item);
int colorId;
if (item == GradientScaleType.SOLID) {
if (item.getAttrName().equals(SOLID_COLOR)) {
colorId = trackDrawInfo.getColor();
} else if (item.equals(getSelectedScaleType())) {
} else if (item.getAttrName().equals(getSelectedAppearanceItem().getAttrName())) {
colorId = ContextCompat.getColor(app, nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light);
} else {
colorId = AndroidUtils.getColorFromAttr(holder.itemView.getContext(), R.attr.default_icon_color);
@ -198,24 +220,20 @@ public class TrackColoringCard extends BaseCard {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int prevSelectedPosition = getItemPosition(getSelectedScaleType());
selectedScaleType = items.get(holder.getAdapterPosition());
int prevSelectedPosition = getItemPosition(getSelectedAppearanceItem());
selectedAppearanceItem = items.get(holder.getAdapterPosition());
notifyItemChanged(holder.getAdapterPosition());
notifyItemChanged(prevSelectedPosition);
trackDrawInfo.setGradientScaleType(selectedScaleType);
mapActivity.refreshMap();
updateHeader();
updateColorSelector();
setGradientScaleType(selectedAppearanceItem);
}
});
}
private void updateButtonBg(TrackColoringViewHolder holder, GradientScaleType item) {
private void updateButtonBg(TrackAppearanceViewHolder holder, TrackAppearanceItem item) {
GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline);
if (rectContourDrawable != null) {
if (getSelectedScaleType() != null && getSelectedScaleType().equals(item)) {
if (getSelectedAppearanceItem() != null && getSelectedAppearanceItem().equals(item)) {
int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), strokeColor);
} else {
@ -232,22 +250,35 @@ public class TrackColoringCard extends BaseCard {
return items.size();
}
int getItemPosition(GradientScaleType name) {
int getItemPosition(TrackAppearanceItem name) {
return items.indexOf(name);
}
}
private static class TrackColoringViewHolder extends RecyclerView.ViewHolder {
public static class TrackAppearanceItem {
final TextView colorKey;
final ImageView icon;
final ImageView button;
private String attrName;
private String localizedValue;
TrackColoringViewHolder(View itemView) {
super(itemView);
colorKey = itemView.findViewById(R.id.groupName);
icon = itemView.findViewById(R.id.groupIcon);
button = itemView.findViewById(R.id.outlineRect);
@DrawableRes
private int iconId;
public TrackAppearanceItem(String attrName, String localizedValue, int iconId) {
this.attrName = attrName;
this.localizedValue = localizedValue;
this.iconId = iconId;
}
public String getAttrName() {
return attrName;
}
public String getLocalizedValue() {
return localizedValue;
}
public int getIconId() {
return iconId;
}
}
}

View file

@ -5,6 +5,7 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.util.Algorithms;
public class TrackDrawInfo {
@ -12,9 +13,6 @@ public class TrackDrawInfo {
private static final String TRACK_WIDTH = "track_width";
private static final String TRACK_GRADIENT_SCALE_TYPE = "track_gradient_scale_type";
private static final String TRACK_COLOR = "track_color";
private static final String TRACK_GRADIENT_SPEED_COLOR = "track_gradient_speed_color";
private static final String TRACK_GRADIENT_ALTITUDE_COLOR = "track_gradient_altitude_color";
private static final String TRACK_GRADIENT_SLOPE_COLOR = "track_gradient_slope_color";
private static final String TRACK_SPLIT_TYPE = "track_split_type";
private static final String TRACK_SPLIT_INTERVAL = "track_split_interval";
private static final String TRACK_JOIN_SEGMENTS = "track_join_segments";
@ -25,17 +23,12 @@ public class TrackDrawInfo {
private String width;
private GradientScaleType gradientScaleType;
private int color;
private int gradientSpeedColor;
private int gradientAltitudeColor;
private int gradientSlopeColor;
private int splitType;
private double splitInterval;
private boolean joinSegments;
private boolean showArrows;
private boolean showStartFinish;
private OnTrackAppearanceChangedListener trackAppearanceListener;
public TrackDrawInfo() {
}
@ -45,9 +38,6 @@ public class TrackDrawInfo {
width = gpxDataItem.getWidth();
gradientScaleType = gpxDataItem.getGradientScaleType();
color = gpxDataItem.getColor();
gradientSpeedColor = gpxDataItem.getGradientSpeedColor();
gradientAltitudeColor = gpxDataItem.getGradientAltitudeColor();
gradientSlopeColor = gpxDataItem.getGradientSlopeColor();
splitType = gpxDataItem.getSplitType();
splitInterval = gpxDataItem.getSplitInterval();
joinSegments = gpxDataItem.isJoinSegments();
@ -55,10 +45,6 @@ public class TrackDrawInfo {
showStartFinish = gpxDataItem.isShowStartFinish();
}
public void setTrackAppearanceListener(OnTrackAppearanceChangedListener trackAppearanceListener) {
this.trackAppearanceListener = trackAppearanceListener;
}
public String getFilePath() {
return filePath;
}
@ -69,9 +55,6 @@ public class TrackDrawInfo {
public void setWidth(String width) {
this.width = width;
if (trackAppearanceListener != null) {
trackAppearanceListener.onTrackWidthChanged();
}
}
public GradientScaleType getGradientScaleType() {
@ -88,9 +71,6 @@ public class TrackDrawInfo {
public void setColor(int color) {
this.color = color;
if (trackAppearanceListener != null) {
trackAppearanceListener.onTrackColorChanged();
}
}
public int getSplitType() {
@ -128,11 +108,11 @@ public class TrackDrawInfo {
protected void readBundle(@NonNull Bundle bundle) {
filePath = bundle.getString(TRACK_FILE_PATH);
width = bundle.getString(TRACK_WIDTH);
gradientScaleType = GradientScaleType.valueOf(bundle.getString(TRACK_GRADIENT_SCALE_TYPE));
String gradientScaleTypeName = bundle.getString(TRACK_GRADIENT_SCALE_TYPE);
if (!Algorithms.isEmpty(gradientScaleTypeName)) {
gradientScaleType = GradientScaleType.valueOf(gradientScaleTypeName);
}
color = bundle.getInt(TRACK_COLOR);
gradientSpeedColor = bundle.getInt(TRACK_GRADIENT_SPEED_COLOR);
gradientAltitudeColor = bundle.getInt(TRACK_GRADIENT_ALTITUDE_COLOR);
gradientSlopeColor = bundle.getInt(TRACK_GRADIENT_SLOPE_COLOR);
splitType = bundle.getInt(TRACK_SPLIT_TYPE);
splitInterval = bundle.getDouble(TRACK_SPLIT_INTERVAL);
joinSegments = bundle.getBoolean(TRACK_JOIN_SEGMENTS);
@ -143,22 +123,12 @@ public class TrackDrawInfo {
protected void saveToBundle(@NonNull Bundle bundle) {
bundle.putString(TRACK_FILE_PATH, filePath);
bundle.putString(TRACK_WIDTH, width);
bundle.putString(TRACK_GRADIENT_SCALE_TYPE, gradientScaleType.name());
bundle.putString(TRACK_GRADIENT_SCALE_TYPE, gradientScaleType != null ? gradientScaleType.name() : "");
bundle.putInt(TRACK_COLOR, color);
bundle.putInt(TRACK_GRADIENT_SPEED_COLOR, gradientSpeedColor);
bundle.putInt(TRACK_GRADIENT_ALTITUDE_COLOR, gradientAltitudeColor);
bundle.putInt(TRACK_GRADIENT_SLOPE_COLOR, gradientSlopeColor);
bundle.putInt(TRACK_SPLIT_TYPE, splitType);
bundle.putDouble(TRACK_SPLIT_INTERVAL, splitInterval);
bundle.putBoolean(TRACK_JOIN_SEGMENTS, joinSegments);
bundle.putBoolean(TRACK_SHOW_ARROWS, showArrows);
bundle.putBoolean(TRACK_SHOW_START_FINISH, showStartFinish);
}
public interface OnTrackAppearanceChangedListener {
void onTrackColorChanged();
void onTrackWidthChanged();
}
}

View file

@ -5,7 +5,6 @@ import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@ -77,8 +76,8 @@ public class TrackWidthCard extends BaseCard {
String selectedWidth = trackDrawInfo.getWidth();
for (AppearanceListItem item : appearanceItems) {
if (Algorithms.objectEquals(item.getValue(), selectedWidth)
|| ((Algorithms.isEmpty(selectedWidth) || Algorithms.isInt(selectedWidth))
&& CUSTOM_WIDTH.equals(item.getAttrName()))) {
|| Algorithms.isEmpty(selectedWidth) && Algorithms.isEmpty(item.getValue())
|| Algorithms.isInt(selectedWidth) && CUSTOM_WIDTH.equals(item.getAttrName())) {
selectedItem = item;
break;
}
@ -152,7 +151,7 @@ public class TrackWidthCard extends BaseCard {
mapActivity.refreshMap();
}
private class GpxWidthAdapter extends RecyclerView.Adapter<GpxWidthViewHolder> {
private class GpxWidthAdapter extends RecyclerView.Adapter<TrackAppearanceViewHolder> {
private List<AppearanceListItem> items;
@ -162,24 +161,24 @@ public class TrackWidthCard extends BaseCard {
@NonNull
@Override
public GpxWidthViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
public TrackAppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode);
View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false);
view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width);
view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height);
GpxWidthViewHolder holder = new GpxWidthViewHolder(view);
TrackAppearanceViewHolder holder = new TrackAppearanceViewHolder(view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, holder.widthButton, nightMode, R.drawable.ripple_solid_light_6dp,
AndroidUtils.setBackground(app, holder.button, nightMode, R.drawable.ripple_solid_light_6dp,
R.drawable.ripple_solid_dark_6dp);
}
return holder;
}
@Override
public void onBindViewHolder(@NonNull final GpxWidthViewHolder holder, int position) {
public void onBindViewHolder(@NonNull final TrackAppearanceViewHolder holder, int position) {
AppearanceListItem item = items.get(position);
holder.widthAttrName.setText(item.getLocalizedValue());
holder.title.setText(item.getLocalizedValue());
updateButtonBg(holder, item);
updateWidthIcon(holder, item);
@ -200,7 +199,7 @@ public class TrackWidthCard extends BaseCard {
});
}
private void updateWidthIcon(GpxWidthViewHolder holder, AppearanceListItem item) {
private void updateWidthIcon(TrackAppearanceViewHolder holder, AppearanceListItem item) {
int color = trackDrawInfo.getColor();
int iconId;
@ -210,10 +209,10 @@ public class TrackWidthCard extends BaseCard {
} else {
iconId = GpxAppearanceAdapter.getWidthIconId(item.getValue());
}
holder.widthIcon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconId, color));
holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconId, color));
}
private void updateButtonBg(GpxWidthViewHolder holder, AppearanceListItem item) {
private void updateButtonBg(TrackAppearanceViewHolder holder, AppearanceListItem item) {
GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline);
if (rectContourDrawable != null) {
if (getSelectedItem() != null && getSelectedItem().equals(item)) {
@ -224,7 +223,7 @@ public class TrackWidthCard extends BaseCard {
: R.color.stroked_buttons_and_links_outline_light);
rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 1), strokeColor);
}
holder.widthButton.setImageDrawable(rectContourDrawable);
holder.button.setImageDrawable(rectContourDrawable);
}
}
@ -237,18 +236,4 @@ public class TrackWidthCard extends BaseCard {
return items.indexOf(name);
}
}
private static class GpxWidthViewHolder extends RecyclerView.ViewHolder {
final TextView widthAttrName;
final ImageView widthIcon;
final ImageView widthButton;
GpxWidthViewHolder(View itemView) {
super(itemView);
widthAttrName = itemView.findViewById(R.id.groupName);
widthIcon = itemView.findViewById(R.id.groupIcon);
widthButton = itemView.findViewById(R.id.outlineRect);
}
}
}

View file

@ -48,9 +48,11 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.PointImageDrawable;
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
import net.osmand.plus.track.SaveGpxAsyncTask;
import net.osmand.plus.render.OsmandRenderer;
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
import net.osmand.plus.track.TrackDrawInfo;
import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
import net.osmand.plus.views.ContextMenuLayer.IMoveObjectProvider;
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
@ -62,7 +64,6 @@ import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -94,6 +95,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
private Drawable startPointIcon;
private Drawable finishPointIcon;
private LayerDrawable selectedPoint;
private TrackDrawInfo trackDrawInfo;
private TrackChartPoints trackChartPoints;
private GpxSelectionHelper selectedGpxHelper;
@ -141,6 +143,14 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
this.trackChartPoints = trackChartPoints;
}
public boolean isInTrackAppearanceMode() {
return trackDrawInfo != null;
}
public void setTrackDrawInfo(TrackDrawInfo trackDrawInfo) {
this.trackDrawInfo = trackDrawInfo;
}
private void initUI() {
paint = new Paint();
paint.setStyle(Style.STROKE);
@ -224,10 +234,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
if (textLayer != null && isTextVisible()) {
textLayer.putData(this, cache);
}
}
private int updatePaints(int color, String width, boolean routePoints, boolean currentTrack, DrawSettings drawSettings, RotatedTileBox tileBox) {
private void updatePaints(int color, String width, boolean routePoints, boolean currentTrack, DrawSettings drawSettings, RotatedTileBox tileBox) {
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
int hash = calculateHash(rrs, cachedTrackWidth, routePoints, nightMode, tileBox.getMapDensity(), tileBox.getZoom(),
@ -291,7 +300,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
if (strikeWidth != null) {
paint.setStrokeWidth(strikeWidth);
}
return cachedColor;
}
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
@ -324,8 +332,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
DrawSettings settings) {
if (tileBox.getZoom() >= START_ZOOM) {
// request to load
OsmandApplication app = view.getApplication();
for (SelectedGpxFile g : selectedGPXFiles) {
List<GpxDisplayGroup> groups = g.getDisplayGroups(view.getApplication());
List<GpxDisplayGroup> groups = g.getDisplayGroups(app);
if (groups != null && !groups.isEmpty()) {
int color = g.getGpxFile().getColor(0);
if (color == 0) {
@ -338,8 +347,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
paintInnerRect.setColor(color);
paintInnerRect.setAlpha(179);
paintTextIcon.setColor(txtlabelColor(color));
paintOuterRect.setColor(txtlabelColor(color));
int contrastColor = UiUtilities.getContrastColor(app, color, false);
paintTextIcon.setColor(contrastColor);
paintOuterRect.setColor(contrastColor);
List<GpxDisplayItem> items = groups.get(0).getModifiableList();
@ -349,14 +359,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
}
}
private int txtlabelColor(int color) {
//Hardy, 2020-03-16: Contrast logic for text labels on tracks
if (((int) Color.red(color) * .299 + Color.green(color) * .587 + Color.blue(color) * .114) > 149) {
return Color.BLACK;
}
return Color.WHITE;
}
private void drawSplitItems(Canvas canvas, RotatedTileBox tileBox, List<GpxDisplayItem> items, DrawSettings settings) {
final QuadRect latLonBounds = tileBox.getLatLonBounds();
int r = (int) (12 * tileBox.getDensity());
@ -406,12 +408,18 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
if (!tileBox.isZoomAnimated()) {
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
boolean showArrows = selectedGpxFile.getGpxFile().isShowArrows();
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
showArrows = trackDrawInfo.isShowArrows();
}
if (showArrows) {
QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
int color = selectedGpxFile.getGpxFile().getColor(cachedColor);
if (selectedGpxFile.isShowCurrentTrack()) {
color = currentTrackColor;
}
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
color = trackDrawInfo.getColor();
}
int contrastColor = UiUtilities.getContrastColor(view.getApplication(), color, false);
GeometryWayStyle arrowsWayStyle = new GeometryArrowsWayStyle(wayContext, contrastColor);
for (TrkSegment segment : selectedGpxFile.getPointsToDisplay()) {
@ -526,20 +534,30 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
private void drawSelectedFilesStartEndPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
if (tileBox.getZoom() >= START_ZOOM) {
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
if (selectedGpxFile.getGpxFile().isShowStartFinish()) {
boolean showStartFinish = selectedGpxFile.getGpxFile().isShowStartFinish();
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
showStartFinish = trackDrawInfo.isShowStartFinish();
}
if (showStartFinish) {
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
TrkSegment endSegment = segments.get(segments.size() - 1);
for (TrkSegment segment : segments) {
if (segment.points.size() >= 2) {
WptPt start = segment.points.get(0);
WptPt end = segment.points.get(segment.points.size() - 1);
WptPt start = segments.get(0).points.get(0);
WptPt end = endSegment.points.get(endSegment.points.size() - 1);
drawPoint(canvas, tileBox, start, startPointIcon);
drawPoint(canvas, tileBox, end, finishPointIcon);
drawPoint(canvas, tileBox, start, startPointIcon);
drawPoint(canvas, tileBox, end, finishPointIcon);
}
}
}
}
}
}
private boolean hasTrackDrawInfoForSelectedGpx(SelectedGpxFile selectedGpxFile) {
return trackDrawInfo != null && trackDrawInfo.getFilePath().equals(selectedGpxFile.getGpxFile().path);
}
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, WptPt wptPt, Drawable icon) {
int pointX = (int) tileBox.getPixXFromLatLon(wptPt.lat, wptPt.lon);
int pointY = (int) tileBox.getPixYFromLatLon(wptPt.lat, wptPt.lon);
@ -703,6 +721,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
String width = selectedGpxFile.getGpxFile().getWidth(currentTrackWidthPref.get());
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
width = trackDrawInfo.getWidth();
}
if (!cachedTrackWidth.containsKey(width)) {
cachedTrackWidth.put(width, null);
}
@ -732,6 +753,10 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
if (color == 0) {
color = ts.getColor(cachedColor);
}
if (hasTrackDrawInfoForSelectedGpx(selectedGpxFile)) {
color = trackDrawInfo.getColor();
width = trackDrawInfo.getWidth();
}
if (ts.renderer == null && !ts.points.isEmpty()) {
if (currentTrack) {
ts.renderer = new Renderable.CurrentTrack(ts.points);
@ -1010,10 +1035,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
@Override
public void applyNewObjectPosition(@NonNull Object o,
@NonNull LatLon position,
@Nullable ContextMenuLayer.ApplyMovedObjectCallback callback) {
@Nullable final ContextMenuLayer.ApplyMovedObjectCallback callback) {
if (o instanceof WptPt) {
WptPt objectInMotion = (WptPt) o;
final WptPt objectInMotion = (WptPt) o;
SelectedGpxFile selectedGpxFile = pointFileMap.get(objectInMotion);
if (selectedGpxFile != null) {
GPXFile gpxFile = selectedGpxFile.getGpxFile();
@ -1027,7 +1051,20 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
callback.onApplyMovedObject(true, objectInMotion);
}
} else {
new SaveGpxFileAsyncTask(view.getApplication(), callback, objectInMotion).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, gpxFile);
new SaveGpxAsyncTask(gpxFile, new SaveGpxAsyncTask.SaveGpxListener() {
@Override
public void gpxSavingStarted() {
}
@Override
public void gpxSavingFinished(Exception errorMessage) {
if (callback != null) {
callback.onApplyMovedObject(errorMessage == null, objectInMotion);
}
}
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
} else if (callback != null) {
@ -1041,33 +1078,4 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
mapMarkersHelper.runSynchronization(group);
}
}
static class SaveGpxFileAsyncTask extends AsyncTask<GPXFile, Void, Exception> {
private final OsmandApplication app;
@Nullable
private final ContextMenuLayer.ApplyMovedObjectCallback callback;
@Nullable
private final WptPt point;
SaveGpxFileAsyncTask(OsmandApplication app,
@Nullable ContextMenuLayer.ApplyMovedObjectCallback callback,
@Nullable WptPt point) {
this.app = app;
this.callback = callback;
this.point = point;
}
@Override
protected Exception doInBackground(GPXFile... params) {
GPXFile gpxFile = params[0];
return GPXUtilities.writeGpxFile(new File(gpxFile.path), gpxFile);
}
@Override
protected void onPostExecute(Exception errorMessage) {
if (callback != null) {
callback.onApplyMovedObject(errorMessage == null, point);
}
}
}
}
}

View file

@ -906,7 +906,8 @@ public class MapControlsLayer extends OsmandMapLayer {
backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.map_widget_back_to_loc));
}
boolean visible = !(tracked && rh.isFollowingMode());
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode() && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait));
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode()
&& !isInTrackAppearanceMode() && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait));
if (app.accessibilityEnabled()) {
backToLocationControl.iv.setClickable(enabled && visible);
}

View file

@ -57,6 +57,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
private final ContextMenuLayer contextMenuLayer;
private final MeasurementToolLayer measurementToolLayer;
private final MapMarkersLayer mapMarkersLayer;
private final GPXLayer gpxLayer;
private ImageView contextMarker;
private final MapActivity mapActivity;
private final OsmandApplication app;
@ -84,9 +85,9 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
quickActionRegistry = app.getQuickActionRegistry();
measurementToolLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
mapMarkersLayer = mapActivity.getMapLayers().getMapMarkersLayer();
gpxLayer = mapActivity.getMapLayers().getGpxLayer();
}
@Override
public void initLayer(OsmandMapTileView view) {
this.view = view;
@ -410,6 +411,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
contextMenuLayer.isInGpxDetailsMode() ||
measurementToolLayer.isInMeasurementMode() ||
mapMarkersLayer.isInPlanRouteMode() ||
gpxLayer.isInTrackAppearanceMode() ||
mapRouteInfoMenu.isVisible() ||
MapRouteInfoMenu.chooseRoutesVisible ||
MapRouteInfoMenu.waypointsVisible ||