Remove unused strings, use Unicode character instead three dots, move method getActionText() to parent class

This commit is contained in:
androiddevkotlin 2021-04-11 20:47:07 +03:00
parent 3560de5e3e
commit 1ce74b23ea
15 changed files with 49 additions and 59 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4074,7 +4074,6 @@
<string name="on_hold">Várakoztatva</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="map_quick_action_pattern">%1$s → …</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="user_points">Felhasználói pontok</string>

View file

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

View file

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

View file

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

View file

@ -12,7 +12,6 @@
-->
<string name="map_quick_action_arrow_direction_pattern">%1$s %2$s …</string>
<string name="output">Output</string>
<string name="user_points">User points</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 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<T> 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<T> 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<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() {
@Override
public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
@ -92,9 +101,9 @@ public abstract class SwitchableAction<T> 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<T> 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<T> extends QuickAction {
public abstract List<T> 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<T> extends QuickAction {
private List<T> 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<T> 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);
}
}
}

View file

@ -248,11 +248,4 @@ public class MapStyleAction extends SwitchableAction<String> {
: 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);
}
}

View file

@ -226,13 +226,4 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
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);
}
}

View file

@ -216,14 +216,4 @@ public class MapSourceAction extends SwitchableAction<Pair<String, String>> {
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);
}
}

View file

@ -228,13 +228,4 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
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);
}
}