Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
62fac13d26
13 changed files with 75 additions and 130 deletions
|
@ -1,11 +1,11 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.support.annotation.IdRes;
|
||||||
import android.support.annotation.LayoutRes;
|
import android.support.annotation.LayoutRes;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||||
|
@ -35,60 +35,38 @@ import java.util.Set;
|
||||||
public class ContextMenuAdapter {
|
public class ContextMenuAdapter {
|
||||||
private static final Log LOG = PlatformUtil.getLog(ContextMenuAdapter.class);
|
private static final Log LOG = PlatformUtil.getLog(ContextMenuAdapter.class);
|
||||||
|
|
||||||
private final Context ctx;
|
|
||||||
@LayoutRes
|
@LayoutRes
|
||||||
private int defaultLayoutId = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ?
|
private int DEFAULT_LAYOUT_ID = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ?
|
||||||
R.layout.list_menu_item : R.layout.list_menu_item_native;
|
R.layout.list_menu_item : R.layout.list_menu_item_native;
|
||||||
List<ContextMenuItem> items = new ArrayList<>();
|
List<ContextMenuItem> items = new ArrayList<>();
|
||||||
private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
|
private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
|
||||||
//neded to detect whether user opened all modes or not
|
//neded to detect whether user opened all modes or not
|
||||||
private BooleanResult allModes = new BooleanResult();
|
|
||||||
|
|
||||||
public ContextMenuAdapter(Context ctx, boolean allModes) {
|
|
||||||
this.ctx = ctx;
|
|
||||||
this.allModes.setResult(allModes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContextMenuAdapter(Context ctx) {
|
|
||||||
this.ctx = ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int length() {
|
public int length() {
|
||||||
return items.size();
|
return items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public int getElementId(int position) {
|
public int getElementId(int position) {
|
||||||
return items.get(position).getTitleId();
|
return items.get(position).getTitleId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public OnContextMenuClick getClickAdapter(int position) {
|
public OnContextMenuClick getClickAdapter(int position) {
|
||||||
return items.get(position).getCheckBoxListener();
|
return items.get(position).getCheckBoxListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnIntegerValueChangedListener getIntegerLister(int position) {
|
@Deprecated
|
||||||
return items.get(position).getIntegerListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getItemName(int position) {
|
public String getItemName(int position) {
|
||||||
return items.get(position).getTitle();
|
return items.get(position).getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItemDescr(int position) {
|
@Deprecated
|
||||||
return items.get(position).getDescription();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getSelection(int position) {
|
public Boolean getSelection(int position) {
|
||||||
return items.get(position).getSelected();
|
return items.get(position).getSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgress(int position) {
|
@Deprecated
|
||||||
return items.get(position).getProgress();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLoading(int position) {
|
|
||||||
return items.get(position).isLoading() ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Drawable getImage(OsmandApplication ctx, int position, boolean light) {
|
public Drawable getImage(OsmandApplication ctx, int position, boolean light) {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
int lst = items.get(position).getIcon();
|
int lst = items.get(position).getIcon();
|
||||||
|
@ -103,39 +81,12 @@ public class ContextMenuAdapter {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getSecondaryImage(OsmandApplication ctx, int position, boolean light) {
|
@Deprecated
|
||||||
@DrawableRes
|
|
||||||
int secondaryDrawableId = items.get(position).getSecondaryLightIcon();
|
|
||||||
if (secondaryDrawableId != -1) {
|
|
||||||
return ctx.getIconsCache().getIcon(secondaryDrawableId, light);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBackgroundColor(Context ctx, boolean holoLight) {
|
|
||||||
if (holoLight) {
|
|
||||||
return ctx.getResources().getColor(R.color.bg_color_light);
|
|
||||||
} else {
|
|
||||||
return ctx.getResources().getColor(R.color.bg_color_dark);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCategory(int pos) {
|
|
||||||
return items.get(pos).isCategory();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLayoutId(int position) {
|
|
||||||
int l = items.get(position).getLayout();
|
|
||||||
if (l != -1) {
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
return defaultLayoutId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemName(int position, String str) {
|
public void setItemName(int position, String str) {
|
||||||
items.get(position).setTitle(str);
|
items.get(position).setTitle(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setItemDescription(int position, String str) {
|
public void setItemDescription(int position, String str) {
|
||||||
items.get(position).setDescription(str);
|
items.get(position).setDescription(str);
|
||||||
}
|
}
|
||||||
|
@ -144,6 +95,7 @@ public class ContextMenuAdapter {
|
||||||
items.get(position).setSelected(s);
|
items.get(position).setSelected(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setProgress(int position, int progress) {
|
public void setProgress(int position, int progress) {
|
||||||
items.get(position).setProgress(progress);
|
items.get(position).setProgress(progress);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +118,7 @@ public class ContextMenuAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultLayoutId(int defaultLayoutId) {
|
public void setDefaultLayoutId(int defaultLayoutId) {
|
||||||
this.defaultLayoutId = defaultLayoutId;
|
this.DEFAULT_LAYOUT_ID = defaultLayoutId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,34 +128,45 @@ public class ContextMenuAdapter {
|
||||||
|
|
||||||
|
|
||||||
public ArrayAdapter<?> createListAdapter(final Activity activity, final boolean holoLight) {
|
public ArrayAdapter<?> createListAdapter(final Activity activity, final boolean holoLight) {
|
||||||
final int layoutId = defaultLayoutId;
|
final int layoutId = DEFAULT_LAYOUT_ID;
|
||||||
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
|
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
|
||||||
return new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
|
return new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
|
||||||
items.toArray(new ContextMenuItem[items.size()]), app, holoLight);
|
items.toArray(new ContextMenuItem[items.size()]), app, holoLight, changeAppModeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ContextMenuArrayAdapter extends ArrayAdapter<ContextMenuItem> {
|
public class ContextMenuArrayAdapter extends ArrayAdapter<ContextMenuItem> {
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private boolean holoLight;
|
private boolean holoLight;
|
||||||
|
@LayoutRes
|
||||||
private int layoutId;
|
private int layoutId;
|
||||||
|
private final ConfigureMapMenu.OnClickListener changeAppModeListener;
|
||||||
|
|
||||||
public ContextMenuArrayAdapter(Activity context, int resource, int textViewResourceId,
|
public ContextMenuArrayAdapter(Activity context,
|
||||||
ContextMenuItem[] objects, OsmandApplication app, boolean holoLight) {
|
@LayoutRes
|
||||||
super(context, resource, textViewResourceId, objects);
|
int layoutRes,
|
||||||
|
@IdRes
|
||||||
|
int textViewResourceId,
|
||||||
|
ContextMenuItem[] objects,
|
||||||
|
OsmandApplication app,
|
||||||
|
boolean holoLight,
|
||||||
|
ConfigureMapMenu.OnClickListener changeAppModeListener) {
|
||||||
|
super(context, layoutRes, textViewResourceId, objects);
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.holoLight = holoLight;
|
this.holoLight = holoLight;
|
||||||
layoutId = resource;
|
layoutId = layoutRes;
|
||||||
|
this.changeAppModeListener = changeAppModeListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
// User super class to create the View
|
// User super class to create the View
|
||||||
final ContextMenuItem item = getItem(position);
|
final ContextMenuItem item = getItem(position);
|
||||||
Integer lid = getLayoutId(position);
|
int layoutId = item.getLayout();
|
||||||
if (lid == R.layout.mode_toggles) {
|
layoutId = layoutId != -1 ? layoutId : DEFAULT_LAYOUT_ID;
|
||||||
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
|
if (layoutId == R.layout.mode_toggles) {
|
||||||
|
final Set<ApplicationMode> selected = new LinkedHashSet<>();
|
||||||
return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(),
|
return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(),
|
||||||
selected, allModes, true, new View.OnClickListener() {
|
selected, true, new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (selected.size() > 0) {
|
if (selected.size() > 0) {
|
||||||
|
@ -211,23 +174,22 @@ public class ContextMenuAdapter {
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
if (changeAppModeListener != null) {
|
if (changeAppModeListener != null) {
|
||||||
changeAppModeListener.onClick(allModes.getResult());
|
changeAppModeListener.onClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (convertView == null || (!lid.equals(convertView.getTag()))) {
|
if (convertView == null || (layoutId != convertView.getTag())) {
|
||||||
convertView = LayoutInflater.from(getContext()).inflate(lid, parent, false);
|
convertView = LayoutInflater.from(getContext()).inflate(layoutId, parent, false);
|
||||||
// AndroidUtils.setListItemBackground(ctx, convertView, !holoLight);
|
convertView.setTag(layoutId);
|
||||||
convertView.setTag(lid);
|
|
||||||
}
|
}
|
||||||
TextView tv = (TextView) convertView.findViewById(R.id.title);
|
TextView tv = (TextView) convertView.findViewById(R.id.title);
|
||||||
if (!isCategory(position)) {
|
if (!item.isCategory()) {
|
||||||
AndroidUtils.setTextPrimaryColor(getContext(), tv, !holoLight);
|
AndroidUtils.setTextPrimaryColor(getContext(), tv, !holoLight);
|
||||||
}
|
}
|
||||||
tv.setText(isCategory(position) ? getItemName(position).toUpperCase() : getItemName(position));
|
tv.setText(item.isCategory() ? item.getTitle().toUpperCase() : item.getTitle());
|
||||||
|
|
||||||
if (layoutId == R.layout.simple_list_menu_item) {
|
if (this.layoutId == R.layout.simple_list_menu_item) {
|
||||||
int color = ContextCompat.getColor(getContext(),
|
int color = ContextCompat.getColor(getContext(),
|
||||||
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
|
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
|
||||||
Drawable imageId = ContextCompat.getDrawable(getContext(), item.getLightIcon());
|
Drawable imageId = ContextCompat.getDrawable(getContext(), item.getLightIcon());
|
||||||
|
@ -241,7 +203,6 @@ public class ContextMenuAdapter {
|
||||||
} else {
|
} else {
|
||||||
Drawable drawable = getImage(app, position, holoLight);
|
Drawable drawable = getImage(app, position, holoLight);
|
||||||
if (drawable != null) {
|
if (drawable != null) {
|
||||||
|
|
||||||
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable);
|
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable);
|
||||||
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
|
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
|
||||||
} else if (convertView.findViewById(R.id.icon) != null) {
|
} else if (convertView.findViewById(R.id.icon) != null) {
|
||||||
|
@ -249,11 +210,11 @@ public class ContextMenuAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
int secondaryLightDrawable = item.getSecondaryLightIcon();
|
int secondaryDrawable = item.getSecondaryIcon();
|
||||||
if (secondaryLightDrawable != -1) {
|
if (secondaryDrawable != -1) {
|
||||||
int color = ContextCompat.getColor(getContext(),
|
int color = ContextCompat.getColor(getContext(),
|
||||||
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
|
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
|
||||||
Drawable drawable = getSecondaryImage(app, position, holoLight);
|
Drawable drawable = ContextCompat.getDrawable(getContext(), item.getSecondaryIcon());
|
||||||
DrawableCompat.setTint(drawable, color);
|
DrawableCompat.setTint(drawable, color);
|
||||||
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
|
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
|
||||||
imageView.setImageDrawable(drawable);
|
imageView.setImageDrawable(drawable);
|
||||||
|
@ -265,13 +226,13 @@ public class ContextMenuAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCategory(position)) {
|
if (item.isCategory()) {
|
||||||
tv.setTypeface(Typeface.DEFAULT_BOLD);
|
tv.setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
} else {
|
} else {
|
||||||
tv.setTypeface(null);
|
tv.setTypeface(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (convertView.findViewById(R.id.toggle_item) != null) {
|
if (convertView.findViewById(R.id.toggle_item) != null && !item.isCategory()) {
|
||||||
final CompoundButton ch = (CompoundButton) convertView.findViewById(R.id.toggle_item);
|
final CompoundButton ch = (CompoundButton) convertView.findViewById(R.id.toggle_item);
|
||||||
if (item.getSelected() != null) {
|
if (item.getSelected() != null) {
|
||||||
ch.setOnCheckedChangeListener(null);
|
ch.setOnCheckedChangeListener(null);
|
||||||
|
@ -282,10 +243,10 @@ public class ContextMenuAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
OnContextMenuClick ca = getClickAdapter(position);
|
OnContextMenuClick ca = item.getCheckBoxListener();
|
||||||
item.setSelected(isChecked);
|
item.setSelected(isChecked);
|
||||||
if (ca != null) {
|
if (ca != null) {
|
||||||
ca.onContextMenuClick(la, getElementId(position), position, isChecked);
|
ca.onContextMenuClick(la, item.getTitleId(), position, isChecked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -299,11 +260,11 @@ public class ContextMenuAdapter {
|
||||||
if (convertView.findViewById(R.id.seekbar) != null) {
|
if (convertView.findViewById(R.id.seekbar) != null) {
|
||||||
SeekBar seekBar = (SeekBar) convertView.findViewById(R.id.seekbar);
|
SeekBar seekBar = (SeekBar) convertView.findViewById(R.id.seekbar);
|
||||||
if (item.getProgress() != -1) {
|
if (item.getProgress() != -1) {
|
||||||
seekBar.setProgress(getProgress(position));
|
seekBar.setProgress(item.getProgress());
|
||||||
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
OnIntegerValueChangedListener listener = getIntegerLister(position);
|
OnIntegerValueChangedListener listener = item.getIntegerListener();
|
||||||
item.setProgress(progress);
|
item.setProgress(progress);
|
||||||
if (listener != null && fromUser) {
|
if (listener != null && fromUser) {
|
||||||
listener.onIntegerValueChangedListener(progress);
|
listener.onIntegerValueChangedListener(progress);
|
||||||
|
@ -333,7 +294,7 @@ public class ContextMenuAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String itemDescr = getItemDescr(position);
|
String itemDescr = item.getDescription();
|
||||||
if (convertView.findViewById(R.id.description) != null) {
|
if (convertView.findViewById(R.id.description) != null) {
|
||||||
((TextView) convertView.findViewById(R.id.description)).setText(itemDescr);
|
((TextView) convertView.findViewById(R.id.description)).setText(itemDescr);
|
||||||
}
|
}
|
||||||
|
@ -366,17 +327,4 @@ public class ContextMenuAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BooleanResult {
|
|
||||||
private boolean result = false;
|
|
||||||
|
|
||||||
public void setResult(boolean value) {
|
|
||||||
result = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getResult() {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ public class ContextMenuItem {
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
private final int lightIcon;
|
private final int lightIcon;
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
private final int secondaryLightIcon;
|
private final int secondaryIcon;
|
||||||
private Boolean selected;
|
private Boolean selected;
|
||||||
private int progress;
|
private int progress;
|
||||||
@LayoutRes
|
@LayoutRes
|
||||||
|
@ -30,7 +30,7 @@ public class ContextMenuItem {
|
||||||
private ContextMenuAdapter.OnContextMenuClick checkBoxListener;
|
private ContextMenuAdapter.OnContextMenuClick checkBoxListener;
|
||||||
private ContextMenuAdapter.OnIntegerValueChangedListener integerListener;
|
private ContextMenuAdapter.OnIntegerValueChangedListener integerListener;
|
||||||
|
|
||||||
private ContextMenuItem(int titleId, String title, int icon, int lightIcon, int secondaryLightIcon,
|
private ContextMenuItem(int titleId, String title, int icon, int lightIcon, int secondaryIcon,
|
||||||
Boolean selected, int progress, int layout, boolean loading, boolean category,
|
Boolean selected, int progress, int layout, boolean loading, boolean category,
|
||||||
int pos, String description, ContextMenuAdapter.OnContextMenuClick checkBoxListener,
|
int pos, String description, ContextMenuAdapter.OnContextMenuClick checkBoxListener,
|
||||||
ContextMenuAdapter.OnIntegerValueChangedListener integerListener) {
|
ContextMenuAdapter.OnIntegerValueChangedListener integerListener) {
|
||||||
|
@ -38,7 +38,7 @@ public class ContextMenuItem {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.lightIcon = lightIcon;
|
this.lightIcon = lightIcon;
|
||||||
this.secondaryLightIcon = secondaryLightIcon;
|
this.secondaryIcon = secondaryIcon;
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
|
@ -66,8 +66,8 @@ public class ContextMenuItem {
|
||||||
return lightIcon;
|
return lightIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSecondaryLightIcon() {
|
public int getSecondaryIcon() {
|
||||||
return secondaryLightIcon;
|
return secondaryIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getSelected() {
|
public Boolean getSelected() {
|
||||||
|
@ -143,7 +143,7 @@ public class ContextMenuItem {
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
private int mIcon = -1;
|
private int mIcon = -1;
|
||||||
private int mLightIcon = -1;
|
private int mLightIcon = -1;
|
||||||
private int mSecondaryLightIcon = -1;
|
private int mSecondaryIcon = -1;
|
||||||
private Boolean mSelected = null;
|
private Boolean mSelected = null;
|
||||||
private int mProgress = -1;
|
private int mProgress = -1;
|
||||||
private int mLayout = -1;
|
private int mLayout = -1;
|
||||||
|
@ -178,8 +178,8 @@ public class ContextMenuItem {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemBuilder setSecondaryLightIcon(int secondaryLightIcon) {
|
public ItemBuilder setSecondaryIcon(int secondaryIcon) {
|
||||||
mSecondaryLightIcon = secondaryLightIcon;
|
mSecondaryIcon = secondaryIcon;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ public class ContextMenuItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContextMenuItem createItem() {
|
public ContextMenuItem createItem() {
|
||||||
return new ContextMenuItem(mTitleId, mTitle, mIcon, mLightIcon, mSecondaryLightIcon, mSelected, mProgress, mLayout, mLoading, mCat, mPos, mDescription, mCheckBoxListener, mIntegerListener);
|
return new ContextMenuItem(mTitleId, mTitle, mIcon, mLightIcon, mSecondaryIcon, mSelected, mProgress, mLayout, mLoading, mCat, mPos, mDescription, mCheckBoxListener, mIntegerListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
|
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
|
||||||
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter(mapActivity) : iadapter;
|
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter() : iadapter;
|
||||||
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder();
|
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder();
|
||||||
adapter.addItem(itemBuilder.setTitleId(R.string.context_menu_item_search, mapActivity)
|
adapter.addItem(itemBuilder.setTitleId(R.string.context_menu_item_search, mapActivity)
|
||||||
.setColorIcon(R.drawable.ic_action_search_dark).createItem());
|
.setColorIcon(R.drawable.ic_action_search_dark).createItem());
|
||||||
|
@ -594,7 +594,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
public ContextMenuAdapter createMainOptionsMenu() {
|
public ContextMenuAdapter createMainOptionsMenu() {
|
||||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||||
final OsmandApplication app = mapActivity.getMyApplication();
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter();
|
||||||
|
|
||||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.home, mapActivity)
|
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.home, mapActivity)
|
||||||
.setColorIcon(R.drawable.map_dashboard)
|
.setColorIcon(R.drawable.map_dashboard)
|
||||||
|
|
|
@ -261,7 +261,7 @@ public class MapActivityLayers {
|
||||||
public AlertDialog selectPOIFilterLayer(final OsmandMapTileView mapView, final PoiUIFilter[] selected) {
|
public AlertDialog selectPOIFilterLayer(final OsmandMapTileView mapView, final PoiUIFilter[] selected) {
|
||||||
OsmandApplication app = (OsmandApplication) getApplication();
|
OsmandApplication app = (OsmandApplication) getApplication();
|
||||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||||
.setTitleId(R.string.shared_string_search, app)
|
.setTitleId(R.string.shared_string_search, app)
|
||||||
.setColorIcon(R.drawable.ic_action_search_dark).createItem());
|
.setColorIcon(R.drawable.ic_action_search_dark).createItem());
|
||||||
|
|
|
@ -10,7 +10,6 @@ import android.widget.LinearLayout.LayoutParams;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -36,7 +35,7 @@ public class AppModeDialog {
|
||||||
|
|
||||||
//special method for drawer menu
|
//special method for drawer menu
|
||||||
//needed because if there's more than 4 items - the don't fit in drawer
|
//needed because if there's more than 4 items - the don't fit in drawer
|
||||||
public static View prepareAppModeDrawerView(Activity a, final Set<ApplicationMode> selected, ContextMenuAdapter.BooleanResult allModes,
|
public static View prepareAppModeDrawerView(Activity a, final Set<ApplicationMode> selected,
|
||||||
boolean useMapTheme, final View.OnClickListener onClickListener) {
|
boolean useMapTheme, final View.OnClickListener onClickListener) {
|
||||||
OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings();
|
OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings();
|
||||||
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(settings));
|
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(settings));
|
||||||
|
|
|
@ -56,22 +56,20 @@ public class ConfigureMapMenu {
|
||||||
private static final Log LOG = PlatformUtil.getLog(ConfigureMapMenu.class);
|
private static final Log LOG = PlatformUtil.getLog(ConfigureMapMenu.class);
|
||||||
|
|
||||||
public interface OnClickListener {
|
public interface OnClickListener {
|
||||||
public void onClick(boolean result);
|
void onClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
private boolean allModes = false;
|
private boolean allModes = false;
|
||||||
|
|
||||||
public ContextMenuAdapter createListAdapter(final MapActivity ma) {
|
public ContextMenuAdapter createListAdapter(final MapActivity ma) {
|
||||||
ContextMenuAdapter adapter = new ContextMenuAdapter(ma, allModes);
|
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
adapter.setDefaultLayoutId(R.layout.drawer_list_item);
|
adapter.setDefaultLayoutId(R.layout.drawer_list_item);
|
||||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||||
.setTitleId(R.string.app_modes_choose, ma)
|
.setTitleId(R.string.app_modes_choose, ma)
|
||||||
.setLayout(R.layout.mode_toggles).createItem());
|
.setLayout(R.layout.mode_toggles).createItem());
|
||||||
adapter.setChangeAppModeListener(new OnClickListener() {
|
adapter.setChangeAppModeListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean result) {
|
public void onClick() {
|
||||||
allModes = true;
|
allModes = true;
|
||||||
ma.getDashboard().updateListAdapter(createListAdapter(ma));
|
ma.getDashboard().updateListAdapter(createListAdapter(ma));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class RasterMapMenu {
|
||||||
|
|
||||||
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity,
|
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity,
|
||||||
final OsmandRasterMapsPlugin.RasterMapType type) {
|
final OsmandRasterMapsPlugin.RasterMapType type) {
|
||||||
ContextMenuAdapter adapter = new ContextMenuAdapter(mapActivity, false);
|
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||||
createLayersItems(adapter, mapActivity, type);
|
createLayersItems(adapter, mapActivity, type);
|
||||||
return adapter;
|
return adapter;
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
|
|
||||||
private void showContextMenu(final LocalIndexInfo info) {
|
private void showContextMenu(final LocalIndexInfo info) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(getActivity());
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
basicFileOperation(info, adapter);
|
basicFileOperation(info, adapter);
|
||||||
OsmandPlugin.onContextMenuActivity(getActivity(), null, info, adapter);
|
OsmandPlugin.onContextMenuActivity(getActivity(), null, info, adapter);
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
ActionBar actionBar = getDownloadActivity().getSupportActionBar();
|
ActionBar actionBar = getDownloadActivity().getSupportActionBar();
|
||||||
//hide action bar from downloadindexfragment
|
//hide action bar from downloadindexfragment
|
||||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||||
optionsMenuAdapter = new ContextMenuAdapter(getDownloadActivity());
|
optionsMenuAdapter = new ContextMenuAdapter();
|
||||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class GpxUiHelper {
|
||||||
private static ContextMenuAdapter createGpxContextMenuAdapter(Activity activity, List<String> allGpxList,
|
private static ContextMenuAdapter createGpxContextMenuAdapter(Activity activity, List<String> allGpxList,
|
||||||
List<String> selectedGpxList, boolean multipleChoice,
|
List<String> selectedGpxList, boolean multipleChoice,
|
||||||
boolean showCurrentTrack) {
|
boolean showCurrentTrack) {
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
//element position in adapter
|
//element position in adapter
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String s : allGpxList) {
|
for (String s : allGpxList) {
|
||||||
|
|
|
@ -553,7 +553,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buttonMorePressed() {
|
public void buttonMorePressed() {
|
||||||
final ContextMenuAdapter menuAdapter = new ContextMenuAdapter(mapActivity);
|
final ContextMenuAdapter menuAdapter = new ContextMenuAdapter();
|
||||||
for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) {
|
for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) {
|
||||||
layer.populateObjectContextMenu(latLon, object, menuAdapter, mapActivity);
|
layer.populateObjectContextMenu(latLon, object, menuAdapter, mapActivity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ public class RoutePreferencesMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void selectVoiceGuidance(final MapActivity mapActivity, final CallbackWithObject<String> callback) {
|
public static void selectVoiceGuidance(final MapActivity mapActivity, final CallbackWithObject<String> callback) {
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(mapActivity);
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
|
|
||||||
String[] entries;
|
String[] entries;
|
||||||
final String[] entrieValues;
|
final String[] entrieValues;
|
||||||
|
|
|
@ -327,7 +327,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
||||||
((FavoritesActivity) getActivity()).getClearToolbar(false);
|
((FavoritesActivity) getActivity()).getClearToolbar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
optionsMenuAdapter = new ContextMenuAdapter(getActivity());
|
optionsMenuAdapter = new ContextMenuAdapter();
|
||||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, final int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, final int itemId, int pos, boolean isChecked) {
|
||||||
|
|
|
@ -403,7 +403,7 @@ public class MapWidgetRegistry {
|
||||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.messageId, map)
|
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.messageId, map)
|
||||||
.setSelected(r.visibleCollapsed(mode) || r.visible(mode))
|
.setSelected(r.visibleCollapsed(mode) || r.visible(mode))
|
||||||
.setColorIcon(r.drawableMenu)
|
.setColorIcon(r.drawableMenu)
|
||||||
.setSecondaryLightIcon(R.drawable.ic_action_additional_option)
|
.setSecondaryIcon(R.drawable.ic_action_additional_option)
|
||||||
.setListener(new OnContextMenuClick() {
|
.setListener(new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
|
||||||
|
@ -496,14 +496,14 @@ public class MapWidgetRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) {
|
public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) {
|
||||||
final ContextMenuAdapter cm = new ContextMenuAdapter(map);
|
final ContextMenuAdapter cm = new ContextMenuAdapter();
|
||||||
cm.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
cm.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.app_modes_choose, map)
|
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.app_modes_choose, map)
|
||||||
.setLayout(R.layout.mode_toggles).createItem());
|
.setLayout(R.layout.mode_toggles).createItem());
|
||||||
cm.setChangeAppModeListener(new ConfigureMapMenu.OnClickListener() {
|
cm.setChangeAppModeListener(new ConfigureMapMenu.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean allModes) {
|
public void onClick() {
|
||||||
map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter(map));
|
map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter(map));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue