From 3560de5e3e82df9633ff49614bc6cc5bdb16c72f Mon Sep 17 00:00:00 2001
From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com>
Date: Fri, 9 Apr 2021 14:02:27 +0300
Subject: [PATCH 1/4] Review
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use this arrow LTR: "▶", RTL: "◀".
Check how it work with RTL.
---
OsmAnd/res/values/strings.xml | 2 +-
.../quickaction/actions/MapStyleAction.java | 9 ++++++---
.../plus/rastermaps/MapOverlayAction.java | 7 +++++--
.../osmand/plus/rastermaps/MapSourceAction.java | 17 ++++++++++-------
.../plus/rastermaps/MapUnderlayAction.java | 9 ++++++---
5 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 97cfcf3a42..5bac9b0326 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -12,7 +12,7 @@
-->
- %1$s → …
+ %1$s %2$s …
Output
User points
Announce when exceeded
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
index 5838bfc1a2..c487cd494c 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
@@ -30,6 +30,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import static net.osmand.AndroidUtils.isLayoutRtl;
+
public class MapStyleAction extends SwitchableAction {
@@ -54,7 +56,7 @@ public class MapStyleAction extends SwitchableAction {
if (current != null) {
return current.getName();
} else {
- return RendererRegistry.DEFAULT_RENDER;
+ return RendererRegistry.DEFAULT_RENDER;
}
}
@@ -77,7 +79,7 @@ public class MapStyleAction extends SwitchableAction {
executeWithParams(activity, nextStyle);
} else {
Toast.makeText(activity, R.string.quick_action_need_to_add_item_to_list,
- Toast.LENGTH_LONG).show();
+ Toast.LENGTH_LONG).show();
}
}
@@ -249,7 +251,8 @@ public class MapStyleAction extends SwitchableAction {
@Override
public String getActionText(OsmandApplication application) {
String currentSource = application.getSettings().RENDERER.get();
+ String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
- return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
+ return application.getString(R.string.map_quick_action_arrow_direction_pattern, getTranslatedItemName(application, currentSource), arrowDirection);
}
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
index 8190b6c995..cc01b93e24 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
@@ -15,19 +15,21 @@ import com.google.gson.reflect.TypeToken;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.quickaction.SwitchableAction;
+import net.osmand.plus.settings.backend.OsmandSettings;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import static net.osmand.AndroidUtils.isLayoutRtl;
+
public class MapOverlayAction extends SwitchableAction> {
private final static String KEY_OVERLAYS = "overlays";
@@ -229,7 +231,8 @@ public class MapOverlayAction extends SwitchableAction> {
public String getActionText(OsmandApplication application) {
String currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
: application.getSettings().MAP_OVERLAY.get();
+ String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
- return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
+ return application.getString(R.string.map_quick_action_arrow_direction_pattern, getTranslatedItemName(application, currentSource), arrowDirection);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
index d81b1f12ed..187e6e262a 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
@@ -15,13 +15,13 @@ import com.google.gson.reflect.TypeToken;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.quickaction.SwitchableAction;
+import net.osmand.plus.settings.backend.OsmandSettings;
import java.lang.reflect.Type;
import java.util.ArrayList;
@@ -29,6 +29,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import static net.osmand.AndroidUtils.isLayoutRtl;
+
public class MapSourceAction extends SwitchableAction> {
public static final String LAYER_OSM_VECTOR = "LAYER_OSM_VECTOR";
@@ -98,8 +100,8 @@ public class MapSourceAction extends SwitchableAction> {
}
Pair currentSource = settings.MAP_ONLINE_DATA.get()
- ? new Pair<>(settings.MAP_TILE_SOURCES.get(), settings.MAP_TILE_SOURCES.get())
- : new Pair<>(LAYER_OSM_VECTOR, activity.getString(R.string.vector_data));
+ ? new Pair<>(settings.MAP_TILE_SOURCES.get(), settings.MAP_TILE_SOURCES.get())
+ : new Pair<>(LAYER_OSM_VECTOR, activity.getString(R.string.vector_data));
Pair nextSource = sources.get(0);
int index = sources.indexOf(currentSource);
@@ -135,7 +137,7 @@ public class MapSourceAction extends SwitchableAction> {
return item;
}
}
-
+
@Override
protected int getAddBtnText() {
return R.string.quick_action_map_source_action;
@@ -218,9 +220,10 @@ public class MapSourceAction extends SwitchableAction> {
@Override
public String getActionText(OsmandApplication application) {
String currentSource = application.getSettings().MAP_ONLINE_DATA.get()
- ? application.getSettings().MAP_TILE_SOURCES.get()
- : application.getString(R.string.vector_data);
+ ? application.getSettings().MAP_TILE_SOURCES.get()
+ : application.getString(R.string.vector_data);
+ String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
- return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
+ return application.getString(R.string.map_quick_action_arrow_direction_pattern, getTranslatedItemName(application, currentSource), arrowDirection);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
index ddb941e10b..fa7aae54c0 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
@@ -28,6 +28,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import static net.osmand.AndroidUtils.isLayoutRtl;
+
public class MapUnderlayAction extends SwitchableAction> {
@@ -103,7 +105,7 @@ public class MapUnderlayAction extends SwitchableAction> {
int index = -1;
final String currentSource = settings.MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY
- : settings.MAP_UNDERLAY.get();
+ : settings.MAP_UNDERLAY.get();
for (int idx = 0; idx < sources.size(); idx++) {
if (sources.get(idx).first.equals(currentSource)) {
@@ -157,7 +159,7 @@ public class MapUnderlayAction extends SwitchableAction> {
return item;
}
}
-
+
@Override
protected int getAddBtnText() {
return R.string.quick_action_map_underlay_action;
@@ -231,7 +233,8 @@ public class MapUnderlayAction extends SwitchableAction> {
public String getActionText(OsmandApplication application) {
String currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY
: application.getSettings().MAP_UNDERLAY.get();
+ String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
- return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
+ return application.getString(R.string.map_quick_action_arrow_direction_pattern, getTranslatedItemName(application, currentSource), arrowDirection);
}
}
From 1ce74b23eab4627852ad7cf91344a5b8ed729c0c Mon Sep 17 00:00:00 2001
From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com>
Date: Sun, 11 Apr 2021 20:47:07 +0300
Subject: [PATCH 2/4] Remove unused strings, use Unicode character instead
three dots, move method getActionText() to parent class
---
OsmAnd/res/values-ar/strings.xml | 1 -
OsmAnd/res/values-de/strings.xml | 1 -
OsmAnd/res/values-eo/strings.xml | 1 -
OsmAnd/res/values-es-rAR/strings.xml | 1 -
OsmAnd/res/values-fr/strings.xml | 1 -
OsmAnd/res/values-hu/strings.xml | 1 -
OsmAnd/res/values-iw/strings.xml | 1 -
OsmAnd/res/values-pt/strings.xml | 1 -
OsmAnd/res/values-uk/strings.xml | 1 -
OsmAnd/res/values/strings.xml | 1 -
.../plus/quickaction/SwitchableAction.java | 63 ++++++++++++++-----
.../quickaction/actions/MapStyleAction.java | 7 ---
.../plus/rastermaps/MapOverlayAction.java | 9 ---
.../plus/rastermaps/MapSourceAction.java | 10 ---
.../plus/rastermaps/MapUnderlayAction.java | 9 ---
15 files changed, 49 insertions(+), 59 deletions(-)
diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml
index 3b5b131c57..073b26b6a2 100644
--- a/OsmAnd/res/values-ar/strings.xml
+++ b/OsmAnd/res/values-ar/strings.xml
@@ -4154,5 +4154,4 @@
الإعلان عند التجاوز
نقاط المستخدم
المخرج
- %1$s ← …
\ No newline at end of file
diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml
index 094ba47620..dae511a7f4 100644
--- a/OsmAnd/res/values-de/strings.xml
+++ b/OsmAnd/res/values-de/strings.xml
@@ -4089,5 +4089,4 @@
Meldung bei Überschreitung
Anwenderpunkte
Leistung
- %1$s → …
\ No newline at end of file
diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml
index 54026c0c08..5df11bbf9d 100644
--- a/OsmAnd/res/values-eo/strings.xml
+++ b/OsmAnd/res/values-eo/strings.xml
@@ -4085,5 +4085,4 @@
Numero de elirejo
Poentoj de uzanto
Eligo
- %1$s → …
\ No newline at end of file
diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml
index bcf6918377..c7a7007a59 100644
--- a/OsmAnd/res/values-es-rAR/strings.xml
+++ b/OsmAnd/res/values-es-rAR/strings.xml
@@ -4087,5 +4087,4 @@
Anunciar al excederse
Puntos de usuario
Salida
- %1$s → …
\ No newline at end of file
diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml
index b45c597a1a..8fa7588019 100644
--- a/OsmAnd/res/values-fr/strings.xml
+++ b/OsmAnd/res/values-fr/strings.xml
@@ -4075,5 +4075,4 @@
Numéro de sortie
Annoncer en cas de dépassement
Sortie
- %1$s → …
\ No newline at end of file
diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml
index 9709e8bce8..ced108288e 100644
--- a/OsmAnd/res/values-hu/strings.xml
+++ b/OsmAnd/res/values-hu/strings.xml
@@ -4074,7 +4074,6 @@
Várakoztatva
Lejárt
Frissüljön minden térkép, amely hozzá lett adva ehhez: %1$s\?
- %1$s → …
Kijárat száma
Értesítés túllépéskor
Felhasználói pontok
diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml
index e7684a1670..8fee045082 100644
--- a/OsmAnd/res/values-iw/strings.xml
+++ b/OsmAnd/res/values-iw/strings.xml
@@ -4087,5 +4087,4 @@
להכריז בחריגה
נקודות משתמש
פלט
- %1$s ← …
\ No newline at end of file
diff --git a/OsmAnd/res/values-pt/strings.xml b/OsmAnd/res/values-pt/strings.xml
index e1558ef4be..9dd4028264 100644
--- a/OsmAnd/res/values-pt/strings.xml
+++ b/OsmAnd/res/values-pt/strings.xml
@@ -4089,5 +4089,4 @@
Anunciar quando ultrapassado
Pontos do utilizador
Saída
- %1$s → …
\ No newline at end of file
diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml
index ecfadc84d3..051d717f3c 100644
--- a/OsmAnd/res/values-uk/strings.xml
+++ b/OsmAnd/res/values-uk/strings.xml
@@ -4084,5 +4084,4 @@
Повідомляти про перевищення
Користувацькі точки
Вивід
- %1$s → …
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 5bac9b0326..9959488bd2 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -12,7 +12,6 @@
-->
- %1$s %2$s …
Output
User points
Announce when exceeded
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java
index f1bc2c927a..f912e9260f 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java
@@ -13,7 +13,6 @@ import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
-import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.SwitchCompat;
@@ -32,12 +31,22 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import static net.osmand.AndroidUtils.isLayoutRtl;
+
public abstract class SwitchableAction extends QuickAction {
public static final String KEY_ID = "id";
-
+
protected static final String KEY_DIALOG = "dialog";
+ private final static String MAP_STYLE_ACTION = "mapstyle.change";
+ private final static String MAP_SOURCE_ACTION = "mapsource.change";
+ private final static String MAP_OVERLAY_ACTION = "mapoverlay.change";
+ private final static String MAP_UNDERLAY_ACTION = "mapunderlay.change";
+
+ private final static String KEY_NO_OVERLAY = "no_overlay";
+ private final static String KEY_NO_UNDERLAY = "no_underlay";
+
private transient EditText title;
private transient Adapter adapter;
@@ -62,7 +71,7 @@ public abstract class SwitchableAction extends QuickAction {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_switchable_action, parent, false);
- final SwitchCompat showDialog = (SwitchCompat) view.findViewById(R.id.saveButton);
+ final SwitchCompat showDialog = view.findViewById(R.id.saveButton);
if (!getParams().isEmpty()) {
showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
}
@@ -74,7 +83,7 @@ public abstract class SwitchableAction extends QuickAction {
}
});
- RecyclerView list = (RecyclerView) view.findViewById(R.id.list);
+ RecyclerView list = view.findViewById(R.id.list);
adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() {
@Override
public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
@@ -92,9 +101,9 @@ public abstract class SwitchableAction extends QuickAction {
list.setAdapter(adapter);
- TextView dscrTitle = (TextView) view.findViewById(R.id.textDscrTitle);
- TextView dscrHint = (TextView) view.findViewById(R.id.textDscrHint);
- Button addBtn = (Button) view.findViewById(R.id.btnAdd);
+ TextView dscrTitle = view.findViewById(R.id.textDscrTitle);
+ TextView dscrHint = view.findViewById(R.id.textDscrHint);
+ Button addBtn = view.findViewById(R.id.btnAdd);
dscrTitle.setText(parent.getContext().getString(getDiscrTitle()) + ":");
dscrHint.setText(getDiscrHint());
@@ -104,10 +113,36 @@ public abstract class SwitchableAction extends QuickAction {
parent.addView(view);
}
+ @Override
+ public String getActionText(OsmandApplication application) {
+ String currentSource = "";
+ switch (getActionType().getStringId()) {
+ case MAP_STYLE_ACTION:
+ currentSource = application.getSettings().RENDERER.get();
+ break;
+ case MAP_SOURCE_ACTION:
+ currentSource = application.getSettings().MAP_ONLINE_DATA.get()
+ ? application.getSettings().MAP_TILE_SOURCES.get()
+ : application.getString(R.string.vector_data);
+ break;
+ case MAP_OVERLAY_ACTION:
+ currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
+ : application.getSettings().MAP_OVERLAY.get();
+ break;
+ case MAP_UNDERLAY_ACTION:
+ currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY
+ : application.getSettings().MAP_UNDERLAY.get();
+ break;
+ }
+ String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
+
+ return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, currentSource), arrowDirection + "\u2026");
+ }
+
@Override
public boolean fillParams(View root, MapActivity activity) {
- final RecyclerView list = (RecyclerView) root.findViewById(R.id.list);
+ final RecyclerView list = root.findViewById(R.id.list);
final Adapter adapter = (Adapter) list.getAdapter();
boolean hasParams = adapter.itemsList != null && !adapter.itemsList.isEmpty();
@@ -124,7 +159,7 @@ public abstract class SwitchableAction extends QuickAction {
public abstract List loadListFromParams();
public abstract void executeWithParams(MapActivity activity, String params);
-
+
public abstract String getTranslatedItemName(Context context, String item);
protected void showChooseDialog(FragmentManager fm) {
@@ -143,7 +178,7 @@ public abstract class SwitchableAction extends QuickAction {
private List itemsList = new ArrayList<>();
private final QuickActionListFragment.OnStartDragListener onStartDragListener;
- private Context context;
+ private final Context context;
public Adapter(Context context, QuickActionListFragment.OnStartDragListener onStartDragListener) {
this.context = context;
@@ -293,10 +328,10 @@ public abstract class SwitchableAction extends QuickAction {
public ItemHolder(View itemView) {
super(itemView);
- title = (TextView) itemView.findViewById(R.id.title);
- handleView = (ImageView) itemView.findViewById(R.id.handle_view);
- closeBtn = (ImageView) itemView.findViewById(R.id.closeImageButton);
- icon = (ImageView) itemView.findViewById(R.id.imageView);
+ title = itemView.findViewById(R.id.title);
+ handleView = itemView.findViewById(R.id.handle_view);
+ closeBtn = itemView.findViewById(R.id.closeImageButton);
+ icon = itemView.findViewById(R.id.imageView);
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
index c487cd494c..3e2d297566 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
@@ -248,11 +248,4 @@ public class MapStyleAction extends SwitchableAction {
: filters.get(0);
}
- @Override
- public String getActionText(OsmandApplication application) {
- String currentSource = application.getSettings().RENDERER.get();
- String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
-
- return application.getString(R.string.map_quick_action_arrow_direction_pattern, getTranslatedItemName(application, currentSource), arrowDirection);
- }
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
index cc01b93e24..ac341d9b50 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
@@ -226,13 +226,4 @@ public class MapOverlayAction extends SwitchableAction> {
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return super.fillParams(root, activity);
}
-
- @Override
- public String getActionText(OsmandApplication application) {
- String currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
- : application.getSettings().MAP_OVERLAY.get();
- String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
-
- return application.getString(R.string.map_quick_action_arrow_direction_pattern, getTranslatedItemName(application, currentSource), arrowDirection);
- }
}
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
index 187e6e262a..92c08f8745 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
@@ -216,14 +216,4 @@ public class MapSourceAction extends SwitchableAction> {
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return super.fillParams(root, activity);
}
-
- @Override
- public String getActionText(OsmandApplication application) {
- String currentSource = application.getSettings().MAP_ONLINE_DATA.get()
- ? application.getSettings().MAP_TILE_SOURCES.get()
- : application.getString(R.string.vector_data);
- String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
-
- return application.getString(R.string.map_quick_action_arrow_direction_pattern, getTranslatedItemName(application, currentSource), arrowDirection);
- }
}
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
index fa7aae54c0..704afc47a2 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
@@ -228,13 +228,4 @@ public class MapUnderlayAction extends SwitchableAction> {
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return super.fillParams(root, activity);
}
-
- @Override
- public String getActionText(OsmandApplication application) {
- String currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY
- : application.getSettings().MAP_UNDERLAY.get();
- String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
-
- return application.getString(R.string.map_quick_action_arrow_direction_pattern, getTranslatedItemName(application, currentSource), arrowDirection);
- }
}
From 28df99cffb1a5ae8edcee7d172deebf995e7eb20 Mon Sep 17 00:00:00 2001
From: Vitaliy
Date: Mon, 12 Apr 2021 11:31:24 +0300
Subject: [PATCH 3/4] Small fixes
---
.../plus/quickaction/SwitchableAction.java | 30 ++-----------------
.../quickaction/actions/MapStyleAction.java | 2 --
.../plus/rastermaps/MapOverlayAction.java | 4 +--
.../plus/rastermaps/MapSourceAction.java | 2 --
.../plus/rastermaps/MapUnderlayAction.java | 4 +--
5 files changed, 4 insertions(+), 38 deletions(-)
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java
index f912e9260f..412eba2323 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java
@@ -39,14 +39,6 @@ public abstract class SwitchableAction extends QuickAction {
protected static final String KEY_DIALOG = "dialog";
- private final static String MAP_STYLE_ACTION = "mapstyle.change";
- private final static String MAP_SOURCE_ACTION = "mapsource.change";
- private final static String MAP_OVERLAY_ACTION = "mapoverlay.change";
- private final static String MAP_UNDERLAY_ACTION = "mapunderlay.change";
-
- private final static String KEY_NO_OVERLAY = "no_overlay";
- private final static String KEY_NO_UNDERLAY = "no_underlay";
-
private transient EditText title;
private transient Adapter adapter;
@@ -115,28 +107,10 @@ public abstract class SwitchableAction extends QuickAction {
@Override
public String getActionText(OsmandApplication application) {
- String currentSource = "";
- switch (getActionType().getStringId()) {
- case MAP_STYLE_ACTION:
- currentSource = application.getSettings().RENDERER.get();
- break;
- case MAP_SOURCE_ACTION:
- currentSource = application.getSettings().MAP_ONLINE_DATA.get()
- ? application.getSettings().MAP_TILE_SOURCES.get()
- : application.getString(R.string.vector_data);
- break;
- case MAP_OVERLAY_ACTION:
- currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
- : application.getSettings().MAP_OVERLAY.get();
- break;
- case MAP_UNDERLAY_ACTION:
- currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY
- : application.getSettings().MAP_UNDERLAY.get();
- break;
- }
+ String item = getSelectedItem(application);
String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
- return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, currentSource), arrowDirection + "\u2026");
+ return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, item), arrowDirection + "\u2026");
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
index 3e2d297566..eedfe1beb7 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
@@ -30,8 +30,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import static net.osmand.AndroidUtils.isLayoutRtl;
-
public class MapStyleAction extends SwitchableAction {
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
index ac341d9b50..2dc809488e 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
@@ -28,8 +28,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import static net.osmand.AndroidUtils.isLayoutRtl;
-
public class MapOverlayAction extends SwitchableAction> {
private final static String KEY_OVERLAYS = "overlays";
@@ -61,7 +59,7 @@ public class MapOverlayAction extends SwitchableAction> {
@Override
public String getSelectedItem(OsmandApplication app) {
- return app.getSettings().MAP_OVERLAY.get();
+ return app.getSettings().MAP_OVERLAY.get() != null ? app.getSettings().MAP_OVERLAY.get() : KEY_NO_OVERLAY;
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
index 92c08f8745..8ace30844b 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
@@ -29,8 +29,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import static net.osmand.AndroidUtils.isLayoutRtl;
-
public class MapSourceAction extends SwitchableAction> {
public static final String LAYER_OSM_VECTOR = "LAYER_OSM_VECTOR";
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
index 704afc47a2..167338add1 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
@@ -28,8 +28,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import static net.osmand.AndroidUtils.isLayoutRtl;
-
public class MapUnderlayAction extends SwitchableAction> {
@@ -61,7 +59,7 @@ public class MapUnderlayAction extends SwitchableAction> {
@Override
public String getSelectedItem(OsmandApplication app) {
- return app.getSettings().MAP_UNDERLAY.get();
+ return app.getSettings().MAP_UNDERLAY.get() != null ? app.getSettings().MAP_UNDERLAY.get() : KEY_NO_UNDERLAY;
}
@Override
From a418f94cd1cd60185e5764284e5427ffe3b0430a Mon Sep 17 00:00:00 2001
From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com>
Date: Mon, 12 Apr 2021 12:30:46 +0300
Subject: [PATCH 4/4] Refactor, profilechange overide
---
.../plus/quickaction/SwitchableAction.java | 30 ++-----------------
.../quickaction/actions/MapStyleAction.java | 2 --
.../actions/SwitchProfileAction.java | 9 ++++++
.../plus/rastermaps/MapOverlayAction.java | 4 +--
.../plus/rastermaps/MapSourceAction.java | 2 --
.../plus/rastermaps/MapUnderlayAction.java | 4 +--
6 files changed, 13 insertions(+), 38 deletions(-)
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java
index f912e9260f..412eba2323 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java
@@ -39,14 +39,6 @@ public abstract class SwitchableAction extends QuickAction {
protected static final String KEY_DIALOG = "dialog";
- private final static String MAP_STYLE_ACTION = "mapstyle.change";
- private final static String MAP_SOURCE_ACTION = "mapsource.change";
- private final static String MAP_OVERLAY_ACTION = "mapoverlay.change";
- private final static String MAP_UNDERLAY_ACTION = "mapunderlay.change";
-
- private final static String KEY_NO_OVERLAY = "no_overlay";
- private final static String KEY_NO_UNDERLAY = "no_underlay";
-
private transient EditText title;
private transient Adapter adapter;
@@ -115,28 +107,10 @@ public abstract class SwitchableAction extends QuickAction {
@Override
public String getActionText(OsmandApplication application) {
- String currentSource = "";
- switch (getActionType().getStringId()) {
- case MAP_STYLE_ACTION:
- currentSource = application.getSettings().RENDERER.get();
- break;
- case MAP_SOURCE_ACTION:
- currentSource = application.getSettings().MAP_ONLINE_DATA.get()
- ? application.getSettings().MAP_TILE_SOURCES.get()
- : application.getString(R.string.vector_data);
- break;
- case MAP_OVERLAY_ACTION:
- currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
- : application.getSettings().MAP_OVERLAY.get();
- break;
- case MAP_UNDERLAY_ACTION:
- currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY
- : application.getSettings().MAP_UNDERLAY.get();
- break;
- }
+ String item = getSelectedItem(application);
String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
- return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, currentSource), arrowDirection + "\u2026");
+ return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, item), arrowDirection + "\u2026");
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
index 3e2d297566..eedfe1beb7 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java
@@ -30,8 +30,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import static net.osmand.AndroidUtils.isLayoutRtl;
-
public class MapStyleAction extends SwitchableAction {
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java
index da31b61466..24bff5e458 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/SwitchProfileAction.java
@@ -27,6 +27,8 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import static net.osmand.AndroidUtils.isLayoutRtl;
+
public class SwitchProfileAction extends SwitchableAction {
private final static String KEY_PROFILES = "profiles";
@@ -230,4 +232,11 @@ public class SwitchProfileAction extends SwitchableAction {
}
}
}
+
+ @Override
+ public String getActionText(OsmandApplication application) {
+ String item = getSelectedItem(application);
+
+ return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, item), "\u2026");
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
index ac341d9b50..2dc809488e 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
@@ -28,8 +28,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import static net.osmand.AndroidUtils.isLayoutRtl;
-
public class MapOverlayAction extends SwitchableAction> {
private final static String KEY_OVERLAYS = "overlays";
@@ -61,7 +59,7 @@ public class MapOverlayAction extends SwitchableAction> {
@Override
public String getSelectedItem(OsmandApplication app) {
- return app.getSettings().MAP_OVERLAY.get();
+ return app.getSettings().MAP_OVERLAY.get() != null ? app.getSettings().MAP_OVERLAY.get() : KEY_NO_OVERLAY;
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
index 92c08f8745..8ace30844b 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapSourceAction.java
@@ -29,8 +29,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import static net.osmand.AndroidUtils.isLayoutRtl;
-
public class MapSourceAction extends SwitchableAction> {
public static final String LAYER_OSM_VECTOR = "LAYER_OSM_VECTOR";
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
index 704afc47a2..167338add1 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
@@ -28,8 +28,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import static net.osmand.AndroidUtils.isLayoutRtl;
-
public class MapUnderlayAction extends SwitchableAction> {
@@ -61,7 +59,7 @@ public class MapUnderlayAction extends SwitchableAction> {
@Override
public String getSelectedItem(OsmandApplication app) {
- return app.getSettings().MAP_UNDERLAY.get();
+ return app.getSettings().MAP_UNDERLAY.get() != null ? app.getSettings().MAP_UNDERLAY.get() : KEY_NO_UNDERLAY;
}
@Override