Skip to content

Commit

Permalink
Merge branch 'master' into rzr-click
Browse files Browse the repository at this point in the history
  • Loading branch information
RZR-UA committed Dec 3, 2024
2 parents ffca910 + b333085 commit 32a836c
Show file tree
Hide file tree
Showing 26 changed files with 3,393 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class TrackFolderLoaderTask(

if (file.isDirectory()) {
val subfolder = TrackFolder(file, folder)
subfolder.dirItem = GpxDbHelper.getGpxDirItem(file)
launch {
log.info("Loading track subfolder = $subfolder")
scanFolder(subfolder, progress, trackItems)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.osmand.shared.gpx.data

import net.osmand.shared.gpx.GpxDirItem
import net.osmand.shared.gpx.GpxHelper
import net.osmand.shared.gpx.TrackItem
import net.osmand.shared.gpx.filters.TrackFolderAnalysis
Expand All @@ -17,6 +18,7 @@ class TrackFolder(dirFile: KFile, parentFolder: TrackFolder?) :
private var flattenedSubFolders: List<TrackFolder>? = null
private var folderAnalysis: TrackFolderAnalysis? = null
private var lastModified: Long = -1
var dirItem: GpxDirItem? = null

init {
this.dirFile = dirFile
Expand Down
2 changes: 1 addition & 1 deletion OsmAnd/res/values-de/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
<string name="poi_craft_photographic_laboratory">Fotolabor</string>
<string name="poi_physiotherapist">Physiotherapeut</string>
<string name="poi_picnic_site">Picknickplatz</string>
<string name="poi_pier">Hafendamm</string>
<string name="poi_pier">Pier</string>
<string name="poi_pitch">Sportplatz</string>
<string name="poi_place_allotments">Kleingartensiedlung</string>
<string name="poi_place_farm">Farm</string>
Expand Down
101 changes: 11 additions & 90 deletions OsmAnd/res/values-eo/strings.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions OsmAnd/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5616,10 +5616,10 @@
<string name="percent_hour">%/h</string>
<string name="obd_fuel_consumption_rate_percent_hour_desc">Affiche la consommation de carburant du véhicule basée sur des calculs (%/h)</string>
<string name="l_100km">l/100km</string>
<string name="obd_fuel_consumption_rate_l_km_desc">Affiche la consommation de carburant du véhicule basée sur des calculs (l/km)</string>
<string name="obd_fuel_consumption_rate_l_km_desc">Affiche la consommation de carburant du véhicule basée sur des calculs (L/100 km)</string>
<string name="kpa_unit">kPa</string>
<string name="simulate_obd">Simuler des données OBD</string>
<string name="obd_fuel_consumption_rate_l_km">Consommation de carburant (l/km)</string>
<string name="obd_fuel_consumption_rate_l_km">Consommation de carburant (L/100 km)</string>
<string name="obd_engine_runtime_desc">Affiche la durée de fonctionnement du moteur du véhicule à partir du scanneur OBD.</string>
<string name="obd_throttle_position_desc">Affiche la pression de carburant du véhicule (pression de gauge) à partir du scanner obd</string>
<string name="obd_throttle_position">Position de l\'accélérateur</string>
Expand Down
3,234 changes: 3,227 additions & 7 deletions OsmAnd/res/values-ga/strings.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion OsmAnd/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5972,7 +5972,7 @@
<string name="obd_fuel_level_percent">Tingkat bahan bakar (%)</string>
<string name="obd_fuel_left_km">Bahan bakar tersisa (km)</string>
<string name="obd_fuel_consumption_rate_scanner">Tingkat konsumsi bahan bakar (obd)</string>
<string name="obd_fuel_consumption_rate_liter_hour">Tingkat konsumsi bahan bakar L/j</string>
<string name="obd_fuel_consumption_rate_liter_hour">Tingkat konsumsi bahan bakar</string>
<string name="obd_fuel_consumption_rate_percent_hour">Tingkat konsumsi bahan bakar %/j</string>
<string name="route_guidance_desc">Menyediakan panduan rute waktu nyata, termasuk jarak belokan berikutnya, nama jalan, nama jalan saat ini, dan informasi jalur. Widget aktif selama navigasi.</string>
<string name="obd_nothing_found_text">Tidak ada pemindai yang ditemukan</string>
Expand Down
11 changes: 11 additions & 0 deletions OsmAnd/res/values-nb/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1952,4 +1952,15 @@
<string name="poi_cash_in_customers">Kunder</string>
<string name="poi_diet_pescetarian_no">Pesco-vegetarisk: nei</string>
<string name="poi_waste_accepted">Akseptert avfall</string>
<string name="poi_route_track_point">Andre rutepunkter</string>
<string name="poi_activities_bicycle">Sykling</string>
<string name="poi_activities_pedestrian">Gåing</string>
<string name="poi_route_track">Andre ruter</string>
<string name="poi_activities_skiing">Vintersport</string>
<string name="poi_osmand_foot_prohibited_tunnel">Tunnel forbudt for fotgjengere</string>
<string name="poi_osmand_bicycle_prohibited_tunnel">Tunnel forbudt for syklister</string>
<string name="poi_activities_mountain_bike">Terrengsykling</string>
<string name="poi_activities_kayak">Vannsport</string>
<string name="poi_activities_running">Løping</string>
<string name="poi_activities_trekking">Fotturer</string>
</resources>
7 changes: 7 additions & 0 deletions OsmAnd/res/values-ro/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5915,4 +5915,11 @@
<string name="reset_average_value">Resetarea valorii medii</string>
<string name="average_temperature_slider_description">Selectați intervalul de timp pentru măsurarea temperaturii medii.</string>
<string name="current_temperature">Temperatura actuală</string>
<string name="shared_string_instant">Instantanee</string>
<string name="average_temperature">Temperatura medie instantanee</string>
<string name="show_minor_turns_descr">Benzile de circulație vor fi afișate în toate intersecțiile de trecere, indiferent de instrucțiunile vocale</string>
<string name="fuel_tank_capacity">Capacitatea rezervorului de combustibil</string>
<string name="shared_strings_dimensions">Dimensiuni</string>
<string name="litres">Litri</string>
<string name="us_gallons_unit">galon</string>
</resources>
3 changes: 3 additions & 0 deletions OsmAnd/res/values-sk/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4509,4 +4509,7 @@
<string name="poi_cash_in_yes">Áno</string>
<string name="poi_cash_in_no">Nie</string>
<string name="poi_diet_pescetarian_no">Pescetariánska diéta (z mäsa len ryby): nie</string>
<string name="poi_name_etymology">Pôvod názvu</string>
<string name="poi_name_left">Názov ľavej strany</string>
<string name="poi_name_right">Názov pravej strany</string>
</resources>
11 changes: 9 additions & 2 deletions OsmAnd/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5517,7 +5517,7 @@
<string name="no_photos_available">Nie sú dostupné žiadne fotografie</string>
<string name="percent_unit">%</string>
<string name="obd_plugin_name">Merania vozidla</string>
<string name="obd_plugin_description">Sledujte kľúčové parametre vozidla pomocou protokolu OBD-II. Získajte údaje vrátane: * Rýchlosť otáčok * Spotreba paliva * Zostávajúce palivo * Vzdialednosť od naštartovania motora * Teplota nasávania * Teplota okolia * Teplota chladiacej kvapaliny * Rýchlosť vozidla * Percento batérie</string>
<string name="obd_plugin_description">Sledujte kľúčové parametre vozidla pomocou protokolu OBD-II. Získajte údaje vrátane:\n • Rýchlosť otáčok, Čas behu motora, Vypočítaná záťaž motora\n • Spotreba paliva, Tlak v palive, Zostávajúce palivo\n • Teplota nasávania, Teplota okolia, Teplota chladiacej kvapaliny, Teplota motorového oleja\n • Rýchlosť vozidla, Pozícia škrtiacej klapky, Napätie batérie\n</string>
<string name="vehicle_metrics_plugin_settings">Nastavenia Meraní vozidla</string>
<string name="obd_support">Podpora OBD</string>
<string name="offline_wikivoyage">Offline Wikivoyage</string>
Expand Down Expand Up @@ -5553,7 +5553,7 @@
<string name="obd_fuel_consumption_rate_percent_hour_desc">Zobrazuje rýchlosť spotreby paliva podľa výpočtov (%/h)</string>
<string name="obd_fuel_pressure">Tlak paliva</string>
<string name="obd_fuel_level_percent">Úroveň paliva (%)</string>
<string name="obd_fuel_consumption_rate_liter_hour">Spotreba paliva l/h</string>
<string name="obd_fuel_consumption_rate_liter_hour">Rýchlosť spotreby paliva</string>
<string name="obd_fuel_consumption_rate_percent_hour">Spotreba paliva %/h</string>
<string name="obd_fuel_type">Typ paliva</string>
<string name="speedometer_maximum">Maximum</string>
Expand Down Expand Up @@ -5621,4 +5621,11 @@
<string name="obd_engine_coolant_temp">Teplota chladiacej kvapaliny</string>
<string name="obd_engine_runtime_desc">Zobrazuje ako dlho motor beží od jeho naštartovania.</string>
<string name="obd_engine_oil_temperature_desc">Zobrazuje teplotu motorového oleja.</string>
<string name="av_audio_sample_rate">Vzorkovacia frekvencia zvuku</string>
<string name="auto_zoom_3d_angle">Uhol automatického 3D priblíženia</string>
<string name="shared_string_engine">Motor</string>
<string name="vehicle_metrics_recording_description">Vyberte parametre, ktoré sa majú zaznamenať do súboru GPX.</string>
<string name="av_audio_sample_rate_descr">Zvoľte vzorkovaciu frekvenciu zvuku.</string>
<string name="connect_new_scanner">Pripojiť nový snímač</string>
<string name="preview_next_turn">Zobraziť nasledujúce odbočenie</string>
</resources>
2 changes: 1 addition & 1 deletion OsmAnd/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5340,7 +5340,7 @@
<string name="help_article_navigation_routing_car_based_routing_name">Автомаршрути (вантажівки, мотоцикли)</string>
<string name="help_article_navigation_routing_online_routing_name">Онлайн-маршрутизація</string>
<string name="help_article_map_map_context_menu_name">Контекстне меню мапи</string>
<string name="help_article_navigation_car_play_name">Автомобільні ігри</string>
<string name="help_article_navigation_car_play_name">CarPlay</string>
<string name="help_article_navigation_guidance_map_during_navigation_name">Екран мапи під час навігації</string>
<string name="help_article_navigation_routing_name">Параметри маршруту</string>
<string name="help_article_navigation_routing_osmand_routing_name">Про маршрутизацію OsmAnd</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class TrackSortModesHelper {

private static final String ROOT_FOLDER = IndexConstants.GPX_INDEX_DIR;
private static final String ROOT_FOLDER_ID = "";
private static final String SEPARATOR = ",,";

private final Map<String, TracksSortMode> cachedSortModes = new ConcurrentHashMap<>();
Expand All @@ -34,27 +34,29 @@ public TrackSortModesHelper(@NonNull OsmandApplication app) {

@NonNull
public TracksSortMode getRootFolderSortMode() {
return requireSortMode("");
return requireSortMode(ROOT_FOLDER_ID);
}

@NonNull
public TracksSortMode requireSortMode(@Nullable String id) {
TracksSortMode sortMode = getSortMode(id);
TracksSortMode sortMode = id != null ? getSortMode(id) : null;
return sortMode != null ? sortMode : TracksSortMode.getDefaultSortMode();
}

@Nullable
public TracksSortMode getSortMode(@Nullable String id) {
public TracksSortMode getSortMode(@NonNull String id) {
id = removeExtraFileSeparator(id);
return cachedSortModes.get(id);
}

public void setSortMode(@NonNull String id, @NonNull TracksSortMode sortMode) {
public void setSortMode(@NonNull String id, @Nullable TracksSortMode sortMode) {
id = removeExtraFileSeparator(id);
cachedSortModes.put(id, sortMode);
}

public void setSortModes(@NonNull Map<String, TracksSortMode> sortModes) {
// The extra file separator is not checked here to avoid redundant validations.
// It should be handled in the methods that call this one.
cachedSortModes.clear();
cachedSortModes.putAll(sortModes);
}
Expand All @@ -69,7 +71,7 @@ public void updateAfterMoveTrackFolder(@NonNull TrackFolder trackFolder, @NonNul
}

public void updateAfterDeleteTrackFolder(@NonNull TrackFolder trackFolder) {
cachedSortModes.remove(trackFolder.getId());
setSortMode(trackFolder.getId(), null);
syncSettings();
}

Expand All @@ -83,7 +85,8 @@ private void loadFromPreference(@NonNull OsmandApplication app) {
for (String token : tokens) {
String[] tokenParts = token.split(SEPARATOR);
if (tokenParts.length == 2) {
cachedSortModes.put(tokenParts[0], TracksSortMode.getByValue(tokenParts[1]));
String id = removeExtraFileSeparator(tokenParts[0]);
cachedSortModes.put(id, TracksSortMode.getByValue(tokenParts[1]));
}
}
UpgradeTrackSortModeKeysAlgorithm.execute(app, this);
Expand All @@ -93,25 +96,33 @@ private void loadFromPreference(@NonNull OsmandApplication app) {
private void saveToPreference() {
List<String> tokens = new ArrayList<>();
for (Entry<String, TracksSortMode> entry : cachedSortModes.entrySet()) {
tokens.add(entry.getKey() + SEPARATOR + entry.getValue().name());
TracksSortMode value = entry.getValue();
if (value != null) {
tokens.add(entry.getKey() + SEPARATOR + value.name());
}
}
preference.setStringsList(tokens);
}

@NonNull
public static String getFolderId(@NonNull String absolutePath) {
int index = absolutePath.indexOf(ROOT_FOLDER);
String basePath = IndexConstants.GPX_INDEX_DIR;
int index = absolutePath.indexOf(basePath);
if (index > 0) {
index += ROOT_FOLDER.length();
index += basePath.length();
String relativePath = absolutePath.substring(index);
return removeExtraFileSeparator(relativePath);
} else if (absolutePath.endsWith(removeExtraFileSeparator(basePath))) {
return ROOT_FOLDER_ID;
}
return index > 0 ? absolutePath.substring(index) : absolutePath;
return absolutePath;
}

@Nullable
private static String removeExtraFileSeparator(@Nullable String id) {
@NonNull
private static String removeExtraFileSeparator(@NonNull String id) {
// Ensure consistency by removing trailing File.separator from relative paths
// before querying or saving to settings to avoid key mismatches.
if (id != null && id.endsWith(File.separator)) {
if (id.endsWith(File.separator)) {
return id.substring(0, id.length() - 1);
}
return id;
Expand Down
5 changes: 5 additions & 0 deletions OsmAnd/src/net/osmand/plus/configmap/tracks/TrackTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public int getDefaultOrder() {
return type.ordinal();
}

public boolean isBaseFolder() {
String id = getId();
return id.isEmpty();
}

@NonNull
public List<TrackItem> getTrackItems() {
List<TrackItem> trackItems = new ArrayList<>();
Expand Down
13 changes: 9 additions & 4 deletions OsmAnd/src/net/osmand/plus/configmap/tracks/TrackTabsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,21 @@ public void sortTrackTab(@NonNull TrackTab trackTab) {
}

public void loadTabsSortModes() {
TrackSortModesHelper sortModes = app.getTrackSortModesHelper();
for (Entry<String, TrackTab> entry : trackTabs.entrySet()) {
TracksSortMode sortMode = sortModes.getSortMode(entry.getKey());
TrackSortModesHelper sortModesHelper = app.getTrackSortModesHelper();
for (TrackTab trackTab : trackTabs.values()) {
TracksSortMode sortMode = sortModesHelper.getSortMode(trackTab.getId());
if (sortMode != null) {
TrackTab trackTab = entry.getValue();
trackTab.setSortMode(sortMode);
}
}
}

public void saveTabSortMode(@NonNull TrackTab trackTab) {
TrackSortModesHelper sortModesHelper = app.getTrackSortModesHelper();
sortModesHelper.setSortMode(trackTab.getId(), trackTab.getSortMode());
sortModesHelper.syncSettings();
}

public void saveTabsSortModes() {
TrackSortModesHelper sortModesHelper = app.getTrackSortModesHelper();
for (TrackTab trackTab : trackTabs.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager.SimpleOnPageChangeListener;

import net.osmand.IndexConstants;
import net.osmand.plus.shared.SharedUtil;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
Expand Down Expand Up @@ -191,11 +190,12 @@ private void showOptionsMenu(@NonNull View view) {
PopUpMenu.show(displayData);
}

protected void setTabs(@NonNull List<TrackTab> tabs) {
@Override
protected void setTabs(@NonNull List<TrackTab> tabs, int preselectedTabIndex) {
tabSize = tabs.size();
setViewPagerAdapter(viewPager, tabs);
tabLayout.setViewPager(viewPager);
viewPager.setCurrentItem(0);
viewPager.setCurrentItem(preselectedTabIndex);
viewPager.addOnPageChangeListener(new SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
Expand Down Expand Up @@ -317,7 +317,11 @@ public void setTracksSortMode(@NonNull TracksSortMode sortMode, boolean sortSubF
if (trackTab != null) {
trackTab.setSortMode(sortMode);
trackTabsHelper.sortTrackTab(trackTab);
trackTabsHelper.saveTabsSortModes();
trackTabsHelper.saveTabSortMode(trackTab);
// Update tabs order if sort mode changed for the "Tracks" base folder
if (trackTab.isBaseFolder()) {
setTabs(getSortedTrackTabs(), trackTab.getId());
}
updateTabsContent();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.osmand.plus.settings.enums.TracksSortMode;
import net.osmand.shared.gpx.GpxDataItem;
import net.osmand.shared.gpx.GpxDbHelper;
import net.osmand.shared.gpx.GpxDirItem;
import net.osmand.shared.gpx.SmartFolderHelper;
import net.osmand.shared.gpx.data.SmartFolder;
import net.osmand.shared.io.KFile;
Expand Down Expand Up @@ -57,7 +58,7 @@ private void executeImpl() {
putUpgradedKey(upgradedCache, TrackTabType.ON_MAP.name());
putUpgradedKey(upgradedCache, TrackTabType.ALL.name());
putUpgradedKey(upgradedCache, TrackTabType.FOLDERS.name());
for (String id : getDirIds()) {
for (String id : collectStandardDirectoriesIds()) {
putUpgradedKey(upgradedCache, id);
}
for (SmartFolder folder : smartFolderHelper.getSmartFolders()) {
Expand All @@ -68,20 +69,28 @@ private void executeImpl() {
}

@NonNull
private Set<String> getDirIds() {
Set<String> ids = new HashSet<>();
private Set<String> collectStandardDirectoriesIds() {
Set<String> result = new HashSet<>();
// add root directory
result.add("");
// collect all directories registered in tracks DB
Set<String> absolutePaths = new HashSet<>();
for (GpxDirItem item : gpxDbHelper.getDirItems()) {
KFile file = item.getFile();
absolutePaths.add(file.absolutePath());
}
// collect all subdirectories which contain at least one gpx track
for (GpxDataItem item : gpxDbHelper.getItems()) {
KFile file = item.getFile();
KFile dir = file.getParentFile();
if (dir != null) {
String path = dir.absolutePath();
if (!path.endsWith(File.separator)) {
path += File.separator;
}
ids.add(getFolderIdV2(path));
KFile directory = file.getParentFile();
if (directory != null) {
absolutePaths.add(directory.absolutePath());
}
}
return ids;
for (String absolutePath : absolutePaths) {
result.add(getFolderIdV2(absolutePath));
}
return result;
}

private void putUpgradedKey(@NonNull Map<String, TracksSortMode> map, @NonNull String id) {
Expand All @@ -91,6 +100,7 @@ private void putUpgradedKey(@NonNull Map<String, TracksSortMode> map, @NonNull S
}
}

@Nullable
private TracksSortMode getSortMode(@NonNull String id) {
TracksSortMode sortMode = sortModesHelper.getSortMode(id);
if (sortMode == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void requestNetworkLocationUpdates(@NonNull LocationCallback locationCall
for (String provider : providers) {
if (provider == null
|| provider.equals(LocationManager.GPS_PROVIDER)
|| provider.equals(LocationManager.PASSIVE_PROVIDER)
|| provider.equals(LocationManager.FUSED_PROVIDER)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public GmsLocationServiceHelper(@NonNull OsmandApplication app) {

fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(app);
fusedLocationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 100).build();
networkLocationRequest = new LocationRequestCompat.Builder(100).setQuality(LocationRequestCompat.QUALITY_HIGH_ACCURACY).build();
networkLocationRequest = new LocationRequestCompat.Builder(5000).setQuality(LocationRequestCompat.QUALITY_HIGH_ACCURACY).build();
fusedLocationCallback = new com.google.android.gms.location.LocationCallback() {
@Override
public void onLocationResult(@NonNull LocationResult locationResult) {
Expand Down
Loading

0 comments on commit 32a836c

Please sign in to comment.