Updated functionality of waypoints dialog
This commit is contained in:
parent
f7cb3b46a8
commit
faba5d32af
4 changed files with 81 additions and 38 deletions
32
OsmAnd/res/layout/drawer_list_radius.xml
Normal file
32
OsmAnd/res/layout/drawer_list_radius.xml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="5dp">
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:id="@+id/ProgressBar"
|
||||||
|
android:layout_marginLeft="4dp"/>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/title"
|
||||||
|
android:text="@string/search_radius_proximity"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:textSize="20sp"/>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/descr"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textColor="@color/sherpafy_selection"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginRight="8dp"/>
|
||||||
|
</LinearLayout>
|
|
@ -19,7 +19,8 @@ public class ContextMenuAdapter {
|
||||||
items.clear();
|
items.clear();
|
||||||
isCategory.clear();
|
isCategory.clear();
|
||||||
itemNames.clear();
|
itemNames.clear();
|
||||||
listeners.clear();
|
checkListeners.clear();
|
||||||
|
itemListeners.clear();
|
||||||
selectedList.clear();
|
selectedList.clear();
|
||||||
layoutIds.clear();
|
layoutIds.clear();
|
||||||
iconList.clear();
|
iconList.clear();
|
||||||
|
@ -40,8 +41,10 @@ public class ContextMenuAdapter {
|
||||||
final TIntArrayList items = new TIntArrayList();
|
final TIntArrayList items = new TIntArrayList();
|
||||||
final TIntArrayList isCategory = new TIntArrayList();
|
final TIntArrayList isCategory = new TIntArrayList();
|
||||||
final ArrayList<String> itemNames = new ArrayList<String>();
|
final ArrayList<String> itemNames = new ArrayList<String>();
|
||||||
final ArrayList<OnContextMenuClick> listeners = new ArrayList<ContextMenuAdapter.OnContextMenuClick>();
|
final ArrayList<OnContextMenuClick> checkListeners = new ArrayList<ContextMenuAdapter.OnContextMenuClick>();
|
||||||
|
final ArrayList<OnContextMenuClick> itemListeners = new ArrayList<ContextMenuAdapter.OnContextMenuClick>();
|
||||||
final TIntArrayList selectedList = new TIntArrayList();
|
final TIntArrayList selectedList = 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 iconListLight = new TIntArrayList();
|
||||||
|
@ -68,7 +71,11 @@ public class ContextMenuAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnContextMenuClick getClickAdapter(int i) {
|
public OnContextMenuClick getClickAdapter(int i) {
|
||||||
return listeners.get(i);
|
return checkListeners.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OnContextMenuClick getItemClickAdapter(int i) {
|
||||||
|
return itemListeners.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItemName(int pos){
|
public String getItemName(int pos){
|
||||||
|
@ -96,6 +103,10 @@ public class ContextMenuAdapter {
|
||||||
public int getSelection(int pos) {
|
public int getSelection(int pos) {
|
||||||
return selectedList.get(pos);
|
return selectedList.get(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLoading(int pos) {
|
||||||
|
return loadingList.get(pos);
|
||||||
|
}
|
||||||
|
|
||||||
public void setSelection(int pos, int s) {
|
public void setSelection(int pos, int s) {
|
||||||
selectedList.set(pos, s);
|
selectedList.set(pos, s);
|
||||||
|
@ -142,10 +153,12 @@ public class ContextMenuAdapter {
|
||||||
String name;
|
String name;
|
||||||
int selected = -1;
|
int selected = -1;
|
||||||
int layout = -1;
|
int layout = -1;
|
||||||
|
int loading = -1;
|
||||||
boolean cat;
|
boolean cat;
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
String description = "";
|
String description = "";
|
||||||
private OnContextMenuClick listener;
|
private OnContextMenuClick checkBoxListener;
|
||||||
|
private OnContextMenuClick itemClickListener;
|
||||||
boolean enabled = false;
|
boolean enabled = false;
|
||||||
|
|
||||||
private Item() {
|
private Item() {
|
||||||
|
@ -171,6 +184,11 @@ public class ContextMenuAdapter {
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Item loading(int loading) {
|
||||||
|
this.loading = loading;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Item layout(int l) {
|
public Item layout(int l) {
|
||||||
this.layout = l;
|
this.layout = l;
|
||||||
|
@ -183,9 +201,13 @@ public class ContextMenuAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item listen(OnContextMenuClick l) {
|
public Item listen(OnContextMenuClick l) {
|
||||||
this.listener = l;
|
this.checkBoxListener = l;
|
||||||
return this;
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item itemClickListen(OnContextMenuClick l) {
|
||||||
|
this.itemClickListener = l;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reg() {
|
public void reg() {
|
||||||
|
@ -196,10 +218,11 @@ public class ContextMenuAdapter {
|
||||||
itemNames.add(pos, name);
|
itemNames.add(pos, name);
|
||||||
itemDescription.add(pos, description);
|
itemDescription.add(pos, description);
|
||||||
selectedList.insert(pos, selected);
|
selectedList.insert(pos, selected);
|
||||||
|
loadingList.insert(pos, loading);
|
||||||
layoutIds.insert(pos, layout);
|
layoutIds.insert(pos, layout);
|
||||||
iconList.insert(pos, icon);
|
iconList.insert(pos, icon);
|
||||||
iconListLight.insert(pos, lightIcon);
|
iconListLight.insert(pos, lightIcon);
|
||||||
listeners.add(pos, listener);
|
checkListeners.add(pos, checkBoxListener);
|
||||||
isCategory.insert(pos, cat ? 1 : 0);
|
isCategory.insert(pos, cat ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,11 +245,13 @@ public class ContextMenuAdapter {
|
||||||
items.removeAt(pos);
|
items.removeAt(pos);
|
||||||
itemNames.remove(pos);
|
itemNames.remove(pos);
|
||||||
selectedList.removeAt(pos);
|
selectedList.removeAt(pos);
|
||||||
|
loadingList.clear();
|
||||||
iconList.removeAt(pos);
|
iconList.removeAt(pos);
|
||||||
iconListLight.removeAt(pos);
|
iconListLight.removeAt(pos);
|
||||||
listeners.remove(pos);
|
checkListeners.remove(pos);
|
||||||
isCategory.removeAt(pos);
|
isCategory.removeAt(pos);
|
||||||
layoutIds.removeAt(pos);
|
layoutIds.removeAt(pos);
|
||||||
|
loadingList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLayoutId(int position) {
|
public int getLayoutId(int position) {
|
||||||
|
@ -270,30 +295,8 @@ public class ContextMenuAdapter {
|
||||||
tv.setTypeface(null);
|
tv.setTypeface(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v.findViewById(R.id.check_item) instanceof CheckBox){
|
if (v.findViewById(R.id.check_item) != null) {
|
||||||
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
|
CompoundButton ch = (CompoundButton) v.findViewById(R.id.check_item);
|
||||||
|
|
||||||
if(selectedList.get(position) != -1) {
|
|
||||||
ch.setOnCheckedChangeListener(null);
|
|
||||||
ch.setVisibility(View.VISIBLE);
|
|
||||||
ch.setChecked(selectedList.get(position) > 0);
|
|
||||||
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
OnContextMenuClick ca = getClickAdapter(position);
|
|
||||||
if(ca != null) {
|
|
||||||
ca.onContextMenuClick(getElementId(position), position, isChecked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ch.setVisibility(View.VISIBLE);
|
|
||||||
} else if (ch != null) {
|
|
||||||
ch.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
} else if (v.findViewById(R.id.check_item) instanceof Switch) {
|
|
||||||
final Switch ch = (Switch) v.findViewById(R.id.check_item);
|
|
||||||
|
|
||||||
if(selectedList.get(position) != -1) {
|
if(selectedList.get(position) != -1) {
|
||||||
ch.setOnCheckedChangeListener(null);
|
ch.setOnCheckedChangeListener(null);
|
||||||
ch.setVisibility(View.VISIBLE);
|
ch.setVisibility(View.VISIBLE);
|
||||||
|
@ -314,6 +317,14 @@ public class ContextMenuAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (v.findViewById(R.id.ProgressBar) != null){
|
||||||
|
ProgressBar bar = (ProgressBar) v.findViewById(R.id.ProgressBar);
|
||||||
|
if(loadingList.get(position) == 1){
|
||||||
|
bar.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
bar.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String itemDescr = getItemDescr(position);
|
String itemDescr = getItemDescr(position);
|
||||||
if (v.findViewById(R.id.descr) != null){
|
if (v.findViewById(R.id.descr) != null){
|
||||||
|
|
|
@ -564,7 +564,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Working with location listeners
|
// Working with location checkListeners
|
||||||
private class NetworkListener implements LocationListener {
|
private class NetworkListener implements LocationListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -542,7 +542,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
if (waypointHelper.isTypeVisible(i)) {
|
if (waypointHelper.isTypeVisible(i)) {
|
||||||
final boolean checked = waypointHelper.isTypeEnabled(i);
|
final boolean checked = waypointHelper.isTypeEnabled(i);
|
||||||
final int type = i;
|
final int type = i;
|
||||||
adapter.item(getHeader(ctx, i, checked)).enabled(checked).layout(R.layout.drawer_list_poi_header).listen(new ContextMenuAdapter.OnContextMenuClick() {
|
adapter.item(getHeader(ctx, i, checked)).enabled(checked).layout(R.layout.drawer_list_poi_header).itemClickListen(new ContextMenuAdapter.OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
|
||||||
running[0] = pos;
|
running[0] = pos;
|
||||||
|
@ -554,10 +554,10 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).reg();
|
}).loading(0).reg();
|
||||||
|
|
||||||
if (i == WaypointHelper.POI && waypointHelper.isTypeEnabled(WaypointHelper.POI)){
|
if (i == WaypointHelper.POI && waypointHelper.isTypeEnabled(WaypointHelper.POI)){
|
||||||
adapter.item(ctx.getString(R.string.search_radius_proximity)).listen(new ContextMenuAdapter.OnContextMenuClick() {
|
adapter.item(ctx.getString(R.string.search_radius_proximity)).itemClickListen(new ContextMenuAdapter.OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(int itemId, final int pos, boolean isChecked) {
|
public boolean onContextMenuClick(int itemId, final int pos, boolean isChecked) {
|
||||||
int length = WaypointHelper.SEARCH_RADIUS_VALUES.length;
|
int length = WaypointHelper.SEARCH_RADIUS_VALUES.length;
|
||||||
|
@ -588,9 +588,9 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
.show();
|
.show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).reg();
|
}).loading(0).selected(app.getSettings().SHOW_POI_OVER_MAP.get() ? 1 : 0).reg();
|
||||||
} else if (i == WaypointHelper.FAVORITES && waypointHelper.isTypeEnabled(WaypointHelper.FAVORITES)){
|
} else if (i == WaypointHelper.FAVORITES && waypointHelper.isTypeEnabled(WaypointHelper.FAVORITES)){
|
||||||
adapter.item(ctx.getString(R.string.search_radius_proximity)).listen(new ContextMenuAdapter.OnContextMenuClick() {
|
adapter.item(ctx.getString(R.string.search_radius_proximity)).itemClickListen(new ContextMenuAdapter.OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(int itemId, final int pos, boolean isChecked) {
|
public boolean onContextMenuClick(int itemId, final int pos, boolean isChecked) {
|
||||||
int length = WaypointHelper.SEARCH_RADIUS_VALUES.length;
|
int length = WaypointHelper.SEARCH_RADIUS_VALUES.length;
|
||||||
|
@ -620,7 +620,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
.show();
|
.show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).reg();
|
}).loading(0).selected(app.getSettings().SHOW_FAVORITES.get() ? 1 : 0).reg();
|
||||||
}
|
}
|
||||||
if (tp != null && tp.size() > 0) {
|
if (tp != null && tp.size() > 0) {
|
||||||
for (LocationPointWrapper p : tp){
|
for (LocationPointWrapper p : tp){
|
||||||
|
|
Loading…
Reference in a new issue