some bug fixes
This commit is contained in:
parent
00b401d525
commit
0f31e291d8
8 changed files with 309 additions and 41 deletions
|
@ -15,14 +15,26 @@
|
|||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="24dp"
|
||||
android:tint="?attr/primary_icon_color"
|
||||
android:scaleType="centerInside"/>
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:tint="?attr/primary_icon_color"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageSlash"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:scaleType="centerInside"/>
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
|
|
@ -2471,11 +2471,14 @@ If you need help with OsmAnd application, please contact our support team: suppo
|
|||
<string name="quick_action_add_marker">Add marker</string>
|
||||
<string name="quick_action_add_poi">Add POI</string>
|
||||
<string name="quick_action_map_style">Change map style</string>
|
||||
<string name="quick_action_map_style_switch">Map style has been changed to the \"%s\".</string>
|
||||
<string name="quick_action_take_audio_note">Take audio note</string>
|
||||
<string name="quick_action_take_video_note">Take video note</string>
|
||||
<string name="quick_action_take_photo_note">Take photo note</string>
|
||||
<string name="quick_action_add_osm_bug">Add OSM bug</string>
|
||||
<string name="quick_action_navigation_voice">Voice On/Off</string>
|
||||
<string name="quick_action_navigation_voice_off">Voice Off</string>
|
||||
<string name="quick_action_navigation_voice_on">Voice On</string>
|
||||
<string name="quick_action_add_gpx">Add GPX waypoint</string>
|
||||
<string name="quick_action_add_parking">Add Parking place</string>
|
||||
<string name="quick_action_new_action">Add action</string>
|
||||
|
@ -2507,8 +2510,12 @@ If you need help with OsmAnd application, please contact our support team: suppo
|
|||
<string name="quick_action_duplicate">Quick action name duplicate</string>
|
||||
<string name="quick_action_showhides_favorites_discr">Tap on action will Show or Hide favorites points on map.</string>
|
||||
<string name="quick_action_showhides_poi_discr">Tap on action will Show or Hide POI points on map.</string>
|
||||
<string name="quic_action_showhide_favorites_title">Show/Hide Favorites</string>
|
||||
<string name="quic_action_showhide_poi_title">Show/Hide POI</string>
|
||||
<string name="quick_action_showhide_favorites_title">Show/Hide Favorites</string>
|
||||
<string name="quick_action_favorites_show">Show Favorites</string>
|
||||
<string name="quick_action_favorites_hide">Hide Favorites</string>
|
||||
<string name="quick_action_showhide_poi_title">Show/Hide POI</string>
|
||||
<string name="quick_action_poi_show">Show %1$s</string>
|
||||
<string name="quick_action_poi_hide">Hide %1$s</string>
|
||||
<string name="quick_action_add_category">Add category</string>
|
||||
<string name="quick_action_add_create_items">Create items</string>
|
||||
<string name="quick_action_add_configure_map">Configure map</string>
|
||||
|
|
|
@ -41,8 +41,13 @@ public class AddQuickActionDialog extends DialogFragment {
|
|||
|
||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
List<QuickAction> active = ((MapActivity) getActivity())
|
||||
.getMapLayers()
|
||||
.getQuickActionRegistry()
|
||||
.getQuickActions();
|
||||
|
||||
View root = inflater.inflate(R.layout.quick_action_add_dialog, container, false);
|
||||
Adapter adapter = new Adapter(QuickActionFactory.produceTypeActionsListWithHeaders());
|
||||
Adapter adapter = new Adapter(QuickActionFactory.produceTypeActionsListWithHeaders(active));
|
||||
|
||||
RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recycler_view);
|
||||
Button btnDismiss = (Button) root.findViewById(R.id.btnDismiss);
|
||||
|
|
|
@ -180,6 +180,9 @@ public class CreateEditActionDialog extends DialogFragment {
|
|||
}
|
||||
});
|
||||
|
||||
name.setEnabled(!action.isSingle() && !action.toggle);
|
||||
action.setAutoGeneratedTitle(name);
|
||||
|
||||
if (savedInstanceState == null) name.setText(action.getName(getContext()));
|
||||
else action.setName(name.getText().toString());
|
||||
|
||||
|
|
|
@ -2,21 +2,25 @@ package net.osmand.plus.quickaction;
|
|||
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class QuickAction {
|
||||
|
@ -58,6 +62,8 @@ public class QuickAction {
|
|||
this.iconRes = quickAction.iconRes;
|
||||
this.name = quickAction.name;
|
||||
this.params = quickAction.params;
|
||||
this.single = quickAction.single;
|
||||
this.toggle = quickAction.toggle;
|
||||
}
|
||||
|
||||
public int getNameRes() {
|
||||
|
@ -76,6 +82,10 @@ public class QuickAction {
|
|||
return name == null || name.isEmpty() ? nameRes > 0 ? context.getString(nameRes) : "" : name;
|
||||
}
|
||||
|
||||
public boolean isSingle() {
|
||||
return single;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getParams() {
|
||||
|
||||
if (params == null) params = new HashMap<>();
|
||||
|
@ -91,10 +101,30 @@ public class QuickAction {
|
|||
this.params = params;
|
||||
}
|
||||
|
||||
public boolean isActionWithSlash(OsmandApplication application){
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getActionText(OsmandApplication application){
|
||||
return getName(application);
|
||||
}
|
||||
|
||||
public void setAutoGeneratedTitle(EditText title){
|
||||
}
|
||||
|
||||
public void execute(MapActivity activity){};
|
||||
public void drawUI(ViewGroup parent, MapActivity activity){};
|
||||
public boolean fillParams(View root, MapActivity activity){ return true; };
|
||||
|
||||
public boolean hasInstanceInList(List<QuickAction> active){
|
||||
|
||||
for (QuickAction action: active){
|
||||
if (action.type == type) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiFilter;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.osm.edit.OSMSettings;
|
||||
|
@ -71,6 +72,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.osmand.plus.osmedit.AdvancedEditPoiFragment.addPoiToStringSet;
|
||||
|
||||
|
@ -100,19 +102,6 @@ public class QuickActionFactory {
|
|||
return quickActions != null ? quickActions : new ArrayList<QuickAction>();
|
||||
}
|
||||
|
||||
// public static List<QuickAction> produceTypeActionsList() {
|
||||
//
|
||||
// ArrayList<QuickAction> quickActions = new ArrayList<>();
|
||||
//
|
||||
// quickActions.add(new MarkerAction());
|
||||
// quickActions.add(new FavoriteAction());
|
||||
// quickActions.add(new ShowHideFavoritesAction());
|
||||
// quickActions.add(new ShowHidePoiAction());
|
||||
// quickActions.add(new GPXAction());
|
||||
//
|
||||
// return quickActions;
|
||||
// }
|
||||
|
||||
public static List<QuickAction> produceTypeActionsListWithHeaders() {
|
||||
|
||||
ArrayList<QuickAction> quickActions = new ArrayList<>();
|
||||
|
@ -151,6 +140,76 @@ public class QuickActionFactory {
|
|||
return quickActions;
|
||||
}
|
||||
|
||||
public static List<QuickAction> produceTypeActionsListWithHeaders(List<QuickAction> active) {
|
||||
|
||||
ArrayList<QuickAction> quickActions = new ArrayList<>();
|
||||
|
||||
quickActions.add(new QuickAction(0, R.string.quick_action_add_create_items));
|
||||
quickActions.add(new FavoriteAction());
|
||||
quickActions.add(new GPXAction());
|
||||
|
||||
QuickAction marker = new MarkerAction();
|
||||
|
||||
if (!marker.hasInstanceInList(active)) {
|
||||
quickActions.add(marker);
|
||||
}
|
||||
|
||||
if (OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class) != null) {
|
||||
|
||||
QuickAction audio = new TakeAudioNoteAction();
|
||||
QuickAction photo = new TakePhotoNoteAction();
|
||||
QuickAction vedio = new TakeVideoNoteAction();
|
||||
|
||||
if (!audio.hasInstanceInList(active)) {
|
||||
quickActions.add(audio);
|
||||
}
|
||||
|
||||
if (!photo.hasInstanceInList(active)) {
|
||||
quickActions.add(photo);
|
||||
}
|
||||
|
||||
if (!vedio.hasInstanceInList(active)) {
|
||||
quickActions.add(vedio);
|
||||
}
|
||||
}
|
||||
|
||||
if (OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null) {
|
||||
|
||||
quickActions.add(new AddPOIAction());
|
||||
quickActions.add(new AddOSMBugAction());
|
||||
}
|
||||
|
||||
if (OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class) != null) {
|
||||
|
||||
QuickAction parking = new ParkingAction();
|
||||
|
||||
if (!parking.hasInstanceInList(active)) {
|
||||
quickActions.add(parking);
|
||||
}
|
||||
}
|
||||
|
||||
quickActions.add(new QuickAction(0, R.string.quick_action_add_configure_map));
|
||||
quickActions.add(new MapStyleAction());
|
||||
|
||||
QuickAction favorites = new ShowHideFavoritesAction();
|
||||
|
||||
if (!favorites.hasInstanceInList(active)) {
|
||||
quickActions.add(favorites);
|
||||
}
|
||||
|
||||
quickActions.add(new ShowHidePoiAction());
|
||||
|
||||
QuickAction voice = new NavigationVoiceAction();
|
||||
|
||||
if (!voice.hasInstanceInList(active)) {
|
||||
|
||||
quickActions.add(new QuickAction(0, R.string.quick_action_add_navigation));
|
||||
quickActions.add(voice);
|
||||
}
|
||||
|
||||
return quickActions;
|
||||
}
|
||||
|
||||
public static QuickAction newActionByType(int type) {
|
||||
|
||||
switch (type) {
|
||||
|
@ -412,7 +471,7 @@ public class QuickActionFactory {
|
|||
name.setText(getParams().get(KEY_NAME));
|
||||
categoryEdit.setText(getParams().get(KEY_CATEGORY_NAME));
|
||||
|
||||
if (getParams().get(KEY_NAME).isEmpty() && Integer.valueOf(getParams().get(KEY_CATEGORY_NAME)) == 0) {
|
||||
if (getParams().get(KEY_NAME).isEmpty() && Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)) == 0) {
|
||||
|
||||
categoryEdit.setText(activity.getString(R.string.shared_string_favorites));
|
||||
categoryImage.setColorFilter(activity.getResources().getColor(R.color.color_favorite));
|
||||
|
@ -526,7 +585,7 @@ public class QuickActionFactory {
|
|||
protected ShowHideFavoritesAction() {
|
||||
id = System.currentTimeMillis();
|
||||
type = TYPE;
|
||||
nameRes = R.string.quic_action_showhide_favorites_title;
|
||||
nameRes = R.string.quick_action_showhide_favorites_title;
|
||||
iconRes = R.drawable.ic_action_fav_dark;
|
||||
single = true;
|
||||
toggle = true;
|
||||
|
@ -556,6 +615,20 @@ public class QuickActionFactory {
|
|||
|
||||
parent.addView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionText(OsmandApplication application) {
|
||||
|
||||
return application.getSettings().SHOW_FAVORITES.get()
|
||||
? application.getString(R.string.quick_action_favorites_hide)
|
||||
: application.getString(R.string.quick_action_favorites_show);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionWithSlash(OsmandApplication application) {
|
||||
|
||||
return application.getSettings().SHOW_FAVORITES.get();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShowHidePoiAction extends QuickAction {
|
||||
|
@ -564,10 +637,12 @@ public class QuickActionFactory {
|
|||
|
||||
public static final String KEY_FILTERS = "filters";
|
||||
|
||||
private transient EditText title;
|
||||
|
||||
protected ShowHidePoiAction() {
|
||||
id = System.currentTimeMillis();
|
||||
type = TYPE;
|
||||
nameRes = R.string.quic_action_showhide_poi_title;
|
||||
nameRes = R.string.quick_action_showhide_poi_title;
|
||||
iconRes = R.drawable.ic_action_gabout_dark;
|
||||
toggle = true;
|
||||
}
|
||||
|
@ -576,14 +651,34 @@ public class QuickActionFactory {
|
|||
super(quickAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionText(OsmandApplication application) {
|
||||
|
||||
return !isCurrentFilters(application)
|
||||
? application.getString(R.string.quick_action_poi_show, getName(application))
|
||||
: application.getString(R.string.quick_action_poi_hide, getName(application));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionWithSlash(OsmandApplication application) {
|
||||
|
||||
return isCurrentFilters(application);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoGeneratedTitle(EditText title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MapActivity activity) {
|
||||
|
||||
PoiFiltersHelper pf = activity.getMyApplication().getPoiFilters();
|
||||
List<PoiUIFilter> poiFilters = loadPoiFilters(activity.getMyApplication().getPoiFilters());
|
||||
|
||||
if (pf.getSelectedPoiFilters().isEmpty()) {
|
||||
if (!isCurrentFilters(pf.getSelectedPoiFilters(), poiFilters)){
|
||||
|
||||
List<PoiUIFilter> poiFilters = loadPoiFilters(activity.getMyApplication().getPoiFilters());
|
||||
pf.clearSelectedPoiFilters();
|
||||
|
||||
for (PoiUIFilter filter : poiFilters) {
|
||||
pf.addSelectedPoiFilter(filter);
|
||||
|
@ -591,9 +686,26 @@ public class QuickActionFactory {
|
|||
|
||||
} else pf.clearSelectedPoiFilters();
|
||||
|
||||
|
||||
|
||||
activity.getMapLayers().updateLayers(activity.getMapView());
|
||||
}
|
||||
|
||||
private boolean isCurrentFilters(OsmandApplication application) {
|
||||
|
||||
PoiFiltersHelper pf = application.getPoiFilters();
|
||||
List<PoiUIFilter> poiFilters = loadPoiFilters(application.getPoiFilters());
|
||||
|
||||
return isCurrentFilters(pf.getSelectedPoiFilters(), poiFilters);
|
||||
}
|
||||
|
||||
private boolean isCurrentFilters(Set<PoiUIFilter> currentPoiFilters, List<PoiUIFilter> poiFilters){
|
||||
|
||||
if (currentPoiFilters.size() != poiFilters.size()) return false;
|
||||
|
||||
return currentPoiFilters.containsAll(poiFilters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawUI(ViewGroup parent, final MapActivity activity) {
|
||||
|
||||
|
@ -646,7 +758,7 @@ public class QuickActionFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(Holder holder, final int position) {
|
||||
public void onBindViewHolder(final Holder holder, final int position) {
|
||||
|
||||
final PoiUIFilter filter = filters.get(position);
|
||||
|
||||
|
@ -663,10 +775,18 @@ public class QuickActionFactory {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
String oldTitle = getTitle(filters);
|
||||
|
||||
filters.remove(position);
|
||||
savePoiFilters(filters);
|
||||
|
||||
notifyDataSetChanged();
|
||||
|
||||
if (oldTitle.equals(title.getText().toString()) || title.getText().toString().equals(getName(holder.title.getContext()))) {
|
||||
|
||||
String newTitle = getTitle(filters);
|
||||
title.setText(newTitle);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -727,7 +847,7 @@ public class QuickActionFactory {
|
|||
return poiFilters;
|
||||
}
|
||||
|
||||
private void showSingleChoicePoiFilterDialog(final OsmandApplication app, MapActivity activity, final Adapter filtersAdapter) {
|
||||
private void showSingleChoicePoiFilterDialog(final OsmandApplication app, final MapActivity activity, final Adapter filtersAdapter) {
|
||||
|
||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
|
@ -752,7 +872,16 @@ public class QuickActionFactory {
|
|||
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
String oldTitle = getTitle(filtersAdapter.filters);
|
||||
|
||||
filtersAdapter.addItem(list.get(which));
|
||||
|
||||
if (oldTitle.equals(title.getText().toString()) || title.getText().toString().equals(getName(activity))) {
|
||||
|
||||
String newTitle = getTitle(filtersAdapter.filters);
|
||||
title.setText(newTitle);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -773,6 +902,15 @@ public class QuickActionFactory {
|
|||
alertDialog.show();
|
||||
}
|
||||
|
||||
private String getTitle(List<PoiUIFilter> filters) {
|
||||
|
||||
if (filters.isEmpty()) return "";
|
||||
|
||||
return filters.size() > 1
|
||||
? filters.get(0).getName() + " +" + (filters.size() - 1)
|
||||
: filters.get(0).getName();
|
||||
}
|
||||
|
||||
private void addFilterToList(final ContextMenuAdapter adapter,
|
||||
final List<PoiUIFilter> list,
|
||||
final PoiUIFilter f) {
|
||||
|
@ -878,7 +1016,7 @@ public class QuickActionFactory {
|
|||
name.setText(getParams().get(KEY_NAME));
|
||||
categoryEdit.setText(getParams().get(KEY_CATEGORY_NAME));
|
||||
|
||||
if (getParams().get(KEY_NAME).isEmpty() && Integer.valueOf(getParams().get(KEY_CATEGORY_NAME)) == 0) {
|
||||
if (getParams().get(KEY_NAME).isEmpty() && Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)) == 0) {
|
||||
|
||||
categoryEdit.setText("");
|
||||
categoryImage.setColorFilter(activity.getResources().getColor(R.color.icon_color));
|
||||
|
@ -1161,6 +1299,20 @@ public class QuickActionFactory {
|
|||
|
||||
parent.addView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionText(OsmandApplication application) {
|
||||
|
||||
return application.getSettings().VOICE_MUTE.get()
|
||||
? application.getString(R.string.quick_action_navigation_voice_off)
|
||||
: application.getString(R.string.quick_action_navigation_voice_on);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionWithSlash(OsmandApplication application) {
|
||||
|
||||
return application.getSettings().VOICE_MUTE.get();
|
||||
}
|
||||
}
|
||||
|
||||
public static class AddOSMBugAction extends QuickAction {
|
||||
|
@ -1422,6 +1574,8 @@ public class QuickActionFactory {
|
|||
|
||||
private static String KEY_STYLES = "styles";
|
||||
|
||||
private transient EditText title;
|
||||
|
||||
protected MapStyleAction() {
|
||||
id = System.currentTimeMillis();
|
||||
type = TYPE;
|
||||
|
@ -1437,7 +1591,7 @@ public class QuickActionFactory {
|
|||
@Override
|
||||
public void execute(MapActivity activity) {
|
||||
|
||||
List<String> mapStyles = getFilteredStyles(activity.getMyApplication());
|
||||
List<String> mapStyles = getFilteredStyles();
|
||||
|
||||
String curStyle = activity.getMyApplication().getSettings().RENDERER.get();
|
||||
int index = mapStyles.indexOf(curStyle);
|
||||
|
@ -1458,13 +1612,15 @@ public class QuickActionFactory {
|
|||
activity.getMyApplication().getRendererRegistry().setCurrentSelectedRender(loaded);
|
||||
ConfigureMapMenu.refreshMapComplete(activity);
|
||||
|
||||
Toast.makeText(activity, activity.getString(R.string.quick_action_map_style_switch, nextStyle), Toast.LENGTH_SHORT).show();
|
||||
|
||||
} else {
|
||||
|
||||
Toast.makeText(activity, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
protected List<String> getFilteredStyles(OsmandApplication application){
|
||||
protected List<String> getFilteredStyles(){
|
||||
|
||||
List<String> filtered = new ArrayList<>();
|
||||
boolean enabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) != null;
|
||||
|
@ -1483,6 +1639,21 @@ public class QuickActionFactory {
|
|||
return filtered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoGeneratedTitle(EditText title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
private String getTitle(List<String> filters) {
|
||||
|
||||
if (filters.isEmpty()) return "";
|
||||
|
||||
return filters.size() > 1
|
||||
? filters.get(0) + " +" + (filters.size() - 1)
|
||||
: filters.get(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawUI(ViewGroup parent, final MapActivity activity) {
|
||||
|
||||
|
@ -1542,7 +1713,18 @@ public class QuickActionFactory {
|
|||
String renderer = visibleNamesList.get(i);
|
||||
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
|
||||
|
||||
if (loaded != null) adapter.addItem(renderer);
|
||||
if (loaded != null) {
|
||||
|
||||
String oldTitle = getTitle(adapter.itemsList);
|
||||
|
||||
adapter.addItem(renderer);
|
||||
|
||||
if (oldTitle.equals(title.getText().toString()) || title.getText().toString().equals(getName(activity))) {
|
||||
|
||||
String newTitle = getTitle(adapter.itemsList);
|
||||
title.setText(newTitle);
|
||||
}
|
||||
}
|
||||
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
|
@ -1591,7 +1773,16 @@ public class QuickActionFactory {
|
|||
holder.closeBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
String oldTitle = getTitle(itemsList);
|
||||
|
||||
deleteItem(position);
|
||||
|
||||
if (oldTitle.equals(title.getText().toString()) || title.getText().toString().equals(getName(holder.handleView.getContext()))) {
|
||||
|
||||
String newTitle = getTitle(itemsList);
|
||||
title.setText(newTitle);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1644,6 +1835,8 @@ public class QuickActionFactory {
|
|||
if (selectedPosition < 0 || targetPosition < 0)
|
||||
return false;
|
||||
|
||||
String oldTitle = getTitle(itemsList);
|
||||
|
||||
Collections.swap(itemsList, selectedPosition, targetPosition);
|
||||
if (selectedPosition - targetPosition < -1) {
|
||||
notifyItemMoved(selectedPosition, targetPosition);
|
||||
|
@ -1657,6 +1850,12 @@ public class QuickActionFactory {
|
|||
notifyItemChanged(selectedPosition);
|
||||
notifyItemChanged(targetPosition);
|
||||
|
||||
if (oldTitle.equals(title.getText().toString()) || title.getText().toString().equals(getName(recyclerView.getContext()))) {
|
||||
|
||||
String newTitle = getTitle(itemsList);
|
||||
title.setText(newTitle);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ public class QuickActionRegistry {
|
|||
if (action.type == QuickActionFactory.MapStyleAction.TYPE) {
|
||||
|
||||
if (((QuickActionFactory.MapStyleAction) QuickActionFactory.produceAction(action))
|
||||
.getFilteredStyles(settings.getContext()).isEmpty()){
|
||||
.getFilteredStyles().isEmpty()){
|
||||
|
||||
skip = true;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,8 @@ public class QuickActionsWidget extends LinearLayout {
|
|||
|
||||
private void setupLayout(Context context, int pageCount){
|
||||
|
||||
boolean light = ((OsmandApplication) context.getApplicationContext()).getSettings().isLightContent();
|
||||
OsmandApplication application = ((OsmandApplication) getContext().getApplicationContext());
|
||||
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
|
||||
|
||||
inflate(new ContextThemeWrapper(context, light
|
||||
? R.style.OsmandLightTheme
|
||||
|
@ -159,7 +160,8 @@ public class QuickActionsWidget extends LinearLayout {
|
|||
|
||||
private void updateControls(int position) {
|
||||
|
||||
boolean light = ((OsmandApplication) getContext().getApplicationContext()).getSettings().isLightContent();
|
||||
OsmandApplication application = ((OsmandApplication) getContext().getApplicationContext());
|
||||
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
|
||||
|
||||
int colorEnabled = light ? R.color.icon_color : R.color.color_white;
|
||||
int colorDisabled = light ? R.color.icon_color_light : R.color.white_50_transparent;
|
||||
|
@ -184,7 +186,8 @@ public class QuickActionsWidget extends LinearLayout {
|
|||
|
||||
private View createPageView(ViewGroup container, int position){
|
||||
|
||||
boolean light = ((OsmandApplication) getContext().getApplicationContext()).getSettings().isLightContent();
|
||||
OsmandApplication application = ((OsmandApplication) getContext().getApplicationContext());
|
||||
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
|
||||
|
||||
LayoutInflater li = getLayoutInflater(light
|
||||
? R.style.OsmandLightTheme
|
||||
|
@ -202,13 +205,22 @@ public class QuickActionsWidget extends LinearLayout {
|
|||
|
||||
if (i + (position * ELEMENT_PER_PAGE) < actions.size()) {
|
||||
|
||||
final QuickAction action = actions.get(i + (position * ELEMENT_PER_PAGE));
|
||||
final QuickAction action = QuickActionFactory.produceAction(
|
||||
actions.get(i + (position * ELEMENT_PER_PAGE)));
|
||||
|
||||
((ImageView) view.findViewById(R.id.imageView))
|
||||
.setImageResource(action.getIconRes());
|
||||
|
||||
((TextView) view.findViewById(R.id.title))
|
||||
.setText(action.getName(getContext()));
|
||||
.setText(action.getActionText(application));
|
||||
|
||||
if (action.isActionWithSlash(application)) {
|
||||
|
||||
((ImageView) view.findViewById(R.id.imageSlash))
|
||||
.setImageResource(light
|
||||
? R.drawable.ic_action_icon_hide_white
|
||||
: R.drawable.ic_action_icon_hide_dark);
|
||||
}
|
||||
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue