Implementing layout for configure screen.

This commit is contained in:
GaidamakUA 2016-03-23 18:35:09 +02:00
parent ea59f417ec
commit dc19cb8a0c
22 changed files with 269 additions and 187 deletions

View file

@ -1,46 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="54dp"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="54dp"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
<android.support.v7.widget.AppCompatImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="32dp"
android:layout_gravity="center_vertical"
tools:src="@drawable/ic_action_gabout_dark" />
android:layout_marginBottom="16dp"
android:layout_marginRight="32dp"
android:layout_marginTop="16dp"
tools:src="@drawable/ic_action_gabout_dark"/>
<TextView
<android.support.v7.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="@dimen/default_list_text_size"
android:layout_weight="1"
android:layout_gravity="center_vertical"
tools:text="Some title text" />
android:layout_weight="1"
android:textSize="@dimen/default_list_text_size"
tools:text="Some title text"/>
<ImageView
android:id="@+id/menu"
<android.support.v7.widget.AppCompatImageView
android:id="@+id/secondary_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="center_vertical"
tools:src="@drawable/ic_action_gabout_dark" />
android:layout_margin="16dp"
tools:src="@drawable/ic_action_gabout_dark"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:focusable="false"
android:layout_gravity="center_vertical" />
android:layout_gravity="center_vertical"
android:focusable="false"/>
</LinearLayout>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="54dp"
android:orientation="horizontal">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_marginLeft="16dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:textSize="@dimen/default_list_text_size"
tools:text="Some title text"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/description"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:inputType="textCapWords"
tools:text="topbar"
android:textColor="?colorAccent"
android:layout_marginLeft="16dp"
android:focusable="false"/>
</LinearLayout>

View file

@ -5,8 +5,12 @@ import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
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.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
@ -88,7 +92,8 @@ public class ContextMenuAdapter {
final TIntArrayList loadingList = new TIntArrayList();
final TIntArrayList layoutIds = new TIntArrayList();
final TIntArrayList iconList = new TIntArrayList();
final TIntArrayList iconListLight = 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>();
private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
@ -170,13 +175,22 @@ public class ContextMenuAdapter {
if (lst != 0) {
return ctx.getResources().getDrawable(lst);
}
int lstLight = iconListLight.get(pos);
int lstLight = lightIconList.get(pos);
if (lstLight != 0) {
return ctx.getIconsCache().getIcon(lstLight, light);
}
return null;
}
public Drawable getSecondaryImage(OsmandApplication ctx, int pos, boolean light) {
@DrawableRes
int secondaryDrawableId = secondaryLightIconList.get(pos);
if (secondaryDrawableId != 0) {
return ContextCompat.getDrawable(ctx, secondaryDrawableId);
}
return null;
}
public int getBackgroundColor(Context ctx, boolean holoLight) {
if (holoLight) {
return ctx.getResources().getColor(R.color.bg_color_light);
@ -206,12 +220,18 @@ public class ContextMenuAdapter {
}
public class Item {
@DrawableRes
int icon = 0;
@DrawableRes
int lightIcon = 0;
@DrawableRes
int secondaryLightIcon = 0;
@IdRes
int id;
String name;
int selected = -1;
int progress = -1;
@LayoutRes
int layout = -1;
int loading = -1;
boolean cat;
@ -223,16 +243,20 @@ public class ContextMenuAdapter {
private Item() {
}
public Item icon(int icon) {
public Item icon(@DrawableRes int icon) {
this.icon = icon;
return this;
}
public Item iconColor(int icon) {
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;
@ -254,7 +278,7 @@ public class ContextMenuAdapter {
return this;
}
public Item layout(int l) {
public Item layout(@LayoutRes int l) {
this.layout = l;
return this;
}
@ -286,7 +310,8 @@ public class ContextMenuAdapter {
loadingList.insert(pos, loading);
layoutIds.insert(pos, layout);
iconList.insert(pos, icon);
iconListLight.insert(pos, lightIcon);
lightIconList.insert(pos, lightIcon);
secondaryLightIconList.insert(pos, secondaryLightIcon);
checkListeners.add(pos, checkBoxListener);
integerListeners.add(pos, integerListener);
isCategory.insert(pos, cat ? 1 : 0);
@ -314,7 +339,8 @@ public class ContextMenuAdapter {
selectedList.removeAt(pos);
progressList.removeAt(pos);
iconList.removeAt(pos);
iconListLight.removeAt(pos);
lightIconList.removeAt(pos);
secondaryLightIconList.removeAt(pos);
checkListeners.remove(pos);
integerListeners.remove(pos);
isCategory.removeAt(pos);
@ -344,9 +370,8 @@ public class ContextMenuAdapter {
public ArrayAdapter<?> createListAdapter(final Activity activity, final boolean holoLight) {
final int layoutId = defaultLayoutId;
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
ArrayAdapter<String> listAdapter = new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
return new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
getItemNames(), app, holoLight);
return listAdapter;
}
public class ContextMenuArrayAdapter extends ArrayAdapter<String> {
@ -385,7 +410,7 @@ public class ContextMenuAdapter {
}
if (convertView == null || (!lid.equals(convertView.getTag()))) {
convertView = activity.getLayoutInflater().inflate(lid, parent, false);
AndroidUtils.setListItemBackground(ctx, convertView, !holoLight);
// AndroidUtils.setListItemBackground(ctx, convertView, !holoLight);
convertView.setTag(lid);
}
TextView tv = (TextView) convertView.findViewById(R.id.title);
@ -398,7 +423,7 @@ public class ContextMenuAdapter {
int color = activity.getResources()
.getColor(holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
Drawable imageId = app.getIconsCache().getPaintedContentIcon(
iconListLight.get(position), color);
lightIconList.get(position), color);
float density = activity.getResources().getDisplayMetrics().density;
int paddingInPixels = (int) (24 * density);
int drawableSizeInPixels = (int) (24 * density); // 32
@ -406,15 +431,31 @@ public class ContextMenuAdapter {
tv.setCompoundDrawables(imageId, null, null, null);
tv.setCompoundDrawablePadding(paddingInPixels);
} else {
Drawable imageId = getImage(app, position, holoLight);
if (imageId != null) {
Drawable drawable = getImage(app, position, holoLight);
if (drawable != null) {
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(imageId);
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable);
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
} else if (convertView.findViewById(R.id.icon) != null) {
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
}
}
@DrawableRes
int secondaryLightDrawable = secondaryLightIconList.get(position);
if (secondaryLightDrawable != 0) {
int color = ContextCompat.getColor(ctx,
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
Drawable drawable = getSecondaryImage(app, position, holoLight);
DrawableCompat.setTint(drawable, color);
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
imageView.setImageDrawable(drawable);
imageView.setVisibility(View.VISIBLE);
} else {
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
if (imageView != null) {
imageView.setVisibility(View.GONE);
}
}
if (isCategory(position)) {
tv.setTypeface(Typeface.DEFAULT_BOLD);

View file

@ -279,14 +279,14 @@ 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).iconColor(R.drawable.ic_action_search_dark).reg();
adapter.item(R.string.context_menu_item_search).colorIcon(R.drawable.ic_action_search_dark).reg();
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {
adapter.item(R.string.context_menu_item_directions_from).iconColor(
adapter.item(R.string.context_menu_item_directions_from).colorIcon(
R.drawable.ic_action_gdirections_dark).reg();
}
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() != null &&
(mapActivity.getRoutingHelper().isFollowingMode() || mapActivity.getRoutingHelper().isRoutePlanningMode())) {
adapter.item(R.string.context_menu_item_last_intermediate_point).iconColor(
adapter.item(R.string.context_menu_item_last_intermediate_point).colorIcon(
R.drawable.ic_action_intermediate).reg();
}
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
@ -593,7 +593,7 @@ public class MapActivityActions implements DialogProvider {
final OsmandApplication app = mapActivity.getMyApplication();
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
optionsMenuHelper.item(R.string.home).iconColor(R.drawable.map_dashboard)
optionsMenuHelper.item(R.string.home).colorIcon(R.drawable.map_dashboard)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -604,7 +604,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
if (settings.USE_MAP_MARKERS.get()) {
optionsMenuHelper.item(R.string.map_markers).iconColor(R.drawable.ic_action_flag_dark)
optionsMenuHelper.item(R.string.map_markers).colorIcon(R.drawable.ic_action_flag_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -614,7 +614,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
} else {
optionsMenuHelper.item(R.string.waypoints).iconColor(R.drawable.ic_action_intermediate)
optionsMenuHelper.item(R.string.waypoints).colorIcon(R.drawable.ic_action_intermediate)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -624,7 +624,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
}
optionsMenuHelper.item(R.string.get_directions).iconColor(R.drawable.ic_action_gdirections_dark)
optionsMenuHelper.item(R.string.get_directions).colorIcon(R.drawable.ic_action_gdirections_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -643,7 +643,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
// Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
optionsMenuHelper.item(R.string.search_button)
.iconColor(R.drawable.ic_action_search_dark)
.colorIcon(R.drawable.ic_action_search_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -661,7 +661,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
optionsMenuHelper.item(R.string.shared_string_my_places).iconColor(R.drawable.ic_action_fav_dark)
optionsMenuHelper.item(R.string.shared_string_my_places).colorIcon(R.drawable.ic_action_fav_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -674,7 +674,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
optionsMenuHelper.item(R.string.show_point_options).iconColor(R.drawable.ic_action_marker_dark)
optionsMenuHelper.item(R.string.show_point_options).colorIcon(R.drawable.ic_action_marker_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -684,7 +684,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
optionsMenuHelper.item(R.string.configure_map).iconColor(R.drawable.ic_action_layers_dark)
optionsMenuHelper.item(R.string.configure_map).colorIcon(R.drawable.ic_action_layers_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -694,7 +694,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
optionsMenuHelper.item(R.string.layer_map_appearance).iconColor(R.drawable.ic_configure_screen_dark)
optionsMenuHelper.item(R.string.layer_map_appearance).colorIcon(R.drawable.ic_configure_screen_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -711,7 +711,7 @@ public class MapActivityActions implements DialogProvider {
d += " (" + updt.size() + ")";
}
}
optionsMenuHelper.item(R.string.index_settings).name(d).iconColor(R.drawable.ic_type_archive)
optionsMenuHelper.item(R.string.index_settings).name(d).colorIcon(R.drawable.ic_type_archive)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -724,7 +724,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
if (Version.isGooglePlayEnabled(app)) {
optionsMenuHelper.item(R.string.osm_live).iconColor(R.drawable.ic_action_osm_live)
optionsMenuHelper.item(R.string.osm_live).colorIcon(R.drawable.ic_action_osm_live)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -736,7 +736,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
}
optionsMenuHelper.item(R.string.prefs_plugins).iconColor(R.drawable.ic_extension_dark)
optionsMenuHelper.item(R.string.prefs_plugins).colorIcon(R.drawable.ic_extension_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -749,7 +749,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
optionsMenuHelper.item(R.string.shared_string_settings).iconColor(R.drawable.ic_action_settings)
optionsMenuHelper.item(R.string.shared_string_settings).colorIcon(R.drawable.ic_action_settings)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -760,7 +760,7 @@ public class MapActivityActions implements DialogProvider {
return true;
}
}).reg();
optionsMenuHelper.item(R.string.shared_string_help).iconColor(R.drawable.ic_action_help)
optionsMenuHelper.item(R.string.shared_string_help).colorIcon(R.drawable.ic_action_help)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -774,7 +774,7 @@ public class MapActivityActions implements DialogProvider {
//////////// Others
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
// optionsMenuHelper.item(R.string.shared_string_exit).iconColor(R.drawable.ic_action_quit_dark )
// optionsMenuHelper.item(R.string.shared_string_exit).colorIcon(R.drawable.ic_action_quit_dark )
// .listen(new OnContextMenuClick() {
// @Override
// public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -262,7 +262,7 @@ 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).iconColor(R.drawable.ic_action_search_dark).reg();
adapter.item(R.string.shared_string_search).colorIcon(R.drawable.ic_action_search_dark).reg();
final List<PoiUIFilter> list = new ArrayList<PoiUIFilter>();
list.add(poiFilters.getCustomPOIFilter());
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {

View file

@ -591,7 +591,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
};
adapter.item(R.string.layer_recordings).selected(SHOW_RECORDINGS.get() ? 1 : 0)
.iconColor(R.drawable.ic_action_micro_dark).listen(listener).position(12).reg();
.colorIcon(R.drawable.ic_action_micro_dark).listen(listener).position(12).reg();
}
@Override
@ -600,7 +600,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
if (isRecording()) {
return;
}
adapter.item(R.string.recording_context_menu_arecord).iconColor(R.drawable.ic_action_micro_dark)
adapter.item(R.string.recording_context_menu_arecord).colorIcon(R.drawable.ic_action_micro_dark)
.listen(new OnContextMenuClick() {
@Override
@ -609,7 +609,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
return true;
}
}).position(6).reg();
adapter.item(R.string.recording_context_menu_vrecord).iconColor(R.drawable.ic_action_video_dark)
adapter.item(R.string.recording_context_menu_vrecord).colorIcon(R.drawable.ic_action_video_dark)
.listen(new OnContextMenuClick() {
@Override
@ -618,7 +618,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
return true;
}
}).position(7).reg();
adapter.item(R.string.recording_context_menu_precord).iconColor(R.drawable.ic_action_photo_dark)
adapter.item(R.string.recording_context_menu_precord).colorIcon(R.drawable.ic_action_photo_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -874,7 +874,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
if (listBackgroundView != null) {
listBackgroundView.setBackgroundColor(backgroundColor);
} else {
listView.setBackgroundColor(backgroundColor);
// listView.setBackgroundColor(backgroundColor);
listEmptyTextView.setBackgroundColor(backgroundColor);
}
if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS

View file

@ -56,7 +56,7 @@ 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).iconColor(R.drawable.ic_action_gabout_dark)
helper.item(R.string.version_settings).colorIcon(R.drawable.ic_action_gabout_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -172,20 +172,20 @@ public class ConfigureMapMenu {
adapter.item(R.string.shared_string_show).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
adapter.item(R.string.layer_poi).selected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null ? 1 : 0)
.iconColor(R.drawable.ic_action_info_dark).listen(l).reg();
.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)
.iconColor(R.drawable.ic_action_text_dark).listen(l).reg();
.colorIcon(R.drawable.ic_action_text_dark).listen(l).reg();
adapter.item(R.string.shared_string_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0)
.iconColor(R.drawable.ic_action_fav_dark).listen(l).reg();
.colorIcon(R.drawable.ic_action_fav_dark).listen(l).reg();
adapter.item(R.string.layer_gpx_layer).selected(
app.getSelectedGpxHelper().isShowingAnyGpxFiles() ? 1 : 0)
.iconColor(R.drawable.ic_action_polygom_dark)
.colorIcon(R.drawable.ic_action_polygom_dark)
.listen(l).reg();
adapter.item(R.string.layer_map).iconColor(R.drawable.ic_world_globe_dark)
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)
.iconColor(R.drawable.ic_action_bus_dark).listen(l).reg();
.colorIcon(R.drawable.ic_action_bus_dark).listen(l).reg();
}
OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity);

View file

@ -129,7 +129,7 @@ public class RasterMapMenu {
// android:max="255" in layout is expected
contextMenuAdapter.item(mapTypeStringTransparency)
.layout(R.layout.progress_list_item)
.iconColor(R.drawable.ic_action_opacity)
.colorIcon(R.drawable.ic_action_opacity)
.progress(mapTransparencyPreference.get())
.listen(l)
.listenInteger(integerListener).reg();

View file

@ -675,7 +675,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
return true;
}
};
adapter.item(R.string.delete_point).iconColor(R.drawable.ic_action_delete_dark).listen(listener).reg();
adapter.item(R.string.delete_point).colorIcon(R.drawable.ic_action_delete_dark).listen(listener).reg();
}
}
}

View file

@ -208,7 +208,7 @@ public class GpxUiHelper {
s = s.replace('_', ' ');
adapter.item(s).selected(multipleChoice ? 0 : -1)
.iconColor(R.drawable.ic_action_polygom_dark).reg();
.colorIcon(R.drawable.ic_action_polygom_dark).reg();
//if there's some selected files - need to mark them as selected
if (selectedGpxList != null) {

View file

@ -140,12 +140,12 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
return true;
}
};
adapter.item(R.string.context_menu_item_add_waypoint).iconColor(R.drawable.ic_action_gnew_label_dark)
adapter.item(R.string.context_menu_item_add_waypoint).colorIcon(R.drawable.ic_action_gnew_label_dark)
.listen(listener).reg();
if (selectedObj instanceof WptPt) {
WptPt pt = (WptPt) selectedObj;
if (app.getSelectedGpxHelper().getSelectedGPXFile(pt) != null) {
adapter.item(R.string.context_menu_item_edit_waypoint).iconColor(R.drawable.ic_action_edit_dark)
adapter.item(R.string.context_menu_item_edit_waypoint).colorIcon(R.drawable.ic_action_edit_dark)
.listen(listener).reg();
}
}

View file

@ -216,15 +216,15 @@ public class OsmEditingPlugin extends OsmandPlugin {
isEditable = !amenity.getType().isWiki() && !poiType.isNotEditableOsm();
}
if (isEditable) {
adapter.item(R.string.poi_context_menu_modify).iconColor(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg();
adapter.item(R.string.poi_context_menu_delete).iconColor(R.drawable.ic_action_delete_dark).listen(listener).position(2).reg();
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();
} else if (selectedObj instanceof OpenstreetmapPoint && ((OpenstreetmapPoint) selectedObj).getAction() != Action.DELETE) {
adapter.item(R.string.poi_context_menu_modify_osm_change)
.iconColor(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg();
.colorIcon(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg();
} else {
adapter.item(R.string.context_menu_item_create_poi).iconColor(R.drawable.ic_action_plus_dark).listen(listener).position(-1).reg();
adapter.item(R.string.context_menu_item_create_poi).colorIcon(R.drawable.ic_action_plus_dark).listen(listener).position(-1).reg();
}
adapter.item(R.string.context_menu_item_open_note).iconColor(R.drawable.ic_action_bug_dark).listen(listener).reg();
adapter.item(R.string.context_menu_item_open_note).colorIcon(R.drawable.ic_action_bug_dark).listen(listener).reg();
}
@Override
@ -240,7 +240,7 @@ 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)
.iconColor(R.drawable.ic_action_bug_dark).listen(new OnContextMenuClick() {
.colorIcon(R.drawable.ic_action_bug_dark).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -263,7 +263,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
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)
.iconColor(R.drawable.ic_action_export)
.colorIcon(R.drawable.ic_action_export)
.listen(new OnContextMenuClick() {
@Override

View file

@ -274,7 +274,7 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
@Override
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
helper.item(R.string.osmo_groups).iconColor(R.drawable.ic_osmo_dark).position(6)
helper.item(R.string.osmo_groups).colorIcon(R.drawable.ic_osmo_dark).position(6)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -227,7 +227,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
}
};
adapter.item(R.string.context_menu_item_add_parking_point)
.iconColor( R.drawable.ic_action_parking_dark).listen(addListener).reg();
.colorIcon(R.drawable.ic_action_parking_dark).listen(addListener).reg();
}

View file

@ -255,11 +255,11 @@ 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)
.iconColor(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
.colorIcon(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
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)
.iconColor(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
.colorIcon(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
}
@ -280,9 +280,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
return true;
}
};
adapter.item(R.string.context_menu_item_update_map).iconColor(R.drawable.ic_action_refresh_dark)
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).iconColor(R.drawable.ic_action_import)
adapter.item(R.string.shared_string_download_map).colorIcon(R.drawable.ic_action_import)
.listen(listener).reg();
}
}

View file

@ -2,8 +2,8 @@ package net.osmand.plus.routepointsnavigation;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.os.AsyncTask;
import android.widget.ArrayAdapter;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
@ -17,9 +17,6 @@ import net.osmand.plus.views.OsmandMapTileView;
import java.util.List;
/**
* Created by Barsik on 20.06.2014.
*/
public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
private final RoutePointsPlugin plugin;
@ -112,10 +109,10 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
};
if (plugin.getCurrentRoute().getPointStatus(point)){
adapter.item(R.string.mark_as_not_visited).iconColor(
adapter.item(R.string.mark_as_not_visited).colorIcon(
R.drawable.ic_action_gremove_dark).listen(listener).reg();
} else {
adapter.item(R.string.mark_as_visited).iconColor(
adapter.item(R.string.mark_as_visited).colorIcon(
R.drawable.ic_action_done).listen(listener).reg();
}
@ -123,11 +120,11 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
if (routePoint != null) {
if (routePoint.isNextNavigate) {
adapter.item(R.string.navigate_to_next)
.iconColor(R.drawable.ic_action_gnext_dark).listen(listener)
.colorIcon(R.drawable.ic_action_gnext_dark).listen(listener)
.reg();
} else {
adapter.item(R.string.mark_as_current)
.iconColor(R.drawable.ic_action_signpost_dark)
.colorIcon(R.drawable.ic_action_signpost_dark)
.listen(listener).reg();
}
}

View file

@ -115,7 +115,7 @@ public class SRTMPlugin extends OsmandPlugin {
}
};
adapter.item(R.string.layer_hillshade).selected(HILLSHADE.get()? 1 : 0)
.iconColor( R.drawable.ic_action_hillshade_dark).listen(listener).position(13).layout(R.layout.drawer_list_item).reg();
.colorIcon(R.drawable.ic_action_hillshade_dark).listen(listener).position(13).layout(R.layout.drawer_list_item).reg();
}
@Override

View file

@ -143,7 +143,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
};
adapter.item(R.string.shared_string_show_description)
.iconColor(R.drawable.ic_action_note_dark).listen(listener)
.colorIcon(R.drawable.ic_action_note_dark).listen(listener)
.reg();
}
}

View file

@ -176,7 +176,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
}
};
adapter.item(R.string.avoid_road).iconColor(
adapter.item(R.string.avoid_road).colorIcon(
R.drawable.ic_action_road_works_dark).listen(listener).reg();
}
}

View file

@ -2,6 +2,8 @@ package net.osmand.plus.views.mapwidgets;
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
@ -28,30 +30,30 @@ import java.util.Set;
import java.util.TreeSet;
public class MapWidgetRegistry {
private Set<MapWidgetRegInfo> left = new TreeSet<MapWidgetRegistry.MapWidgetRegInfo>();
private Set<MapWidgetRegInfo> right = new TreeSet<MapWidgetRegistry.MapWidgetRegInfo>();
private Map<ApplicationMode, Set<String>> visibleElementsFromSettings = new LinkedHashMap<ApplicationMode, Set<String>>();
private final OsmandSettings settings;
public MapWidgetRegistry(OsmandSettings settings) {
this.settings = settings;
for(ApplicationMode ms : ApplicationMode.values(settings) ) {
for (ApplicationMode ms : ApplicationMode.values(settings)) {
String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms);
if(mpf.equals("")) {
if (mpf.equals("")) {
visibleElementsFromSettings.put(ms, null);
} else {
LinkedHashSet<String> set = new LinkedHashSet<String>();
visibleElementsFromSettings.put(ms, set);
Collections.addAll(set, mpf.split(";"));
Collections.addAll(set, mpf.split(";"));
}
}
}
public void populateStackControl(LinearLayout stack,
ApplicationMode mode, boolean left, boolean expanded) {
public void populateStackControl(LinearLayout stack,
ApplicationMode mode, boolean left, boolean expanded) {
Set<MapWidgetRegInfo> s = left ? this.left : this.right;
for (MapWidgetRegInfo r : s) {
if (r.visible(mode) || r.widget.isExplicitlyVisible()) {
@ -60,14 +62,14 @@ public class MapWidgetRegistry {
}
if (expanded) {
for (MapWidgetRegInfo r : s) {
if (r.visibleCollapsed(mode) &&
if (r.visibleCollapsed(mode) &&
!r.widget.isExplicitlyVisible()) {
stack.addView(r.widget.getView());
}
}
}
}
public boolean hasCollapsibles(ApplicationMode mode) {
for (MapWidgetRegInfo r : left) {
if (r.visibleCollapsed(mode)) {
@ -81,8 +83,8 @@ public class MapWidgetRegistry {
}
return false;
}
public void updateInfo(ApplicationMode mode, DrawSettings drawSettings, boolean expanded) {
update(mode, drawSettings, expanded, left);
update(mode, drawSettings, expanded, right);
@ -95,8 +97,8 @@ public class MapWidgetRegistry {
}
}
}
public void removeSideWidgetInternal(TextInfoWidget widget) {
Iterator<MapWidgetRegInfo> it = left.iterator();
while (it.hasNext()) {
@ -111,24 +113,26 @@ public class MapWidgetRegistry {
}
}
}
public <T extends TextInfoWidget> T getSideWidget(Class<T> cl) {
for(MapWidgetRegInfo ri : left) {
if(cl.isInstance(ri)) {
for (MapWidgetRegInfo ri : left) {
if (cl.isInstance(ri)) {
return (T) ri.widget;
}
}
for(MapWidgetRegInfo ri : right) {
if(cl.isInstance(ri)) {
for (MapWidgetRegInfo ri : right) {
if (cl.isInstance(ri)) {
return (T) ri.widget;
}
}
return null;
}
public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, int drawableMenu,
int messageId, String key, boolean left, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,
public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget,
@DrawableRes int drawableMenu,
@StringRes int messageId,
String key, boolean left, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,
messageId, priorityOrder, left);
for (ApplicationMode ms : ApplicationMode.values(settings)) {
boolean collapse = ms.isWidgetCollapsible(key);
@ -155,14 +159,14 @@ public class MapWidgetRegistry {
if (widget != null) {
widget.setContentTitle(messageId);
}
if(left) {
if (left) {
this.left.add(ii);
} else {
this.right.add(ii);
}
return ii;
}
private void restoreModes(Set<String> set, Set<MapWidgetRegInfo> mi, ApplicationMode mode) {
for (MapWidgetRegInfo m : mi) {
if (m.visibleModes.contains(mode)) {
@ -174,7 +178,7 @@ public class MapWidgetRegistry {
}
}
}
public void changeVisibility(MapWidgetRegInfo m) {
ApplicationMode mode = settings.APPLICATION_MODE.get();
boolean visible = m.visible(mode);
@ -238,9 +242,9 @@ public class MapWidgetRegistry {
}
settings.MAP_INFO_CONTROLS.set(bs.toString());
}
private void resetDefault(ApplicationMode mode, Set<MapWidgetRegInfo> set ){
private void resetDefault(ApplicationMode mode, Set<MapWidgetRegInfo> set) {
for (MapWidgetRegInfo ri : set) {
ri.visibleCollapsible.remove(mode);
ri.visibleModes.remove(mode);
@ -253,7 +257,7 @@ public class MapWidgetRegistry {
}
}
}
public void resetToDefault() {
ApplicationMode appMode = settings.getApplicationMode();
resetDefault(appMode, left);
@ -262,7 +266,7 @@ public class MapWidgetRegistry {
this.visibleElementsFromSettings.put(appMode, null);
settings.MAP_INFO_CONTROLS.set("");
}
private void resetDefaultAppearance(ApplicationMode appMode) {
// settings.SHOW_RULER.resetToDefault();
settings.SHOW_DESTINATION_ARROW.resetToDefault();
@ -271,13 +275,13 @@ public class MapWidgetRegistry {
settings.CENTER_POSITION_ON_MAP.resetToDefault();
settings.MAP_MARKERS_MODE.resetToDefault();
}
public void addControlsAppearance(final MapActivity map, final ContextMenuAdapter cm, ApplicationMode mode) {
// addControlId(mil, cm, R.string.map_widget_show_ruler, settings.SHOW_RULER);
addControlId(map, cm, R.string.map_widget_show_destination_arrow, settings.SHOW_DESTINATION_ARROW);
addControlId(map, cm, R.string.map_widget_transparent, settings.TRANSPARENT_MAP_THEME);
addControlId(map, cm, R.string.always_center_position_on_map, settings.CENTER_POSITION_ON_MAP);
if(mode != ApplicationMode.DEFAULT) {
if (mode != ApplicationMode.DEFAULT) {
addControlId(map, cm, R.string.map_widget_top_text, settings.SHOW_STREET_NAME);
}
if (settings.USE_MAP_MARKERS.get()) {
@ -314,18 +318,18 @@ public class MapWidgetRegistry {
bld.show();
return false;
}
}).layout(R.layout.drawer_list_doubleitem).reg();
}).layout(R.layout.list_item_text_button).reg();
}
}
private void addControlId(final MapActivity map, ContextMenuAdapter cm, int stringId, OsmandPreference<Boolean> pref) {
cm.item(stringId).selected( pref.get() ? 1 : 0)
cm.item(stringId).selected(pref.get() ? 1 : 0)
// .icons(r.drawableDark, r.drawableLight)
.listen(new ApearanceOnContextMenuClick(pref, map)).reg();
.listen(new ApearanceOnContextMenuClick(pref, map)).reg();
}
class ApearanceOnContextMenuClick implements OnContextMenuClick {
private MapActivity map;
private OsmandPreference<Boolean> pref;
@ -333,49 +337,53 @@ public class MapWidgetRegistry {
this.pref = pref;
this.map = map;
}
@Override
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
pref.set(!pref.get());
map.updateApplicationModeSettings();
a.notifyDataSetChanged();;
a.notifyDataSetChanged();
;
return false;
}
};
}
public static boolean distChanged(int oldDist, int dist){
if(oldDist != 0 && oldDist - dist < 100 && Math.abs(((float) dist - oldDist)/oldDist) < 0.01){
;
public static boolean distChanged(int oldDist, int dist) {
if (oldDist != 0 && oldDist - dist < 100 && Math.abs(((float) dist - oldDist) / oldDist) < 0.01) {
return false;
}
return true;
}
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();
addControls(map, cm, right, mode);
if(mode != ApplicationMode.DEFAULT) {
if (mode != ApplicationMode.DEFAULT) {
cm.item(R.string.map_widget_left).setCategory(true).layout(R.layout.list_group_title_with_switch).reg();
addControls(map, cm, left, mode);
}
cm.item(R.string.map_widget_appearance_rem).setCategory(true).layout(R.layout.list_group_title_with_switch).reg();
addControlsAppearance(map, cm, mode);
addControlsAppearance(map, cm, mode);
}
public String getText(Context ctx, final ApplicationMode mode, final MapWidgetRegInfo r) {
return (r.visibleCollapsed(mode)? " + " : " ") + ctx.getString(r.messageId);
return (r.visibleCollapsed(mode) ? " + " : " ") + ctx.getString(r.messageId);
}
public Set<MapWidgetRegInfo> getRight() {
return right;
}
public Set<MapWidgetRegInfo> getLeft() {
return left;
}
private void addControls(final MapActivity map, final ContextMenuAdapter adapter, Set<MapWidgetRegInfo> top, final ApplicationMode mode) {
private void addControls(final MapActivity map, final ContextMenuAdapter adapter,
Set<MapWidgetRegInfo> top, final ApplicationMode mode) {
for (final MapWidgetRegInfo r : top) {
if (mode == ApplicationMode.DEFAULT) {
if ("intermediate_distance".equals(r.key) || "distance".equals(r.key) || "time".equals(r.key)) {
@ -385,33 +393,35 @@ 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)
.iconColor(r.drawableMenu).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
changeVisibility(r);
MapInfoLayer mil = map.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
adapter.setItemName(pos, getText(mil.getMapActivity(), mode, r));
adapter.setSelection(pos, r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0);
a.notifyDataSetChanged();
return false;
}
}).reg();
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() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
changeVisibility(r);
MapInfoLayer mil = map.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
adapter.setItemName(pos, getText(mil.getMapActivity(), mode, r));
adapter.setSelection(pos, r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0);
a.notifyDataSetChanged();
return false;
}
})
.reg();
adapter.setItemName(adapter.length() - 1, getText(map, mode, r));
}
}
public static class MapWidgetRegInfo implements Comparable<MapWidgetRegInfo> {
public static class MapWidgetRegInfo implements Comparable<MapWidgetRegInfo> {
public final TextInfoWidget widget;
@DrawableRes
public final int drawableMenu;
@StringRes
public final int messageId;
public final String key;
public final boolean left;
@ -419,9 +429,9 @@ public class MapWidgetRegistry {
private final Set<ApplicationMode> visibleCollapsible = new LinkedHashSet<ApplicationMode>();
private final Set<ApplicationMode> visibleModes = new LinkedHashSet<ApplicationMode>();
private Runnable stateChangeListener = null;
public MapWidgetRegInfo(String key, TextInfoWidget widget, int drawableMenu,
int messageId, int priorityOrder, boolean left) {
public MapWidgetRegInfo(String key, TextInfoWidget widget, @DrawableRes int drawableMenu,
@StringRes int messageId, int priorityOrder, boolean left) {
this.key = key;
this.widget = widget;
this.drawableMenu = drawableMenu;
@ -429,29 +439,30 @@ public class MapWidgetRegistry {
this.priorityOrder = priorityOrder;
this.left = left;
}
public boolean visibleCollapsed(ApplicationMode mode){
public boolean visibleCollapsed(ApplicationMode mode) {
return visibleCollapsible.contains(mode);
}
public boolean visible(ApplicationMode mode){
public boolean visible(ApplicationMode mode) {
return visibleModes.contains(mode);
}
public MapWidgetRegInfo required(ApplicationMode... modes){
Collections.addAll(visibleModes, modes);
public MapWidgetRegInfo required(ApplicationMode... modes) {
Collections.addAll(visibleModes, modes);
return this;
}
public void setStateChangeListener(Runnable stateChangeListener) {
this.stateChangeListener = stateChangeListener;
}
@Override
public int hashCode() {
return messageId;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
@ -465,18 +476,19 @@ public class MapWidgetRegistry {
return false;
return true;
}
@Override
public int compareTo(MapWidgetRegInfo another) {
if (messageId == another.messageId) {
return 0;
}
if(priorityOrder == another.priorityOrder) {
if (priorityOrder == another.priorityOrder) {
return messageId - another.messageId;
}
return priorityOrder - another.priorityOrder;
}
}
public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) {
final ContextMenuAdapter cm = new ContextMenuAdapter(map);
cm.setDefaultLayoutId(R.layout.list_item_icon_and_menu);