Skip to content

Commit

Permalink
Merge branch 'osmandapp:master' into hardy_Afa
Browse files Browse the repository at this point in the history
  • Loading branch information
sonora authored Jun 12, 2024
2 parents 646da7b + 12a2902 commit e44ee20
Show file tree
Hide file tree
Showing 33 changed files with 311 additions and 252 deletions.
17 changes: 13 additions & 4 deletions OsmAnd-java/src/main/java/net/osmand/gpx/GPXUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class GPXUtilities {
public static final String PROFILE_TYPE_EXTENSION = "profile";
public static final String ADDRESS_EXTENSION = "address";
public static final String HIDDEN_EXTENSION = "hidden";
public static final String POINT_TYPE_EXTENSION = "point_type";

public static final String GPXTPX_PREFIX = "gpxtpx:";
public static final String OSMAND_EXTENSIONS_PREFIX = "osmand:";
Expand Down Expand Up @@ -210,7 +211,7 @@ public void removeExtensionsWriter(String key) {
getExtensionsWriters().remove(key);
}

public int getColor(int defColor) {
public Integer getColor(Integer defColor) {
String value = getColorValue();
return parseColor(value, defColor);
}
Expand Down Expand Up @@ -249,7 +250,7 @@ public void removeColor() {
}
}

public static int parseColor(String colorString, int defColor) {
public static Integer parseColor(String colorString, Integer defColor) {
Integer color = parseColor(colorString);
return color != null ? color : defColor;
}
Expand Down Expand Up @@ -435,8 +436,16 @@ public String getBackgroundType() {
return getExtensionsToRead().get(BACKGROUND_TYPE_EXTENSION);
}

public void setBackgroundType(String backType) {
getExtensionsToWrite().put(BACKGROUND_TYPE_EXTENSION, backType);
public void setBackgroundType(String type) {
getExtensionsToWrite().put(BACKGROUND_TYPE_EXTENSION, type);
}

public String getSpecialPointType() {
return getExtensionsToRead().get(POINT_TYPE_EXTENSION);
}

public void setSpecialPointType(String type) {
getExtensionsToWrite().put(POINT_TYPE_EXTENSION, type);
}

public String getProfileType() {
Expand Down
2 changes: 1 addition & 1 deletion OsmAnd-java/src/main/java/net/osmand/gpx/GpxParameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum GpxParameter {
AVG_SPEED("avgSpeed", "double", Double.class, 0d, true),
POINTS("points", "int", Integer.class, 0, true),
WPT_POINTS("wptPoints", "int", Integer.class, 0, true),
COLOR("color", "TEXT", Integer.class, 0, false),
COLOR("color", "TEXT", Integer.class, null, false),
FILE_LAST_MODIFIED_TIME("fileLastModifiedTime", "bigint", Long.class, 0L, false),
FILE_LAST_UPLOADED_TIME("fileLastUploadedTime", "bigint", Long.class, 0L, false),
FILE_CREATION_TIME("fileCreationTime", "bigint", Long.class, -1L, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ public static String uploadFile(String urlText, File fileToUpload, String userNa
return r.getBody();
}
return null;
} catch (InterruptedException e) {
log.error(e);
} catch (ExecutionException e) {
} catch (InterruptedException | ExecutionException e) {
log.error(e);
}
return null;
Expand Down
2 changes: 2 additions & 0 deletions OsmAnd/res/values-es-rAR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5760,4 +5760,6 @@
<string name="key_assignment_add_key">Añadir tecla</string>
<string name="assigned_keys">Teclas asignadas</string>
<string name="action_icon">Añadir icono</string>
<string name="user_palette">Paleta del usuario</string>
<string name="shared_string_colors">Colores</string>
</resources>
2 changes: 1 addition & 1 deletion OsmAnd/res/values-fr/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4229,7 +4229,7 @@
<string name="poi_board_type_sight">Vue</string>
<string name="poi_board_type_sport">Sport</string>
<string name="poi_board_type_welcome_sign">Panneau de bienvenue</string>
<string name="poi_tiles">Magasin de tuiles</string>
<string name="poi_tiles">Magasin de carrelage</string>
<string name="poi_collector">Collectionneur</string>
<string name="poi_hospice">Hospice</string>
<string name="poi_skate">Boutique de skate</string>
Expand Down
6 changes: 5 additions & 1 deletion OsmAnd/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2797,7 +2797,7 @@
<string name="run_full_osmand_header">Lanciare OsmAnd\?</string>
<string name="previous_route">Percorsi precedenti</string>
<string name="add_home">Aggiungi casa</string>
<string name="step_by_step">Svolta per svolta</string>
<string name="step_by_step">Svolta dopo svolta</string>
<string name="routeInfo_road_types_name">Tipi di strade</string>
<string name="show_more">Mostra di più</string>
<string name="tracks_on_map">Tracciati visualizzati</string>
Expand Down Expand Up @@ -5734,4 +5734,8 @@
<string name="assigned_keys">Tasti assegnati</string>
<string name="key_assignment_add_action">Aggiungi azione</string>
<string name="no_assigned_keys_desc">Seleziona un\'azione e assegna un tasto toccando il pulsante \"Aggiungi\".</string>
<string name="action_icon">Icona azione</string>
<string name="shared_string_colors">Colori</string>
<string name="user_palette">Tavolozza utente</string>
<string name="routing_attr_avoid_cobblestone_description">Evita il ciottolo</string>
</resources>
1 change: 1 addition & 0 deletions OsmAnd/res/values-ro/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4866,4 +4866,5 @@
<string name="poi_indoor_seating_no">Nu există locuri în interior</string>
<string name="poi_indoor_seating_bar_table">Locuri în interior: masă de bar</string>
<string name="poi_property_management">Birou de administrare proprietăți</string>
<string name="poi_engineer">Birou de inginer</string>
</resources>
12 changes: 11 additions & 1 deletion OsmAnd/res/values-ro/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5666,7 +5666,7 @@
<string name="change_default_appearance_confirmation">Schimbați aspectul implicit al lui %1$s?</string>
<string name="use_3d_track_visualization">Vizualizare 3D</string>
<string name="shared_string_changes">Modificări</string>
<string name="map_widget_map_scale">Scala hărții</string>
<string name="map_widget_map_scale">Scara hărții</string>
<string name="release_4_7">Noul widget \"Speedometru\" compatibil cu Android Auto
\n
\n • Configurați ecranul hărții prin adăugarea mai multor butoane \"Acțiuni rapide\"
Expand Down Expand Up @@ -5739,4 +5739,14 @@
<string name="clear_all_key_shortcuts_summary">Toate asignările de taste pentru tipul selectat vor fi eliminate.</string>
<string name="shared_string_colors">Culori</string>
<string name="rendering_value_dark_orange_name">Portocaliu închis</string>
<string name="action_icon">Pictograma de acțiune</string>
<string name="assigned_keys">Chei atribuite</string>
<string name="clear_all_key_shortcuts">Șterge toate scurtăturile de taste</string>
<string name="no_assigned_keys">Nicio tastă asignată</string>
<string name="no_assigned_keys_desc">Selectați o acțiune și asignați-i o tastă atingând butonul \'Adaugă\'.</string>
<string name="shared_string_key">Tastă</string>
<string name="key_assignment_add_action">Adaugă acțiune</string>
<string name="new_key_assignment">Asignare nouă de tastă</string>
<string name="key_name_pattern">Tasta \"%1$s\"</string>
<string name="key_assignment_add_key">Adaugă tastă</string>
</resources>
2 changes: 2 additions & 0 deletions OsmAnd/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5734,4 +5734,6 @@
<string name="key_name_pattern">按鍵「%1$s」</string>
<string name="key_assignment_add_key">新增鍵</string>
<string name="action_icon">動作圖示</string>
<string name="user_palette">使用者調色板</string>
<string name="shared_string_colors">顏色</string>
</resources>
20 changes: 16 additions & 4 deletions OsmAnd/src/net/osmand/data/FavouritePoint.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package net.osmand.data;

import static net.osmand.data.SpecialPointType.HOME;
import static net.osmand.data.SpecialPointType.WORK;
import static net.osmand.gpx.GPXUtilities.DEFAULT_ICON_NAME;
import static net.osmand.plus.mapmarkers.ItineraryDataHelper.CREATION_DATE;
import static net.osmand.plus.mapmarkers.ItineraryDataHelper.VISITED_DATE;
import static net.osmand.plus.myplaces.favorites.FavoriteGroup.PERSONAL_CATEGORY;

import android.content.Context;

Expand Down Expand Up @@ -100,7 +103,7 @@ public FavouritePoint(@NonNull FavouritePoint point) {
}

private void initPersonalType() {
if (FavoriteGroup.PERSONAL_CATEGORY.equals(category)) {
if (PERSONAL_CATEGORY.equals(category)) {
for (SpecialPointType pointType : SpecialPointType.values()) {
if (Algorithms.stringsEqual(pointType.getName(), this.name)) {
this.specialPointType = pointType;
Expand All @@ -109,12 +112,17 @@ private void initPersonalType() {
}
}

@Nullable
public SpecialPointType getSpecialPointType() {
return specialPointType;
}

public void setSpecialPointType(@Nullable SpecialPointType pointType) {
this.specialPointType = pointType;
}

public boolean isHomeOrWork() {
return specialPointType == SpecialPointType.HOME || specialPointType == SpecialPointType.WORK;
return specialPointType == HOME || specialPointType == WORK;
}

public int getColor() {
Expand Down Expand Up @@ -418,8 +426,9 @@ public static FavouritePoint fromWpt(@NonNull WptPt wptPt, @Nullable String cate
if (iconName != null) {
point.setIconIdFromName(iconName);
}
BackgroundType backgroundType = BackgroundType.getByTypeName(wptPt.getBackgroundType(), null);
point.setBackgroundType(backgroundType);
point.setSpecialPointType(SpecialPointType.getByName(wptPt.getSpecialPointType()));
point.setBackgroundType(BackgroundType.getByTypeName(wptPt.getBackgroundType(), null));

return point;
}

Expand Down Expand Up @@ -461,6 +470,9 @@ public WptPt toWpt(@NonNull Context ctx) {
if (backgroundType != null) {
point.setBackgroundType(backgroundType.getTypeName());
}
if (specialPointType != null) {
point.setSpecialPointType(specialPointType.getName());
}
if (getColor() != 0) {
point.setColor(getColor());
}
Expand Down
26 changes: 21 additions & 5 deletions OsmAnd/src/net/osmand/data/SpecialPointType.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package net.osmand.data;

import static net.osmand.plus.myplaces.favorites.FavoriteGroup.PERSONAL_CATEGORY;
import static net.osmand.plus.plugins.parking.ParkingPositionPlugin.PARKING_TYPE;

import android.content.Context;

import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.myplaces.favorites.FavoriteGroup;
import net.osmand.plus.plugins.parking.ParkingPositionPlugin;
import net.osmand.plus.settings.backend.preferences.BooleanPreference;
import net.osmand.plus.settings.backend.preferences.OsmandPreference;

Expand All @@ -31,27 +33,41 @@ public enum SpecialPointType {
this.iconId = iconId;
}

@NonNull
public String getName() {
return typeName;
}

@NonNull
public String getCategory() {
return FavoriteGroup.PERSONAL_CATEGORY;
return PERSONAL_CATEGORY;
}

@DrawableRes
public int getIconId(@NonNull Context ctx) {
if (this == PARKING) {
OsmandApplication app = (OsmandApplication) ctx.getApplicationContext();
OsmandPreference<?> parkingType = app.getSettings().getPreference(ParkingPositionPlugin.PARKING_TYPE);
if (parkingType instanceof BooleanPreference && ((BooleanPreference) parkingType).get()) {
OsmandPreference<?> preference = app.getSettings().getPreference(PARKING_TYPE);
if (preference instanceof BooleanPreference && ((BooleanPreference) preference).get()) {
return R.drawable.mx_special_parking_time_limited;
}
return iconId;
}
return iconId;
}

@NonNull
public String getHumanString(@NonNull Context ctx) {
return ctx.getString(resId);
}

@Nullable
public static SpecialPointType getByName(@NonNull String name) {
for (SpecialPointType type : values()) {
if (type.getName().equalsIgnoreCase(name)) {
return type;
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,17 @@
public class ColorsPaletteController implements IColorsPaletteController {

protected final OsmandApplication app;
protected OnColorsPaletteListener externalListener;
protected List<WeakReference<IColorsPalette>> palettes = new ArrayList<>();
protected ColorsCollection colorsCollection;
protected final List<WeakReference<IColorsPalette>> palettes = new ArrayList<>();

protected ColorsCollection collection;
protected PaletteColor editedPaletteColor;
protected PaletteColor selectedPaletteColor;
protected OnColorsPaletteListener listener;

public ColorsPaletteController(@NonNull OsmandApplication app,
@NonNull ColorsCollection colorsCollection,
@ColorInt int selectedColorInt) {
public ColorsPaletteController(@NonNull OsmandApplication app, @NonNull ColorsCollection collection, @Nullable Integer color) {
this.app = app;
this.colorsCollection = colorsCollection;
this.selectedPaletteColor = colorsCollection.findPaletteColor(selectedColorInt);
this.collection = collection;
this.selectedPaletteColor = color != null ? collection.findPaletteColor(color) : null;
}

@Override
Expand Down Expand Up @@ -77,7 +75,7 @@ private void notifyUpdatePaletteColors(@Nullable PaletteColor targetPaletteColor

@Override
public void setPaletteListener(@NonNull OnColorsPaletteListener onColorsPaletteListener) {
this.externalListener = onColorsPaletteListener;
this.listener = onColorsPaletteListener;
}

@Override
Expand Down Expand Up @@ -107,11 +105,11 @@ public void onSelectColorFromPalette(@NonNull PaletteColor color, boolean renewL

@Override
public void onApplyColorPickerSelection(@Nullable Integer oldColor, @ColorInt int newColor) {
PaletteColor paletteColor = colorsCollection.addOrUpdateColor(editedPaletteColor, newColor);
PaletteColor paletteColor = collection.addOrUpdateColor(editedPaletteColor, newColor);
if (paletteColor != null) {
notifyUpdatePaletteColors(paletteColor);
if (externalListener != null) {
externalListener.onColorAddedToPalette(editedPaletteColor, paletteColor);
if (listener != null) {
listener.onColorAddedToPalette(editedPaletteColor, paletteColor);
}
if (oldColor == null || Objects.equals(editedPaletteColor, selectedPaletteColor)) {
PaletteColor oldSelectedColor = selectedPaletteColor;
Expand All @@ -123,8 +121,8 @@ public void onApplyColorPickerSelection(@Nullable Integer oldColor, @ColorInt in
}

@Override
public void selectColor(@ColorInt int colorInt) {
selectColor(colorsCollection.findPaletteColor(colorInt));
public void selectColor(@ColorInt @Nullable Integer color) {
selectColor(color != null ? collection.findPaletteColor(color) : null);
}

@Override
Expand All @@ -134,14 +132,14 @@ public void selectColor(@Nullable PaletteColor paletteColor) {
}

protected void onColorSelected(@Nullable PaletteColor paletteColor) {
if (externalListener != null && paletteColor != null) {
externalListener.onColorSelectedFromPalette(paletteColor);
if (listener != null && paletteColor != null) {
listener.onColorSelectedFromPalette(paletteColor);
}
}

@Override
public void refreshLastUsedTime() {
colorsCollection.askRenewLastUsedTime(selectedPaletteColor);
collection.askRenewLastUsedTime(selectedPaletteColor);
}

@Override
Expand Down Expand Up @@ -202,12 +200,12 @@ private void showColorPickerDialog(@NonNull FragmentActivity activity, @Nullable
}

private void duplicateColor(@NonNull PaletteColor paletteColor) {
PaletteColor duplicate = colorsCollection.duplicateColor(paletteColor);
PaletteColor duplicate = collection.duplicateColor(paletteColor);
notifyUpdatePaletteColors(duplicate);
}

private void removeCustomColor(@NonNull PaletteColor paletteColor) {
if (colorsCollection.askRemoveColor(paletteColor)) {
if (collection.askRemoveColor(paletteColor)) {
notifyUpdatePaletteColors(null);
}
}
Expand All @@ -226,7 +224,7 @@ public boolean isSelectedColor(@NonNull PaletteColor paletteColor) {
@NonNull
@Override
public List<PaletteColor> getColors(@NonNull PaletteSortingMode sortingMode) {
return colorsCollection.getColors(sortingMode);
return collection.getColors(sortingMode);
}

@NonNull
Expand All @@ -250,7 +248,7 @@ protected Drawable getContentIcon(@DrawableRes int id) {

@NonNull
public String getColorName(@ColorInt int colorInt) {
PaletteColor paletteColor = colorsCollection.findPaletteColor(colorInt);
PaletteColor paletteColor = collection.findPaletteColor(colorInt);
return paletteColor != null
? paletteColor.toHumanString(app)
: app.getString(R.string.shared_string_custom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface IColorsPaletteController extends IDialogController, ColorPicker

void onSelectColorFromPalette(@NonNull PaletteColor color, boolean renewLastUsedTime);

void selectColor(@ColorInt int colorInt);
void selectColor(@Nullable Integer color);

void selectColor(@Nullable PaletteColor paletteColor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void refreshLastUsedTime() {
}
}
addPaletteColor(paletteColors, selectedPaletteMode);
colorsCollection.renewLastUsedTime(paletteColors);
collection.renewLastUsedTime(paletteColors);
}

private void addPaletteColor(@NonNull List<PaletteColor> paletteColors, @NonNull PaletteMode paletteMode) {
Expand Down
Loading

0 comments on commit e44ee20

Please sign in to comment.