Updated layouts for configure map menu
This commit is contained in:
parent
535e020418
commit
834d513614
7 changed files with 68 additions and 47 deletions
|
@ -9,7 +9,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView android:id="@+id/header"
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
|
@ -10,17 +10,19 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<LinearLayout android:layout_marginLeft="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="0dp">
|
||||
<TextView android:id="@+id/header"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView android:id="@+id/title"
|
||||
android:textSize="18sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextureView android:id="@+id/descr"
|
||||
<TextView android:id="@+id/descr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
<CheckBox android:id="@+id/chek"
|
||||
<CheckBox android:id="@+id/check_item"
|
||||
android:focusable="false"
|
||||
android:layout_marginLeft="11dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp">
|
||||
|
||||
<LinearLayout android:layout_width="wrap_content"
|
||||
<LinearLayout android:layout_width="0dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="0dp">
|
||||
<TextView android:id="@+id/header"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextureView android:id="@+id/descr"
|
||||
<TextView android:id="@+id/descr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox android:id="@+id/check"
|
||||
<CheckBox android:id="@+id/check_item"
|
||||
android:focusable="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="8dp"/>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp">
|
||||
<TextView android:id="@+id/header"
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.widget.*;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -10,12 +11,7 @@ import android.graphics.Typeface;
|
|||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ContextMenuAdapter {
|
||||
|
||||
|
@ -36,6 +32,7 @@ public class ContextMenuAdapter {
|
|||
final TIntArrayList layoutIds = new TIntArrayList();
|
||||
final TIntArrayList iconList = new TIntArrayList();
|
||||
final TIntArrayList iconListLight = new TIntArrayList();
|
||||
final ArrayList<String> itemDescription = new ArrayList<String>();
|
||||
|
||||
public ContextMenuAdapter(Context ctx) {
|
||||
this.ctx = ctx;
|
||||
|
@ -65,10 +62,18 @@ public class ContextMenuAdapter {
|
|||
return itemNames.get(pos);
|
||||
}
|
||||
|
||||
public String getItemDescr(int pos){
|
||||
return itemDescription.get(pos);
|
||||
}
|
||||
|
||||
public void setItemName(int pos, String str) {
|
||||
itemNames.set(pos, str);
|
||||
}
|
||||
|
||||
public void setItemDescription(int pos, String str) {
|
||||
itemDescription.set(pos, str);
|
||||
}
|
||||
|
||||
public int getSelection(int pos) {
|
||||
return selectedList.get(pos);
|
||||
}
|
||||
|
@ -120,6 +125,7 @@ public class ContextMenuAdapter {
|
|||
int layout = -1;
|
||||
boolean cat;
|
||||
int pos = -1;
|
||||
String description = "";
|
||||
private OnContextMenuClick listener;
|
||||
|
||||
private Item() {
|
||||
|
@ -151,6 +157,11 @@ public class ContextMenuAdapter {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Item description(String descr){
|
||||
this.description = descr;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item listen(OnContextMenuClick l) {
|
||||
this.listener = l;
|
||||
return this;
|
||||
|
@ -163,6 +174,7 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
items.insert(pos, id);
|
||||
itemNames.add(pos, name);
|
||||
itemDescription.add(pos, description);
|
||||
selectedList.insert(pos, selected);
|
||||
layoutIds.insert(pos, layout);
|
||||
iconList.insert(pos, icon);
|
||||
|
@ -219,11 +231,12 @@ public class ContextMenuAdapter {
|
|||
TextView tv = (TextView) v.findViewById(R.id.title);
|
||||
tv.setText(getItemName(position));
|
||||
|
||||
// Put the image on the TextView
|
||||
if (getImageId(position, holoLight) != 0) {
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(getImageId(position, holoLight), 0, 0, 0);
|
||||
} else {
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_transparent, 0, 0, 0);
|
||||
int imageId = getImageId(position, holoLight);
|
||||
if (imageId != 0) {
|
||||
((ImageView) v.findViewById(R.id.icon)).setImageResource(imageId);
|
||||
v.findViewById(R.id.icon).setVisibility(View.VISIBLE);
|
||||
} else if (v.findViewById(R.id.icon) != null){
|
||||
v.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
}
|
||||
tv.setCompoundDrawablePadding(padding);
|
||||
|
||||
|
@ -249,9 +262,14 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
});
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
} else if (ch != null) {
|
||||
ch.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
String itemDescr = getItemDescr(position);
|
||||
if (v.findViewById(R.id.descr) != null){
|
||||
((TextView)v.findViewById(R.id.descr)).setText(itemDescr);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -91,24 +91,24 @@ public class ConfigureMapMenu {
|
|||
OsmandApplication app = activity.getMyApplication();
|
||||
OsmandSettings settings = app.getSettings();
|
||||
LayerMenuListener l = new LayerMenuListener(activity);
|
||||
adapter.item(R.string.layers_category_show).setCategory(true).reg();
|
||||
adapter.item(R.string.layers_category_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.SHOW_POI_OVER_MAP.get() ? 1 : 0)
|
||||
.icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).listen(l).reg();
|
||||
.icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light).listen(l).layout(R.layout.drawer_list_layer).reg();
|
||||
adapter.item(R.string.layer_amenity_label).selected(settings.SHOW_POI_LABEL.get() ? 1 : 0)
|
||||
.icons(R.drawable.ic_action_text_dark, R.drawable.ic_action_text_light).listen(l).reg();
|
||||
.icons(R.drawable.ic_action_text_dark, R.drawable.ic_action_text_light).listen(l).layout(R.layout.drawer_list_layer).reg();
|
||||
adapter.item(R.string.layer_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0)
|
||||
.icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).listen(l).reg();
|
||||
.icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).listen(l).layout(R.layout.drawer_list_layer).reg();
|
||||
adapter.item(R.string.layer_gpx_layer).selected(
|
||||
app.getSelectedGpxHelper().isShowingAnyGpxFiles()? 1 : 0)
|
||||
app.getSelectedGpxHelper().isShowingAnyGpxFiles() ? 1 : 0)
|
||||
// .icons(R.drawable.ic_action_foot_dark, R.drawable.ic_action_foot_light)
|
||||
.icons(R.drawable.ic_action_polygom_dark, R.drawable.ic_action_polygom_light)
|
||||
.listen(l).reg();
|
||||
adapter.item(R.string.layer_transport).selected( settings.SHOW_TRANSPORT_OVER_MAP.get() ? 1 : 0)
|
||||
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).reg();
|
||||
.listen(l).layout(R.layout.drawer_list_layer).reg();
|
||||
adapter.item(R.string.layer_transport).selected(settings.SHOW_TRANSPORT_OVER_MAP.get() ? 1 : 0)
|
||||
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).layout(R.layout.drawer_list_layer).reg();
|
||||
if(TransportRouteHelper.getInstance().routeIsCalculated()){
|
||||
adapter.item(R.string.layer_transport_route).selected(1)
|
||||
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).reg();
|
||||
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).listen(l).layout(R.layout.drawer_list_layer).reg();
|
||||
}
|
||||
|
||||
OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity);
|
||||
|
@ -120,8 +120,8 @@ public class ConfigureMapMenu {
|
|||
activity.getMapView().refreshMap(true);
|
||||
}
|
||||
|
||||
private void createRenderingAttributeItems(ContextMenuAdapter adapter, final MapActivity activity) {
|
||||
adapter.item(R.string.map_widget_map_rendering).setCategory(true).reg();
|
||||
private void createRenderingAttributeItems(final ContextMenuAdapter adapter, final MapActivity activity) {
|
||||
adapter.item(R.string.map_widget_map_rendering).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
adapter.item(R.string.map_widget_renderer).listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
|
||||
|
@ -160,9 +160,9 @@ public class ConfigureMapMenu {
|
|||
bld.show();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).layout(R.layout.drawer_list_rendering).reg();
|
||||
|
||||
adapter.item(R.string.map_widget_day_night).listen(new OnContextMenuClick() {
|
||||
adapter.item(R.string.map_widget_day_night).description(activity.getMyApplication().getSettings().DAYNIGHT_MODE.get().toHumanString(activity)).listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
|
@ -184,7 +184,7 @@ public class ConfigureMapMenu {
|
|||
bld.show();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).layout(R.layout.drawer_list_rendering).reg();
|
||||
|
||||
adapter.item(R.string.text_size).listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
|
@ -193,7 +193,7 @@ public class ConfigureMapMenu {
|
|||
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
|
||||
// test old descr as title
|
||||
b.setTitle(R.string.text_size);
|
||||
final Float[] txtValues = new Float[] { 0.75f, 1f, 1.25f, 1.5f, 2f, 3f };
|
||||
final Float[] txtValues = new Float[]{0.75f, 1f, 1.25f, 1.5f, 2f, 3f};
|
||||
int selected = -1;
|
||||
final String[] txtNames = new String[txtValues.length];
|
||||
for (int i = 0; i < txtNames.length; i++) {
|
||||
|
@ -212,7 +212,7 @@ public class ConfigureMapMenu {
|
|||
b.show();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).layout(R.layout.drawer_list_rendering).reg();
|
||||
|
||||
RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||
if (renderer != null) {
|
||||
|
@ -223,7 +223,7 @@ public class ConfigureMapMenu {
|
|||
|
||||
private void createCustomRenderingProperties(RenderingRulesStorage renderer, ContextMenuAdapter adapter , final MapActivity activity){
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
adapter.item(R.string.map_widget_vector_attributes).setCategory(true).reg();
|
||||
adapter.item(R.string.map_widget_vector_attributes).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
final OsmandApplication app = view.getApplication();
|
||||
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
|
||||
for (final RenderingRuleProperty p : customRules) {
|
||||
|
@ -243,7 +243,7 @@ public class ConfigureMapMenu {
|
|||
refreshMapComplete(activity);
|
||||
return false;
|
||||
}
|
||||
}).selected(pref.get() ? 1 : 0).reg();
|
||||
}).selected(pref.get() ? 1 : 0).layout(R.layout.drawer_list_rendering).reg();
|
||||
} else {
|
||||
final OsmandSettings.CommonPreference<String> pref = view.getApplication().getSettings()
|
||||
.getCustomRenderProperty(p.getAttrName());
|
||||
|
@ -276,7 +276,7 @@ public class ConfigureMapMenu {
|
|||
b.show();
|
||||
return false;
|
||||
}
|
||||
}).reg();
|
||||
}).layout(R.layout.drawer_list_rendering).reg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
}
|
||||
};
|
||||
adapter.item(R.string.layer_hillshade).selected(HILLSHADE.get()? 1 : 0)
|
||||
.icons( R.drawable.ic_action_hillshade_dark, R.drawable.ic_action_hillshade_light).listen(listener).position(9).reg();
|
||||
.icons( R.drawable.ic_action_hillshade_dark, R.drawable.ic_action_hillshade_light).listen(listener).position(9).layout(R.layout.drawer_list_layer).reg();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue