Merge pull request #11377 from osmandapp/Arrow-direction-pattern

Review
This commit is contained in:
Vitaliy 2021-04-12 12:43:50 +03:00 committed by GitHub
commit 08c40319f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 43 additions and 66 deletions

View file

@ -4154,5 +4154,4 @@
<string name="announce_when_exceeded">الإعلان عند التجاوز</string> <string name="announce_when_exceeded">الإعلان عند التجاوز</string>
<string name="user_points">نقاط المستخدم</string> <string name="user_points">نقاط المستخدم</string>
<string name="output">الإخراج</string> <string name="output">الإخراج</string>
<string name="map_quick_action_pattern">%1$s ← …</string>
</resources> </resources>

View file

@ -4089,5 +4089,4 @@
<string name="announce_when_exceeded">Meldung bei Überschreitung</string> <string name="announce_when_exceeded">Meldung bei Überschreitung</string>
<string name="user_points">Anwenderpunkte</string> <string name="user_points">Anwenderpunkte</string>
<string name="output">Leistung</string> <string name="output">Leistung</string>
<string name="map_quick_action_pattern">%1$s → …</string>
</resources> </resources>

View file

@ -4085,5 +4085,4 @@
<string name="exit_number">Numero de elirejo</string> <string name="exit_number">Numero de elirejo</string>
<string name="user_points">Poentoj de uzanto</string> <string name="user_points">Poentoj de uzanto</string>
<string name="output">Eligo</string> <string name="output">Eligo</string>
<string name="map_quick_action_pattern">%1$s → …</string>
</resources> </resources>

View file

@ -4087,5 +4087,4 @@
<string name="announce_when_exceeded">Anunciar al excederse</string> <string name="announce_when_exceeded">Anunciar al excederse</string>
<string name="user_points">Puntos de usuario</string> <string name="user_points">Puntos de usuario</string>
<string name="output">Salida</string> <string name="output">Salida</string>
<string name="map_quick_action_pattern">%1$s → …</string>
</resources> </resources>

View file

@ -4075,5 +4075,4 @@
<string name="exit_number">Numéro de sortie</string> <string name="exit_number">Numéro de sortie</string>
<string name="announce_when_exceeded">Annoncer en cas de dépassement</string> <string name="announce_when_exceeded">Annoncer en cas de dépassement</string>
<string name="output">Sortie</string> <string name="output">Sortie</string>
<string name="map_quick_action_pattern">%1$s → …</string>
</resources> </resources>

View file

@ -4074,7 +4074,6 @@
<string name="on_hold">Várakoztatva</string> <string name="on_hold">Várakoztatva</string>
<string name="expired">Lejárt</string> <string name="expired">Lejárt</string>
<string name="update_all_maps_added">Frissüljön minden térkép, amely hozzá lett adva ehhez: %1$s\?</string> <string name="update_all_maps_added">Frissüljön minden térkép, amely hozzá lett adva ehhez: %1$s\?</string>
<string name="map_quick_action_pattern">%1$s → …</string>
<string name="exit_number">Kijárat száma</string> <string name="exit_number">Kijárat száma</string>
<string name="announce_when_exceeded">Értesítés túllépéskor</string> <string name="announce_when_exceeded">Értesítés túllépéskor</string>
<string name="user_points">Felhasználói pontok</string> <string name="user_points">Felhasználói pontok</string>

View file

@ -4087,5 +4087,4 @@
<string name="announce_when_exceeded">להכריז בחריגה</string> <string name="announce_when_exceeded">להכריז בחריגה</string>
<string name="user_points">נקודות משתמש</string> <string name="user_points">נקודות משתמש</string>
<string name="output">פלט</string> <string name="output">פלט</string>
<string name="map_quick_action_pattern">%1$s ← …</string>
</resources> </resources>

View file

@ -4089,5 +4089,4 @@
<string name="announce_when_exceeded">Anunciar quando ultrapassado</string> <string name="announce_when_exceeded">Anunciar quando ultrapassado</string>
<string name="user_points">Pontos do utilizador</string> <string name="user_points">Pontos do utilizador</string>
<string name="output">Saída</string> <string name="output">Saída</string>
<string name="map_quick_action_pattern">%1$s → …</string>
</resources> </resources>

View file

@ -4084,5 +4084,4 @@
<string name="announce_when_exceeded">Повідомляти про перевищення</string> <string name="announce_when_exceeded">Повідомляти про перевищення</string>
<string name="user_points">Користувацькі точки</string> <string name="user_points">Користувацькі точки</string>
<string name="output">Вивід</string> <string name="output">Вивід</string>
<string name="map_quick_action_pattern">%1$s → …</string>
</resources> </resources>

View file

@ -12,7 +12,6 @@
--> -->
<string name="map_quick_action_pattern">%1$s → …</string>
<string name="output">Output</string> <string name="output">Output</string>
<string name="user_points">User points</string> <string name="user_points">User points</string>
<string name="announce_when_exceeded">Announce when exceeded</string> <string name="announce_when_exceeded">Announce when exceeded</string>

View file

@ -13,7 +13,6 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
@ -32,6 +31,8 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static net.osmand.AndroidUtils.isLayoutRtl;
public abstract class SwitchableAction<T> extends QuickAction { public abstract class SwitchableAction<T> extends QuickAction {
public static final String KEY_ID = "id"; public static final String KEY_ID = "id";
@ -62,7 +63,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
View view = LayoutInflater.from(parent.getContext()) View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_switchable_action, parent, false); .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()) { if (!getParams().isEmpty()) {
showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG))); showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
} }
@ -74,7 +75,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
} }
}); });
RecyclerView list = (RecyclerView) view.findViewById(R.id.list); RecyclerView list = view.findViewById(R.id.list);
adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() { adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() {
@Override @Override
public void onStartDrag(RecyclerView.ViewHolder viewHolder) { public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
@ -92,9 +93,9 @@ public abstract class SwitchableAction<T> extends QuickAction {
list.setAdapter(adapter); list.setAdapter(adapter);
TextView dscrTitle = (TextView) view.findViewById(R.id.textDscrTitle); TextView dscrTitle = view.findViewById(R.id.textDscrTitle);
TextView dscrHint = (TextView) view.findViewById(R.id.textDscrHint); TextView dscrHint = view.findViewById(R.id.textDscrHint);
Button addBtn = (Button) view.findViewById(R.id.btnAdd); Button addBtn = view.findViewById(R.id.btnAdd);
dscrTitle.setText(parent.getContext().getString(getDiscrTitle()) + ":"); dscrTitle.setText(parent.getContext().getString(getDiscrTitle()) + ":");
dscrHint.setText(getDiscrHint()); dscrHint.setText(getDiscrHint());
@ -104,10 +105,18 @@ public abstract class SwitchableAction<T> extends QuickAction {
parent.addView(view); parent.addView(view);
} }
@Override
public String getActionText(OsmandApplication application) {
String item = getSelectedItem(application);
String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, item), arrowDirection + "\u2026");
}
@Override @Override
public boolean fillParams(View root, MapActivity activity) { 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(); final Adapter adapter = (Adapter) list.getAdapter();
boolean hasParams = adapter.itemsList != null && !adapter.itemsList.isEmpty(); boolean hasParams = adapter.itemsList != null && !adapter.itemsList.isEmpty();
@ -143,7 +152,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
private List<T> itemsList = new ArrayList<>(); private List<T> itemsList = new ArrayList<>();
private final QuickActionListFragment.OnStartDragListener onStartDragListener; private final QuickActionListFragment.OnStartDragListener onStartDragListener;
private Context context; private final Context context;
public Adapter(Context context, QuickActionListFragment.OnStartDragListener onStartDragListener) { public Adapter(Context context, QuickActionListFragment.OnStartDragListener onStartDragListener) {
this.context = context; this.context = context;
@ -293,10 +302,10 @@ public abstract class SwitchableAction<T> extends QuickAction {
public ItemHolder(View itemView) { public ItemHolder(View itemView) {
super(itemView); super(itemView);
title = (TextView) itemView.findViewById(R.id.title); title = itemView.findViewById(R.id.title);
handleView = (ImageView) itemView.findViewById(R.id.handle_view); handleView = itemView.findViewById(R.id.handle_view);
closeBtn = (ImageView) itemView.findViewById(R.id.closeImageButton); closeBtn = itemView.findViewById(R.id.closeImageButton);
icon = (ImageView) itemView.findViewById(R.id.imageView); icon = itemView.findViewById(R.id.imageView);
} }
} }
} }

View file

@ -246,10 +246,4 @@ public class MapStyleAction extends SwitchableAction<String> {
: filters.get(0); : filters.get(0);
} }
@Override
public String getActionText(OsmandApplication application) {
String currentSource = application.getSettings().RENDERER.get();
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
}
} }

View file

@ -27,6 +27,8 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import static net.osmand.AndroidUtils.isLayoutRtl;
public class SwitchProfileAction extends SwitchableAction<String> { public class SwitchProfileAction extends SwitchableAction<String> {
private final static String KEY_PROFILES = "profiles"; private final static String KEY_PROFILES = "profiles";
@ -230,4 +232,11 @@ public class SwitchProfileAction extends SwitchableAction<String> {
} }
} }
} }
@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");
}
} }

View file

@ -15,13 +15,13 @@ import com.google.gson.reflect.TypeToken;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.quickaction.SwitchableAction; import net.osmand.plus.quickaction.SwitchableAction;
import net.osmand.plus.settings.backend.OsmandSettings;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
@ -59,7 +59,7 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
@Override @Override
public String getSelectedItem(OsmandApplication app) { 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 @Override
@ -224,12 +224,4 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return super.fillParams(root, activity); 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();
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
}
} }

View file

@ -15,13 +15,13 @@ import com.google.gson.reflect.TypeToken;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.quickaction.SwitchableAction; import net.osmand.plus.quickaction.SwitchableAction;
import net.osmand.plus.settings.backend.OsmandSettings;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
@ -214,13 +214,4 @@ public class MapSourceAction extends SwitchableAction<Pair<String, String>> {
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return super.fillParams(root, activity); 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);
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
}
} }

View file

@ -59,7 +59,7 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
@Override @Override
public String getSelectedItem(OsmandApplication app) { 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 @Override
@ -226,12 +226,4 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked())); getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return super.fillParams(root, activity); 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();
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
}
} }