From 54c20876c420424945caf620aa0e276f2cb65053 Mon Sep 17 00:00:00 2001 From: Corwin-Kh Date: Mon, 10 Jun 2024 03:21:35 +0300 Subject: [PATCH 01/24] Improved weather forecast animation --- .../plus/plugins/weather/WeatherPlugin.java | 11 ++++ .../plugins/weather/WeatherRasterLayer.java | 32 +++++++++-- .../dialogs/WeatherForecastFragment.java | 56 +++++++++++++------ .../plus/utils/AndroidNetworkUtils.java | 3 + 4 files changed, 81 insertions(+), 21 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherPlugin.java b/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherPlugin.java index 85671941699..cdb45777f1b 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherPlugin.java +++ b/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherPlugin.java @@ -550,6 +550,17 @@ public void setForecastDate(@Nullable Date date) { updateLayersDate(); } + public void prepareForDayAnimation(@NonNull Date date) { + forecastDate = date; + long time = forecastDate.getTime(); + if (weatherLayerLow != null) { + weatherLayerLow.prepareForDayAnimation(time); + } + if (weatherLayerHigh != null) { + weatherLayerHigh.prepareForDayAnimation(time); + } + } + private void updateLayersDate() { long time = forecastDate != null ? forecastDate.getTime() : System.currentTimeMillis(); if (weatherLayerLow != null) { diff --git a/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java b/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java index ea68118410a..d3308c58add 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java +++ b/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java @@ -24,6 +24,7 @@ import java.util.List; public class WeatherRasterLayer extends BaseMapLayer { + private static final long MINUTE_IN_MILLISECONDS = 60 * 1000; private static final long HOUR_IN_MILLISECONDS = 60 * 60 * 1000; private static final long DAY_IN_MILLISECONDS = 24 * HOUR_IN_MILLISECONDS; private final WeatherHelper weatherHelper; @@ -78,20 +79,41 @@ public long getDateTime() { return dateTime; } + public void prepareForDayAnimation(long dateTime) { + timePeriodStart = OsmAndFormatter.getStartOfDayForTime(dateTime); + timePeriodEnd = timePeriodStart + DAY_IN_MILLISECONDS; + timePeriodStep = 30 * MINUTE_IN_MILLISECONDS; + requireTimePeriodChange = true; + this.dateTime = dateTime; + } + public void setDateTime(long dateTime) { - long dayStart = OsmAndFormatter.getStartOfDayForTime(dateTime); + long dayStart = OsmAndFormatter.getStartOfDayForTime(timePeriodStart); long dayEnd = dayStart + DAY_IN_MILLISECONDS; + if (dateTime < dayStart || dateTime > dayEnd) { + dayStart = OsmAndFormatter.getStartOfDayForTime(dateTime); + dayEnd = dayStart + DAY_IN_MILLISECONDS; + } long todayStep = HOUR_IN_MILLISECONDS; long nextStep = todayStep * 3; long startOfToday = OsmAndFormatter.getStartOfToday(); long step = dayStart == startOfToday ? todayStep : nextStep; + long switchStepTime = (System.currentTimeMillis() + DAY_IN_MILLISECONDS) / nextStep * nextStep; + if (switchStepTime > startOfToday && switchStepTime >= dayStart + todayStep && switchStepTime <= dayEnd - nextStep) { + if (dateTime < switchStepTime) { + dayEnd = switchStepTime; + step = todayStep; + } else + dayStart = switchStepTime; + } long prevTime = (dateTime - dayStart) / step * step + dayStart; long nextTime = prevTime + step; + long nearestTime = dateTime - prevTime < nextTime - dateTime ? prevTime : nextTime; if (timePeriodStep != step - || timePeriodStart != dayStart - || timePeriodEnd != dayEnd) { - timePeriodStart = dayStart; - timePeriodEnd = dayEnd; + || (timePeriodStart > dayStart && nearestTime <= timePeriodStart) + || (timePeriodEnd < dayEnd && nearestTime >= timePeriodEnd)) { + timePeriodStart = Math.max(nearestTime - step * 2, dayStart); + timePeriodEnd = Math.min(nearestTime + step * 2, dayEnd); timePeriodStep = step; requireTimePeriodChange = true; } diff --git a/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java b/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java index 71c8a80ec72..4e6f65f3539 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java +++ b/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java @@ -75,8 +75,8 @@ public class WeatherForecastFragment extends BaseOsmAndFragment { private static final String PREVIOUS_WEATHER_CONTOUR_KEY = "previous_weather_contour"; private static final long MIN_UTC_HOURS_OFFSET = 24 * 60 * 60 * 1000; - public static final int ANIM_DELAY_MILLIS = 3000; - public static final int WAIT_FOR_NEW_DOWNLOAD_START_DELAY = 2000; + public static final int ANIM_DELAY_MILLIS = 125; + public static final int WAIT_FOR_NEW_DOWNLOAD_START_DELAY = 1000; private WeatherHelper weatherHelper; private WeatherPlugin plugin; @@ -96,7 +96,7 @@ public class WeatherForecastFragment extends BaseOsmAndFragment { private WeatherContour previousWeatherContour; private boolean isAnimatingForecast; private ImageButton playForecastBtn; - + private int currentStep; @Override public int getStatusBarColorId() { @@ -196,7 +196,10 @@ private void updatePlayForecastButton() { private void onPlayForecastClicked() { isAnimatingForecast = !isAnimatingForecast; if (isAnimatingForecast) { - moveToNextForecastFrame(); + plugin.prepareForDayAnimation(new Date(System.currentTimeMillis())); + requireMapActivity().refreshMap(); + showProgressBar(true); + scheduleAnimationStart(); } else { animateForecastHandler.removeCallbacksAndMessages(null); } @@ -204,10 +207,25 @@ private void onPlayForecastClicked() { } private void moveToNextForecastFrame() { - float currentValue = timeSlider.getValue(); - float newValue = currentValue == timeSlider.getValueTo() ? timeSlider.getValueFrom() : currentValue + 1; + animateForecastHandler.removeCallbacksAndMessages(null); + if (currentStep + 1 > getStepsCount()) { + currentStep = 0; + } else { + currentStep++; + } + float newValue = timeSlider.getValueFrom() + currentStep * timeSlider.getStepSize(); timeSlider.setValue(newValue); - animateForecastHandler.postDelayed(this::moveToNextForecastFrame, ANIM_DELAY_MILLIS); + if (isAnimatingForecast) { + animateForecastHandler.postDelayed(this::moveToNextForecastFrame, ANIM_DELAY_MILLIS); + } + } + + private int getStepsCount() { + if (timeSlider != null) { + return (int) ((timeSlider.getValueTo() - timeSlider.getValueFrom()) / timeSlider.getStepSize()); + } else { + return 0; + } } @Override @@ -501,16 +519,22 @@ public static void showInstance(@NonNull FragmentManager manager) { private void onDownloadStateChanged(boolean isDownloading) { progressUpdateHandler.removeCallbacksAndMessages(null); if (isAnimatingForecast) { - playForecastBtn.setEnabled(true); - showProgressBar(false); - } else if (isDownloading) { - playForecastBtn.setEnabled(false); - showProgressBar(true); + if (isDownloading) { + showProgressBar(true); + } else { + scheduleAnimationStart(); + } } else { - progressUpdateHandler.postDelayed(() -> { - playForecastBtn.setEnabled(true); - showProgressBar(false); - }, WAIT_FOR_NEW_DOWNLOAD_START_DELAY); + showProgressBar(false); } } + + private void scheduleAnimationStart() { + progressUpdateHandler.removeCallbacksAndMessages(null); + progressUpdateHandler.postDelayed(() -> { + showProgressBar(false); + currentStep = (int) (timeSlider.getValue() / timeSlider.getStepSize()); + moveToNextForecastFrame(); + }, WAIT_FOR_NEW_DOWNLOAD_START_DELAY); + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/utils/AndroidNetworkUtils.java b/OsmAnd/src/net/osmand/plus/utils/AndroidNetworkUtils.java index 3d828a83d8f..cf834e9d4f6 100644 --- a/OsmAnd/src/net/osmand/plus/utils/AndroidNetworkUtils.java +++ b/OsmAnd/src/net/osmand/plus/utils/AndroidNetworkUtils.java @@ -636,6 +636,9 @@ public static long downloadModifiedFile( } else { long lastModified = connection.getLastModified(); if (lastModified > 0 && lastModified <= lastTime) { + if (progress != null) { + progress.finishTask(); + } return 0; } if (progress != null) { From 65e5be088f1038552bceadc086932395b6aa69c7 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 10 Jun 2024 15:54:44 +0300 Subject: [PATCH 02/24] Import / Export (Backup) for Color source files --- .../main/java/net/osmand/IndexConstants.java | 2 + OsmAnd/res/values/strings.xml | 2 + .../plus/download/local/LocalIndexHelper.java | 5 ++ .../plus/download/local/LocalItemType.java | 3 +- .../plus/download/local/LocalItemUtils.java | 7 ++ .../download/local/LocalOperationTask.java | 3 + .../plus/helpers/ColorsPaletteUtils.java | 54 ++++++++++++++ .../exporttype/ColorPaletteExportType.java | 73 +++++++++++++++++++ .../backend/backup/exporttype/ExportType.java | 3 +- .../backup/items/FileSettingsItem.java | 8 +- .../fragments/DuplicatesSettingsAdapter.java | 5 ++ .../fragments/ExportItemsBottomSheet.java | 5 ++ 12 files changed, 167 insertions(+), 3 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/helpers/ColorsPaletteUtils.java create mode 100644 OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ColorPaletteExportType.java diff --git a/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java b/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java index 671266143b4..3b2d0fff910 100644 --- a/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java +++ b/OsmAnd-java/src/main/java/net/osmand/IndexConstants.java @@ -67,6 +67,7 @@ public class IndexConstants { public static final String AVOID_ROADS_FILE_EXT = ".geojson"; public static final String OBJ_FILE_EXT = ".obj"; + public static final String TXT_EXT = ".txt"; public static final String POI_TABLE = "poi"; @@ -109,4 +110,5 @@ public class IndexConstants { public static final String VOICE_PROVIDER_SUFFIX = "-tts"; public static final String MODEL_NAME_PREFIX = "model_"; + public static final String COLOR_PALETTE_DIR = "color-palette/"; } diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a425808ab77..ba340635c25 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,8 @@ --> Dark orange + User palette + Colors Wall height Change Terrain color scheme Play weather forecast diff --git a/OsmAnd/src/net/osmand/plus/download/local/LocalIndexHelper.java b/OsmAnd/src/net/osmand/plus/download/local/LocalIndexHelper.java index 5a5b365f808..cb669e1d5db 100644 --- a/OsmAnd/src/net/osmand/plus/download/local/LocalIndexHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/local/LocalIndexHelper.java @@ -2,6 +2,7 @@ import static net.osmand.IndexConstants.*; +import static net.osmand.plus.download.local.LocalItemType.COLOR_DATA; import static net.osmand.plus.download.local.LocalItemType.DEPTH_DATA; import static net.osmand.plus.download.local.LocalItemType.FONT_DATA; import static net.osmand.plus.download.local.LocalItemType.LIVE_UPDATES; @@ -241,6 +242,10 @@ public List getLocalIndexItems(boolean readFiles, boolean shouldUpdat loadDataImpl(app.getAppPath(SRTM_INDEX_DIR), TERRAIN_DATA, BINARY_MAP_INDEX_EXT, readFiles, shouldUpdate, items, indexFiles, task); break; + case COLOR_DATA: + loadDataImpl(app.getAppPath(COLOR_PALETTE_DIR), COLOR_DATA, TXT_EXT, + readFiles, shouldUpdate, items, indexFiles, task); + break; } } return items; diff --git a/OsmAnd/src/net/osmand/plus/download/local/LocalItemType.java b/OsmAnd/src/net/osmand/plus/download/local/LocalItemType.java index c8e79bea505..e9c4c24b7da 100644 --- a/OsmAnd/src/net/osmand/plus/download/local/LocalItemType.java +++ b/OsmAnd/src/net/osmand/plus/download/local/LocalItemType.java @@ -35,6 +35,7 @@ public enum LocalItemType { ACTIVE_MARKERS(R.string.map_markers, R.drawable.ic_action_flag_stroke), HISTORY_MARKERS(R.string.shared_string_history, R.drawable.ic_action_history), ITINERARY_GROUPS(R.string.shared_string_itinerary, R.drawable.ic_action_flag_stroke), + COLOR_DATA(R.string.shared_string_colors, R.drawable.ic_action_file_color_palette), PROFILES(R.string.shared_string_profiles, R.drawable.ic_action_manage_profiles), OTHER(R.string.shared_string_other, R.drawable.ic_action_settings); @@ -76,7 +77,7 @@ public CategoryType getCategoryType() { } public boolean isSettingsCategory() { - return CollectionUtils.equalsToAny(this, PROFILES, OTHER); + return CollectionUtils.equalsToAny(this, COLOR_DATA, PROFILES, OTHER); } public boolean isMyPlacesCategory() { diff --git a/OsmAnd/src/net/osmand/plus/download/local/LocalItemUtils.java b/OsmAnd/src/net/osmand/plus/download/local/LocalItemUtils.java index 242acbc22e6..d3f66f59a97 100644 --- a/OsmAnd/src/net/osmand/plus/download/local/LocalItemUtils.java +++ b/OsmAnd/src/net/osmand/plus/download/local/LocalItemUtils.java @@ -27,6 +27,7 @@ import net.osmand.plus.R; import net.osmand.plus.download.SrtmDownloadItem; import net.osmand.plus.download.local.dialogs.LiveGroupItem; +import net.osmand.plus.helpers.ColorsPaletteUtils; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.mapmarkers.ItineraryDataHelper; import net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording; @@ -211,6 +212,8 @@ public static LocalItemType getItemType(@NonNull OsmandApplication app, @NonNull } else if (path.startsWith(app.getCacheDir().getAbsolutePath()) && (path.contains(WEATHER_FORECAST_DIR) || path.contains(GEOTIFF_SQLITE_CACHE_DIR))) { return file.isFile() ? CACHE : null; + } else if (path.contains(COLOR_PALETTE_DIR) && name.endsWith(TXT_EXT)) { + return COLOR_DATA; } if (file.isFile() && file.length() >= OTHER_MIN_SIZE) { return OTHER; @@ -255,6 +258,8 @@ public static CharSequence getItemName(@NonNull Context context, @NonNull LocalI if (attachedObject instanceof String) { return RendererRegistry.getRendererName(context, (String) attachedObject); } + } else if (type == COLOR_DATA) { + return ColorsPaletteUtils.getPaletteName(item.getFile()); } OsmandApplication app = (OsmandApplication) context.getApplicationContext(); OsmandRegions regions = app.getResourceManager().getOsmandRegions(); @@ -278,6 +283,8 @@ public static String getItemDescription(@NonNull Context context, @NonNull Local String size = AndroidUtils.formatSize(context, item.getFile().length()); if (item.getType() == CACHE) { return size; + } else if (item.getType() == COLOR_DATA) { + return ColorsPaletteUtils.getPaletteTypeName(context, item.getFile()); } else { String formattedDate = getFormattedDate(new Date(item.getLastModified())); return context.getString(R.string.ltr_or_rtl_combine_via_bold_point, size, formattedDate); diff --git a/OsmAnd/src/net/osmand/plus/download/local/LocalOperationTask.java b/OsmAnd/src/net/osmand/plus/download/local/LocalOperationTask.java index 49cf8dba93c..ba7b9015c71 100644 --- a/OsmAnd/src/net/osmand/plus/download/local/LocalOperationTask.java +++ b/OsmAnd/src/net/osmand/plus/download/local/LocalOperationTask.java @@ -1,6 +1,7 @@ package net.osmand.plus.download.local; import static net.osmand.IndexConstants.*; +import static net.osmand.plus.download.local.LocalItemType.COLOR_DATA; import static net.osmand.plus.download.local.LocalItemType.DEPTH_DATA; import static net.osmand.plus.download.local.LocalItemType.FONT_DATA; import static net.osmand.plus.download.local.LocalItemType.MAP_DATA; @@ -227,6 +228,8 @@ private File getFileToRestore(@NonNull LocalItem item) { || fileName.endsWith(BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) { parent = app.getAppPath(WIKIVOYAGE_INDEX_DIR); } + } else if (item.getType() == COLOR_DATA) { + parent = app.getAppPath(COLOR_PALETTE_DIR); } return new File(parent, fileName); } diff --git a/OsmAnd/src/net/osmand/plus/helpers/ColorsPaletteUtils.java b/OsmAnd/src/net/osmand/plus/helpers/ColorsPaletteUtils.java new file mode 100644 index 00000000000..134a4da4fd7 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/ColorsPaletteUtils.java @@ -0,0 +1,54 @@ +package net.osmand.plus.helpers; + +import android.content.Context; + +import androidx.annotation.NonNull; + +import net.osmand.IndexConstants; +import net.osmand.plus.R; +import net.osmand.util.Algorithms; + +import java.io.File; + +public class ColorsPaletteUtils { + + public static final String ROUTE_PREFIX = "route_"; + public static final String WEATHER_PREFIX = "weather_"; + public static final String USER_PALETTE_PREFIX = "user_palette_"; + + @NonNull + public static String getPaletteName(@NonNull File file) { + String fileName = file.getName(); + String prefix = null; + if (fileName.startsWith(ROUTE_PREFIX)) { + prefix = ROUTE_PREFIX; + } else if (fileName.startsWith(WEATHER_PREFIX)) { + prefix = WEATHER_PREFIX; + } else if (fileName.startsWith(USER_PALETTE_PREFIX)) { + prefix = USER_PALETTE_PREFIX; + } + if (prefix != null) { + fileName = fileName.replace(prefix, ""); + } + fileName = fileName.replace(IndexConstants.TXT_EXT, ""); + StringBuilder result = new StringBuilder(); + for (String part : fileName.split("_")) { + result.append(Algorithms.capitalizeFirstLetter(part)).append(" "); + } + return result.toString().trim(); + } + + @NonNull + public static String getPaletteTypeName(@NonNull Context context, @NonNull File file) { + String fileName = file.getName(); + if (fileName.startsWith(ROUTE_PREFIX)) { + return context.getString(R.string.layer_route); + } else if (fileName.startsWith(WEATHER_PREFIX)) { + return context.getString(R.string.shared_string_weather); + } else if (fileName.startsWith(USER_PALETTE_PREFIX)) { + return context.getString(R.string.user_palette); + } + return context.getString(R.string.shared_string_terrain); + } + +} diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ColorPaletteExportType.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ColorPaletteExportType.java new file mode 100644 index 00000000000..b7ffac8b894 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ColorPaletteExportType.java @@ -0,0 +1,73 @@ +package net.osmand.plus.settings.backend.backup.exporttype; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.download.local.LocalItemType; +import net.osmand.plus.plugins.OsmandPlugin; +import net.osmand.plus.settings.backend.ExportCategory; +import net.osmand.plus.settings.backend.backup.SettingsItemType; +import net.osmand.plus.settings.backend.backup.items.FileSettingsItem; +import net.osmand.plus.settings.backend.backup.items.FileSettingsItem.FileSubtype; +import net.osmand.plus.settings.backend.backup.items.SettingsItem; + +import java.util.Collections; +import java.util.List; + +public class ColorPaletteExportType extends LocalResourcesExportType { + + @Override + public int getTitleId() { + return R.string.shared_string_colors; + } + + @Override + public int getIconId() { + return R.drawable.ic_action_file_color_palette; + } + + @NonNull + @Override + public List fetchExportData(@NonNull OsmandApplication app, boolean offlineBackup) { + return collectLocalResources(app); + } + + @NonNull + @Override + public List fetchImportData(@NonNull SettingsItem settingsItem, boolean importCompleted) { + FileSettingsItem fileSettingsItem = (FileSettingsItem) settingsItem; + return Collections.singletonList(fileSettingsItem); + } + + @NonNull + @Override + public ExportCategory getRelatedExportCategory() { + return ExportCategory.RESOURCES; + } + + @NonNull + @Override + public SettingsItemType getRelatedSettingsItemType() { + return SettingsItemType.FILE; + } + + @NonNull + @Override + public List getRelatedFileSubtypes() { + return Collections.singletonList(FileSubtype.COLOR_PALETTE); + } + + @Nullable + @Override + public LocalItemType getRelatedLocalItemType() { + return LocalItemType.COLOR_DATA; + } + + @Nullable + @Override + public Class getRelatedPluginClass() { + return null; + } +} diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ExportType.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ExportType.java index fbe459781fc..40aa3816d5e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ExportType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ExportType.java @@ -57,7 +57,8 @@ public enum ExportType { TERRAIN_DATA(new TerrainDataExportType()), TTS_VOICE(new TtsVoiceExportType()), VOICE(new VoiceExportType()), - FAVORITES_BACKUP(new FavoritesBackupExportType()); + FAVORITES_BACKUP(new FavoritesBackupExportType()), + COLOR_PALETTE(new ColorPaletteExportType()); @NonNull private final IExportType instance; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/FileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/FileSettingsItem.java index 97b34aa4007..addfc209b6c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/FileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/items/FileSettingsItem.java @@ -52,7 +52,8 @@ public enum FileSubtype { TRAVEL("travel", IndexConstants.WIKIVOYAGE_INDEX_DIR, R.drawable.ic_plugin_wikipedia), MULTIMEDIA_NOTES("multimedia_notes", IndexConstants.AV_INDEX_DIR, R.drawable.ic_action_photo_dark), NAUTICAL_DEPTH("nautical_depth", IndexConstants.NAUTICAL_INDEX_DIR, R.drawable.ic_action_nautical_depth), - FAVORITES_BACKUP("favorites_backup", IndexConstants.BACKUP_INDEX_DIR, R.drawable.ic_action_folder_favorites); + FAVORITES_BACKUP("favorites_backup", IndexConstants.BACKUP_INDEX_DIR, R.drawable.ic_action_folder_favorites), + COLOR_PALETTE("colors_palette", IndexConstants.COLOR_PALETTE_DIR, R.drawable.ic_action_file_color_palette); private final String subtypeName; private final String subtypeFolder; @@ -147,6 +148,11 @@ public static FileSubtype getSubtypeByFileName(@NonNull String fileName) { return subtype; } break; + case COLOR_PALETTE: + if (name.endsWith(IndexConstants.TXT_EXT)) { + return subtype; + } + break; default: if (name.startsWith(subtype.subtypeFolder)) { return subtype; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index a2910504f72..98d79f514a3 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -18,6 +18,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.avoidroads.AvoidRoadInfo; +import net.osmand.plus.helpers.ColorsPaletteUtils; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.mapmarkers.ItineraryType; @@ -161,6 +162,10 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconId, activeColorRes)); } else if (fileSubtype == FileSubtype.FAVORITES_BACKUP) { itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_folder_favorites, activeColorRes)); + } else if (fileSubtype == FileSubtype.COLOR_PALETTE) { + itemHolder.icon.setImageDrawable(uiUtilities.getIcon(fileSubtype.getIconId(), activeColorRes)); + itemHolder.title.setText(ColorsPaletteUtils.getPaletteName(file)); + itemHolder.subTitle.setText(ColorsPaletteUtils.getPaletteTypeName(app, file)); } else if (fileSubtype.isMap() || fileSubtype == FileSubtype.TTS_VOICE || fileSubtype == FileSubtype.VOICE) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java index 734c1f7443f..2e97bba29a1 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java @@ -33,6 +33,7 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.SimpleDividerItem; import net.osmand.plus.download.SrtmDownloadItem; import net.osmand.plus.avoidroads.AvoidRoadInfo; +import net.osmand.plus.helpers.ColorsPaletteUtils; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.mapmarkers.ItineraryType; @@ -429,6 +430,10 @@ private void setupBottomSheetItemForFile(BottomSheetItemWithCompoundButton item, item.setDescription(AndroidUtils.formatSize(app, file.length())); } else if (fileSubtype == FileSubtype.FAVORITES_BACKUP) { item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_folder_favorites, getItemIconColor(item.getTag()))); + } else if (fileSubtype == FileSubtype.COLOR_PALETTE) { + item.setTitle(ColorsPaletteUtils.getPaletteName(file)); + item.setDescription(ColorsPaletteUtils.getPaletteTypeName(app, file)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_file_color_palette, getItemIconColor(item.getTag()))); } else if (fileSubtype.isMap() || fileSubtype == FileSettingsItem.FileSubtype.TTS_VOICE || fileSubtype == FileSettingsItem.FileSubtype.VOICE) { From 17f5b78b70724a0f3a5ab3c42502e724ceee26a7 Mon Sep 17 00:00:00 2001 From: Corwin-Kh Date: Tue, 11 Jun 2024 11:47:19 +0300 Subject: [PATCH 03/24] #2547: Implemented 3h animation; fixes after review --- .../plugins/weather/WeatherRasterLayer.java | 4 +-- .../dialogs/WeatherForecastFragment.java | 27 ++++++++++++------- .../plus/utils/AndroidNetworkUtils.java | 3 +++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java b/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java index d3308c58add..37884d8c815 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java +++ b/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java @@ -80,8 +80,8 @@ public long getDateTime() { } public void prepareForDayAnimation(long dateTime) { - timePeriodStart = OsmAndFormatter.getStartOfDayForTime(dateTime); - timePeriodEnd = timePeriodStart + DAY_IN_MILLISECONDS; + timePeriodStart = dateTime; + timePeriodEnd = timePeriodStart + 3 * HOUR_IN_MILLISECONDS; timePeriodStep = 30 * MINUTE_IN_MILLISECONDS; requireTimePeriodChange = true; this.dateTime = dateTime; diff --git a/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java b/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java index 4e6f65f3539..74b0658553d 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java +++ b/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java @@ -97,6 +97,7 @@ public class WeatherForecastFragment extends BaseOsmAndFragment { private boolean isAnimatingForecast; private ImageButton playForecastBtn; private int currentStep; + private int animateStepCount; @Override public int getStatusBarColorId() { @@ -196,8 +197,15 @@ private void updatePlayForecastButton() { private void onPlayForecastClicked() { isAnimatingForecast = !isAnimatingForecast; if (isAnimatingForecast) { - plugin.prepareForDayAnimation(new Date(System.currentTimeMillis())); + Calendar calendar = getDefaultCalendar(); + calendar.setTime(selectedDate.getTime()); + int hour = (int) timeSlider.getValue(); + calendar.set(Calendar.HOUR_OF_DAY, hour); + calendar.set(Calendar.MINUTE, (int) ((timeSlider.getValue() - (float) hour) * 60.0f)); + plugin.prepareForDayAnimation(calendar.getTime()); requireMapActivity().refreshMap(); + currentStep = (int) (timeSlider.getValue() / timeSlider.getStepSize()) + 1; + animateStepCount = (int) (3.0 / timeSlider.getStepSize()) - 1; showProgressBar(true); scheduleAnimationStart(); } else { @@ -208,15 +216,17 @@ private void onPlayForecastClicked() { private void moveToNextForecastFrame() { animateForecastHandler.removeCallbacksAndMessages(null); - if (currentStep + 1 > getStepsCount()) { - currentStep = 0; + if (currentStep + 1 > getStepsCount() || animateStepCount <= 0) { + isAnimatingForecast = false; + updatePlayForecastButton(); } else { currentStep++; - } - float newValue = timeSlider.getValueFrom() + currentStep * timeSlider.getStepSize(); - timeSlider.setValue(newValue); - if (isAnimatingForecast) { - animateForecastHandler.postDelayed(this::moveToNextForecastFrame, ANIM_DELAY_MILLIS); + animateStepCount--; + float newValue = timeSlider.getValueFrom() + currentStep * timeSlider.getStepSize(); + timeSlider.setValue(newValue); + if (isAnimatingForecast) { + animateForecastHandler.postDelayed(this::moveToNextForecastFrame, ANIM_DELAY_MILLIS); + } } } @@ -533,7 +543,6 @@ private void scheduleAnimationStart() { progressUpdateHandler.removeCallbacksAndMessages(null); progressUpdateHandler.postDelayed(() -> { showProgressBar(false); - currentStep = (int) (timeSlider.getValue() / timeSlider.getStepSize()); moveToNextForecastFrame(); }, WAIT_FOR_NEW_DOWNLOAD_START_DELAY); } diff --git a/OsmAnd/src/net/osmand/plus/utils/AndroidNetworkUtils.java b/OsmAnd/src/net/osmand/plus/utils/AndroidNetworkUtils.java index cf834e9d4f6..5a6651bf9de 100644 --- a/OsmAnd/src/net/osmand/plus/utils/AndroidNetworkUtils.java +++ b/OsmAnd/src/net/osmand/plus/utils/AndroidNetworkUtils.java @@ -632,6 +632,9 @@ public static long downloadModifiedFile( } connection.connect(); if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { + if (progress != null) { + progress.finishTask(); + } return result; } else { long lastModified = connection.getLastModified(); From 535eb14963d5f5445295eba56f182f58a5807442 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 11 Jun 2024 13:04:05 +0300 Subject: [PATCH 04/24] Quick Fix "Key Assignment loses keycodes without confirm" --- .../fragments/editassignment/EditKeyAssignmentController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/keyevent/fragments/editassignment/EditKeyAssignmentController.java b/OsmAnd/src/net/osmand/plus/keyevent/fragments/editassignment/EditKeyAssignmentController.java index 94daa417798..2021c11bdef 100644 --- a/OsmAnd/src/net/osmand/plus/keyevent/fragments/editassignment/EditKeyAssignmentController.java +++ b/OsmAnd/src/net/osmand/plus/keyevent/fragments/editassignment/EditKeyAssignmentController.java @@ -251,7 +251,7 @@ public void enterEditMode() { initialBundle = new EditingBundle(); if (assignment != null) { editBundle.action = assignment.getAction(); - editBundle.keyCodes = assignment.getKeyCodes(); + editBundle.keyCodes = new ArrayList<>(assignment.getKeyCodes()); initialBundle.action = editBundle.action; initialBundle.keyCodes = new ArrayList<>(editBundle.keyCodes); } From 8e868297806333519a158b982ff9d72576b98050 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 11 Jun 2024 13:35:17 +0300 Subject: [PATCH 05/24] Sort "Colors Palette" files by type name, than by file name --- .../exporttype/ColorPaletteExportType.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ColorPaletteExportType.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ColorPaletteExportType.java index b7ffac8b894..d9aee188100 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ColorPaletteExportType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/exporttype/ColorPaletteExportType.java @@ -1,8 +1,13 @@ package net.osmand.plus.settings.backend.backup.exporttype; +import static net.osmand.plus.helpers.ColorsPaletteUtils.getPaletteName; +import static net.osmand.plus.helpers.ColorsPaletteUtils.getPaletteTypeName; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import net.osmand.Collator; +import net.osmand.OsmAndCollator; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.download.local.LocalItemType; @@ -13,6 +18,7 @@ import net.osmand.plus.settings.backend.backup.items.FileSettingsItem.FileSubtype; import net.osmand.plus.settings.backend.backup.items.SettingsItem; +import java.io.File; import java.util.Collections; import java.util.List; @@ -31,7 +37,7 @@ public int getIconId() { @NonNull @Override public List fetchExportData(@NonNull OsmandApplication app, boolean offlineBackup) { - return collectLocalResources(app); + return collectSortedLocalResource(app); } @NonNull @@ -41,6 +47,21 @@ public List fetchImportData(@NonNull SettingsItem settingsItem, boolean impor return Collections.singletonList(fileSettingsItem); } + @NonNull + private List collectSortedLocalResource(@NonNull OsmandApplication app) { + List files = collectLocalResources(app); + sortLocalFiles(app, files); + return files; + } + + private void sortLocalFiles(@NonNull OsmandApplication app, @NonNull List files) { + Collator collator = OsmAndCollator.primaryCollator(); + files.sort((lhs, rhs) -> { + int r = collator.compare(getPaletteTypeName(app, lhs), getPaletteTypeName(app, rhs)); + return r == 0 ? collator.compare(getPaletteName(lhs), getPaletteName(rhs)) : r; + }); + } + @NonNull @Override public ExportCategory getRelatedExportCategory() { From 8d82ed16c068f8d10e4b0e34630440eb7ebaf302 Mon Sep 17 00:00:00 2001 From: Flex16 Date: Tue, 11 Jun 2024 11:22:58 +0000 Subject: [PATCH 06/24] Translated using Weblate (German) Currently translated at 99.9% (5118 of 5120 strings) --- OsmAnd/res/values-de/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 2ba0d8e7a24..48d1ce554c8 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -633,7 +633,7 @@ Danke, dass Sie OsmAnd verwenden. Laden Sie regionale Daten für die Offline-Verwendung über „Menü → Karten herunterladen“ herunter, um Landkarten anzusehen, Adressen, POIs und öffentliche Verkehrsmittel zu finden. Auf Signal warten … Suche in der Nähe - Suche um Aufenthaltsort + In der Nähe suchen Wie Standardeinstellung Hochformat Querformat From e453021429a1e5a455c6ffd474af3714aaf1c2a9 Mon Sep 17 00:00:00 2001 From: Flex16 Date: Tue, 11 Jun 2024 10:44:59 +0000 Subject: [PATCH 07/24] Translated using Weblate (German) Currently translated at 100.0% (4867 of 4867 strings) --- OsmAnd/res/values-de/phrases.xml | 44 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/OsmAnd/res/values-de/phrases.xml b/OsmAnd/res/values-de/phrases.xml index ec19866a012..3454a9fc245 100644 --- a/OsmAnd/res/values-de/phrases.xml +++ b/OsmAnd/res/values-de/phrases.xml @@ -91,7 +91,7 @@ Kap Autoteile Autovermietung - Kfz-Werkstatt + Autowerkstatt Carsharing Autohändler Autowaschanlage @@ -227,7 +227,7 @@ Glaserei Golf Golfplatz - Regierung + Behörde Friedhof Gemüseladen Streugutbehälter @@ -727,7 +727,7 @@ Vietnamesisches Wiki Internetzugang: Terminal Internetzugang: Dienst - ja;Gebühr + Ja;Gebühr Marke Höchstgewicht Betreiber @@ -923,7 +923,7 @@ Facebook Handy nein - ja;Trinkwasser + Ja;Trinkwasser nein Beaufsichtigt Ohne Aufsicht @@ -1014,7 +1014,7 @@ Höhe Meereshöhe Anfangsdatum - ja;Rollstuhl + Ja;Rollstuhl nein eingeschränkt Großhandel @@ -1292,7 +1292,7 @@ Alternative Bezeichnung Manuell Keine Pumpe - ja;Pumpe + Ja;Pumpe Tafel Karte Büro @@ -1311,13 +1311,13 @@ Gewerbegebiet ja;Feuerstelle Keine Feuerstelle - ja;überdacht + Ja;überdacht Nicht überdacht Nicht erlaubt Nur draußen Erlaubt In einem separaten Raum - ja;Ampelsignalton + Ja;Ampelsignalton kein Signalton Rettungsstation Mini-Kreisverkehr @@ -1346,7 +1346,7 @@ Gartenstil: englisch Gartenstil: japanisch Kapazität - ja;Behindertenplätze + Ja;Behindertenplätze Keine Behindertenplätze Behindertenplätze Frauenplätze @@ -1362,7 +1362,7 @@ Durchschnittliche Fahrzeit, Minuten Mit Überdachung Ohne Überdachung - ja;beheizt + Ja;beheizt Keine Heizung Erlaubt Fahrrad: nicht erlaubt @@ -1412,19 +1412,19 @@ Diners Club-Karten nicht akzeptiert DKV DKV nicht akzeptiert - ja;Bedienung im Fahrzeug + Ja;Bedienung im Fahrzeug Bedienung im Fahrzeug: nein - ja;Drive-in + Ja;Drive-in Drive-in: nein Brauereiname - ja;Mikrobrauerei + Ja;Mikrobrauerei Keine Minibrauerei Zum Mitnehmen Nicht zum Mitnehmen Nur zum Mitnehmen - Lieferung + Lieferservice Kein Lieferservice - Nur Lieferung + Nur Lieferservice ja;Cocktails Händler Reparatur @@ -1600,7 +1600,7 @@ Maut Keine Maut Lkw-Maut - ja;Blindenleitsystem + Ja;Blindenleitsystem Ohne Blindenleitsystem Nur Freigabeton Raststätte @@ -2784,7 +2784,7 @@ Sitzplätze im Freien Gebühr Rauchen - Lieferung + Lieferservice Zum Mitnehmen Cocktails Kleinbrauerei @@ -2992,14 +2992,14 @@ Teriyaki Zahlungsart (Transport) ja;Sitzplätze im Freien - ja;Lieferung + Ja;Lieferservice Vegetarisch Vegan Glutenfrei Koscher Halal Laktosefrei - ja;zum Mitnehmen + Ja;zum Mitnehmen ja;Dusche Zielgruppe Druckluft @@ -3048,7 +3048,7 @@ Güterbahnhof Coworking Cafeteria - ja;Cafeteria + Ja;Cafeteria Wein: ja Wein: Einzelhandel Wein: Ausschank @@ -3527,7 +3527,7 @@ Naturdenkmal Orientierungspunkt Park-and-ride - ja;Parken und Reisen + Ja;Parken und Reisen Zug Bus U-Bahn @@ -3789,7 +3789,7 @@ Wasserstand: über dem mittleren Wasserstand Wasserstand: unter dem mittleren Wasserstand Hindernis - ja;Trinkwasser nachfüllen;nachfüllen + Ja;Trinkwasser nachfüllen;nachfüllen Trinkwassernachfüllung: nein Trinkwasser-Nachfüllnetzwerk Internetzugang: Kunden From 85599b15deae1207c9aea94960f38d86f691f0ce Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Tue, 11 Jun 2024 05:05:48 +0000 Subject: [PATCH 08/24] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (5120 of 5120 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 3f2aefb5083..a85d4154364 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -5721,4 +5721,17 @@ 播放天氣預報 旅遊話題 牆的高度 + 深橘色 + 將會移除所選類型的所有按鍵分配。 + + 分配按鍵 + 清除所有快捷鍵 + 選擇一個操作並透過點擊「新增」按鈕分配一個鍵。 + 分配新按鍵 + 新增動作 + 將會清除所選動作的按鍵分配。 + 沒有分配的按鍵 + 按鍵「%1$s」 + 新增鍵 + 動作圖示 \ No newline at end of file From 7542d5f966bc5456bfc72f6412728e3ae7c17a30 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Tue, 11 Jun 2024 05:05:25 +0000 Subject: [PATCH 09/24] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (4867 of 4867 strings) --- OsmAnd/res/values-zh-rTW/phrases.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-zh-rTW/phrases.xml b/OsmAnd/res/values-zh-rTW/phrases.xml index 15f2bb57c44..b6e4711443e 100644 --- a/OsmAnd/res/values-zh-rTW/phrases.xml +++ b/OsmAnd/res/values-zh-rTW/phrases.xml @@ -4866,4 +4866,5 @@ 沒有室內座位 室內座位:吧臺 物業管理辦公室 + 工程師辦公室 \ No newline at end of file From f55bf8b9c80a1f18090e32e330a5c29916540863 Mon Sep 17 00:00:00 2001 From: Corwin-Kh Date: Tue, 11 Jun 2024 14:33:12 +0300 Subject: [PATCH 10/24] #2547: Changed animation duretion, default time value --- .../net/osmand/plus/plugins/weather/WeatherRasterLayer.java | 3 ++- .../plugins/weather/dialogs/WeatherForecastFragment.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java b/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java index 37884d8c815..d6c1c3e9191 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java +++ b/OsmAnd/src/net/osmand/plus/plugins/weather/WeatherRasterLayer.java @@ -24,6 +24,7 @@ import java.util.List; public class WeatherRasterLayer extends BaseMapLayer { + public static final int FORECAST_ANIMATION_DURATION_HOURS = 6; private static final long MINUTE_IN_MILLISECONDS = 60 * 1000; private static final long HOUR_IN_MILLISECONDS = 60 * 60 * 1000; private static final long DAY_IN_MILLISECONDS = 24 * HOUR_IN_MILLISECONDS; @@ -81,7 +82,7 @@ public long getDateTime() { public void prepareForDayAnimation(long dateTime) { timePeriodStart = dateTime; - timePeriodEnd = timePeriodStart + 3 * HOUR_IN_MILLISECONDS; + timePeriodEnd = timePeriodStart + FORECAST_ANIMATION_DURATION_HOURS * HOUR_IN_MILLISECONDS; timePeriodStep = 30 * MINUTE_IN_MILLISECONDS; requireTimePeriodChange = true; this.dateTime = dateTime; diff --git a/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java b/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java index 74b0658553d..4a23ed44199 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java +++ b/OsmAnd/src/net/osmand/plus/plugins/weather/dialogs/WeatherForecastFragment.java @@ -39,6 +39,7 @@ import net.osmand.plus.plugins.weather.WeatherContour; import net.osmand.plus.plugins.weather.WeatherHelper; import net.osmand.plus.plugins.weather.WeatherPlugin; +import net.osmand.plus.plugins.weather.WeatherRasterLayer; import net.osmand.plus.plugins.weather.WeatherUtils; import net.osmand.plus.plugins.weather.widgets.WeatherWidgetsPanel; import net.osmand.plus.utils.AndroidUtils; @@ -205,7 +206,7 @@ private void onPlayForecastClicked() { plugin.prepareForDayAnimation(calendar.getTime()); requireMapActivity().refreshMap(); currentStep = (int) (timeSlider.getValue() / timeSlider.getStepSize()) + 1; - animateStepCount = (int) (3.0 / timeSlider.getStepSize()) - 1; + animateStepCount = (int) (WeatherRasterLayer.FORECAST_ANIMATION_DURATION_HOURS / timeSlider.getStepSize()) - 1; showProgressBar(true); scheduleAnimationStart(); } else { @@ -278,7 +279,7 @@ private LabelFormatter getLabelFormatter() { private void updateTimeSlider() { boolean today = OsmAndFormatter.isSameDay(selectedDate, currentDate); - timeSlider.setValue(today ? currentDate.get(Calendar.HOUR_OF_DAY) : 12); + timeSlider.setValue(today ? currentDate.get(Calendar.HOUR_OF_DAY) : 9); timeSlider.setStepSize(today ? 1.0f / 6.0f : 3.0f / 9.0f); // today ? 10 minutes : 20 minutes } From d28d5e38671ac4401a0dd2ac37e960fa34221990 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 11 Jun 2024 14:36:15 +0300 Subject: [PATCH 11/24] Fix missing dividers on the "Required Maps" screen --- ...th_descr_and_checkbox_and_divider_56dp.xml | 83 +++++++++++++++++++ .../plus/base/BaseOsmAndDialogFragment.java | 5 ++ .../RequiredMapsFragment.java | 12 ++- 3 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml new file mode 100644 index 00000000000..ea088bee69b --- /dev/null +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/src/net/osmand/plus/base/BaseOsmAndDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/BaseOsmAndDialogFragment.java index 4351755d42e..29eff5ce30f 100644 --- a/OsmAnd/src/net/osmand/plus/base/BaseOsmAndDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/BaseOsmAndDialogFragment.java @@ -51,6 +51,11 @@ protected boolean isUsedOnMap() { return false; } + @NonNull + protected View inflate(@LayoutRes int layoutRedId) { + return inflate(layoutRedId, null); + } + @NonNull protected View inflate(@LayoutRes int layoutResId, @Nullable ViewGroup root) { return inflate(layoutResId, root, false); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RequiredMapsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RequiredMapsFragment.java index 66ad0e6a7b5..042bca850ed 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RequiredMapsFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RequiredMapsFragment.java @@ -176,15 +176,18 @@ private void updateToolbarMenu() { private void setupItemsList() { ViewGroup container = view.findViewById(R.id.items_container); container.removeAllViews(); - for (DownloadItem downloadItem : controller.getMapsToDownload()) { - container.addView(createItemView(downloadItem)); + List items = controller.getMapsToDownload(); + for (int i = 0; i < items.size(); i++) { + DownloadItem downloadItem = items.get(i); + boolean showBottomDivider = i < items.size() - 1; + container.addView(createItemView(downloadItem, showBottomDivider)); } updateListSelection(); } @NonNull - private View createItemView(@NonNull DownloadItem downloadItem) { - View view = inflate(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp, null); + private View createItemView(@NonNull DownloadItem downloadItem, boolean showBottomDivider) { + View view = inflate(R.layout.bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp); ImageView icon = view.findViewById(R.id.icon); boolean downloaded = downloadItem.isDownloaded(); icon.setImageResource(downloaded ? R.drawable.ic_action_map_update : R.drawable.ic_action_map_download); @@ -212,6 +215,7 @@ private View createItemView(@NonNull DownloadItem downloadItem) { updateSelection(); }); view.setTag(downloadItem); + updateVisibility(view.findViewById(R.id.divider_bottom), showBottomDivider); return view; } From 872ec12f301a77e992d05c88ef095589983fa7b9 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 11 Jun 2024 16:34:31 +0300 Subject: [PATCH 12/24] Fix missing dividers on the "Required Maps" screen v2 --- ...heet_item_with_descr_and_checkbox_56dp.xml | 49 +-------------- ...th_descr_and_checkbox_and_divider_56dp.xml | 60 ++----------------- ...m_with_descr_and_checkbox_content_56dp.xml | 50 ++++++++++++++++ 3 files changed, 57 insertions(+), 102 deletions(-) create mode 100644 OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_content_56dp.xml diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_56dp.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_56dp.xml index f4698e70dc9..2771385fa31 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_56dp.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_56dp.xml @@ -5,60 +5,17 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" - android:gravity="center_vertical" - android:paddingLeft="@dimen/content_padding" - android:paddingRight="@dimen/content_padding" - android:paddingEnd="@dimen/content_padding" - android:paddingStart="@dimen/content_padding" - android:paddingTop="@dimen/context_menu_padding_margin_medium" - android:paddingBottom="@dimen/context_menu_padding_margin_medium"> + android:gravity="center_vertical"> - - - - - - - - + diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml index ea088bee69b..4102fa31f66 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml @@ -1,6 +1,5 @@ - + tools:src="@drawable/list_destination" /> - + - - - - - - - - - - - - + diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_content_56dp.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_content_56dp.xml new file mode 100644 index 00000000000..2c7a8b2a555 --- /dev/null +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_content_56dp.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + \ No newline at end of file From 3d62be6ddf02959d9a2b5b73548b23b843f04d78 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 11 Jun 2024 16:43:33 +0300 Subject: [PATCH 13/24] Small fix --- ...om_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml index 4102fa31f66..6b99f254af7 100644 --- a/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml +++ b/OsmAnd/res/layout/bottom_sheet_item_with_descr_and_checkbox_and_divider_56dp.xml @@ -24,7 +24,9 @@ - + From 9c9f274a4e4cfcfa4fc8fcc9337ea3f73002ef4e Mon Sep 17 00:00:00 2001 From: vshcherb Date: Tue, 11 Jun 2024 17:11:03 +0300 Subject: [PATCH 14/24] Update bundled_assets.xml --- OsmAnd/assets/bundled_assets.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/assets/bundled_assets.xml b/OsmAnd/assets/bundled_assets.xml index 62bcb74e1d3..6542d6d471a 100644 --- a/OsmAnd/assets/bundled_assets.xml +++ b/OsmAnd/assets/bundled_assets.xml @@ -124,6 +124,7 @@ + From 844d97e82c193ec631d92a6dfb240868fc6f2c01 Mon Sep 17 00:00:00 2001 From: chumv Date: Tue, 11 Jun 2024 18:04:38 +0300 Subject: [PATCH 15/24] Fix #19776 --- .../net/osmand/plus/download/DownloadActivity.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 170f1bab2e9..c9dd7b7cc0a 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -75,6 +75,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo public static final String REGION_TO_SEARCH = "search_region"; + private static final boolean SUGGEST_TO_DOWNLOAD_BASEMAP = false; private static boolean SUGGESTED_TO_DOWNLOAD_BASEMAP; private OsmandApplication app; @@ -387,13 +388,13 @@ private void showDownloadWorldMapIfNeeded() { if (downloadThread.getCurrentDownloadingItem() == null) { return; } - IndexItem worldMap = downloadThread.getIndexes().getWorldBaseMapItem(); - // (!worldMap.isDownloaded() || worldMap.isOutdated()) - now suggest to download if downloaded - if (!SUGGESTED_TO_DOWNLOAD_BASEMAP && worldMap != null && worldMap.isDownloaded() - && worldMap.isOutdated() && !downloadThread.isDownloading(worldMap)) { + IndexItem item = downloadThread.getIndexes().getWorldBaseMapItem(); + if (SUGGEST_TO_DOWNLOAD_BASEMAP && !SUGGESTED_TO_DOWNLOAD_BASEMAP && item != null + && item.isDownloaded() && item.isOutdated() && !downloadThread.isDownloading(item)) { SUGGESTED_TO_DOWNLOAD_BASEMAP = true; + AskMapDownloadFragment fragment = new AskMapDownloadFragment(); - fragment.setIndexItem(worldMap); + fragment.setIndexItem(item); fragment.show(getSupportFragmentManager(), AskMapDownloadFragment.TAG); } } From 665319d2b9694dad454c12c4f347d48ff4a56956 Mon Sep 17 00:00:00 2001 From: Simona Iacob Date: Tue, 11 Jun 2024 14:43:17 +0000 Subject: [PATCH 16/24] Translated using Weblate (Romanian) Currently translated at 99.8% (5112 of 5122 strings) --- OsmAnd/res/values-ro/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/res/values-ro/strings.xml b/OsmAnd/res/values-ro/strings.xml index 9f6cba52e2d..e09fa69c88d 100644 --- a/OsmAnd/res/values-ro/strings.xml +++ b/OsmAnd/res/values-ro/strings.xml @@ -5734,4 +5734,9 @@ Evită piatra cubică Înălțime fixă Înălțime perete + Atribuirea tastelor pentru acțiunea selectată va fi ștearsă. + Paleta utilizatorului + Toate asignările de taste pentru tipul selectat vor fi eliminate. + Culori + Portocaliu închis \ No newline at end of file From 608b9f7c527df86cdf1af49727cb8d1daef742f0 Mon Sep 17 00:00:00 2001 From: 99 efi Date: Tue, 11 Jun 2024 15:16:39 +0000 Subject: [PATCH 17/24] Translated using Weblate (Hungarian) Currently translated at 100.0% (5122 of 5122 strings) --- OsmAnd/res/values-hu/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index 706f05d3bfa..f30f5bfdbe1 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -5742,4 +5742,6 @@ A kiválasztott művelethez tartozó billentyű-hozzárendelés törlődik. Billentyű hozzáadása Műveletikon + Színek + Felhasználói paletta \ No newline at end of file From 2f356174045b7e2f9cb3989298dc41497b996c77 Mon Sep 17 00:00:00 2001 From: gallegonovato Date: Tue, 11 Jun 2024 14:31:04 +0000 Subject: [PATCH 18/24] Translated using Weblate (Spanish) Currently translated at 100.0% (5122 of 5122 strings) --- OsmAnd/res/values-es/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-es/strings.xml b/OsmAnd/res/values-es/strings.xml index be563e87f49..3d2435397d8 100644 --- a/OsmAnd/res/values-es/strings.xml +++ b/OsmAnd/res/values-es/strings.xml @@ -2812,7 +2812,7 @@ Trazas mostradas Hora del día En %1$s - Giro a giro + Navegación paso a paso Tipos de caminos Bajar en Esperar en la parada @@ -5745,4 +5745,6 @@ Tecla «%1$s» Icono con la acción Teclas asignadas + Colores + Paleta del usuario \ No newline at end of file From 4550c820badb05fd959a33a2b047c16a5683694e Mon Sep 17 00:00:00 2001 From: ERYpTION Date: Tue, 11 Jun 2024 13:12:49 +0000 Subject: [PATCH 19/24] Translated using Weblate (Danish) Currently translated at 100.0% (5122 of 5122 strings) --- OsmAnd/res/values-da/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index f624e67c66b..3cb23602518 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -5749,4 +5749,6 @@ Vælg en handling, og tildel en tast ved at trykke på knappen \'Tilføj\'. Ingen tildelte taster Tast + Brugerpalet + Farver \ No newline at end of file From 28c72374c8e4132bd6b06aa5da5f8d6d952e3857 Mon Sep 17 00:00:00 2001 From: D M Date: Tue, 11 Jun 2024 14:07:13 +0000 Subject: [PATCH 20/24] Translated using Weblate (Serbian) Currently translated at 100.0% (5122 of 5122 strings) --- OsmAnd/res/values-sr/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-sr/strings.xml b/OsmAnd/res/values-sr/strings.xml index f065d8002c3..7759161fb4a 100644 --- a/OsmAnd/res/values-sr/strings.xml +++ b/OsmAnd/res/values-sr/strings.xml @@ -2865,7 +2865,7 @@ Неодређено Доба дана До %1$s - Корак-по-корак + Скретање-по-скретање Врсте путева Излаз на Замени @@ -5741,4 +5741,6 @@ Додај акцију Додељења тастера Додај икону + Корисничка палета + Боје \ No newline at end of file From 2f1d2c549ef9d778cea16883d8bc1739c81b8cc8 Mon Sep 17 00:00:00 2001 From: Flex16 Date: Tue, 11 Jun 2024 15:32:40 +0000 Subject: [PATCH 21/24] Translated using Weblate (German) Currently translated at 100.0% (4867 of 4867 strings) --- OsmAnd/res/values-de/phrases.xml | 152 +++++++++++++++---------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/OsmAnd/res/values-de/phrases.xml b/OsmAnd/res/values-de/phrases.xml index 3454a9fc245..13dc179a0f7 100644 --- a/OsmAnd/res/values-de/phrases.xml +++ b/OsmAnd/res/values-de/phrases.xml @@ -922,9 +922,9 @@ Fax Facebook Handy - nein + Nein Ja;Trinkwasser - nein + Nein Beaufsichtigt Ohne Aufsicht Mit Ampeln @@ -951,7 +951,7 @@ Tierischer Abfall Überwachungsstation ja;saisonal - nein + Nein Trockenzeit Regenzeit Container @@ -1015,7 +1015,7 @@ Meereshöhe Anfangsdatum Ja;Rollstuhl - nein + Nein eingeschränkt Großhandel Inhalt: Silage @@ -1166,7 +1166,7 @@ Orthopädisch Offenes Feuer erlaubt Offenes Feuer verboten - ja;Waschmaschine + Ja;Waschmaschine Waschmaschine: nein Dusche: ja Dusche: nein @@ -1174,9 +1174,9 @@ Dusche: im Freien Dusche: kalt Dusche: drinnen - ja;Wohnwagen + Ja;Wohnwagen Wohnwagen: nein - ja;Stromversorgung + Ja;Stromversorgung Stromanschluss: nein Sockel: CEE 17 blau Sockel: CEE 7/4 @@ -1432,7 +1432,7 @@ ja;automatisiert Nicht automatisiert Bürstenlos: nein - nein + Nein;Autowaschanlage: Nein Männlich Für Männer verboten Weiblich @@ -1617,7 +1617,7 @@ Tourenski Schneemobil Skaten - nein + Nein Buckel Gartentyp: Hausgarten Gartentyp: Gemeinschaftsgarten @@ -2094,9 +2094,9 @@ Solarium Erlaubt Zelten nicht gestattet - ja;Hinterland - nein - ja;Pfadfinder + Ja;Hinterland + Nein + Ja;Pfadfinder Pfadfinderlager: nein Nur Gruppen: ja Nur Gruppen: nein @@ -2418,10 +2418,10 @@ Explosion: Einheit Religiöse Waren Baumschule - ja;Druckluft + Ja;Druckluft Druckluft: nein - ja;Autowäsche - ja;Staubsauger + Ja;Autowäsche + Ja;Staubsauger Staubsauger: nein Staubsauger Freies Fliegen (Sport) @@ -2577,7 +2577,7 @@ Beratung: nein Notaufnahme: ja Notaufnahme: nein - ja;Hausbesuch + Ja;Hausbesuch Hausbesuch: nein Ebola: nein Autismus: nein @@ -2670,7 +2670,7 @@ Bahnübergangsüberwachung: keine Bahnübergangsüberwachung: Bediensteter Bahnübergangsüberwachung: Kamera - ja;nach Rezept + Ja;nach Rezept Nach Rezept: nein Pumpstation Anzeige: ja @@ -2714,8 +2714,8 @@ Aquakultur: Garnelen Aquakultur: Fisch Aquakultur: Muscheln - ja;Bio - nein + Ja;Bio + Nein ausschließlich;nur Bio Konsulat Ständige Vertretung @@ -2742,7 +2742,7 @@ Kraftstoffsorte Zahlungsart Zusätzlich - Ladestation: ja;Fahrradladestation;E-Bike-Ladestation + Ladestation: Ja;Fahrradladestation;E-Bike-Ladestation Ladestation: nein Geschäft für Kunsthandwerksbedarf Kraftstoffart (Flugzeuge) @@ -3000,7 +3000,7 @@ Halal Laktosefrei Ja;zum Mitnehmen - ja;Dusche + Ja;Dusche Zielgruppe Druckluft Staubsauger @@ -3138,7 +3138,7 @@ Erforderlich Empfohlen ja - nein + Nein Nur für Mitglieder Mietboote Bootsvermietung @@ -3288,7 +3288,7 @@ Roller: nein Lkw: nein ja - nein + Nein Parkgebühr Stromstärke Lage: oben @@ -3493,7 +3493,7 @@ Schuhreparatur Verpackungsfreie Waren Art - ja;verpackungsfreie Waren + Ja;verpackungsfreie Waren ausschließlich;nur verpackungsfreie Waren Umspannwerk Verteiler @@ -3555,7 +3555,7 @@ Strahlentherapie Kletterfelsen Selbsthilfebox - ja;Kletterfelsen + Ja;Kletterfelsen Reddit Gefahr: Erosion Gefahr: Steinschlag @@ -3565,7 +3565,7 @@ Gefahr: Minenfeld Gefahr: Kontamination Standort - ja;Wickeltisch: ja + Ja;Wickeltisch: Ja nein;Wickeltisch: nein begrenzt;Wickeltisch: begrenzt Wickeltischposition: Raum @@ -3599,7 +3599,7 @@ Zufahrt Fahrzeuge: militärisch Zufahrt Fahrzeuge: Lieferung Zufahrt Fahrzeuge: Forstwirtschaft - ja;Pkw + Ja;Pkw Zufahrt Pkw: privat Zufahrt Pkw: nein Zufahrt Pkw: für Anlieger @@ -3664,33 +3664,33 @@ Zufahrt Taxi: ausgewiesen Zufahrt Taxi: nein Behindertengerechter Zugang: nein - ja;Schneemobil + Ja;Schneemobil ausgewiesen;ausgewiesen für Schneemobile gestattet;Zugang für Schneemobile gestattet - ja;Bus;Busse + Ja;Bus;Busse Ausgewiesen;Ausgewiesen für Busse - ja;Wohnwagen + Ja;Wohnwagen ausgewiesen;ausgewiesen für Wohnwagen - ja;Wohnmobil + Ja;Wohnmobil ausgewiesen;für Wohnmobile ausgewiesen - ja;Anhänger + Ja;Anhänger ausgewiesen;ausgewiesen für Anhänger - ja;Motorrad + Ja;Motorrad gestattet;Zugang für Motorräder gestattet Anlieger frei;Zugang für Motorräder als Anlieger frei ausgewiesen;für Motorräder ausgewiesen - ja;Moped + Ja;Moped ausgewiesen;ausgewiesen für Mopeds - ja;Mofa + Ja;Mofa ausgewiesen;ausgewiesen für Mofas - ja;Lkw;Laster;Lastwagen + Ja;Lkw;Laster;Lastwagen Anlieger frei;Zugang für Lkw als Anlieger frei gestattet;Zugang für Lkw gestattet ausgewiesen;für Lkw ausgewiesen Lieferung;Zufahrt für Lieferwagen - ja;Zufahrt für leichte Nutzfahrzeuge + Ja;Zufahrt für leichte Nutzfahrzeuge ausgewiesen;Zufahrt für leichte Nutzfahrzeuge ausgewiesen - ja;Behinderte + Ja;Behinderte Ausgewiesen;Ausgewiesener Zugang für Behinderte Kellereingang Gesundes Essen @@ -3729,8 +3729,8 @@ Fluss See Fußbad - ja;Freibad - nein + Ja;Freibad + Nein Klostertyp: Mönche Klostertyp: Einsiedelei Freibad @@ -3769,10 +3769,10 @@ Tauchzentrum SMS Video - ja;SMS - nein - ja;Video - nein + Ja;SMS + Nein + Ja;Video + Nein Nur Pilotton Farblich abgesetzt Fehlerhaft @@ -3799,8 +3799,8 @@ Rohr Druck Pumpenzustand: fehlender Arm - ja;Pfeil in Gangrichtung - ja;Ampelvibration + Ja;Pfeil in Gangrichtung + Ja;Ampelvibration kein Vibrieren Pfeil in Gangrichtung Vibrieren @@ -3811,7 +3811,7 @@ Flugplan;Abflugtafel Echtzeit;Abflugtafel Verspätung;Abflugtafel - ja;Abflugtafel + Ja;Abflugtafel Anzeige der Abreisezeiten: nein Pfeil in Gangrichtung: nein Anzeige der Abreisezeiten @@ -3825,11 +3825,11 @@ Dachparkplätze GPX-Wegpunkt Radarturm - nein + Nein ja - nein + Nein ja - nein + Nein ja Subnationales Büro Repräsentanzbüro @@ -3969,7 +3969,7 @@ Webcam LinkedIn Sitzplätze im Freien - ja;Keine Authentifizierung + Ja;Keine Authentifizierung Authentifizierung nicht erforderlich: nein Zur Authentifizierung verwendeter SMS Text Zur Authentifizierung verwendete SMS Nummer @@ -4000,7 +4000,7 @@ Erlaubt für Autos Allgemeiner Zugang Ziel - ja;Unterstand + Ja;Unterstand Unterstand: nein Liegestuhl Richtung Südwesten @@ -4012,8 +4012,8 @@ Richtung Osten Richtung Norden ausschließlich;nur Dauercamping - nein - ja;Dauercamping + Nein + Ja;Dauercamping Unterstand Dauerstellplätze Felsbogen @@ -4039,13 +4039,13 @@ Lamm Schwein Halal - ja;Kaffee - nein - ja;Speiseeis + Ja;Kaffee + Nein + Ja;Speiseeis Herkunft - ja;Tabak - ja;Mitgliedschaft - nein + Ja;Tabak + Ja;Mitgliedschaft + Nein Diabetikerbedarf Orthopädiebedarf Orthesen @@ -4088,8 +4088,8 @@ Generatortyp: kalte Fusion Gebraucht;Gebrauchte Möbel Büro;Büromöbel - ja;Fleurop - nein + Ja;Fleurop + Nein Sofa;Möbel Kategorie des Sanitätsbedarfs Landwirtschaftliche Betriebsmittel @@ -4102,7 +4102,7 @@ Behandlungen der ästhetischen Medizin Massage Pediküre - ja;Landhandel + Ja;Landhandel Schädlingsbekämpfungsmittel Dünger Saatgut @@ -4165,15 +4165,15 @@ Generatortyp: Nickel-Cadmium-Akku Generatortyp: Redox-Flow-Batterie Generatortyp: Thermalbatterie - ja;Matratze + Ja;Matratze Wohnzimmer;Wohnzimmermöbel Küche;Küchenmöbel Schlafzimmer;Schlafzimmermöbel - ja;Möbel - nein + Ja;Möbel + Nein Bett;Möbel - ja;Heizung - nein + Ja;Heizung + Nein Feuerstelle LGBTQ: primär LGBTQ: ausschließlich @@ -4182,8 +4182,8 @@ Fernwärme Gas Heizkörper - ja;Kühlschrank - nein + Ja;Kühlschrank + Nein Fumarole Kunst Biologie @@ -4208,15 +4208,15 @@ LGBTQ: nein Computerteile Vegan: eingeschränkt - ja;Computerverkauf + Ja;Computerverkauf Computerverkauf Computerreparatur Computerverkauf: nein Computerreparatur: nein - ja;Computerteile + Ja;Computerteile Computerteile: nein gebraucht;gebrauchte Computer - ja;Computerreparatur + Ja;Computerreparatur Thema des Museums Art Kunst @@ -4315,9 +4315,9 @@ Taubenschlag Fischtreppe ja - nein + Nein ja - nein + Nein Termitenhügel Ameisenhügel Wildtiere @@ -4403,7 +4403,7 @@ Schwierigste Route (französischer Grad) Anfänger Sächsischer Klettergrad - nein + Nein Anker Klettergestein: Sandstein Klettergestein: Konglomerat From 7c84ec634b3940a73e2fdc2b4ccbbf49770e84d2 Mon Sep 17 00:00:00 2001 From: D M Date: Tue, 11 Jun 2024 14:09:15 +0000 Subject: [PATCH 22/24] Translated using Weblate (Serbian (latin)) Currently translated at 100.0% (5122 of 5122 strings) --- OsmAnd/res/values-b+sr+Latn/strings.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-b+sr+Latn/strings.xml b/OsmAnd/res/values-b+sr+Latn/strings.xml index f67e4e8216e..502aa4697e3 100644 --- a/OsmAnd/res/values-b+sr+Latn/strings.xml +++ b/OsmAnd/res/values-b+sr+Latn/strings.xml @@ -3802,7 +3802,7 @@ Ukrcavanje na stanici Izlaz na Vrste puteva - Manevri + Skretanje-po-skretanje Do %1$s Doba dana Javni prevoz OsmAnd Live @@ -5750,4 +5750,6 @@ Dodaj akciju Dodaj ikonu Dodeljenja tastera + Korisnička paleta + Boje \ No newline at end of file From e15713a68755385fcdff75d733533eb65b185878 Mon Sep 17 00:00:00 2001 From: Cosmin Date: Tue, 11 Jun 2024 15:49:07 +0000 Subject: [PATCH 23/24] Translated using Weblate (Romanian) Currently translated at 99.8% (5112 of 5122 strings) --- OsmAnd/res/values-ro/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-ro/strings.xml b/OsmAnd/res/values-ro/strings.xml index e09fa69c88d..784ae40a8d8 100644 --- a/OsmAnd/res/values-ro/strings.xml +++ b/OsmAnd/res/values-ro/strings.xml @@ -5734,7 +5734,7 @@ Evită piatra cubică Înălțime fixă Înălțime perete - Atribuirea tastelor pentru acțiunea selectată va fi ștearsă. + Asignarea tastelor pentru acțiunea selectată va fi ștearsă. Paleta utilizatorului Toate asignările de taste pentru tipul selectat vor fi eliminate. Culori From 7dcd0e5e9837b250282ca3dcc1d307e6c83f5405 Mon Sep 17 00:00:00 2001 From: chumv Date: Tue, 11 Jun 2024 22:28:36 +0300 Subject: [PATCH 24/24] Fix #19942 --- .../dialogs/SplitSegmentDialogFragment.java | 184 +++++++----------- 1 file changed, 73 insertions(+), 111 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/tracks/dialogs/SplitSegmentDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/tracks/dialogs/SplitSegmentDialogFragment.java index cc4e8bf73b3..78e8dc1362e 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/tracks/dialogs/SplitSegmentDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/tracks/dialogs/SplitSegmentDialogFragment.java @@ -1,12 +1,12 @@ package net.osmand.plus.myplaces.tracks.dialogs; import static net.osmand.plus.track.helpers.GpxDisplayGroup.getTrackDisplayGroup; +import static net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItemType.TRACK_SEGMENT; import android.app.Dialog; import android.content.res.ColorStateList; import android.graphics.Paint; import android.graphics.Rect; -import android.graphics.drawable.Drawable; import android.os.Bundle; import android.util.DisplayMetrics; import android.view.Gravity; @@ -22,20 +22,16 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.ListPopupWindow; import androidx.appcompat.widget.Toolbar; -import androidx.fragment.app.DialogFragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import net.osmand.gpx.GPXFile; import net.osmand.gpx.GPXTrackAnalysis; -import net.osmand.gpx.GPXUtilities; import net.osmand.gpx.GPXUtilities.TrkSegment; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.base.BaseOsmAndDialogFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.track.GpxSelectionParams; @@ -51,7 +47,6 @@ import net.osmand.plus.utils.AndroidUtils; import net.osmand.plus.utils.ColorUtilities; import net.osmand.plus.utils.OsmAndFormatter; -import net.osmand.plus.utils.UiUtilities; import net.osmand.util.Algorithms; import java.text.DateFormat; @@ -62,77 +57,53 @@ import gnu.trove.list.array.TIntArrayList; -public class SplitSegmentDialogFragment extends DialogFragment { +public class SplitSegmentDialogFragment extends BaseOsmAndDialogFragment { public static final String TAG = "SPLIT_SEGMENT_DIALOG_FRAGMENT"; - private OsmandApplication app; private TrackDisplayHelper displayHelper; - private SplitSegmentsAdapter adapter; - private View headerView; - - private GpxDisplayItem gpxItem; - private final GpxDisplayItemType[] filterTypes = {GpxDisplayItemType.TRACK_SEGMENT}; - private GPXUtilities.TrkSegment trkSegment; + private TrkSegment segment; + private GpxDisplayItem item; private final List options = new ArrayList<>(); private final List distanceSplit = new ArrayList<>(); private final TIntArrayList timeSplit = new TIntArrayList(); - private int selectedSplitInterval; - private UiUtilities ic; - private int minMaxSpeedLayoutWidth; - private Paint minMaxSpeedPaint; - private Rect minMaxSpeedTextBounds; + private final GpxDisplayItemType[] filterTypes = {TRACK_SEGMENT}; + + private final Paint minMaxSpeedPaint = new Paint(); + private final Rect minMaxSpeedTextBounds = new Rect(); + + private View headerView; private ListView listView; private ProgressBar progressBar; + private SplitSegmentsAdapter adapter; + + private int selectedSplitInterval; + private int minMaxSpeedLayoutWidth; private boolean joinSegments; @Override - public void onCreate(@Nullable Bundle savedInstanceState) { + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (displayHelper == null || gpxItem == null || trkSegment == null) { + minMaxSpeedPaint.setTextSize(getResources().getDimension(R.dimen.default_split_segments_data)); + minMaxSpeedPaint.setTypeface(FontCache.getFont(getContext(), "ui-fonts/Roboto-Medium.ttf")); + minMaxSpeedPaint.setStyle(Paint.Style.FILL); + + if (shouldDismiss()) { dismiss(); - return; } - FragmentActivity activity = requireActivity(); - app = (OsmandApplication) activity.getApplication(); - ic = app.getUIUtilities(); - boolean isLightTheme = app.getSettings().isLightContent(); - int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme; - setStyle(STYLE_NO_FRAME, themeId); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - boolean nightMode = !app.getSettings().isLightContent(); - listView.setBackgroundColor(ColorUtilities.getActivityBgColor(app, nightMode)); } @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - minMaxSpeedPaint = new Paint(); - minMaxSpeedPaint.setTextSize(getResources().getDimension(R.dimen.default_split_segments_data)); - minMaxSpeedPaint.setTypeface(FontCache.getFont(getContext(), "ui-fonts/Roboto-Medium.ttf")); - minMaxSpeedPaint.setStyle(Paint.Style.FILL); - minMaxSpeedTextBounds = new Rect(); - - AppCompatActivity trackActivity = (AppCompatActivity) getActivity(); - View view = trackActivity.getLayoutInflater().inflate(R.layout.split_segments_layout, container, false); + View view = themedInflater.inflate(R.layout.split_segments_layout, container, false); Toolbar toolbar = view.findViewById(R.id.split_interval_toolbar); - TextView titleTextView = toolbar.findViewById(R.id.title); - boolean nightMode = !app.getSettings().isLightContent(); - titleTextView.setTextAppearance(nightMode ? - R.style.TextAppearance_AppCompat_Widget_ActionBar_Title : - R.style.Widget_Styled_LightActionBarTitle); - ActionBar trackActivityActionBar = trackActivity.getSupportActionBar(); - if (trackActivityActionBar != null) { - titleTextView.setText(trackActivityActionBar.getTitle()); - } - Drawable icBack = ic.getIcon(AndroidUtils.getNavigationIconResId(app)); - toolbar.setNavigationIcon(icBack); + TextView title = toolbar.findViewById(R.id.title); + title.setTextAppearance(nightMode ? R.style.TextAppearance_AppCompat_Widget_ActionBar_Title : R.style.Widget_Styled_LightActionBarTitle); + + toolbar.setNavigationIcon(getIcon(AndroidUtils.getNavigationIconResId(app))); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); toolbar.setNavigationOnClickListener(v -> { dismiss(); @@ -141,15 +112,18 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, progressBar = view.findViewById(R.id.progress_bar); listView = view.findViewById(R.id.list); + listView.setBackgroundColor(ColorUtilities.getActivityBgColor(app, nightMode)); listView.setDivider(null); listView.setDividerHeight(0); - adapter = new SplitSegmentsAdapter(new ArrayList()); + adapter = new SplitSegmentsAdapter(new ArrayList<>()); headerView = view.findViewById(R.id.header_layout); - ((ImageView) headerView.findViewById(R.id.header_split_image)).setImageDrawable(ic.getIcon(R.drawable.ic_action_split_interval, app.getSettings().isLightContent() ? R.color.icon_color_default_light : 0)); - listView.addHeaderView(trackActivity.getLayoutInflater().inflate(R.layout.gpx_split_segments_empty_header, null, false)); - listView.addFooterView(trackActivity.getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false)); + ImageView splitImage = headerView.findViewById(R.id.header_split_image); + splitImage.setImageDrawable(getIcon(R.drawable.ic_action_split_interval, nightMode ? 0 : R.color.icon_color_default_light)); + + listView.addHeaderView(themedInflater.inflate(R.layout.gpx_split_segments_empty_header, listView, false)); + listView.addFooterView(themedInflater.inflate(R.layout.list_shadow_footer, listView, false)); listView.setOnScrollListener(new AbsListView.OnScrollListener() { int previousYPos = -1; @@ -183,7 +157,6 @@ public void onScroll(AbsListView absListView, int i, int i1, int i2) { } } }); - listView.setAdapter(adapter); return view; @@ -204,18 +177,6 @@ public void onDestroyView() { super.onDestroyView(); } - public void setGpxItem(GpxDisplayItem gpxItem) { - this.gpxItem = gpxItem; - } - - public void setTrkSegment(GPXUtilities.TrkSegment trkSegment) { - this.trkSegment = trkSegment; - } - - public void setJoinSegments(boolean joinSegments) { - this.joinSegments = joinSegments; - } - private void updateHeader() { View splitIntervalView = headerView.findViewById(R.id.split_interval_view); @@ -255,13 +216,13 @@ private void updateHeader() { } public void updateContent() { - if (getActivity() != null) { + if (isAdded() && !shouldDismiss()) { adapter.clear(); adapter.setNotifyOnChange(false); - adapter.add(gpxItem); - List splitSegments = getSplitSegments(); - adapter.addAll(splitSegments); + adapter.add(item); + adapter.addAll(getSplitSegments()); adapter.notifyDataSetChanged(); + listView.setSelection(0); headerView.setTranslationY(0); updateHeader(); @@ -321,7 +282,7 @@ private void setupSplitIntervalView(@NonNull View view) { String titleText = getString(R.string.gpx_split_interval); title.setText(getString(R.string.ltr_or_rtl_combine_via_colon, titleText, "")); text.setTextColor(color); - img.setImageDrawable(ic.getIcon(R.drawable.ic_action_arrow_drop_down, colorId)); + img.setImageDrawable(getIcon(R.drawable.ic_action_arrow_drop_down, colorId)); } private void updateSplitIntervalView(View view) { @@ -407,7 +368,7 @@ private void addOptionSplit(int value, boolean distance, List m private List getSplitSegments() { List splitSegments = new ArrayList<>(); List result = displayHelper.getGpxFile(true); - if (result != null && result.size() > 0 && trkSegment.points.size() > 0) { + if (result != null && result.size() > 0 && segment.points.size() > 0) { for (GpxDisplayGroup group : result) { TrackDisplayGroup trackGroup = getTrackDisplayGroup(group); if (trackGroup != null) { @@ -420,16 +381,16 @@ private List getSplitSegments() { private List collectDisplayItemsFromGroup(@NonNull TrackDisplayGroup group) { List splitSegments = new ArrayList<>(); - boolean generalTrack = gpxItem.isGeneralTrack(); + boolean generalTrack = item.isGeneralTrack(); boolean generalGroup = group.isGeneralTrack(); if ((group.isSplitDistance() || group.isSplitTime()) && (!generalGroup && !generalTrack || generalGroup && generalTrack)) { boolean itemsForSelectedSegment = false; for (GpxDisplayItem item : group.getDisplayItems()) { - itemsForSelectedSegment = trkSegment.points.get(0).equals(item.locationStart) || itemsForSelectedSegment; + itemsForSelectedSegment = segment.points.get(0).equals(item.locationStart) || itemsForSelectedSegment; if (itemsForSelectedSegment) { splitSegments.add(item); } - if (trkSegment.points.get(trkSegment.points.size() - 1).equals(item.locationEnd)) { + if (segment.points.get(segment.points.size() - 1).equals(item.locationEnd)) { break; } } @@ -437,7 +398,7 @@ private List collectDisplayItemsFromGroup(@NonNull TrackDisplayG return splitSegments; } - protected boolean hasFilterType(GpxDisplayItemType filterType) { + private boolean hasFilterType(GpxDisplayItemType filterType) { for (GpxDisplayItemType type : filterTypes) { if (type == filterType) { return true; @@ -446,14 +407,18 @@ protected boolean hasFilterType(GpxDisplayItemType filterType) { return false; } + private boolean shouldDismiss() { + return displayHelper == null || item == null || segment == null; + } + private class SplitSegmentsAdapter extends ArrayAdapter { - SplitSegmentsAdapter(List items) { + private ColorStateList defaultTextColor; + + SplitSegmentsAdapter(@NonNull List items) { super(requireActivity(), 0, items); } - ColorStateList defaultTextColor; - @NonNull @Override public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { @@ -472,7 +437,7 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup TextView overviewTextView = convertView.findViewById(R.id.overview_text); ImageView overviewImageView = convertView.findViewById(R.id.overview_image); if (position == 0) { - overviewImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_time_span_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + overviewImageView.setImageDrawable(getIcon(R.drawable.ic_action_time_span_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); if (defaultTextColor == null) { defaultTextColor = overviewTextView.getTextColors(); } @@ -492,7 +457,7 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup if (currentGpxDisplayItem != null && currentGpxDisplayItem.analysis != null) { overviewTextView.setTextColor(app.getColor(activeColorId)); if (trackGroup != null && trackGroup.isSplitDistance()) { - overviewImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_track_16, activeColorId)); + overviewImageView.setImageDrawable(getIcon(R.drawable.ic_action_track_16, activeColorId)); overviewTextView.setText(""); double metricStart = currentGpxDisplayItem.analysis.metricEnd - currentGpxDisplayItem.analysis.getTotalDistance(); overviewTextView.append(OsmAndFormatter.getFormattedDistance((float) metricStart, app)); @@ -500,9 +465,9 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup overviewTextView.append(OsmAndFormatter.getFormattedDistance((float) currentGpxDisplayItem.analysis.metricEnd, app)); overviewTextView.append(" (" + currentGpxDisplayItem.analysis.getPoints() + ")"); } else if (trackGroup != null && trackGroup.isSplitTime()) { - overviewImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_time_span_16, activeColorId)); + overviewImageView.setImageDrawable(getIcon(R.drawable.ic_action_time_span_16, activeColorId)); overviewTextView.setText(""); - double metricStart = currentGpxDisplayItem.analysis.metricEnd - (currentGpxDisplayItem.analysis.getTimeSpan() / 1000); + double metricStart = currentGpxDisplayItem.analysis.metricEnd - (currentGpxDisplayItem.analysis.getTimeSpan() / 1000f); overviewTextView.append(OsmAndFormatter.getFormattedDuration((int) metricStart, app)); overviewTextView.append(" - "); overviewTextView.append(OsmAndFormatter.getFormattedDuration((int) currentGpxDisplayItem.analysis.metricEnd, app)); @@ -513,21 +478,21 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup } ((ImageView) convertView.findViewById(R.id.start_time_image)) - .setImageDrawable(ic.getIcon(R.drawable.ic_action_time_start_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + .setImageDrawable(getIcon(R.drawable.ic_action_time_start_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); ((ImageView) convertView.findViewById(R.id.end_time_image)) - .setImageDrawable(ic.getIcon(R.drawable.ic_action_time_end_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + .setImageDrawable(getIcon(R.drawable.ic_action_time_end_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); ((ImageView) convertView.findViewById(R.id.average_altitude_image)) - .setImageDrawable(ic.getIcon(R.drawable.ic_action_altitude_average_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + .setImageDrawable(getIcon(R.drawable.ic_action_altitude_average_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); ((ImageView) convertView.findViewById(R.id.altitude_range_image)) - .setImageDrawable(ic.getIcon(R.drawable.ic_action_altitude_range_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + .setImageDrawable(getIcon(R.drawable.ic_action_altitude_range_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); ((ImageView) convertView.findViewById(R.id.ascent_descent_image)) - .setImageDrawable(ic.getIcon(R.drawable.ic_action_altitude_descent_ascent_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + .setImageDrawable(getIcon(R.drawable.ic_action_altitude_descent_ascent_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); ((ImageView) convertView.findViewById(R.id.moving_time_image)) - .setImageDrawable(ic.getIcon(R.drawable.ic_action_time_moving_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + .setImageDrawable(getIcon(R.drawable.ic_action_time_moving_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); ((ImageView) convertView.findViewById(R.id.average_speed_image)) - .setImageDrawable(ic.getIcon(R.drawable.ic_action_speed_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + .setImageDrawable(getIcon(R.drawable.ic_action_speed_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); ((ImageView) convertView.findViewById(R.id.max_speed_image)) - .setImageDrawable(ic.getIcon(R.drawable.ic_action_max_speed_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + .setImageDrawable(getIcon(R.drawable.ic_action_max_speed_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); if (currentGpxDisplayItem != null) { GPXTrackAnalysis analysis = currentGpxDisplayItem.analysis; @@ -536,13 +501,13 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup TextView distanceOrTimeSpanValue = convertView.findViewById(R.id.distance_or_time_span_value); TextView distanceOrTimeSpanText = convertView.findViewById(R.id.distance_or_time_span_text); if (position == 0) { - distanceOrTimeSpanImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_track_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); - float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.getTotalDistance(); + distanceOrTimeSpanImageView.setImageDrawable(getIcon(R.drawable.ic_action_track_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + float totalDistance = !joinSegments && item.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.getTotalDistance(); distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDistance(totalDistance, app)); distanceOrTimeSpanText.setText(app.getString(R.string.distance)); } else { if (trackGroup != null && trackGroup.isSplitDistance()) { - distanceOrTimeSpanImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_time_span_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + distanceOrTimeSpanImageView.setImageDrawable(getIcon(R.drawable.ic_action_time_span_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); if (analysis.getDurationInMs() > 0) { distanceOrTimeSpanValue.setText(Algorithms.formatDuration(analysis.getDurationInSeconds(), app.accessibilityEnabled())); } else { @@ -550,7 +515,7 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup } distanceOrTimeSpanText.setText(app.getString(R.string.shared_string_time_span)); } else if (trackGroup != null && trackGroup.isSplitTime()) { - distanceOrTimeSpanImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_track_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); + distanceOrTimeSpanImageView.setImageDrawable(getIcon(R.drawable.ic_action_track_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0)); distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDistance(analysis.getTotalDistance(), app)); distanceOrTimeSpanText.setText(app.getString(R.string.distance)); } @@ -716,18 +681,15 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup } } - public static boolean showInstance(@NonNull FragmentManager fragmentManager, @NonNull TrackDisplayHelper displayHelper, - @NonNull GpxDisplayItem gpxItem, @NonNull TrkSegment trkSegment) { - try { + public static void showInstance(@NonNull FragmentManager manager, @NonNull TrackDisplayHelper helper, + @NonNull GpxDisplayItem item, @NonNull TrkSegment segment) { + if (AndroidUtils.isFragmentCanBeAdded(manager, TAG)) { SplitSegmentDialogFragment fragment = new SplitSegmentDialogFragment(); - fragment.setGpxItem(gpxItem); - fragment.setTrkSegment(trkSegment); + fragment.item = item; + fragment.segment = segment; + fragment.displayHelper = helper; fragment.setRetainInstance(true); - fragment.displayHelper = displayHelper; - fragment.show(fragmentManager, TAG); - return true; - } catch (RuntimeException e) { - return false; + fragment.show(manager, TAG); } } }