UI fixes second part
This commit is contained in:
parent
0df0d3894b
commit
13e959a6cd
11 changed files with 55 additions and 64 deletions
|
@ -80,7 +80,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/route_info_bg"
|
android:background="?attr/route_info_bg"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="30dp">
|
android:paddingBottom="@dimen/dialog_button_ex_height">
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,13 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/top_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/divider_color_basic"
|
||||||
|
android:focusable="false" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/header_view"
|
android:id="@+id/header_view"
|
||||||
layout="@layout/bottom_sheet_item_with_right_descr" />
|
layout="@layout/bottom_sheet_item_with_right_descr" />
|
||||||
|
|
|
@ -5,6 +5,13 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/top_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/divider_color_basic"
|
||||||
|
android:focusable="false" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/header_view"
|
android:id="@+id/header_view"
|
||||||
layout="@layout/bottom_sheet_item_with_right_descr" />
|
layout="@layout/bottom_sheet_item_with_right_descr" />
|
||||||
|
|
|
@ -386,8 +386,8 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gpxSavingFinished() {
|
public void gpxSavingFinished(Exception errorMessage) {
|
||||||
if (!gpxSelected) {
|
if (errorMessage == null && !gpxSelected) {
|
||||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxFile);
|
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,8 +486,8 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gpxSavingFinished() {
|
public void gpxSavingFinished(Exception errorMessage) {
|
||||||
if (!gpxSelected) {
|
if (errorMessage == null && !gpxSelected) {
|
||||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxFile);
|
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
public class SaveGpxAsyncTask extends AsyncTask<Void, Void, Exception> {
|
||||||
|
|
||||||
private final GPXFile gpx;
|
private final GPXFile gpx;
|
||||||
private final SaveGpxListener saveGpxListener;
|
private final SaveGpxListener saveGpxListener;
|
||||||
|
@ -29,15 +29,14 @@ public class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Exception doInBackground(Void... params) {
|
||||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
|
return GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Exception errorMessage) {
|
||||||
if (saveGpxListener != null) {
|
if (saveGpxListener != null) {
|
||||||
saveGpxListener.gpxSavingFinished();
|
saveGpxListener.gpxSavingFinished(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +44,6 @@ public class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
void gpxSavingStarted();
|
void gpxSavingStarted();
|
||||||
|
|
||||||
void gpxSavingFinished();
|
void gpxSavingFinished(Exception errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1263,7 +1263,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gpxSavingFinished() {
|
public void gpxSavingFinished(Exception errorMessage) {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
if (selectedGpxFile != null) {
|
if (selectedGpxFile != null) {
|
||||||
|
|
|
@ -319,9 +319,11 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gpxSavingFinished() {
|
public void gpxSavingFinished(Exception errorMessage) {
|
||||||
|
if (errorMessage == null) {
|
||||||
app.showShortToastMessage(R.string.shared_string_track_is_saved, Algorithms.getFileWithoutDirs(gpxFile.path));
|
app.showShortToastMessage(R.string.shared_string_track_is_saved, Algorithms.getFileWithoutDirs(gpxFile.path));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ public class TrackColoringCard extends BaseCard {
|
||||||
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
|
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
|
||||||
groupRecyclerView.setAdapter(new GpxWidthAdapter(Arrays.asList(GradientScaleType.values())));
|
groupRecyclerView.setAdapter(new GpxWidthAdapter(Arrays.asList(GradientScaleType.values())));
|
||||||
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
||||||
|
|
||||||
|
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createColorSelector() {
|
private void createColorSelector() {
|
||||||
|
|
|
@ -62,6 +62,8 @@ public class TrackWidthCard extends BaseCard {
|
||||||
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
|
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
|
||||||
groupRecyclerView.setAdapter(widthAdapter);
|
groupRecyclerView.setAdapter(widthAdapter);
|
||||||
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
||||||
|
|
||||||
|
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateItems() {
|
public void updateItems() {
|
||||||
|
|
|
@ -40,12 +40,12 @@ import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.MapMarkersHelper;
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.PointImageDrawable;
|
import net.osmand.plus.base.PointImageDrawable;
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
|
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
|
||||||
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
||||||
|
import net.osmand.plus.myplaces.SaveGpxAsyncTask;
|
||||||
import net.osmand.plus.render.OsmandRenderer;
|
import net.osmand.plus.render.OsmandRenderer;
|
||||||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
||||||
|
@ -61,7 +61,6 @@ import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -225,10 +224,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (textLayer != null && isTextVisible()) {
|
if (textLayer != null && isTextVisible()) {
|
||||||
textLayer.putData(this, cache);
|
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();
|
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
|
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
|
||||||
int hash = calculateHash(rrs, cachedTrackWidth, routePoints, nightMode, tileBox.getMapDensity(), tileBox.getZoom(),
|
int hash = calculateHash(rrs, cachedTrackWidth, routePoints, nightMode, tileBox.getMapDensity(), tileBox.getZoom(),
|
||||||
|
@ -292,7 +290,6 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
if (strikeWidth != null) {
|
if (strikeWidth != null) {
|
||||||
paint.setStrokeWidth(strikeWidth);
|
paint.setStrokeWidth(strikeWidth);
|
||||||
}
|
}
|
||||||
return cachedColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
private void acquireTrackWidth(String widthKey, RenderingRulesStorage rrs, RenderingRuleSearchRequest req, RenderingContext rc) {
|
||||||
|
@ -339,8 +336,8 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
paintInnerRect.setColor(color);
|
paintInnerRect.setColor(color);
|
||||||
paintInnerRect.setAlpha(179);
|
paintInnerRect.setAlpha(179);
|
||||||
|
|
||||||
paintTextIcon.setColor(txtlabelColor(color));
|
paintTextIcon.setColor(UiUtilities.getContrastColor(view.getApplication(), color, false));
|
||||||
paintOuterRect.setColor(txtlabelColor(color));
|
paintOuterRect.setColor(UiUtilities.getContrastColor(view.getApplication(), color, false));
|
||||||
|
|
||||||
List<GpxDisplayItem> items = groups.get(0).getModifiableList();
|
List<GpxDisplayItem> items = groups.get(0).getModifiableList();
|
||||||
|
|
||||||
|
@ -350,14 +347,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) {
|
private void drawSplitItems(Canvas canvas, RotatedTileBox tileBox, List<GpxDisplayItem> items, DrawSettings settings) {
|
||||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||||
int r = (int) (12 * tileBox.getDensity());
|
int r = (int) (12 * tileBox.getDensity());
|
||||||
|
@ -905,10 +894,9 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
@Override
|
@Override
|
||||||
public void applyNewObjectPosition(@NonNull Object o,
|
public void applyNewObjectPosition(@NonNull Object o,
|
||||||
@NonNull LatLon position,
|
@NonNull LatLon position,
|
||||||
@Nullable ContextMenuLayer.ApplyMovedObjectCallback callback) {
|
@Nullable final ContextMenuLayer.ApplyMovedObjectCallback callback) {
|
||||||
|
|
||||||
if (o instanceof WptPt) {
|
if (o instanceof WptPt) {
|
||||||
WptPt objectInMotion = (WptPt) o;
|
final WptPt objectInMotion = (WptPt) o;
|
||||||
SelectedGpxFile selectedGpxFile = pointFileMap.get(objectInMotion);
|
SelectedGpxFile selectedGpxFile = pointFileMap.get(objectInMotion);
|
||||||
if (selectedGpxFile != null) {
|
if (selectedGpxFile != null) {
|
||||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||||
|
@ -922,7 +910,20 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
callback.onApplyMovedObject(true, objectInMotion);
|
callback.onApplyMovedObject(true, objectInMotion);
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
} else if (callback != null) {
|
||||||
|
@ -936,33 +937,4 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
mapMarkersHelper.runSynchronization(group);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue