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:background="?attr/route_info_bg"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="30dp">
|
||||
android:paddingBottom="@dimen/dialog_button_ex_height">
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -5,6 +5,13 @@
|
|||
android:layout_height="wrap_content"
|
||||
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
|
||||
android:id="@+id/header_view"
|
||||
layout="@layout/bottom_sheet_item_with_right_descr" />
|
||||
|
|
|
@ -5,6 +5,13 @@
|
|||
android:layout_height="wrap_content"
|
||||
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
|
||||
android:id="@+id/header_view"
|
||||
layout="@layout/bottom_sheet_item_with_right_descr" />
|
||||
|
|
|
@ -386,8 +386,8 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void gpxSavingFinished() {
|
||||
if (!gpxSelected) {
|
||||
public void gpxSavingFinished(Exception errorMessage) {
|
||||
if (errorMessage == null && !gpxSelected) {
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxFile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -486,8 +486,8 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void gpxSavingFinished() {
|
||||
if (!gpxSelected) {
|
||||
public void gpxSavingFinished(Exception errorMessage) {
|
||||
if (errorMessage == null && !gpxSelected) {
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxFile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.osmand.GPXUtilities.GPXFile;
|
|||
|
||||
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 SaveGpxListener saveGpxListener;
|
||||
|
@ -29,15 +29,14 @@ public class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
|
||||
return null;
|
||||
protected Exception doInBackground(Void... params) {
|
||||
return GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
protected void onPostExecute(Exception errorMessage) {
|
||||
if (saveGpxListener != null) {
|
||||
saveGpxListener.gpxSavingFinished();
|
||||
saveGpxListener.gpxSavingFinished(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +44,6 @@ public class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
void gpxSavingStarted();
|
||||
|
||||
void gpxSavingFinished();
|
||||
void gpxSavingFinished(Exception errorMessage);
|
||||
}
|
||||
}
|
|
@ -1263,7 +1263,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
|||
}
|
||||
|
||||
@Override
|
||||
public void gpxSavingFinished() {
|
||||
public void gpxSavingFinished(Exception errorMessage) {
|
||||
TrackActivity activity = getTrackActivity();
|
||||
if (activity != null) {
|
||||
if (selectedGpxFile != null) {
|
||||
|
|
|
@ -319,8 +319,10 @@ public class TrackAppearanceFragment extends ContextMenuFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void gpxSavingFinished() {
|
||||
app.showShortToastMessage(R.string.shared_string_track_is_saved, Algorithms.getFileWithoutDirs(gpxFile.path));
|
||||
public void gpxSavingFinished(Exception errorMessage) {
|
||||
if (errorMessage == null) {
|
||||
app.showShortToastMessage(R.string.shared_string_track_is_saved, Algorithms.getFileWithoutDirs(gpxFile.path));
|
||||
}
|
||||
}
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ public class TrackColoringCard extends BaseCard {
|
|||
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
|
||||
groupRecyclerView.setAdapter(new GpxWidthAdapter(Arrays.asList(GradientScaleType.values())));
|
||||
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
||||
|
||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
|
||||
}
|
||||
|
||||
private void createColorSelector() {
|
||||
|
|
|
@ -62,6 +62,8 @@ public class TrackWidthCard extends BaseCard {
|
|||
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
|
||||
groupRecyclerView.setAdapter(widthAdapter);
|
||||
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
||||
|
||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
|
||||
}
|
||||
|
||||
public void updateItems() {
|
||||
|
|
|
@ -40,12 +40,12 @@ import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
|||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
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.myplaces.SaveGpxAsyncTask;
|
||||
import net.osmand.plus.render.OsmandRenderer;
|
||||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
||||
|
@ -61,7 +61,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;
|
||||
|
@ -225,10 +224,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(),
|
||||
|
@ -292,7 +290,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) {
|
||||
|
@ -339,8 +336,8 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
|||
paintInnerRect.setColor(color);
|
||||
paintInnerRect.setAlpha(179);
|
||||
|
||||
paintTextIcon.setColor(txtlabelColor(color));
|
||||
paintOuterRect.setColor(txtlabelColor(color));
|
||||
paintTextIcon.setColor(UiUtilities.getContrastColor(view.getApplication(), color, false));
|
||||
paintOuterRect.setColor(UiUtilities.getContrastColor(view.getApplication(), color, false));
|
||||
|
||||
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) {
|
||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||
int r = (int) (12 * tileBox.getDensity());
|
||||
|
@ -905,10 +894,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();
|
||||
|
@ -922,7 +910,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) {
|
||||
|
@ -936,33 +937,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue