Refactoring
This commit is contained in:
parent
12f8c1f115
commit
09b78d044f
26 changed files with 1004 additions and 719 deletions
|
@ -7,9 +7,9 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.Build;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
@ -32,30 +32,14 @@ import java.util.LinkedHashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class ContextMenuAdapter {
|
||||
private static final Log LOG = PlatformUtil.getLog(ContextMenuAdapter.class);
|
||||
|
||||
private final Context ctx;
|
||||
private View anchor;
|
||||
@LayoutRes
|
||||
private int defaultLayoutId = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ?
|
||||
R.layout.list_menu_item : R.layout.list_menu_item_native;
|
||||
final TIntArrayList items = new TIntArrayList();
|
||||
final TIntArrayList isCategory = new TIntArrayList();
|
||||
final ArrayList<String> itemNames = new ArrayList<String>();
|
||||
final ArrayList<OnContextMenuClick> checkListeners = new ArrayList<>();
|
||||
final ArrayList<OnIntegerValueChangedListener> integerListeners = new ArrayList<>();
|
||||
final TIntArrayList selectedList = new TIntArrayList();
|
||||
final TIntArrayList progressList = new TIntArrayList();
|
||||
final TIntArrayList loadingList = new TIntArrayList();
|
||||
final TIntArrayList layoutIds = new TIntArrayList();
|
||||
final TIntArrayList iconList = new TIntArrayList();
|
||||
final TIntArrayList lightIconList = new TIntArrayList();
|
||||
final TIntArrayList secondaryLightIconList = new TIntArrayList();
|
||||
final ArrayList<String> itemDescription = new ArrayList<String>();
|
||||
private List<ApplicationMode> visibleModes = new ArrayList<ApplicationMode>();
|
||||
List<ContextMenuItem> items = new ArrayList<>();
|
||||
private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
|
||||
//neded to detect whether user opened all modes or not
|
||||
private BooleanResult allModes = new BooleanResult();
|
||||
|
@ -69,84 +53,61 @@ public class ContextMenuAdapter {
|
|||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public void setAnchor(View anchor) {
|
||||
this.anchor = anchor;
|
||||
}
|
||||
|
||||
public View getAnchor() {
|
||||
return anchor;
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
public int getElementId(int pos) {
|
||||
return items.get(pos);
|
||||
public int getElementId(int position) {
|
||||
return items.get(position).getTitleId();
|
||||
}
|
||||
|
||||
public OnContextMenuClick getClickAdapter(int i) {
|
||||
return checkListeners.get(i);
|
||||
public OnContextMenuClick getClickAdapter(int position) {
|
||||
return items.get(position).getCheckBoxListener();
|
||||
}
|
||||
|
||||
public OnIntegerValueChangedListener getIntegerLister(int i) {
|
||||
return integerListeners.get(i);
|
||||
public OnIntegerValueChangedListener getIntegerLister(int position) {
|
||||
return items.get(position).getIntegerListener();
|
||||
}
|
||||
|
||||
public String getItemName(int pos) {
|
||||
return itemNames.get(pos);
|
||||
public String getItemName(int position) {
|
||||
return items.get(position).getTitle();
|
||||
}
|
||||
|
||||
public String getItemDescr(int pos) {
|
||||
return itemDescription.get(pos);
|
||||
public String getItemDescr(int position) {
|
||||
return items.get(position).getDescription();
|
||||
}
|
||||
|
||||
public void setItemName(int pos, String str) {
|
||||
itemNames.set(pos, str);
|
||||
public Boolean getSelection(int position) {
|
||||
return items.get(position).getSelected();
|
||||
}
|
||||
|
||||
public void setItemDescription(int pos, String str) {
|
||||
itemDescription.set(pos, str);
|
||||
public int getProgress(int position) {
|
||||
return items.get(position).getProgress();
|
||||
}
|
||||
|
||||
public int getSelection(int pos) {
|
||||
return selectedList.get(pos);
|
||||
public int getLoading(int position) {
|
||||
return items.get(position).isLoading() ? 1 : 0;
|
||||
}
|
||||
|
||||
public int getProgress(int pos) {
|
||||
return progressList.get(pos);
|
||||
}
|
||||
|
||||
public int getLoading(int pos) {
|
||||
return loadingList.get(pos);
|
||||
}
|
||||
|
||||
public void setSelection(int pos, int s) {
|
||||
selectedList.set(pos, s);
|
||||
}
|
||||
|
||||
public void setProgress(int pos, int s) {
|
||||
progressList.set(pos, s);
|
||||
}
|
||||
|
||||
|
||||
public Drawable getImage(OsmandApplication ctx, int pos, boolean light) {
|
||||
int lst = iconList.get(pos);
|
||||
if (lst != 0) {
|
||||
public Drawable getImage(OsmandApplication ctx, int position, boolean light) {
|
||||
@DrawableRes
|
||||
int lst = items.get(position).getIcon();
|
||||
if (lst != -1) {
|
||||
return ctx.getResources().getDrawable(lst);
|
||||
}
|
||||
int lstLight = lightIconList.get(pos);
|
||||
if (lstLight != 0) {
|
||||
@DrawableRes
|
||||
int lstLight = items.get(position).getLightIcon();
|
||||
if (lstLight != -1) {
|
||||
return ctx.getIconsCache().getIcon(lstLight, light);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Drawable getSecondaryImage(OsmandApplication ctx, int pos, boolean light) {
|
||||
public Drawable getSecondaryImage(OsmandApplication ctx, int position, boolean light) {
|
||||
@DrawableRes
|
||||
int secondaryDrawableId = secondaryLightIconList.get(pos);
|
||||
if (secondaryDrawableId != 0) {
|
||||
return ContextCompat.getDrawable(ctx, secondaryDrawableId);
|
||||
int secondaryDrawableId = items.get(position).getSecondaryLightIcon();
|
||||
if (secondaryDrawableId != -1) {
|
||||
return ctx.getIconsCache().getIcon(secondaryDrawableId, light);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -159,55 +120,50 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isCategory(int pos) {
|
||||
return isCategory.get(pos) > 0;
|
||||
}
|
||||
|
||||
public Item item(String name) {
|
||||
Item i = new Item();
|
||||
i.id = (name.hashCode() << 4) | items.size();
|
||||
i.name = name;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
public Item item(@StringRes int resId) {
|
||||
Item i = new Item();
|
||||
i.id = resId;
|
||||
i.name = ctx.getString(resId);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String[] getItemNames() {
|
||||
return itemNames.toArray(new String[itemNames.size()]);
|
||||
}
|
||||
|
||||
public void removeItem(int pos) {
|
||||
items.removeAt(pos);
|
||||
itemNames.remove(pos);
|
||||
selectedList.removeAt(pos);
|
||||
progressList.removeAt(pos);
|
||||
iconList.removeAt(pos);
|
||||
lightIconList.removeAt(pos);
|
||||
secondaryLightIconList.removeAt(pos);
|
||||
checkListeners.remove(pos);
|
||||
integerListeners.remove(pos);
|
||||
isCategory.removeAt(pos);
|
||||
layoutIds.removeAt(pos);
|
||||
loadingList.removeAt(pos);
|
||||
return items.get(pos).isCategory();
|
||||
}
|
||||
|
||||
public int getLayoutId(int position) {
|
||||
int l = layoutIds.get(position);
|
||||
int l = items.get(position).getLayout();
|
||||
if (l != -1) {
|
||||
return l;
|
||||
}
|
||||
return defaultLayoutId;
|
||||
}
|
||||
|
||||
public void setItemName(int position, String str) {
|
||||
items.get(position).setTitle(str);
|
||||
}
|
||||
|
||||
public void setItemDescription(int position, String str) {
|
||||
items.get(position).setDescription(str);
|
||||
}
|
||||
|
||||
public void setSelection(int position, boolean s) {
|
||||
items.get(position).setSelected(s);
|
||||
}
|
||||
|
||||
public void setProgress(int position, int progress) {
|
||||
items.get(position).setProgress(progress);
|
||||
}
|
||||
|
||||
// Adapter related
|
||||
public String[] getItemNames() {
|
||||
String[] itemNames = new String[items.size()];
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
itemNames[i] = items.get(i).getTitle();
|
||||
}
|
||||
return itemNames;
|
||||
}
|
||||
|
||||
public void addItem(ContextMenuItem item) {
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
public void removeItem(int pos) {
|
||||
items.remove(pos);
|
||||
}
|
||||
|
||||
public void setDefaultLayoutId(int defaultLayoutId) {
|
||||
this.defaultLayoutId = defaultLayoutId;
|
||||
|
@ -223,19 +179,17 @@ public class ContextMenuAdapter {
|
|||
final int layoutId = defaultLayoutId;
|
||||
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
|
||||
return new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
|
||||
getItemNames(), app, holoLight);
|
||||
items.toArray(new ContextMenuItem[items.size()]), app, holoLight);
|
||||
}
|
||||
|
||||
public class ContextMenuArrayAdapter extends ArrayAdapter<String> {
|
||||
private Activity activity;
|
||||
public class ContextMenuArrayAdapter extends ArrayAdapter<ContextMenuItem> {
|
||||
private OsmandApplication app;
|
||||
private boolean holoLight;
|
||||
private int layoutId;
|
||||
|
||||
public ContextMenuArrayAdapter(Activity context, int resource, int textViewResourceId,
|
||||
String[] objects, OsmandApplication app, boolean holoLight) {
|
||||
ContextMenuItem[] objects, OsmandApplication app, boolean holoLight) {
|
||||
super(context, resource, textViewResourceId, objects);
|
||||
activity = context;
|
||||
this.app = app;
|
||||
this.holoLight = holoLight;
|
||||
layoutId = resource;
|
||||
|
@ -244,10 +198,12 @@ public class ContextMenuAdapter {
|
|||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
final ContextMenuItem item = getItem(position);
|
||||
Integer lid = getLayoutId(position);
|
||||
if (lid == R.layout.mode_toggles) {
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
|
||||
return AppModeDialog.prepareAppModeDrawerView(activity, visibleModes, selected, allModes, true, new View.OnClickListener() {
|
||||
return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(),
|
||||
selected, allModes, true, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (selected.size() > 0) {
|
||||
|
@ -261,22 +217,22 @@ public class ContextMenuAdapter {
|
|||
});
|
||||
}
|
||||
if (convertView == null || (!lid.equals(convertView.getTag()))) {
|
||||
convertView = activity.getLayoutInflater().inflate(lid, parent, false);
|
||||
convertView = LayoutInflater.from(getContext()).inflate(lid, parent, false);
|
||||
// AndroidUtils.setListItemBackground(ctx, convertView, !holoLight);
|
||||
convertView.setTag(lid);
|
||||
}
|
||||
TextView tv = (TextView) convertView.findViewById(R.id.title);
|
||||
if (!isCategory(position)) {
|
||||
AndroidUtils.setTextPrimaryColor(ctx, tv, !holoLight);
|
||||
AndroidUtils.setTextPrimaryColor(getContext(), tv, !holoLight);
|
||||
}
|
||||
tv.setText(isCategory(position) ? getItemName(position).toUpperCase() : getItemName(position));
|
||||
|
||||
if (layoutId == R.layout.simple_list_menu_item) {
|
||||
int color = activity.getResources()
|
||||
.getColor(holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
|
||||
Drawable imageId = app.getIconsCache().getPaintedContentIcon(
|
||||
lightIconList.get(position), color);
|
||||
float density = activity.getResources().getDisplayMetrics().density;
|
||||
int color = ContextCompat.getColor(getContext(),
|
||||
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
|
||||
Drawable imageId = ContextCompat.getDrawable(getContext(), item.getLightIcon());
|
||||
DrawableCompat.setTint(imageId, color);
|
||||
float density = getContext().getResources().getDisplayMetrics().density;
|
||||
int paddingInPixels = (int) (24 * density);
|
||||
int drawableSizeInPixels = (int) (24 * density); // 32
|
||||
imageId.setBounds(0, 0, drawableSizeInPixels, drawableSizeInPixels);
|
||||
|
@ -293,9 +249,9 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
}
|
||||
@DrawableRes
|
||||
int secondaryLightDrawable = secondaryLightIconList.get(position);
|
||||
if (secondaryLightDrawable != 0) {
|
||||
int color = ContextCompat.getColor(ctx,
|
||||
int secondaryLightDrawable = item.getSecondaryLightIcon();
|
||||
if (secondaryLightDrawable != -1) {
|
||||
int color = ContextCompat.getColor(getContext(),
|
||||
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
|
||||
Drawable drawable = getSecondaryImage(app, position, holoLight);
|
||||
DrawableCompat.setTint(drawable, color);
|
||||
|
@ -317,17 +273,17 @@ public class ContextMenuAdapter {
|
|||
|
||||
if (convertView.findViewById(R.id.toggle_item) != null) {
|
||||
final CompoundButton ch = (CompoundButton) convertView.findViewById(R.id.toggle_item);
|
||||
if (selectedList.get(position) != -1) {
|
||||
if (item.getSelected() != null) {
|
||||
ch.setOnCheckedChangeListener(null);
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
ch.setChecked(selectedList.get(position) > 0);
|
||||
final ArrayAdapter<String> la = this;
|
||||
ch.setChecked(item.getSelected());
|
||||
final ArrayAdapter<ContextMenuItem> la = this;
|
||||
final OnCheckedChangeListener listener = new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
OnContextMenuClick ca = getClickAdapter(position);
|
||||
selectedList.set(position, isChecked ? 1 : 0);
|
||||
item.setSelected(isChecked);
|
||||
if (ca != null) {
|
||||
ca.onContextMenuClick(la, getElementId(position), position, isChecked);
|
||||
}
|
||||
|
@ -342,13 +298,13 @@ public class ContextMenuAdapter {
|
|||
|
||||
if (convertView.findViewById(R.id.seekbar) != null) {
|
||||
SeekBar seekBar = (SeekBar) convertView.findViewById(R.id.seekbar);
|
||||
if (progressList.get(position) != -1) {
|
||||
if (item.getProgress() != -1) {
|
||||
seekBar.setProgress(getProgress(position));
|
||||
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
OnIntegerValueChangedListener listener = getIntegerLister(position);
|
||||
progressList.set(position, progress);
|
||||
item.setProgress(progress);
|
||||
if (listener != null && fromUser) {
|
||||
listener.onIntegerValueChangedListener(progress);
|
||||
}
|
||||
|
@ -370,7 +326,7 @@ public class ContextMenuAdapter {
|
|||
|
||||
if (convertView.findViewById(R.id.ProgressBar) != null) {
|
||||
ProgressBar bar = (ProgressBar) convertView.findViewById(R.id.ProgressBar);
|
||||
if (loadingList.get(position) == 1) {
|
||||
if (item.isLoading()) {
|
||||
bar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
bar.setVisibility(View.INVISIBLE);
|
||||
|
@ -423,113 +379,4 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public class Item {
|
||||
@DrawableRes
|
||||
int icon = 0;
|
||||
@DrawableRes
|
||||
int lightIcon = 0;
|
||||
@DrawableRes
|
||||
int secondaryLightIcon = 0;
|
||||
@StringRes
|
||||
int id;
|
||||
String name;
|
||||
int selected = -1;
|
||||
int progress = -1;
|
||||
@LayoutRes
|
||||
int layout = -1;
|
||||
int loading = -1;
|
||||
boolean cat;
|
||||
int pos = -1;
|
||||
String description = "";
|
||||
private OnContextMenuClick checkBoxListener;
|
||||
private OnIntegerValueChangedListener integerListener;
|
||||
|
||||
private Item() {
|
||||
}
|
||||
|
||||
public Item icon(@DrawableRes int icon) {
|
||||
this.icon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item colorIcon(@DrawableRes int icon) {
|
||||
this.lightIcon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item secondaryIconColor(@DrawableRes int icon) {
|
||||
this.secondaryLightIcon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item position(int pos) {
|
||||
this.pos = pos;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item selected(int selected) {
|
||||
this.selected = selected;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item progress(int progress) {
|
||||
this.progress = progress;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item loading(int loading) {
|
||||
this.loading = loading;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item layout(@LayoutRes int l) {
|
||||
this.layout = l;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item description(String descr) {
|
||||
this.description = descr;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item listen(OnContextMenuClick l) {
|
||||
this.checkBoxListener = l;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item listenInteger(OnIntegerValueChangedListener l) {
|
||||
this.integerListener = l;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void reg() {
|
||||
if (pos >= items.size() || pos < 0) {
|
||||
pos = items.size();
|
||||
}
|
||||
items.insert(pos, id);
|
||||
itemNames.add(pos, name);
|
||||
itemDescription.add(pos, description);
|
||||
selectedList.insert(pos, selected);
|
||||
progressList.insert(pos, progress);
|
||||
loadingList.insert(pos, loading);
|
||||
layoutIds.insert(pos, layout);
|
||||
iconList.insert(pos, icon);
|
||||
lightIconList.insert(pos, lightIcon);
|
||||
secondaryLightIconList.insert(pos, secondaryLightIcon);
|
||||
checkListeners.add(pos, checkBoxListener);
|
||||
integerListeners.add(pos, integerListener);
|
||||
isCategory.insert(pos, cat ? 1 : 0);
|
||||
}
|
||||
|
||||
public Item setCategory(boolean b) {
|
||||
cat = b;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
235
OsmAnd/src/net/osmand/plus/ContextMenuItem.java
Normal file
235
OsmAnd/src/net/osmand/plus/ContextMenuItem.java
Normal file
|
@ -0,0 +1,235 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
/**
|
||||
* Created by GaidamakUA on 3/25/16.
|
||||
*/
|
||||
public class ContextMenuItem {
|
||||
@StringRes
|
||||
private final int titleId;
|
||||
private String title;
|
||||
@DrawableRes
|
||||
private final int icon;
|
||||
@DrawableRes
|
||||
private final int lightIcon;
|
||||
@DrawableRes
|
||||
private final int secondaryLightIcon;
|
||||
private Boolean selected;
|
||||
private int progress;
|
||||
@LayoutRes
|
||||
private final int layout;
|
||||
private boolean loading;
|
||||
private final boolean category;
|
||||
private final int pos;
|
||||
private String description;
|
||||
private ContextMenuAdapter.OnContextMenuClick checkBoxListener;
|
||||
private ContextMenuAdapter.OnIntegerValueChangedListener integerListener;
|
||||
|
||||
private ContextMenuItem(int titleId, String title, int icon, int lightIcon, int secondaryLightIcon,
|
||||
Boolean selected, int progress, int layout, boolean loading, boolean category,
|
||||
int pos, String description, ContextMenuAdapter.OnContextMenuClick checkBoxListener,
|
||||
ContextMenuAdapter.OnIntegerValueChangedListener integerListener) {
|
||||
this.titleId = titleId;
|
||||
this.title = title;
|
||||
this.icon = icon;
|
||||
this.lightIcon = lightIcon;
|
||||
this.secondaryLightIcon = secondaryLightIcon;
|
||||
this.selected = selected;
|
||||
this.progress = progress;
|
||||
this.layout = layout;
|
||||
this.loading = loading;
|
||||
this.category = category;
|
||||
this.pos = pos;
|
||||
this.description = description;
|
||||
this.checkBoxListener = checkBoxListener;
|
||||
this.integerListener = integerListener;
|
||||
}
|
||||
|
||||
public int getTitleId() {
|
||||
return titleId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public int getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public int getLightIcon() {
|
||||
return lightIcon;
|
||||
}
|
||||
|
||||
public int getSecondaryLightIcon() {
|
||||
return secondaryLightIcon;
|
||||
}
|
||||
|
||||
public Boolean getSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public int getLayout() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public boolean isLoading() {
|
||||
return loading;
|
||||
}
|
||||
|
||||
public boolean isCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public int getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public ContextMenuAdapter.OnContextMenuClick getCheckBoxListener() {
|
||||
return checkBoxListener;
|
||||
}
|
||||
|
||||
public ContextMenuAdapter.OnIntegerValueChangedListener getIntegerListener() {
|
||||
return integerListener;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public void setLoading(boolean loading) {
|
||||
this.loading = loading;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setCheckBoxListener(ContextMenuAdapter.OnContextMenuClick checkBoxListener) {
|
||||
this.checkBoxListener = checkBoxListener;
|
||||
}
|
||||
|
||||
public void setIntegerListener(ContextMenuAdapter.OnIntegerValueChangedListener integerListener) {
|
||||
this.integerListener = integerListener;
|
||||
}
|
||||
|
||||
public static ItemBuilder createBuilder(String title) {
|
||||
return new ItemBuilder().setTitle(title);
|
||||
}
|
||||
|
||||
public static class ItemBuilder {
|
||||
private int mTitleId;
|
||||
private String mTitle;
|
||||
private int mIcon = -1;
|
||||
private int mLightIcon = -1;
|
||||
private int mSecondaryLightIcon = -1;
|
||||
private Boolean mSelected = null;
|
||||
private int mProgress = -1;
|
||||
private int mLayout = -1;
|
||||
private boolean mLoading = false;
|
||||
private boolean mCat = false;
|
||||
private int mPos = -1;
|
||||
private String mDescription = null;
|
||||
private ContextMenuAdapter.OnContextMenuClick mCheckBoxListener = null;
|
||||
private ContextMenuAdapter.OnIntegerValueChangedListener mIntegerListener = null;
|
||||
|
||||
public ItemBuilder setTitleId(int titleId, @Nullable Context context) {
|
||||
this.mTitleId = titleId;
|
||||
if (context != null) {
|
||||
mTitle = context.getString(titleId);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setTitle(String title) {
|
||||
this.mTitle = title;
|
||||
this.mTitleId = title.hashCode();
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setIcon(int icon) {
|
||||
mIcon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setColorIcon(int lightIcon) {
|
||||
mLightIcon = lightIcon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setSecondaryLightIcon(int secondaryLightIcon) {
|
||||
mSecondaryLightIcon = secondaryLightIcon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setSelected(boolean selected) {
|
||||
mSelected = selected;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setProgress(int progress) {
|
||||
mProgress = progress;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setLayout(int layout) {
|
||||
mLayout = layout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setLoading(boolean loading) {
|
||||
mLoading = loading;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setCategory(boolean cat) {
|
||||
mCat = cat;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setPosition(int pos) {
|
||||
mPos = pos;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setDescription(String description) {
|
||||
mDescription = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setListener(ContextMenuAdapter.OnContextMenuClick checkBoxListener) {
|
||||
mCheckBoxListener = checkBoxListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setIntegerListener(ContextMenuAdapter.OnIntegerValueChangedListener integerListener) {
|
||||
mIntegerListener = integerListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContextMenuItem createItem() {
|
||||
return new ContextMenuItem(mTitleId, mTitle, mIcon, mLightIcon, mSecondaryLightIcon, mSelected, mProgress, mLayout, mLoading, mCat, mPos, mDescription, mCheckBoxListener, mIntegerListener);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ import net.osmand.map.ITileSource;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
|
@ -279,15 +280,17 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
|
||||
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter(mapActivity) : iadapter;
|
||||
adapter.item(R.string.context_menu_item_search).colorIcon(R.drawable.ic_action_search_dark).reg();
|
||||
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder();
|
||||
adapter.addItem(itemBuilder.setTitleId(R.string.context_menu_item_search, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_search_dark).createItem());
|
||||
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {
|
||||
adapter.item(R.string.context_menu_item_directions_from).colorIcon(
|
||||
R.drawable.ic_action_gdirections_dark).reg();
|
||||
adapter.addItem(itemBuilder.setTitleId(R.string.context_menu_item_directions_from, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_gdirections_dark).createItem());
|
||||
}
|
||||
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() != null &&
|
||||
(mapActivity.getRoutingHelper().isFollowingMode() || mapActivity.getRoutingHelper().isRoutePlanningMode())) {
|
||||
adapter.item(R.string.context_menu_item_last_intermediate_point).colorIcon(
|
||||
R.drawable.ic_action_intermediate).reg();
|
||||
adapter.addItem(itemBuilder.setTitleId(R.string.context_menu_item_last_intermediate_point, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_intermediate).createItem());
|
||||
}
|
||||
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
|
||||
|
||||
|
@ -593,8 +596,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
||||
|
||||
optionsMenuHelper.item(R.string.home).colorIcon(R.drawable.map_dashboard)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.home, mapActivity)
|
||||
.setColorIcon(R.drawable.map_dashboard)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
|
@ -602,30 +606,33 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
if (settings.USE_MAP_MARKERS.get()) {
|
||||
optionsMenuHelper.item(R.string.map_markers).colorIcon(R.drawable.ic_action_flag_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_markers, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_flag_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.MAP_MARKERS);
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
} else {
|
||||
optionsMenuHelper.item(R.string.waypoints).colorIcon(R.drawable.ic_action_intermediate)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.waypoints, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_intermediate)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
}
|
||||
optionsMenuHelper.item(R.string.get_directions).colorIcon(R.drawable.ic_action_gdirections_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_gdirections_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
|
@ -640,11 +647,11 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
// Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
|
||||
optionsMenuHelper.item(R.string.search_button)
|
||||
.colorIcon(R.drawable.ic_action_search_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.search_button, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_search_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
|
@ -659,10 +666,11 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.item(R.string.shared_string_my_places).colorIcon(R.drawable.ic_action_fav_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_fav_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
|
@ -671,38 +679,41 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
|
||||
|
||||
optionsMenuHelper.item(R.string.show_point_options).colorIcon(R.drawable.ic_action_marker_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.show_point_options, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_marker_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getMapLayers().getContextMenuLayer().showContextMenu(mapView.getLatitude(), mapView.getLongitude(), true);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.item(R.string.configure_map).colorIcon(R.drawable.ic_action_layers_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_layers_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.item(R.string.layer_map_appearance).colorIcon(R.drawable.ic_configure_screen_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_configure_screen_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN);
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
|
||||
String d = getString(R.string.index_settings);
|
||||
if (app.getDownloadThread().getIndexes().isDownloadedFromInternet) {
|
||||
|
@ -711,8 +722,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
d += " (" + updt.size() + ")";
|
||||
}
|
||||
}
|
||||
optionsMenuHelper.item(R.string.index_settings).name(d).colorIcon(R.drawable.ic_type_archive)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.index_settings, null)
|
||||
.setTitle(d).setColorIcon(R.drawable.ic_type_archive)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
|
@ -721,11 +733,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
|
||||
if (Version.isGooglePlayEnabled(app)) {
|
||||
optionsMenuHelper.item(R.string.osm_live).colorIcon(R.drawable.ic_action_osm_live)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.osm_live, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_osm_live)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
|
||||
|
@ -733,11 +746,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.startActivity(intent);
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
}
|
||||
|
||||
optionsMenuHelper.item(R.string.prefs_plugins).colorIcon(R.drawable.ic_extension_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_extension_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
|
@ -746,11 +760,12 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
|
||||
|
||||
optionsMenuHelper.item(R.string.shared_string_settings).colorIcon(R.drawable.ic_action_settings)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_settings)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization()
|
||||
|
@ -759,9 +774,10 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.startActivity(settings);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
optionsMenuHelper.item(R.string.shared_string_help).colorIcon(R.drawable.ic_action_help)
|
||||
.listen(new OnContextMenuClick() {
|
||||
}).createItem());
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_help)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent intent = new Intent(mapActivity, HelpActivity.class);
|
||||
|
@ -769,7 +785,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
|
||||
//////////// Others
|
||||
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.osmand.access.AccessibleToast;
|
|||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.Item;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -262,7 +262,9 @@ public class MapActivityLayers {
|
|||
OsmandApplication app = (OsmandApplication) getApplication();
|
||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
||||
adapter.item(R.string.shared_string_search).colorIcon(R.drawable.ic_action_search_dark).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_search, app)
|
||||
.setColorIcon(R.drawable.ic_action_search_dark).createItem());
|
||||
final List<PoiUIFilter> list = new ArrayList<PoiUIFilter>();
|
||||
list.add(poiFilters.getCustomPOIFilter());
|
||||
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
|
||||
|
@ -301,13 +303,14 @@ public class MapActivityLayers {
|
|||
|
||||
private void addFilterToList(final ContextMenuAdapter adapter, final List<PoiUIFilter> list, PoiUIFilter f) {
|
||||
list.add(f);
|
||||
Item it = adapter.item(f.getName()).selected(-1);
|
||||
ContextMenuItem.ItemBuilder builder = new ContextMenuItem.ItemBuilder();
|
||||
builder.setTitle(f.getName());
|
||||
if (RenderingIcons.containsBigIcon(f.getIconId())) {
|
||||
it.icon(RenderingIcons.getBigIconResourceId(f.getIconId()));
|
||||
builder.setIcon(RenderingIcons.getBigIconResourceId(f.getIconId()));
|
||||
} else {
|
||||
it.icon(R.drawable.mx_user_defined);
|
||||
builder.setIcon(R.drawable.mx_user_defined);
|
||||
}
|
||||
it.reg();
|
||||
adapter.addItem(builder.createItem());
|
||||
}
|
||||
|
||||
public void selectMapLayer(final OsmandMapTileView mapView) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class AppModeDialog {
|
|||
|
||||
//special method for drawer menu
|
||||
//needed because if there's more than 4 items - the don't fit in drawer
|
||||
public static View prepareAppModeDrawerView(Activity a, List<ApplicationMode> visible, final Set<ApplicationMode> selected, ContextMenuAdapter.BooleanResult allModes,
|
||||
public static View prepareAppModeDrawerView(Activity a, final Set<ApplicationMode> selected, ContextMenuAdapter.BooleanResult allModes,
|
||||
boolean useMapTheme, final View.OnClickListener onClickListener) {
|
||||
OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings();
|
||||
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(settings));
|
||||
|
|
|
@ -48,6 +48,7 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -590,8 +591,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.layer_recordings).selected(SHOW_RECORDINGS.get() ? 1 : 0)
|
||||
.colorIcon(R.drawable.ic_action_micro_dark).listen(listener).position(12).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_recordings, app)
|
||||
.setSelected(SHOW_RECORDINGS.get())
|
||||
.setColorIcon(R.drawable.ic_action_micro_dark)
|
||||
.setPosition(12)
|
||||
.setListener(listener).createItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -600,33 +604,42 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
if (isRecording()) {
|
||||
return;
|
||||
}
|
||||
adapter.item(R.string.recording_context_menu_arecord).colorIcon(R.drawable.ic_action_micro_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.recording_context_menu_arecord, app)
|
||||
.setColorIcon(R.drawable.ic_action_micro_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
recordAudio(latitude, longitude, mapActivity);
|
||||
return true;
|
||||
}
|
||||
}).position(6).reg();
|
||||
adapter.item(R.string.recording_context_menu_vrecord).colorIcon(R.drawable.ic_action_video_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
})
|
||||
.setPosition(6)
|
||||
.createItem());
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.recording_context_menu_vrecord, app)
|
||||
.setColorIcon(R.drawable.ic_action_video_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
recordVideo(latitude, longitude, mapActivity);
|
||||
return true;
|
||||
}
|
||||
}).position(7).reg();
|
||||
adapter.item(R.string.recording_context_menu_precord).colorIcon(R.drawable.ic_action_photo_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
})
|
||||
.setPosition(7)
|
||||
.createItem());
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.recording_context_menu_precord, app)
|
||||
.setColorIcon(R.drawable.ic_action_photo_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
takePhoto(latitude, longitude, mapActivity, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
}).position(8).reg();
|
||||
})
|
||||
.setPosition(8)
|
||||
.createItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.widget.ArrayAdapter;
|
|||
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -56,15 +57,17 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
|
||||
if (Version.isDeveloperVersion(mapActivity.getMyApplication())) {
|
||||
helper.item(R.string.version_settings).colorIcon(R.drawable.ic_action_gabout_dark)
|
||||
.listen(new OnContextMenuClick() {
|
||||
helper.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.version_settings, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_gabout_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
final Intent mapIntent = new Intent(mapActivity, ContributionVersionActivity.class);
|
||||
mapActivity.startActivityForResult(mapIntent, 0);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.osmand.core.android.MapRendererContext;
|
|||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -54,16 +55,20 @@ import gnu.trove.list.array.TIntArrayList;
|
|||
public class ConfigureMapMenu {
|
||||
private static final Log LOG = PlatformUtil.getLog(ConfigureMapMenu.class);
|
||||
|
||||
public interface OnClickListener{
|
||||
public interface OnClickListener {
|
||||
public void onClick(boolean result);
|
||||
};
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
private boolean allModes = false;
|
||||
|
||||
public ContextMenuAdapter createListAdapter(final MapActivity ma) {
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter(ma, allModes);
|
||||
adapter.setDefaultLayoutId(R.layout.drawer_list_item);
|
||||
adapter.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.app_modes_choose, ma)
|
||||
.setLayout(R.layout.mode_toggles).createItem());
|
||||
adapter.setChangeAppModeListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(boolean result) {
|
||||
|
@ -98,10 +103,10 @@ public class ConfigureMapMenu {
|
|||
|
||||
@Override
|
||||
public boolean onRowItemClick(ArrayAdapter<?> adapter, View view, int itemId, int pos) {
|
||||
if(itemId == R.string.layer_poi) {
|
||||
if (itemId == R.string.layer_poi) {
|
||||
selectPOILayer(ma.getMyApplication().getSettings());
|
||||
return false;
|
||||
} else if(itemId == R.string.layer_gpx_layer && cm.getSelection(pos) == 1) {
|
||||
} else if (itemId == R.string.layer_gpx_layer && cm.getSelection(pos)) {
|
||||
ma.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(), ma.getMapView());
|
||||
return false;
|
||||
} else {
|
||||
|
@ -131,13 +136,13 @@ public class ConfigureMapMenu {
|
|||
public void onDismiss(DialogInterface dialog) {
|
||||
boolean areAnyGpxTracksVisible =
|
||||
ma.getMyApplication().getSelectedGpxHelper().isShowingAnyGpxFiles();
|
||||
cm.setSelection(pos, areAnyGpxTracksVisible ? 1 : 0);
|
||||
cm.setSelection(pos, areAnyGpxTracksVisible);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (itemId == R.string.layer_map) {
|
||||
if(OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
||||
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
||||
Intent intent = new Intent(ma, PluginActivity.class);
|
||||
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, OsmandRasterMapsPlugin.ID);
|
||||
ma.startActivity(intent);
|
||||
|
@ -165,27 +170,44 @@ public class ConfigureMapMenu {
|
|||
}
|
||||
}
|
||||
|
||||
private void createLayersItems(ContextMenuAdapter adapter , MapActivity activity) {
|
||||
private void createLayersItems(ContextMenuAdapter adapter, MapActivity activity) {
|
||||
OsmandApplication app = activity.getMyApplication();
|
||||
OsmandSettings settings = app.getSettings();
|
||||
LayerMenuListener l = new LayerMenuListener(activity, adapter);
|
||||
adapter.item(R.string.shared_string_show).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_show, activity)
|
||||
.setCategory(true).setLayout(R.layout.drawer_list_sub_header).createItem());
|
||||
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
|
||||
adapter.item(R.string.layer_poi).selected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null ? 1 : 0)
|
||||
.colorIcon(R.drawable.ic_action_info_dark).listen(l).reg();
|
||||
adapter.item(R.string.layer_amenity_label).selected(settings.SHOW_POI_LABEL.get() ? 1 : 0)
|
||||
.colorIcon(R.drawable.ic_action_text_dark).listen(l).reg();
|
||||
adapter.item(R.string.shared_string_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0)
|
||||
.colorIcon(R.drawable.ic_action_fav_dark).listen(l).reg();
|
||||
adapter.item(R.string.layer_gpx_layer).selected(
|
||||
app.getSelectedGpxHelper().isShowingAnyGpxFiles() ? 1 : 0)
|
||||
.colorIcon(R.drawable.ic_action_polygom_dark)
|
||||
.listen(l).reg();
|
||||
adapter.item(R.string.layer_map).colorIcon(R.drawable.ic_world_globe_dark)
|
||||
.listen(l).reg();
|
||||
if(TransportRouteHelper.getInstance().routeIsCalculated()){
|
||||
adapter.item(R.string.layer_transport_route).selected(1)
|
||||
.colorIcon(R.drawable.ic_action_bus_dark).listen(l).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.layer_poi, activity)
|
||||
.setSelected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null)
|
||||
.setColorIcon(R.drawable.ic_action_info_dark)
|
||||
.setListener(l).createItem());
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.layer_amenity_label, activity)
|
||||
.setSelected(settings.SHOW_POI_LABEL.get())
|
||||
.setColorIcon(R.drawable.ic_action_text_dark)
|
||||
.setListener(l).createItem());
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_favorites, activity)
|
||||
.setSelected(settings.SHOW_FAVORITES.get())
|
||||
.setColorIcon(R.drawable.ic_action_fav_dark)
|
||||
.setListener(l).createItem());
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.layer_gpx_layer, activity)
|
||||
.setSelected(app.getSelectedGpxHelper().isShowingAnyGpxFiles())
|
||||
.setColorIcon(R.drawable.ic_action_polygom_dark)
|
||||
.setListener(l).createItem());
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.layer_map, activity)
|
||||
.setColorIcon(R.drawable.ic_world_globe_dark)
|
||||
.setListener(l).createItem());
|
||||
if (TransportRouteHelper.getInstance().routeIsCalculated()) {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.layer_transport_route, activity)
|
||||
.setSelected(true)
|
||||
.setColorIcon(R.drawable.ic_action_bus_dark)
|
||||
.setListener(l).createItem());
|
||||
}
|
||||
|
||||
OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity);
|
||||
|
@ -196,20 +218,25 @@ public class ConfigureMapMenu {
|
|||
activity.getMyApplication().getResourceManager().getRenderer().clearCache();
|
||||
activity.updateMapSettings();
|
||||
GPXLayer gpx = activity.getMapView().getLayerByClass(GPXLayer.class);
|
||||
if(gpx != null) {
|
||||
if (gpx != null) {
|
||||
gpx.updateLayerStyle();
|
||||
}
|
||||
RouteLayer rte = activity.getMapView().getLayerByClass(RouteLayer.class);
|
||||
if(rte != null) {
|
||||
if (rte != null) {
|
||||
rte.updateLayerStyle();
|
||||
}
|
||||
activity.getMapView().refreshMap(true);
|
||||
}
|
||||
|
||||
private void createRenderingAttributeItems(final ContextMenuAdapter adapter, final MapActivity activity) {
|
||||
adapter.item(R.string.map_widget_map_rendering).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.map_widget_map_rendering, activity)
|
||||
.setCategory(true)
|
||||
.setLayout(R.layout.drawer_list_sub_header).createItem());
|
||||
String descr = getRenderDescr(activity);
|
||||
adapter.item(R.string.map_widget_renderer).listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.map_widget_renderer, activity)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<?> ad, int itemId, final int pos, boolean isChecked) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
|
||||
|
@ -249,9 +276,12 @@ public class ConfigureMapMenu {
|
|||
bld.show();
|
||||
return false;
|
||||
}
|
||||
}).description(descr).layout(R.layout.drawer_list_doubleitem).reg();
|
||||
}).setDescription(descr).setLayout(R.layout.drawer_list_doubleitem).createItem());
|
||||
|
||||
adapter.item(R.string.map_widget_day_night).description(getDayNightDescr(activity)).listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.map_widget_day_night, activity)
|
||||
.setDescription(getDayNightDescr(activity))
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<?> ad, int itemId, final int pos, boolean isChecked) {
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
|
@ -276,16 +306,17 @@ public class ConfigureMapMenu {
|
|||
bld.show();
|
||||
return false;
|
||||
}
|
||||
}).layout(R.layout.drawer_list_doubleitem).reg();
|
||||
}).setLayout(R.layout.drawer_list_doubleitem).createItem());
|
||||
|
||||
adapter.item(R.string.map_magnifier).listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.map_magnifier, activity).setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<?> ad, int itemId, final int pos, boolean isChecked) {
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
final OsmandSettings.OsmandPreference<Float> mapDensity = view.getSettings().MAP_DENSITY;
|
||||
final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
|
||||
int p = (int) (mapDensity.get() * 100);
|
||||
final TIntArrayList tlist = new TIntArrayList(new int[] { 33, 50, 75, 100, 150, 200, 300, 400 });
|
||||
final TIntArrayList tlist = new TIntArrayList(new int[]{33, 50, 75, 100, 150, 200, 300, 400});
|
||||
final List<String> values = new ArrayList<String>();
|
||||
int i = -1;
|
||||
for (int k = 0; k <= tlist.size(); k++) {
|
||||
|
@ -326,9 +357,12 @@ public class ConfigureMapMenu {
|
|||
bld.show();
|
||||
return false;
|
||||
}
|
||||
}).description(String.format("%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %").layout(R.layout.drawer_list_doubleitem).reg();
|
||||
}).setDescription(String.format("%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %")
|
||||
.setLayout(R.layout.drawer_list_doubleitem)
|
||||
.createItem());
|
||||
|
||||
adapter.item(R.string.text_size).listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.text_size, activity).setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<?> ad, int itemId, final int pos, boolean isChecked) {
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
|
@ -357,9 +391,10 @@ public class ConfigureMapMenu {
|
|||
b.show();
|
||||
return false;
|
||||
}
|
||||
}).description(getScale(activity)).layout(R.layout.drawer_list_doubleitem).reg();
|
||||
}).setDescription(getScale(activity)).setLayout(R.layout.drawer_list_doubleitem).createItem());
|
||||
|
||||
adapter.item(R.string.map_locale).listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.map_locale, activity).setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<?> ad, int itemId, final int pos, boolean isChecked) {
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
|
@ -370,7 +405,7 @@ public class ConfigureMapMenu {
|
|||
final String[] txtValues = getMapNamesValues(activity, txtIds);
|
||||
int selected = -1;
|
||||
for (int i = 0; i < txtIds.length; i++) {
|
||||
if(view.getSettings().MAP_PREFERRED_LOCALE.get().equals(txtIds[i])) {
|
||||
if (view.getSettings().MAP_PREFERRED_LOCALE.get().equals(txtIds[i])) {
|
||||
selected = i;
|
||||
break;
|
||||
}
|
||||
|
@ -388,13 +423,15 @@ public class ConfigureMapMenu {
|
|||
b.show();
|
||||
return false;
|
||||
}
|
||||
}).description(activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get()).layout(R.layout.drawer_list_doubleitem).reg();
|
||||
})
|
||||
.setDescription(activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get())
|
||||
.setLayout(R.layout.drawer_list_doubleitem).createItem());
|
||||
|
||||
RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||
if (renderer != null) {
|
||||
List<RenderingRuleProperty> customRules = new ArrayList<RenderingRuleProperty>();
|
||||
for(RenderingRuleProperty p : renderer.PROPS.getCustomRules()) {
|
||||
if(!RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(p.getCategory())){
|
||||
for (RenderingRuleProperty p : renderer.PROPS.getCustomRules()) {
|
||||
if (!RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(p.getCategory())) {
|
||||
customRules.add(p);
|
||||
}
|
||||
}
|
||||
|
@ -408,29 +445,31 @@ public class ConfigureMapMenu {
|
|||
createProperties(customRules, R.string.rendering_category_routes, "routes",
|
||||
adapter, activity);
|
||||
|
||||
if(customRules.size() > 0) {
|
||||
adapter.item(R.string.rendering_category_others).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
if (customRules.size() > 0) {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.rendering_category_others, activity).setCategory(true)
|
||||
.setLayout(R.layout.drawer_list_sub_header).createItem());
|
||||
createCustomRenderingProperties(adapter, activity, customRules);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] mapNamesIds = new String[] { "", "en", "als", "af", "ar", "az", "be", "bg", "bn", "bpy", "br", "bs", "ca", "ceb", "cs", "cy", "da", "de", "el", "et", "es", "eu", "fa", "fi", "fr", "fy", "ga", "gl", "he", "hi", "hr", "ht", "hu", "hy", "id", "is", "it", "ja", "ka", "ko", "ku", "la", "lb", "lt", "lv", "mk", "ml", "mr", "ms", "nds", "new", "nl", "nn", "no", "nv", "os", "pl", "pms", "pt", "ro", "ru", "sh", "sc", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "uk", "vi", "vo", "zh" };
|
||||
public static String[] mapNamesIds = new String[]{"", "en", "als", "af", "ar", "az", "be", "bg", "bn", "bpy", "br", "bs", "ca", "ceb", "cs", "cy", "da", "de", "el", "et", "es", "eu", "fa", "fi", "fr", "fy", "ga", "gl", "he", "hi", "hr", "ht", "hu", "hy", "id", "is", "it", "ja", "ka", "ko", "ku", "la", "lb", "lt", "lv", "mk", "ml", "mr", "ms", "nds", "new", "nl", "nn", "no", "nv", "os", "pl", "pms", "pt", "ro", "ru", "sh", "sc", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "uk", "vi", "vo", "zh"};
|
||||
|
||||
|
||||
public static String[] getSortedMapNamesIds(Context ctx) {
|
||||
String[] vls = getMapNamesValues(ctx, mapNamesIds);
|
||||
final Map<String, String> mp = new HashMap<String, String>();
|
||||
for(int i = 0; i < mapNamesIds.length; i++) {
|
||||
for (int i = 0; i < mapNamesIds.length; i++) {
|
||||
mp.put(mapNamesIds[i], vls[i]);
|
||||
}
|
||||
ArrayList<String> lst = new ArrayList<String>(mp.keySet());
|
||||
Collections.sort(lst, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String lhs, String rhs) {
|
||||
int i1 = Algorithms.isEmpty(lhs)? 0 : (lhs.equals("en") ? 1 : 2);
|
||||
int i2 = Algorithms.isEmpty(rhs)? 0 : (rhs.equals("en") ? 1 : 2);
|
||||
if(i1 != i2) {
|
||||
int i1 = Algorithms.isEmpty(lhs) ? 0 : (lhs.equals("en") ? 1 : 2);
|
||||
int i2 = Algorithms.isEmpty(rhs) ? 0 : (rhs.equals("en") ? 1 : 2);
|
||||
if (i1 != i2) {
|
||||
return i1 < i2 ? -1 : 1;
|
||||
}
|
||||
return mp.get(lhs).compareTo(mp.get(rhs));
|
||||
|
@ -441,11 +480,11 @@ public class ConfigureMapMenu {
|
|||
|
||||
public static String[] getMapNamesValues(Context ctx, String[] ids) {
|
||||
String[] translates = new String[ids.length];
|
||||
for(int i = 0; i < translates.length; i++) {
|
||||
if(Algorithms.isEmpty(ids[i])) {
|
||||
for (int i = 0; i < translates.length; i++) {
|
||||
if (Algorithms.isEmpty(ids[i])) {
|
||||
translates[i] = ctx.getString(R.string.local_map_names);
|
||||
} else {
|
||||
translates[i] = ((OsmandApplication)ctx.getApplicationContext()).getLangTranslation(ids[i]);
|
||||
translates[i] = ((OsmandApplication) ctx.getApplicationContext()).getLangTranslation(ids[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,17 +507,20 @@ public class ConfigureMapMenu {
|
|||
it.remove();
|
||||
}
|
||||
}
|
||||
if(prefs.size() > 0) {
|
||||
if (prefs.size() > 0) {
|
||||
final String descr = getDescription(prefs);
|
||||
adapter.item(strId).description(descr).
|
||||
layout(R.layout.drawer_list_doubleitem).listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(strId, activity)
|
||||
.setDescription(descr)
|
||||
.setLayout(R.layout.drawer_list_doubleitem)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
|
||||
showPreferencesDialog(adapter, a, pos, activity, activity.getString(strId), ps, prefs);
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
// createCustomRenderingProperties(adapter, activity, ps);
|
||||
}
|
||||
}
|
||||
|
@ -509,7 +551,7 @@ public class ConfigureMapMenu {
|
|||
tempPrefs[i] = prefs.get(i).get();
|
||||
}
|
||||
final String[] vals = new String[ps.size()];
|
||||
for(int i = 0; i < ps.size(); i++) {
|
||||
for (int i = 0; i < ps.size(); i++) {
|
||||
RenderingRuleProperty p = ps.get(i);
|
||||
String propertyName = SettingsActivity.getStringPropertyName(activity, p.getAttrName(),
|
||||
p.getName());
|
||||
|
@ -557,17 +599,17 @@ public class ConfigureMapMenu {
|
|||
}
|
||||
|
||||
protected String getScale(final MapActivity activity) {
|
||||
int scale = (int)(activity.getMyApplication().getSettings().TEXT_SCALE.get() * 100);
|
||||
int scale = (int) (activity.getMyApplication().getSettings().TEXT_SCALE.get() * 100);
|
||||
return scale + " %";
|
||||
}
|
||||
|
||||
|
||||
private void createCustomRenderingProperties(final ContextMenuAdapter adapter , final MapActivity activity,
|
||||
List<RenderingRuleProperty> customRules ){
|
||||
private void createCustomRenderingProperties(final ContextMenuAdapter adapter, final MapActivity activity,
|
||||
List<RenderingRuleProperty> customRules) {
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
for (final RenderingRuleProperty p : customRules) {
|
||||
if (p.getAttrName().equals(RenderingRuleStorageProperties.A_APP_MODE) ||
|
||||
p.getAttrName().equals(RenderingRuleStorageProperties.A_ENGINE_V1)){
|
||||
p.getAttrName().equals(RenderingRuleStorageProperties.A_ENGINE_V1)) {
|
||||
continue;
|
||||
}
|
||||
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(),
|
||||
|
@ -578,7 +620,8 @@ public class ConfigureMapMenu {
|
|||
if (p.isBoolean()) {
|
||||
final OsmandSettings.CommonPreference<Boolean> pref = view.getApplication().getSettings()
|
||||
.getCustomRenderBooleanProperty(p.getAttrName());
|
||||
adapter.item(propertyName).listen(new OnContextMenuClick() {
|
||||
adapter.addItem(ContextMenuItem.createBuilder(propertyName)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
|
@ -586,18 +629,20 @@ public class ConfigureMapMenu {
|
|||
refreshMapComplete(activity);
|
||||
return false;
|
||||
}
|
||||
}).selected(pref.get() ? 1 : 0).reg();
|
||||
})
|
||||
.setSelected(pref.get())
|
||||
.createItem());
|
||||
} else {
|
||||
final OsmandSettings.CommonPreference<String> pref = view.getApplication().getSettings()
|
||||
.getCustomRenderProperty(p.getAttrName());
|
||||
String descr;
|
||||
if(!Algorithms.isEmpty(pref.get())) {
|
||||
if (!Algorithms.isEmpty(pref.get())) {
|
||||
descr = SettingsActivity.getStringPropertyValue(activity, pref.get());
|
||||
} else {
|
||||
descr = SettingsActivity.getStringPropertyValue(view.getContext(),
|
||||
p.getDefaultValueDescription());
|
||||
}
|
||||
adapter.item(propertyName).listen(new OnContextMenuClick() {
|
||||
adapter.addItem(ContextMenuItem.createBuilder(propertyName).setListener(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<?> ad, int itemId, final int pos, boolean isChecked) {
|
||||
|
@ -624,7 +669,7 @@ public class ConfigureMapMenu {
|
|||
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if(which == 0) {
|
||||
if (which == 0) {
|
||||
pref.set("");
|
||||
} else {
|
||||
pref.set(p.getPossibleValues()[which - 1]);
|
||||
|
@ -638,7 +683,7 @@ public class ConfigureMapMenu {
|
|||
b.show();
|
||||
return false;
|
||||
}
|
||||
}).description(descr).layout(R.layout.drawer_list_doubleitem).reg();
|
||||
}).setDescription(descr).setLayout(R.layout.drawer_list_doubleitem).createItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View;
|
|||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -111,12 +112,17 @@ public class RasterMapMenu {
|
|||
return false;
|
||||
}
|
||||
};
|
||||
int selectedCode = selected ? 1 : 0;
|
||||
mapTypeDescr = selected ? mapTypeDescr : mapActivity.getString(R.string.shared_string_none);
|
||||
contextMenuAdapter.item(toggleActionStringId).listen(l).selected(selectedCode).reg();
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(toggleActionStringId, mapActivity)
|
||||
.setListener(l)
|
||||
.setSelected(selected).createItem());
|
||||
if (selected) {
|
||||
contextMenuAdapter.item(mapTypeString).listen(l).layout(R.layout.two_line_list_item)
|
||||
.description(mapTypeDescr).reg();
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(mapTypeString, mapActivity)
|
||||
.setListener(l)
|
||||
.setLayout(R.layout.two_line_list_item)
|
||||
.setDescription(mapTypeDescr).createItem());
|
||||
ContextMenuAdapter.OnIntegerValueChangedListener integerListener =
|
||||
new ContextMenuAdapter.OnIntegerValueChangedListener() {
|
||||
@Override
|
||||
|
@ -127,20 +133,25 @@ public class RasterMapMenu {
|
|||
}
|
||||
};
|
||||
// android:max="255" in layout is expected
|
||||
contextMenuAdapter.item(mapTypeStringTransparency)
|
||||
.layout(R.layout.progress_list_item)
|
||||
.colorIcon(R.drawable.ic_action_opacity)
|
||||
.progress(mapTransparencyPreference.get())
|
||||
.listen(l)
|
||||
.listenInteger(integerListener).reg();
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(mapTypeStringTransparency, mapActivity)
|
||||
.setLayout(R.layout.progress_list_item)
|
||||
.setColorIcon(R.drawable.ic_action_opacity)
|
||||
.setProgress(mapTransparencyPreference.get())
|
||||
.setListener(l)
|
||||
.setIntegerListener(integerListener).createItem());
|
||||
if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY) {
|
||||
contextMenuAdapter.item(R.string.show_polygons).listen(l)
|
||||
.selected(hidePolygonsPref.get() ? 0 : 1).reg();
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.show_polygons, mapActivity)
|
||||
.setListener(l)
|
||||
.setSelected(hidePolygonsPref.get()).createItem());
|
||||
}
|
||||
Boolean transparencySwitchState = settings.SHOW_LAYER_TRANSPARENCY_SEEKBAR.get()
|
||||
&& mapLayers.getMapControlsLayer().isTransparencyBarInitialized();
|
||||
contextMenuAdapter.item(R.string.show_transparency_seekbar).listen(l)
|
||||
.selected(transparencySwitchState ? 1 : 0).reg();
|
||||
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.show_transparency_seekbar, mapActivity)
|
||||
.setListener(l)
|
||||
.setSelected(transparencySwitchState).createItem());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.osmand.data.RotatedTileBox;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.Route;
|
||||
|
@ -640,7 +641,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {
|
||||
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter, MapActivity mapActivity) {
|
||||
if (o != null && o instanceof WptPt) {
|
||||
final WptPt p = (WptPt) o;
|
||||
boolean containsPoint = false;
|
||||
|
@ -675,7 +676,10 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.delete_point).colorIcon(R.drawable.ic_action_delete_dark).listen(listener).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.delete_point, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_delete_dark)
|
||||
.setListener(listener).createItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import net.osmand.IndexConstants;
|
|||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -200,16 +201,28 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
if (info.getType() == LocalIndexType.MAP_DATA || info.getType() == LocalIndexType.SRTM_DATA ||
|
||||
info.getType() == LocalIndexType.WIKI_DATA) {
|
||||
if (!info.isBackupedData()) {
|
||||
adapter.item(R.string.local_index_mi_backup).listen(listener).position(1).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.local_index_mi_backup, getContext())
|
||||
.setListener(listener)
|
||||
.setPosition(1).createItem());
|
||||
}
|
||||
}
|
||||
if (info.isBackupedData()) {
|
||||
adapter.item(R.string.local_index_mi_restore).listen(listener).position(2).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.local_index_mi_restore, getContext())
|
||||
.setListener(listener)
|
||||
.setPosition(2).createItem());
|
||||
}
|
||||
if (info.getType() != LocalIndexType.TTS_VOICE_DATA && info.getType() != LocalIndexType.VOICE_DATA) {
|
||||
adapter.item(R.string.shared_string_rename).listen(listener).position(3).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_rename, getContext())
|
||||
.setListener(listener)
|
||||
.setPosition(3).createItem());
|
||||
}
|
||||
adapter.item(R.string.shared_string_delete).listen(listener).position(4).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_delete, getContext())
|
||||
.setListener(listener)
|
||||
.setPosition(4).createItem());
|
||||
}
|
||||
|
||||
private boolean performBasicOperation(int resId, final LocalIndexInfo info) {
|
||||
|
@ -588,16 +601,24 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
return true;
|
||||
}
|
||||
};
|
||||
optionsMenuAdapter.item(R.string.local_index_mi_reload)
|
||||
.icon(R.drawable.ic_action_refresh_dark)
|
||||
.listen(listener).position(1).reg();
|
||||
optionsMenuAdapter.item(R.string.shared_string_delete)
|
||||
.icon(R.drawable.ic_action_delete_dark)
|
||||
.listen(listener).position(2).reg();
|
||||
optionsMenuAdapter.item(R.string.local_index_mi_backup)
|
||||
.listen(listener).position(3).reg();
|
||||
optionsMenuAdapter.item(R.string.local_index_mi_restore)
|
||||
.listen(listener).position(4).reg();
|
||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.local_index_mi_reload,getContext())
|
||||
.setIcon(R.drawable.ic_action_refresh_dark)
|
||||
.setListener(listener)
|
||||
.createItem());
|
||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_delete,getContext())
|
||||
.setIcon(R.drawable.ic_action_delete_dark)
|
||||
.setListener(listener)
|
||||
.createItem());
|
||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.local_index_mi_backup,getContext())
|
||||
.setListener(listener)
|
||||
.createItem());
|
||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.local_index_mi_restore,getContext())
|
||||
.setListener(listener)
|
||||
.createItem());
|
||||
// doesn't work correctly
|
||||
//int max = getResources().getInteger(R.integer.abs__max_action_buttons);
|
||||
int max = 3;
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.CallbackWithObject;
|
|||
import net.osmand.IndexConstants;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
|
@ -207,8 +208,8 @@ public class GpxUiHelper {
|
|||
}
|
||||
s = s.replace('_', ' ');
|
||||
|
||||
adapter.item(s).selected(multipleChoice ? 0 : -1)
|
||||
.colorIcon(R.drawable.ic_action_polygom_dark).reg();
|
||||
adapter.addItem(ContextMenuItem.createBuilder(s).setSelected(multipleChoice)
|
||||
.setColorIcon(R.drawable.ic_action_polygom_dark).createItem());
|
||||
|
||||
//if there's some selected files - need to mark them as selected
|
||||
if (selectedGpxList != null) {
|
||||
|
@ -223,12 +224,12 @@ public class GpxUiHelper {
|
|||
final ContextMenuAdapter adapter, int i, String fileName) {
|
||||
if (i == 0 && showCurrentTrack) {
|
||||
if (selectedGpxList.contains("")) {
|
||||
adapter.setSelection(i, 1);
|
||||
adapter.setSelection(i, true);
|
||||
}
|
||||
} else {
|
||||
for (String file : selectedGpxList) {
|
||||
if (file.endsWith(fileName)) {
|
||||
adapter.setSelection(i, 1);
|
||||
adapter.setSelection(i, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -303,15 +304,15 @@ public class GpxUiHelper {
|
|||
// }
|
||||
// tv.setCompoundDrawablePadding(padding);
|
||||
final CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item));
|
||||
if (adapter.getSelection(position) == -1) {
|
||||
if (adapter.getSelection(position) == null) {
|
||||
ch.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
ch.setOnCheckedChangeListener(null);
|
||||
ch.setChecked(adapter.getSelection(position) > 0);
|
||||
ch.setChecked(adapter.getSelection(position));
|
||||
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
adapter.setSelection(position, isChecked ? 1 : 0);
|
||||
adapter.setSelection(position, isChecked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -337,12 +338,12 @@ public class GpxUiHelper {
|
|||
if (app != null && app.getSelectedGpxHelper() != null) {
|
||||
app.getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
}
|
||||
if (showCurrentGpx && adapter.getSelection(0) > 0) {
|
||||
if (showCurrentGpx && adapter.getSelection(0)) {
|
||||
currentGPX = app.getSavingTrackHelper().getCurrentGpx();
|
||||
}
|
||||
List<String> s = new ArrayList<>();
|
||||
for (int i = (showCurrentGpx ? 1 : 0); i < adapter.length(); i++) {
|
||||
if (adapter.getSelection(i) > 0) {
|
||||
if (adapter.getSelection(i)) {
|
||||
s.add(list.get(i));
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +361,7 @@ public class GpxUiHelper {
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (multipleChoice) {
|
||||
adapter.setSelection(position, adapter.getSelection(position) > 0 ? 0 : 1);
|
||||
adapter.setSelection(position, !adapter.getSelection(position));
|
||||
listAdapter.notifyDataSetInvalidated();
|
||||
} else {
|
||||
dlg.dismiss();
|
||||
|
|
|
@ -555,7 +555,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
public void buttonMorePressed() {
|
||||
final ContextMenuAdapter menuAdapter = new ContextMenuAdapter(mapActivity);
|
||||
for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) {
|
||||
layer.populateObjectContextMenu(latLon, object, menuAdapter);
|
||||
layer.populateObjectContextMenu(latLon, object, menuAdapter, mapActivity);
|
||||
}
|
||||
|
||||
mapActivity.getMapActions().contextMenuPoint(latLon.getLatitude(), latLon.getLongitude(), menuAdapter, object);
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.Location;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -215,7 +216,8 @@ public class RoutePreferencesMenu {
|
|||
String selectedValue = mapActivity.getMyApplication().getSettings().VOICE_PROVIDER.get();
|
||||
entrieValues[k] = OsmandSettings.VOICE_PROVIDER_NOT_USE;
|
||||
entries[k] = mapActivity.getResources().getString(R.string.shared_string_do_not_use);
|
||||
adapter.item(entries[k]).reg();
|
||||
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder();
|
||||
adapter.addItem(itemBuilder.setTitle(entries[k]).createItem());
|
||||
if (OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(selectedValue)) {
|
||||
selected = k;
|
||||
}
|
||||
|
@ -224,7 +226,7 @@ public class RoutePreferencesMenu {
|
|||
entries[k] = (s.contains("tts") ? mapActivity.getResources().getString(R.string.ttsvoice) + " " : "") +
|
||||
FileNameTranslationHelper.getVoiceName(mapActivity, s);
|
||||
entrieValues[k] = s;
|
||||
adapter.item(entries[k]).reg();
|
||||
adapter.addItem(itemBuilder.setTitle(entries[k]).createItem());
|
||||
if (s.equals(selectedValue)) {
|
||||
selected = k;
|
||||
}
|
||||
|
@ -232,7 +234,7 @@ public class RoutePreferencesMenu {
|
|||
}
|
||||
entrieValues[k] = MORE_VALUE;
|
||||
entries[k] = mapActivity.getResources().getString(R.string.install_more);
|
||||
adapter.item(entries[k]).reg();
|
||||
adapter.addItem(itemBuilder.setTitle(entries[k]).createItem());
|
||||
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
|
||||
bld.setSingleChoiceItems(entries, selected, new DialogInterface.OnClickListener() {
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.ValueHolder;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -140,13 +141,17 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.context_menu_item_add_waypoint).colorIcon(R.drawable.ic_action_gnew_label_dark)
|
||||
.listen(listener).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.context_menu_item_add_waypoint, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_gnew_label_dark)
|
||||
.setListener(listener).createItem());
|
||||
if (selectedObj instanceof WptPt) {
|
||||
WptPt pt = (WptPt) selectedObj;
|
||||
if (app.getSelectedGpxHelper().getSelectedGPXFile(pt) != null) {
|
||||
adapter.item(R.string.context_menu_item_edit_waypoint).colorIcon(R.drawable.ic_action_edit_dark)
|
||||
.listen(listener).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.context_menu_item_edit_waypoint, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_edit_dark)
|
||||
.setListener(listener).createItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import net.osmand.IndexConstants;
|
|||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
|
@ -348,12 +349,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
optionsMenuAdapter.item(R.string.shared_string_show_on_map).icon(R.drawable.ic_show_on_map)
|
||||
.listen(listener).reg();
|
||||
optionsMenuAdapter.item(R.string.shared_string_delete)
|
||||
.icon(R.drawable.ic_action_delete_dark).listen(listener).reg();
|
||||
optionsMenuAdapter.item(R.string.local_index_mi_reload)
|
||||
.icon(R.drawable.ic_action_refresh_dark).listen(listener).reg();
|
||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_show_on_map, getActivity())
|
||||
.setIcon(R.drawable.ic_show_on_map)
|
||||
.setListener(listener).createItem());
|
||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_delete, getActivity())
|
||||
.setIcon(R.drawable.ic_action_delete_dark).setListener(listener).createItem());
|
||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.local_index_mi_reload, getActivity())
|
||||
.setIcon(R.drawable.ic_action_refresh_dark).setListener(listener).createItem());
|
||||
OsmandPlugin.onOptionsMenuActivity(getActivity(), this, optionsMenuAdapter);
|
||||
for (int j = 0; j < optionsMenuAdapter.length(); j++) {
|
||||
final MenuItem item;
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.osmand.osm.PoiType;
|
|||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -216,15 +217,32 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
isEditable = !amenity.getType().isWiki() && !poiType.isNotEditableOsm();
|
||||
}
|
||||
if (isEditable) {
|
||||
adapter.item(R.string.poi_context_menu_modify).colorIcon(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg();
|
||||
adapter.item(R.string.poi_context_menu_delete).colorIcon(R.drawable.ic_action_delete_dark).listen(listener).position(2).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.poi_context_menu_modify, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_edit_dark)
|
||||
.setListener(listener)
|
||||
.setPosition(1)
|
||||
.createItem());
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.poi_context_menu_delete, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_delete_dark)
|
||||
.setListener(listener)
|
||||
.setPosition(2)
|
||||
.createItem());
|
||||
} else if (selectedObj instanceof OpenstreetmapPoint && ((OpenstreetmapPoint) selectedObj).getAction() != Action.DELETE) {
|
||||
adapter.item(R.string.poi_context_menu_modify_osm_change)
|
||||
.colorIcon(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.poi_context_menu_modify_osm_change, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_edit_dark)
|
||||
.setListener(listener)
|
||||
.setPosition(1)
|
||||
.createItem());
|
||||
} else {
|
||||
adapter.item(R.string.context_menu_item_create_poi).colorIcon(R.drawable.ic_action_plus_dark).listen(listener).position(-1).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_create_poi, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_plus_dark)
|
||||
.setListener(listener)
|
||||
.setPosition(-1)
|
||||
.createItem());
|
||||
}
|
||||
adapter.item(R.string.context_menu_item_open_note).colorIcon(R.drawable.ic_action_bug_dark).listen(listener).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_open_note, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_bug_dark)
|
||||
.setListener(listener).createItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -239,8 +257,10 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
|
||||
adapter.item(R.string.layer_osm_bugs).selected(settings.SHOW_OSM_BUGS.get() ? 1 : 0)
|
||||
.colorIcon(R.drawable.ic_action_bug_dark).listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_osm_bugs, mapActivity)
|
||||
.setSelected(settings.SHOW_OSM_BUGS.get())
|
||||
.setColorIcon(R.drawable.ic_action_bug_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
|
@ -250,7 +270,9 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}).position(16).reg();
|
||||
})
|
||||
.setPosition(16)
|
||||
.createItem());
|
||||
|
||||
}
|
||||
|
||||
|
@ -262,16 +284,16 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public void contextMenuFragment(final Activity la, final Fragment fragment, final Object info, ContextMenuAdapter adapter) {
|
||||
if (fragment instanceof AvailableGPXFragment) {
|
||||
adapter.item(R.string.local_index_mi_upload_gpx)
|
||||
.colorIcon(R.drawable.ic_action_export)
|
||||
.listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.local_index_mi_upload_gpx, la)
|
||||
.setColorIcon(R.drawable.ic_action_export)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
sendGPXFiles(la, (AvailableGPXFragment) fragment, (GpxInfo) info);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}).createItem());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,9 +301,9 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
public void optionsMenuFragment(final Activity activity, final Fragment fragment, ContextMenuAdapter optionsMenuAdapter) {
|
||||
if (fragment instanceof AvailableGPXFragment) {
|
||||
final AvailableGPXFragment f = ((AvailableGPXFragment) fragment);
|
||||
optionsMenuAdapter.item(R.string.local_index_mi_upload_gpx)
|
||||
.icon(R.drawable.ic_action_export)
|
||||
.listen(new OnContextMenuClick() {
|
||||
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.local_index_mi_upload_gpx, activity)
|
||||
.setIcon(R.drawable.ic_action_export)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
|
@ -296,7 +318,9 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
});
|
||||
return true;
|
||||
}
|
||||
}).position(5).reg();
|
||||
})
|
||||
.setPosition(5)
|
||||
.createItem());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
|
@ -274,15 +275,18 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
|
|||
|
||||
@Override
|
||||
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
|
||||
helper.item(R.string.osmo_groups).colorIcon(R.drawable.ic_osmo_dark).position(6)
|
||||
.listen(new OnContextMenuClick() {
|
||||
helper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.osmo_groups, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_osmo_dark)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent intent = new Intent(mapActivity, OsMoGroupsActivity.class);
|
||||
mapActivity.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
})
|
||||
.setPosition(6)
|
||||
.createItem());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -226,9 +227,11 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.context_menu_item_add_parking_point)
|
||||
.colorIcon(R.drawable.ic_action_parking_dark).listen(addListener).reg();
|
||||
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.context_menu_item_add_parking_point, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_parking_dark)
|
||||
.setListener(addListener)
|
||||
.createItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.osmand.map.TileSourceManager;
|
|||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -254,12 +255,22 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
|
||||
String overlayMapDescr = settings.MAP_OVERLAY.get();
|
||||
overlayMapDescr = overlayMapDescr != null ? overlayMapDescr : mapActivity.getString(R.string.shared_string_none);
|
||||
adapter.item(R.string.layer_overlay).layout(R.layout.drawer_list_doubleitem).description(overlayMapDescr)
|
||||
.colorIcon(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_overlay, mapActivity)
|
||||
.setLayout(R.layout.drawer_list_doubleitem)
|
||||
.setDescription(overlayMapDescr)
|
||||
.setColorIcon(R.drawable.ic_layer_top_dark)
|
||||
.setListener(listener)
|
||||
.setPosition(14)
|
||||
.createItem());
|
||||
String underlayMapDescr = settings.MAP_UNDERLAY.get();
|
||||
underlayMapDescr = underlayMapDescr != null ? underlayMapDescr : mapActivity.getString(R.string.shared_string_none);
|
||||
adapter.item(R.string.layer_underlay).layout(R.layout.drawer_list_doubleitem).description(underlayMapDescr)
|
||||
.colorIcon(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_underlay, mapActivity)
|
||||
.setLayout(R.layout.drawer_list_doubleitem)
|
||||
.setDescription(underlayMapDescr)
|
||||
.setColorIcon(R.drawable.ic_layer_bottom_dark)
|
||||
.setListener(listener)
|
||||
.setPosition(15)
|
||||
.createItem());
|
||||
}
|
||||
|
||||
|
||||
|
@ -280,10 +291,14 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.context_menu_item_update_map).colorIcon(R.drawable.ic_action_refresh_dark)
|
||||
.listen(listener).reg();
|
||||
adapter.item(R.string.shared_string_download_map).colorIcon(R.drawable.ic_action_import)
|
||||
.listen(listener).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.context_menu_item_update_map, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_refresh_dark)
|
||||
.setListener(listener).createItem());
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_download_map, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_import)
|
||||
.setListener(listener).createItem());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -83,7 +84,7 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
}
|
||||
|
||||
@Override
|
||||
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {
|
||||
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter, MapActivity mapActivity) {
|
||||
if (o != null && o instanceof GPXUtilities.WptPt && plugin.getCurrentRoute() != null){
|
||||
final GPXUtilities.WptPt point = (GPXUtilities.WptPt) o;
|
||||
ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
|
||||
|
@ -109,23 +110,33 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
};
|
||||
|
||||
if (plugin.getCurrentRoute().getPointStatus(point)){
|
||||
adapter.item(R.string.mark_as_not_visited).colorIcon(
|
||||
R.drawable.ic_action_gremove_dark).listen(listener).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.mark_as_not_visited, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_gremove_dark)
|
||||
.setListener(listener)
|
||||
.createItem());
|
||||
} else {
|
||||
adapter.item(R.string.mark_as_visited).colorIcon(
|
||||
R.drawable.ic_action_done).listen(listener).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.mark_as_visited, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_done)
|
||||
.setListener(listener)
|
||||
.createItem());
|
||||
}
|
||||
|
||||
RoutePointsPlugin.RoutePoint routePoint = plugin.getCurrentRoute().getRoutePointFromWpt(point);
|
||||
if (routePoint != null) {
|
||||
if (routePoint.isNextNavigate) {
|
||||
adapter.item(R.string.navigate_to_next)
|
||||
.colorIcon(R.drawable.ic_action_gnext_dark).listen(listener)
|
||||
.reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.navigate_to_next, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_gnext_dark)
|
||||
.setListener(listener)
|
||||
.createItem());
|
||||
} else {
|
||||
adapter.item(R.string.mark_as_current)
|
||||
.colorIcon(R.drawable.ic_action_signpost_dark)
|
||||
.listen(listener).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.mark_as_current, mapActivity)
|
||||
.setColorIcon(R.drawable.ic_action_signpost_dark)
|
||||
.setListener(listener)
|
||||
.createItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.widget.ArrayAdapter;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -114,8 +115,14 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.layer_hillshade).selected(HILLSHADE.get()? 1 : 0)
|
||||
.colorIcon(R.drawable.ic_action_hillshade_dark).listen(listener).position(13).layout(R.layout.drawer_list_item).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.layer_hillshade, mapActivity)
|
||||
.setSelected(HILLSHADE.get())
|
||||
.setColorIcon(R.drawable.ic_action_hillshade_dark)
|
||||
.setListener(listener)
|
||||
.setPosition(13)
|
||||
.setLayout(R.layout.drawer_list_item)
|
||||
.createItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
|
@ -131,7 +132,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {
|
||||
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter, MapActivity mapActivity) {
|
||||
if (menu.hasHiddenBottomInfo()) {
|
||||
ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
|
||||
@Override
|
||||
|
@ -142,9 +143,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.shared_string_show_description)
|
||||
.colorIcon(R.drawable.ic_action_note_dark).listen(listener)
|
||||
.reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setTitleId(R.string.shared_string_show_description, activity)
|
||||
.setColorIcon(R.drawable.ic_action_note_dark).setListener(listener)
|
||||
.createItem());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -160,7 +161,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void populateObjectContextMenu(final LatLon latLon, final Object o, ContextMenuAdapter adapter) {
|
||||
public void populateObjectContextMenu(final LatLon latLon, final Object o, ContextMenuAdapter adapter, MapActivity mapActivity) {
|
||||
if (latLon != null && o == null
|
||||
&& (routingHelper.isRoutePlanningMode() || routingHelper.isFollowingMode())) {
|
||||
|
||||
|
@ -176,8 +177,10 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
|
|||
}
|
||||
};
|
||||
|
||||
adapter.item(R.string.avoid_road).colorIcon(
|
||||
R.drawable.ic_action_road_works_dark).listen(listener).reg();
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.avoid_road, activity)
|
||||
.setColorIcon(R.drawable.ic_action_road_works_dark)
|
||||
.setListener(listener)
|
||||
.createItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.data.QuadRect;
|
|||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.util.MapAlgorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -37,7 +38,7 @@ public abstract class OsmandMapLayer {
|
|||
public void onRetainNonConfigurationInstance(Map<String, Object> map) {
|
||||
}
|
||||
|
||||
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {
|
||||
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter, MapActivity mapActivity) {
|
||||
}
|
||||
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.widget.LinearLayout;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.MapMarkersMode;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
|
@ -285,7 +286,9 @@ public class MapWidgetRegistry {
|
|||
addControlId(map, cm, R.string.map_widget_top_text, settings.SHOW_STREET_NAME);
|
||||
}
|
||||
if (settings.USE_MAP_MARKERS.get()) {
|
||||
cm.item(R.string.map_markers).description(settings.MAP_MARKERS_MODE.get().toHumanString(map)).listen(new OnContextMenuClick() {
|
||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_markers, map)
|
||||
.setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map))
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(final ArrayAdapter<?> ad, int itemId, final int pos, boolean isChecked) {
|
||||
final OsmandMapTileView view = map.getMapView();
|
||||
|
@ -318,14 +321,15 @@ public class MapWidgetRegistry {
|
|||
bld.show();
|
||||
return false;
|
||||
}
|
||||
}).layout(R.layout.list_item_text_button).reg();
|
||||
}).setLayout(R.layout.list_item_text_button).createItem());
|
||||
}
|
||||
}
|
||||
|
||||
private void addControlId(final MapActivity map, ContextMenuAdapter cm, int stringId, OsmandPreference<Boolean> pref) {
|
||||
cm.item(stringId).selected(pref.get() ? 1 : 0)
|
||||
// .icons(r.drawableDark, r.drawableLight)
|
||||
.listen(new ApearanceOnContextMenuClick(pref, map)).reg();
|
||||
private void addControlId(final MapActivity map, ContextMenuAdapter cm,
|
||||
@StringRes int stringId, OsmandPreference<Boolean> pref) {
|
||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(stringId, map)
|
||||
.setSelected(pref.get())
|
||||
.setListener(new ApearanceOnContextMenuClick(pref, map)).createItem());
|
||||
}
|
||||
|
||||
class ApearanceOnContextMenuClick implements OnContextMenuClick {
|
||||
|
@ -360,13 +364,16 @@ public class MapWidgetRegistry {
|
|||
|
||||
|
||||
public void addControls(MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
|
||||
cm.item(R.string.map_widget_right).setCategory(true).layout(R.layout.list_group_title_with_switch).reg();
|
||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_right, map)
|
||||
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
||||
addControls(map, cm, right, mode);
|
||||
if (mode != ApplicationMode.DEFAULT) {
|
||||
cm.item(R.string.map_widget_left).setCategory(true).layout(R.layout.list_group_title_with_switch).reg();
|
||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_left, map)
|
||||
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
||||
addControls(map, cm, left, mode);
|
||||
}
|
||||
cm.item(R.string.map_widget_appearance_rem).setCategory(true).layout(R.layout.list_group_title_with_switch).reg();
|
||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_appearance_rem, map)
|
||||
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
||||
addControlsAppearance(map, cm, mode);
|
||||
}
|
||||
|
||||
|
@ -393,11 +400,11 @@ public class MapWidgetRegistry {
|
|||
if ("map_marker_1st".equals(r.key) || "map_marker_2nd".equals(r.key)) {
|
||||
continue;
|
||||
}
|
||||
adapter.item(r.messageId)
|
||||
.selected(r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0)
|
||||
.colorIcon(r.drawableMenu)
|
||||
.secondaryIconColor(R.drawable.ic_action_additional_option)
|
||||
.listen(new OnContextMenuClick() {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.messageId, map)
|
||||
.setSelected(r.visibleCollapsed(mode) || r.visible(mode))
|
||||
.setColorIcon(r.drawableMenu)
|
||||
.setSecondaryLightIcon(R.drawable.ic_action_additional_option)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
|
||||
changeVisibility(r);
|
||||
|
@ -406,12 +413,11 @@ public class MapWidgetRegistry {
|
|||
mil.recreateControls();
|
||||
}
|
||||
adapter.setItemName(pos, getText(mil.getMapActivity(), mode, r));
|
||||
adapter.setSelection(pos, r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0);
|
||||
adapter.setSelection(pos, r.visibleCollapsed(mode) || r.visible(mode));
|
||||
a.notifyDataSetChanged();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.reg();
|
||||
}).createItem());
|
||||
adapter.setItemName(adapter.length() - 1, getText(map, mode, r));
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +498,8 @@ public class MapWidgetRegistry {
|
|||
public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) {
|
||||
final ContextMenuAdapter cm = new ContextMenuAdapter(map);
|
||||
cm.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||
cm.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.app_modes_choose, map)
|
||||
.setLayout(R.layout.mode_toggles).createItem());
|
||||
cm.setChangeAppModeListener(new ConfigureMapMenu.OnClickListener() {
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue