quick action show hide poi
This commit is contained in:
parent
2ce53c5d50
commit
ce48322c22
5 changed files with 238 additions and 253 deletions
|
@ -16,12 +16,13 @@
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/handle_view"
|
android:id="@+id/icon"
|
||||||
android:layout_width="56dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginRight="4dp"
|
android:layout_marginRight="4dp"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
|
android:tint="@color/icon_color"
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/ic_action_reorder"/>
|
android:src="@drawable/ic_action_reorder"/>
|
||||||
|
|
||||||
|
@ -38,12 +39,13 @@
|
||||||
tools:text="Add marker"/>
|
tools:text="Add marker"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/closeImageButton"
|
android:id="@+id/delete"
|
||||||
android:layout_width="56dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="?android:selectableItemBackground"
|
android:background="?android:selectableItemBackground"
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
|
android:tint="@color/icon_color_light"
|
||||||
android:src="@drawable/ic_action_remove_dark"/>
|
android:src="@drawable/ic_action_remove_dark"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -1,239 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<ScrollView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/editor_scroll_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:fillViewport="true">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingLeft="24dp"
|
|
||||||
android:paddingRight="16dp">
|
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatTextView
|
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
|
||||||
android:text="@string/quick_favorites_show_favorites_dialog"/>
|
|
||||||
|
|
||||||
<android.support.v7.widget.SwitchCompat
|
|
||||||
android:id="@+id/toggle_item"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:focusable="false"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/main_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/title_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?attr/bg_color"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:baselineAligned="false"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="42dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/name_image"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
android:src="@drawable/ic_action_fav_dark"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/name_caption"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginRight="12dp"
|
|
||||||
android:text="@string/favourites_edit_dialog_name"
|
|
||||||
android:textColor="?android:textColorSecondary"
|
|
||||||
android:textSize="@dimen/default_sub_text_size"/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/name_edit"
|
|
||||||
android:hint="@string/quick_favorites_name_preset"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:imeOptions="actionDone"
|
|
||||||
android:inputType="text"
|
|
||||||
android:textColor="?android:textColorPrimary"
|
|
||||||
android:textColorHint="?android:textColorSecondary"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/description"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginRight="12dp"
|
|
||||||
android:text="@string/quick_favorites_name_description"
|
|
||||||
android:textColor="?android:textColorSecondary"
|
|
||||||
android:textSize="@dimen/default_sub_text_size"/>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:baselineAligned="false"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="42dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/category_image"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
android:src="@drawable/ic_action_building_number"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/category_caption"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginRight="12dp"
|
|
||||||
android:text="@string/favourites_edit_dialog_name"
|
|
||||||
android:textColor="?android:textColorSecondary"
|
|
||||||
android:textSize="@dimen/default_list_text_size"/>
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.AutoCompleteTextViewEx
|
|
||||||
android:id="@+id/category_edit"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
|
||||||
android:editable="false"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="48dp"
|
|
||||||
android:foreground="@drawable/bg_contextmenu_shadow"
|
|
||||||
android:foregroundGravity="top|fill_horizontal">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/description_info_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:baselineAligned="false"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="42dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/description_image"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:src="@drawable/ic_action_note_dark"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/description_edit"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:inputType="textMultiLine"
|
|
||||||
android:maxLines="8"
|
|
||||||
android:textColor="?android:textColorPrimary"
|
|
||||||
android:textColorHint="?android:textColorSecondary"/>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
|
@ -12,15 +12,27 @@
|
||||||
android:background="?attr/bg_color"
|
android:background="?attr/bg_color"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/text"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/bg_color"
|
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:text="@string/quick_action_showhides_favorites_discr"
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/quick_action_poi_list"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="@dimen/default_list_text_size" />
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Tou can add few POI categories to display on the map."
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -2514,4 +2514,5 @@ If you need help with OsmAnd application, please contact our support team: suppo
|
||||||
<string name="quick_action_fav_name_discr">Leave field blank and OsmAnd will use the address or name of a place for the favorite point</string>
|
<string name="quick_action_fav_name_discr">Leave field blank and OsmAnd will use the address or name of a place for the favorite point</string>
|
||||||
<string name="quick_action_category_discr">You can select a category to save favorite point.</string>
|
<string name="quick_action_category_discr">You can select a category to save favorite point.</string>
|
||||||
<string name="quick_action_gpx_category_discr">You can select a category to save GPX waypoint point.</string>
|
<string name="quick_action_gpx_category_discr">You can select a category to save GPX waypoint point.</string>
|
||||||
|
<string name="quick_action_poi_list">POI list</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -3,10 +3,17 @@ package net.osmand.plus.quickaction;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.SwitchCompat;
|
import android.support.v7.widget.SwitchCompat;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -16,11 +23,16 @@ import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.osm.PoiFilter;
|
||||||
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
import net.osmand.plus.ContextMenuItem;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.GeocodingLookupService;
|
import net.osmand.plus.GeocodingLookupService;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.MapActivityLayers;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment;
|
import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment;
|
||||||
import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment;
|
import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment;
|
||||||
|
@ -28,11 +40,19 @@ import net.osmand.plus.osmedit.EditPoiDialogFragment;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||||
|
import net.osmand.plus.poi.PoiUIFilter;
|
||||||
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
|
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
|
||||||
|
import net.osmand.search.core.CustomSearchPoiFilter;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class QuickActionFactory {
|
public class QuickActionFactory {
|
||||||
|
|
||||||
|
@ -511,6 +531,8 @@ public class QuickActionFactory {
|
||||||
|
|
||||||
public static final int TYPE = 5;
|
public static final int TYPE = 5;
|
||||||
|
|
||||||
|
public static final String KEY_FILTERS = "filters";
|
||||||
|
|
||||||
protected ShowHidePoiAction() {
|
protected ShowHidePoiAction() {
|
||||||
id = System.currentTimeMillis();
|
id = System.currentTimeMillis();
|
||||||
type = TYPE;
|
type = TYPE;
|
||||||
|
@ -529,24 +551,211 @@ public class QuickActionFactory {
|
||||||
|
|
||||||
if (pf.getSelectedPoiFilters().isEmpty()) {
|
if (pf.getSelectedPoiFilters().isEmpty()) {
|
||||||
|
|
||||||
pf.loadSelectedPoiFilters();
|
List<PoiUIFilter> poiFilters = loadPoiFilters(activity.getMyApplication().getPoiFilters());
|
||||||
|
|
||||||
} else pf.hidePoiFilters();
|
for (PoiUIFilter filter: poiFilters){
|
||||||
|
pf.addSelectedPoiFilter(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else pf.clearSelectedPoiFilters();
|
||||||
|
|
||||||
activity.getMapLayers().updateLayers(activity.getMapView());
|
activity.getMapLayers().updateLayers(activity.getMapView());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawUI(ViewGroup parent, MapActivity activity) {
|
public void drawUI(ViewGroup parent, final MapActivity activity) {
|
||||||
|
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.quick_action_with_text, parent, false);
|
.inflate(R.layout.quick_action_show_hide_poi, parent, false);
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.text)).setText(
|
RecyclerView list = (RecyclerView) view.findViewById(R.id.list);
|
||||||
R.string.quick_action_showhides_poi_discr);
|
Button addFilter = (Button) view.findViewById(R.id.btnAddCategory);
|
||||||
|
|
||||||
|
final Adapter adapter = new Adapter(!getParams().isEmpty()
|
||||||
|
? loadPoiFilters(activity.getMyApplication().getPoiFilters())
|
||||||
|
: new ArrayList<PoiUIFilter>());
|
||||||
|
|
||||||
|
list.setAdapter(adapter);
|
||||||
|
|
||||||
|
addFilter.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
showSingleChoicePoiFilterDialog(activity.getMyApplication(), activity, adapter);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
parent.addView(view);
|
parent.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Adapter extends RecyclerView.Adapter<Adapter.Holder>{
|
||||||
|
|
||||||
|
private List<PoiUIFilter> filters;
|
||||||
|
|
||||||
|
public Adapter(List<PoiUIFilter> filters) {
|
||||||
|
this.filters = filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addItem(PoiUIFilter filter){
|
||||||
|
|
||||||
|
filters.add(filter);
|
||||||
|
savePoiFilters(filters);
|
||||||
|
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
|
return new Holder(LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.quick_action_deletable_list_item, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(Holder holder, final int position) {
|
||||||
|
|
||||||
|
final PoiUIFilter filter = filters.get(position);
|
||||||
|
|
||||||
|
Object res = filter.getIconResource();
|
||||||
|
|
||||||
|
if (res instanceof String && RenderingIcons.containsBigIcon(res.toString())) {
|
||||||
|
holder.icon.setImageResource(RenderingIcons.getBigIconResourceId(res.toString()));
|
||||||
|
} else {
|
||||||
|
holder.icon.setImageResource(R.drawable.mx_user_defined);
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.title.setText(filter.getName());
|
||||||
|
holder.delete.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
filters.remove(position);
|
||||||
|
savePoiFilters(filters);
|
||||||
|
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return filters.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Holder extends RecyclerView.ViewHolder{
|
||||||
|
|
||||||
|
private TextView title;
|
||||||
|
private ImageView icon;
|
||||||
|
private ImageView delete;
|
||||||
|
|
||||||
|
public Holder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
title = (TextView) itemView.findViewById(R.id.title);
|
||||||
|
icon = (ImageView) itemView.findViewById(R.id.icon);
|
||||||
|
delete = (ImageView) itemView.findViewById(R.id.delete);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void savePoiFilters(List<PoiUIFilter> poiFilters) {
|
||||||
|
|
||||||
|
List<String> filters = new ArrayList<>();
|
||||||
|
|
||||||
|
for (PoiUIFilter f : poiFilters) {
|
||||||
|
filters.add(f.getFilterId());
|
||||||
|
}
|
||||||
|
|
||||||
|
getParams().put(KEY_FILTERS, TextUtils.join(",", filters));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<PoiUIFilter> loadPoiFilters(PoiFiltersHelper helper){
|
||||||
|
|
||||||
|
List<String> filters = new ArrayList<>();
|
||||||
|
|
||||||
|
String filtersId = getParams().get(KEY_FILTERS);
|
||||||
|
|
||||||
|
if (filtersId != null && !filtersId.trim().isEmpty()) {
|
||||||
|
Collections.addAll(filters, filtersId.split(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PoiUIFilter> poiFilters = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String f : filters) {
|
||||||
|
|
||||||
|
PoiUIFilter filter = helper.getFilterById(f);
|
||||||
|
|
||||||
|
if (filter != null) {
|
||||||
|
poiFilters.add(filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return poiFilters;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showSingleChoicePoiFilterDialog(final OsmandApplication app, MapActivity activity, final Adapter filtersAdapter) {
|
||||||
|
|
||||||
|
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||||
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
|
|
||||||
|
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||||
|
.setTitleId(R.string.shared_string_search, app)
|
||||||
|
.setIcon(R.drawable.ic_action_search_dark).createItem());
|
||||||
|
|
||||||
|
final List<PoiUIFilter> list = new ArrayList<>();
|
||||||
|
list.add(poiFilters.getCustomPOIFilter());
|
||||||
|
|
||||||
|
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
|
||||||
|
addFilterToList(adapter, list, f);
|
||||||
|
}
|
||||||
|
for (PoiUIFilter f : poiFilters.getSearchPoiFilters()) {
|
||||||
|
addFilterToList(adapter, list, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
final ArrayAdapter<ContextMenuItem> listAdapter =
|
||||||
|
adapter.createListAdapter(activity, app.getSettings().isLightContent());
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
filtersAdapter.addItem(list.get(which));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
builder.setTitle(R.string.show_poi_over_map);
|
||||||
|
builder.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||||
|
|
||||||
|
final AlertDialog alertDialog = builder.create();
|
||||||
|
|
||||||
|
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||||
|
@Override
|
||||||
|
public void onShow(DialogInterface dialog) {
|
||||||
|
Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
|
||||||
|
Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_multiselect);
|
||||||
|
neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addFilterToList(final ContextMenuAdapter adapter,
|
||||||
|
final List<PoiUIFilter> list,
|
||||||
|
final PoiUIFilter f) {
|
||||||
|
list.add(f);
|
||||||
|
ContextMenuItem.ItemBuilder builder = new ContextMenuItem.ItemBuilder();
|
||||||
|
|
||||||
|
builder.setTitle(f.getName());
|
||||||
|
|
||||||
|
if (RenderingIcons.containsBigIcon(f.getIconId())) {
|
||||||
|
builder.setIcon(RenderingIcons.getBigIconResourceId(f.getIconId()));
|
||||||
|
} else {
|
||||||
|
builder.setIcon(R.drawable.mx_user_defined);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.setColor(ContextMenuItem.INVALID_ID);
|
||||||
|
builder.setSkipPaintingWithoutColor(true);
|
||||||
|
adapter.addItem(builder.createItem());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GPXAction extends QuickAction {
|
public static class GPXAction extends QuickAction {
|
||||||
|
|
Loading…
Reference in a new issue