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

@ -3,44 +3,44 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="54dp" android:minHeight="54dp"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp"> android:paddingRight="16dp">
<ImageView <android.support.v7.widget.AppCompatImageView
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="32dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginBottom="16dp"
android:layout_marginRight="32dp"
android:layout_marginTop="16dp"
tools:src="@drawable/ic_action_gabout_dark"/> tools:src="@drawable/ic_action_gabout_dark"/>
<TextView <android.support.v7.widget.AppCompatTextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="@dimen/default_list_text_size"
android:layout_weight="1"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_weight="1"
android:textSize="@dimen/default_list_text_size"
tools:text="Some title text"/> tools:text="Some title text"/>
<ImageView <android.support.v7.widget.AppCompatImageView
android:id="@+id/menu" android:id="@+id/secondary_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_margin="16dp"
tools:src="@drawable/ic_action_gabout_dark"/> tools:src="@drawable/ic_action_gabout_dark"/>
<android.support.v7.widget.SwitchCompat <android.support.v7.widget.SwitchCompat
android:id="@+id/toggle_item" android:id="@+id/toggle_item"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="16dp" android:layout_gravity="center_vertical"
android:focusable="false" android:focusable="false"/>
android:layout_gravity="center_vertical" />
</LinearLayout> </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.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.IdRes;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes; 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.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@ -88,7 +92,8 @@ public class ContextMenuAdapter {
final TIntArrayList loadingList = new TIntArrayList(); final TIntArrayList loadingList = new TIntArrayList();
final TIntArrayList layoutIds = new TIntArrayList(); final TIntArrayList layoutIds = new TIntArrayList();
final TIntArrayList iconList = 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>(); final ArrayList<String> itemDescription = new ArrayList<String>();
private List<ApplicationMode> visibleModes = new ArrayList<ApplicationMode>(); private List<ApplicationMode> visibleModes = new ArrayList<ApplicationMode>();
private ConfigureMapMenu.OnClickListener changeAppModeListener = null; private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
@ -170,13 +175,22 @@ public class ContextMenuAdapter {
if (lst != 0) { if (lst != 0) {
return ctx.getResources().getDrawable(lst); return ctx.getResources().getDrawable(lst);
} }
int lstLight = iconListLight.get(pos); int lstLight = lightIconList.get(pos);
if (lstLight != 0) { if (lstLight != 0) {
return ctx.getIconsCache().getIcon(lstLight, light); return ctx.getIconsCache().getIcon(lstLight, light);
} }
return null; 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) { public int getBackgroundColor(Context ctx, boolean holoLight) {
if (holoLight) { if (holoLight) {
return ctx.getResources().getColor(R.color.bg_color_light); return ctx.getResources().getColor(R.color.bg_color_light);
@ -206,12 +220,18 @@ public class ContextMenuAdapter {
} }
public class Item { public class Item {
@DrawableRes
int icon = 0; int icon = 0;
@DrawableRes
int lightIcon = 0; int lightIcon = 0;
@DrawableRes
int secondaryLightIcon = 0;
@IdRes
int id; int id;
String name; String name;
int selected = -1; int selected = -1;
int progress = -1; int progress = -1;
@LayoutRes
int layout = -1; int layout = -1;
int loading = -1; int loading = -1;
boolean cat; boolean cat;
@ -223,16 +243,20 @@ public class ContextMenuAdapter {
private Item() { private Item() {
} }
public Item icon(int icon) { public Item icon(@DrawableRes int icon) {
this.icon = icon; this.icon = icon;
return this; return this;
} }
public Item iconColor(int icon) { public Item colorIcon(@DrawableRes int icon) {
this.lightIcon = icon; this.lightIcon = icon;
return this; return this;
} }
public Item secondaryIconColor(@DrawableRes int icon) {
this.secondaryLightIcon = icon;
return this;
}
public Item position(int pos) { public Item position(int pos) {
this.pos = pos; this.pos = pos;
@ -254,7 +278,7 @@ public class ContextMenuAdapter {
return this; return this;
} }
public Item layout(int l) { public Item layout(@LayoutRes int l) {
this.layout = l; this.layout = l;
return this; return this;
} }
@ -286,7 +310,8 @@ public class ContextMenuAdapter {
loadingList.insert(pos, loading); loadingList.insert(pos, loading);
layoutIds.insert(pos, layout); layoutIds.insert(pos, layout);
iconList.insert(pos, icon); iconList.insert(pos, icon);
iconListLight.insert(pos, lightIcon); lightIconList.insert(pos, lightIcon);
secondaryLightIconList.insert(pos, secondaryLightIcon);
checkListeners.add(pos, checkBoxListener); checkListeners.add(pos, checkBoxListener);
integerListeners.add(pos, integerListener); integerListeners.add(pos, integerListener);
isCategory.insert(pos, cat ? 1 : 0); isCategory.insert(pos, cat ? 1 : 0);
@ -314,7 +339,8 @@ public class ContextMenuAdapter {
selectedList.removeAt(pos); selectedList.removeAt(pos);
progressList.removeAt(pos); progressList.removeAt(pos);
iconList.removeAt(pos); iconList.removeAt(pos);
iconListLight.removeAt(pos); lightIconList.removeAt(pos);
secondaryLightIconList.removeAt(pos);
checkListeners.remove(pos); checkListeners.remove(pos);
integerListeners.remove(pos); integerListeners.remove(pos);
isCategory.removeAt(pos); isCategory.removeAt(pos);
@ -344,9 +370,8 @@ 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 = defaultLayoutId;
final OsmandApplication app = ((OsmandApplication) activity.getApplication()); 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); getItemNames(), app, holoLight);
return listAdapter;
} }
public class ContextMenuArrayAdapter extends ArrayAdapter<String> { public class ContextMenuArrayAdapter extends ArrayAdapter<String> {
@ -385,7 +410,7 @@ public class ContextMenuAdapter {
} }
if (convertView == null || (!lid.equals(convertView.getTag()))) { if (convertView == null || (!lid.equals(convertView.getTag()))) {
convertView = activity.getLayoutInflater().inflate(lid, parent, false); convertView = activity.getLayoutInflater().inflate(lid, parent, false);
AndroidUtils.setListItemBackground(ctx, convertView, !holoLight); // AndroidUtils.setListItemBackground(ctx, convertView, !holoLight);
convertView.setTag(lid); convertView.setTag(lid);
} }
TextView tv = (TextView) convertView.findViewById(R.id.title); TextView tv = (TextView) convertView.findViewById(R.id.title);
@ -398,7 +423,7 @@ public class ContextMenuAdapter {
int color = activity.getResources() int color = activity.getResources()
.getColor(holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark); .getColor(holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
Drawable imageId = app.getIconsCache().getPaintedContentIcon( Drawable imageId = app.getIconsCache().getPaintedContentIcon(
iconListLight.get(position), color); lightIconList.get(position), color);
float density = activity.getResources().getDisplayMetrics().density; float density = activity.getResources().getDisplayMetrics().density;
int paddingInPixels = (int) (24 * density); int paddingInPixels = (int) (24 * density);
int drawableSizeInPixels = (int) (24 * density); // 32 int drawableSizeInPixels = (int) (24 * density); // 32
@ -406,15 +431,31 @@ public class ContextMenuAdapter {
tv.setCompoundDrawables(imageId, null, null, null); tv.setCompoundDrawables(imageId, null, null, null);
tv.setCompoundDrawablePadding(paddingInPixels); tv.setCompoundDrawablePadding(paddingInPixels);
} else { } else {
Drawable imageId = getImage(app, position, holoLight); Drawable drawable = getImage(app, position, holoLight);
if (imageId != null) { 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); convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
} else if (convertView.findViewById(R.id.icon) != null) { } else if (convertView.findViewById(R.id.icon) != null) {
convertView.findViewById(R.id.icon).setVisibility(View.GONE); 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)) { if (isCategory(position)) {
tv.setTypeface(Typeface.DEFAULT_BOLD); 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) { 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(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()) { 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(); R.drawable.ic_action_gdirections_dark).reg();
} }
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() != null && if (getMyApplication().getTargetPointsHelper().getPointToNavigate() != null &&
(mapActivity.getRoutingHelper().isFollowingMode() || mapActivity.getRoutingHelper().isRoutePlanningMode())) { (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(); R.drawable.ic_action_intermediate).reg();
} }
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj); OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
@ -593,7 +593,7 @@ public class MapActivityActions implements DialogProvider {
final OsmandApplication app = mapActivity.getMyApplication(); final OsmandApplication app = mapActivity.getMyApplication();
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app); 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() { .listen(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) {
@ -604,7 +604,7 @@ public class MapActivityActions implements DialogProvider {
} }
}).reg(); }).reg();
if (settings.USE_MAP_MARKERS.get()) { 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() { .listen(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) {
@ -614,7 +614,7 @@ public class MapActivityActions implements DialogProvider {
} }
}).reg(); }).reg();
} else { } 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() { .listen(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) {
@ -624,7 +624,7 @@ public class MapActivityActions implements DialogProvider {
} }
}).reg(); }).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() { .listen(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) {
@ -643,7 +643,7 @@ public class MapActivityActions implements DialogProvider {
}).reg(); }).reg();
// Default actions (Layers, Configure Map screen, Settings, Search, Favorites) // Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
optionsMenuHelper.item(R.string.search_button) optionsMenuHelper.item(R.string.search_button)
.iconColor(R.drawable.ic_action_search_dark) .colorIcon(R.drawable.ic_action_search_dark)
.listen(new OnContextMenuClick() { .listen(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) {
@ -661,7 +661,7 @@ public class MapActivityActions implements DialogProvider {
} }
}).reg(); }).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() { .listen(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) {
@ -674,7 +674,7 @@ public class MapActivityActions implements DialogProvider {
}).reg(); }).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() { .listen(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) {
@ -684,7 +684,7 @@ public class MapActivityActions implements DialogProvider {
} }
}).reg(); }).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() { .listen(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) {
@ -694,7 +694,7 @@ public class MapActivityActions implements DialogProvider {
} }
}).reg(); }).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() { .listen(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) {
@ -711,7 +711,7 @@ public class MapActivityActions implements DialogProvider {
d += " (" + updt.size() + ")"; 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() { .listen(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) {
@ -724,7 +724,7 @@ public class MapActivityActions implements DialogProvider {
}).reg(); }).reg();
if (Version.isGooglePlayEnabled(app)) { 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() { .listen(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) {
@ -736,7 +736,7 @@ public class MapActivityActions implements DialogProvider {
}).reg(); }).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() { .listen(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) {
@ -749,7 +749,7 @@ public class MapActivityActions implements DialogProvider {
}).reg(); }).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() { .listen(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) {
@ -760,7 +760,7 @@ public class MapActivityActions implements DialogProvider {
return true; return true;
} }
}).reg(); }).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() { .listen(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) {
@ -774,7 +774,7 @@ public class MapActivityActions implements DialogProvider {
//////////// Others //////////// Others
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper); 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() { // .listen(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) {

View file

@ -262,7 +262,7 @@ public class MapActivityLayers {
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(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>(); final List<PoiUIFilter> list = new ArrayList<PoiUIFilter>();
list.add(poiFilters.getCustomPOIFilter()); list.add(poiFilters.getCustomPOIFilter());
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) { 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) 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 @Override
@ -600,7 +600,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
if (isRecording()) { if (isRecording()) {
return; 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() { .listen(new OnContextMenuClick() {
@Override @Override
@ -609,7 +609,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
return true; return true;
} }
}).position(6).reg(); }).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() { .listen(new OnContextMenuClick() {
@Override @Override
@ -618,7 +618,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
return true; return true;
} }
}).position(7).reg(); }).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() { .listen(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) {

View file

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

View file

@ -56,7 +56,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
@Override @Override
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) { public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
if (Version.isDeveloperVersion(mapActivity.getMyApplication())) { 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() { .listen(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) {

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(); adapter.item(R.string.shared_string_show).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] "; // String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
adapter.item(R.string.layer_poi).selected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null ? 1 : 0) 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) 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) 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( adapter.item(R.string.layer_gpx_layer).selected(
app.getSelectedGpxHelper().isShowingAnyGpxFiles() ? 1 : 0) app.getSelectedGpxHelper().isShowingAnyGpxFiles() ? 1 : 0)
.iconColor(R.drawable.ic_action_polygom_dark) .colorIcon(R.drawable.ic_action_polygom_dark)
.listen(l).reg(); .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(); .listen(l).reg();
if(TransportRouteHelper.getInstance().routeIsCalculated()){ if(TransportRouteHelper.getInstance().routeIsCalculated()){
adapter.item(R.string.layer_transport_route).selected(1) 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); OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity);

View file

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

View file

@ -675,7 +675,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
return true; 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('_', ' '); s = s.replace('_', ' ');
adapter.item(s).selected(multipleChoice ? 0 : -1) 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 there's some selected files - need to mark them as selected
if (selectedGpxList != null) { if (selectedGpxList != null) {

View file

@ -140,12 +140,12 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
return true; 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(); .listen(listener).reg();
if (selectedObj instanceof WptPt) { if (selectedObj instanceof WptPt) {
WptPt pt = (WptPt) selectedObj; WptPt pt = (WptPt) selectedObj;
if (app.getSelectedGpxHelper().getSelectedGPXFile(pt) != null) { 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(); .listen(listener).reg();
} }
} }

View file

@ -216,15 +216,15 @@ public class OsmEditingPlugin extends OsmandPlugin {
isEditable = !amenity.getType().isWiki() && !poiType.isNotEditableOsm(); isEditable = !amenity.getType().isWiki() && !poiType.isNotEditableOsm();
} }
if (isEditable) { 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_modify).colorIcon(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_delete).colorIcon(R.drawable.ic_action_delete_dark).listen(listener).position(2).reg();
} else if (selectedObj instanceof OpenstreetmapPoint && ((OpenstreetmapPoint) selectedObj).getAction() != Action.DELETE) { } else if (selectedObj instanceof OpenstreetmapPoint && ((OpenstreetmapPoint) selectedObj).getAction() != Action.DELETE) {
adapter.item(R.string.poi_context_menu_modify_osm_change) 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 { } 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 @Override
@ -240,7 +240,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
@Override @Override
public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) { 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) 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 @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { 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) { public void contextMenuFragment(final Activity la, final Fragment fragment, final Object info, ContextMenuAdapter adapter) {
if (fragment instanceof AvailableGPXFragment) { if (fragment instanceof AvailableGPXFragment) {
adapter.item(R.string.local_index_mi_upload_gpx) adapter.item(R.string.local_index_mi_upload_gpx)
.iconColor(R.drawable.ic_action_export) .colorIcon(R.drawable.ic_action_export)
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override

View file

@ -274,7 +274,7 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
@Override @Override
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) { 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() { .listen(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) {

View file

@ -227,7 +227,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
} }
}; };
adapter.item(R.string.context_menu_item_add_parking_point) 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(); String overlayMapDescr = settings.MAP_OVERLAY.get();
overlayMapDescr = overlayMapDescr != null ? overlayMapDescr : mapActivity.getString(R.string.shared_string_none); 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) 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(); String underlayMapDescr = settings.MAP_UNDERLAY.get();
underlayMapDescr = underlayMapDescr != null ? underlayMapDescr : mapActivity.getString(R.string.shared_string_none); 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) 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; 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(); .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(); .listen(listener).reg();
} }
} }

View file

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

View file

@ -143,7 +143,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
} }
}; };
adapter.item(R.string.shared_string_show_description) 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(); .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(); 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.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -126,8 +128,10 @@ public class MapWidgetRegistry {
return null; return null;
} }
public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, int drawableMenu, public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget,
int messageId, String key, boolean left, int priorityOrder) { @DrawableRes int drawableMenu,
@StringRes int messageId,
String key, boolean left, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu, MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,
messageId, priorityOrder, left); messageId, priorityOrder, left);
for (ApplicationMode ms : ApplicationMode.values(settings)) { for (ApplicationMode ms : ApplicationMode.values(settings)) {
@ -314,7 +318,7 @@ public class MapWidgetRegistry {
bld.show(); bld.show();
return false; return false;
} }
}).layout(R.layout.drawer_list_doubleitem).reg(); }).layout(R.layout.list_item_text_button).reg();
} }
} }
@ -338,10 +342,13 @@ public class MapWidgetRegistry {
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
pref.set(!pref.get()); pref.set(!pref.get());
map.updateApplicationModeSettings(); map.updateApplicationModeSettings();
a.notifyDataSetChanged();; a.notifyDataSetChanged();
;
return false; return false;
} }
}; }
;
public static boolean distChanged(int oldDist, int dist) { public static boolean distChanged(int oldDist, int dist) {
@ -375,7 +382,8 @@ public class MapWidgetRegistry {
return left; 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) { for (final MapWidgetRegInfo r : top) {
if (mode == ApplicationMode.DEFAULT) { if (mode == ApplicationMode.DEFAULT) {
if ("intermediate_distance".equals(r.key) || "distance".equals(r.key) || "time".equals(r.key)) { if ("intermediate_distance".equals(r.key) || "distance".equals(r.key) || "time".equals(r.key)) {
@ -385,9 +393,11 @@ public class MapWidgetRegistry {
if ("map_marker_1st".equals(r.key) || "map_marker_2nd".equals(r.key)) { if ("map_marker_1st".equals(r.key) || "map_marker_2nd".equals(r.key)) {
continue; continue;
} }
adapter.item(r.messageId).selected(r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0) adapter.item(r.messageId)
.iconColor(r.drawableMenu).listen(new OnContextMenuClick() { .selected(r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0)
.colorIcon(r.drawableMenu)
.secondaryIconColor(R.drawable.ic_action_additional_option)
.listen(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) {
changeVisibility(r); changeVisibility(r);
@ -400,18 +410,18 @@ public class MapWidgetRegistry {
a.notifyDataSetChanged(); a.notifyDataSetChanged();
return false; return false;
} }
}).reg(); })
.reg();
adapter.setItemName(adapter.length() - 1, getText(map, mode, r)); 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; public final TextInfoWidget widget;
@DrawableRes
public final int drawableMenu; public final int drawableMenu;
@StringRes
public final int messageId; public final int messageId;
public final String key; public final String key;
public final boolean left; public final boolean left;
@ -420,8 +430,8 @@ public class MapWidgetRegistry {
private final Set<ApplicationMode> visibleModes = new LinkedHashSet<ApplicationMode>(); private final Set<ApplicationMode> visibleModes = new LinkedHashSet<ApplicationMode>();
private Runnable stateChangeListener = null; private Runnable stateChangeListener = null;
public MapWidgetRegInfo(String key, TextInfoWidget widget, int drawableMenu, public MapWidgetRegInfo(String key, TextInfoWidget widget, @DrawableRes int drawableMenu,
int messageId, int priorityOrder, boolean left) { @StringRes int messageId, int priorityOrder, boolean left) {
this.key = key; this.key = key;
this.widget = widget; this.widget = widget;
this.drawableMenu = drawableMenu; this.drawableMenu = drawableMenu;
@ -452,6 +462,7 @@ public class MapWidgetRegistry {
public int hashCode() { public int hashCode() {
return messageId; return messageId;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj)
@ -465,6 +476,7 @@ public class MapWidgetRegistry {
return false; return false;
return true; return true;
} }
@Override @Override
public int compareTo(MapWidgetRegInfo another) { public int compareTo(MapWidgetRegInfo another) {
if (messageId == another.messageId) { if (messageId == another.messageId) {