Merge pull request #9281 from osmandapp/gpx_context_menu_fixes

Gpx context menu UI fixes
This commit is contained in:
vshcherb 2020-06-23 13:43:09 +02:00 committed by GitHub
commit 7125f0f5c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View file

@ -27,7 +27,6 @@ import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
@ -103,7 +102,7 @@ public class OsmAndFormatter {
} else {
calendar.setTimeInMillis(seconds * 1000);
}
if (isSameDay(calendar, Calendar.getInstance())) {
if (org.apache.commons.lang3.time.DateUtils.isSameDay(calendar, Calendar.getInstance())) {
return SIMPLE_TIME_OF_DAY_FORMAT.format(calendar.getTime());
} else {
return SIMPLE_TIME_OF_DAY_FORMAT.format(calendar.getTime()) + " " + localDaysStr[calendar.get(Calendar.DAY_OF_WEEK)];
@ -479,12 +478,6 @@ public class OsmAndFormatter {
return newStrings;
}
private static boolean isSameDay(Calendar cal1, Calendar cal2) {
return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) &&
cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR));
}
public static String getFormattedCoordinates(double lat, double lon, int outputFormat) {
StringBuilder result = new StringBuilder();
if (outputFormat == FORMAT_DEGREES_SHORT) {

View file

@ -23,6 +23,8 @@ import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
import net.osmand.util.Algorithms;
import org.apache.commons.lang3.time.DateUtils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -75,11 +77,16 @@ public class SelectedGpxMenuBuilder extends MenuBuilder {
Date start = new Date(analysis.startTime);
Date end = new Date(analysis.endTime);
DateFormat format = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
DateFormat startFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
DateFormat endFormat;
if (DateUtils.isSameDay(start, end)) {
endFormat = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
} else {
endFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
}
String startEndTimeTitle = app.getString(R.string.shared_string_start_time) + " - " + app.getString(R.string.shared_string_end_time);
buildRow(view, getThemedIcon(R.drawable.ic_action_time_start), null, startEndTimeTitle,
format.format(start) + " - " + format.format(end), 0, null,
startFormat.format(start) + " - " + endFormat.format(end), 0, null,
false, null, false, 0, false, false, false, null, true);
}

View file

@ -789,7 +789,7 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
boolean routeDialogOpened = mapRouteInfoMenu.isVisible() || (showRouteCalculationControls && mapRouteInfoMenu.needShowMenu());
updateMyLocation(rh, routeDialogOpened || trackDialogOpened || contextMenuOpened);
updateMyLocation(rh, routeDialogOpened || contextMenuOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode();
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_info_dark : R.drawable.ic_action_gdirections_dark);