diff --git a/OsmAnd-java/test_turn_lanes.json b/OsmAnd-java/test_turn_lanes.json
index df6515cb10..65908a4011 100644
--- a/OsmAnd-java/test_turn_lanes.json
+++ b/OsmAnd-java/test_turn_lanes.json
@@ -202,6 +202,20 @@
"expectedResults": {
"27611": "+C;TL, +C, TR"
}
+ },
+ {
+ "testName": "10.Ringweg Oost u-turn",
+ "startPoint": {
+ "latitude": 45.69722318654911,
+ "longitude": 35.62708438868003
+ },
+ "endPoint": {
+ "latitude": 45.69793506976422,
+ "longitude": 35.624509468025735
+ },
+ "expectedResults": {
+ "14418": "TL, +TL, C, C, TR"
+ }
}
]
\ No newline at end of file
diff --git a/OsmAnd/res/drawable-hdpi/ic_action_map_day.png b/OsmAnd/res/drawable-hdpi/ic_action_map_day.png
new file mode 100644
index 0000000000..df786a43a7
Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_map_day.png differ
diff --git a/OsmAnd/res/drawable-hdpi/ic_action_map_language.png b/OsmAnd/res/drawable-hdpi/ic_action_map_language.png
new file mode 100644
index 0000000000..d853cb12cb
Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_map_language.png differ
diff --git a/OsmAnd/res/drawable-hdpi/ic_action_map_light_sensor.png b/OsmAnd/res/drawable-hdpi/ic_action_map_light_sensor.png
new file mode 100644
index 0000000000..f5d50870ef
Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_map_light_sensor.png differ
diff --git a/OsmAnd/res/drawable-hdpi/ic_action_map_magnifier.png b/OsmAnd/res/drawable-hdpi/ic_action_map_magnifier.png
new file mode 100644
index 0000000000..7e9f2d89b4
Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_map_magnifier.png differ
diff --git a/OsmAnd/res/drawable-hdpi/ic_action_map_night.png b/OsmAnd/res/drawable-hdpi/ic_action_map_night.png
new file mode 100644
index 0000000000..f36f78aa28
Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_map_night.png differ
diff --git a/OsmAnd/res/drawable-hdpi/ic_action_map_routes.png b/OsmAnd/res/drawable-hdpi/ic_action_map_routes.png
new file mode 100644
index 0000000000..f7943d00d8
Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_map_routes.png differ
diff --git a/OsmAnd/res/drawable-hdpi/ic_action_map_sunst.png b/OsmAnd/res/drawable-hdpi/ic_action_map_sunst.png
new file mode 100644
index 0000000000..24a2e92f96
Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_map_sunst.png differ
diff --git a/OsmAnd/res/drawable-hdpi/ic_action_map_text_size.png b/OsmAnd/res/drawable-hdpi/ic_action_map_text_size.png
new file mode 100644
index 0000000000..44bde61830
Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_map_text_size.png differ
diff --git a/OsmAnd/res/drawable-mdpi/ic_action_map_day.png b/OsmAnd/res/drawable-mdpi/ic_action_map_day.png
new file mode 100644
index 0000000000..52ba02753f
Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_map_day.png differ
diff --git a/OsmAnd/res/drawable-mdpi/ic_action_map_language.png b/OsmAnd/res/drawable-mdpi/ic_action_map_language.png
new file mode 100644
index 0000000000..a45291b345
Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_map_language.png differ
diff --git a/OsmAnd/res/drawable-mdpi/ic_action_map_light_sensor.png b/OsmAnd/res/drawable-mdpi/ic_action_map_light_sensor.png
new file mode 100644
index 0000000000..f5a3e27f0f
Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_map_light_sensor.png differ
diff --git a/OsmAnd/res/drawable-mdpi/ic_action_map_magnifier.png b/OsmAnd/res/drawable-mdpi/ic_action_map_magnifier.png
new file mode 100644
index 0000000000..8033ec45c6
Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_map_magnifier.png differ
diff --git a/OsmAnd/res/drawable-mdpi/ic_action_map_night.png b/OsmAnd/res/drawable-mdpi/ic_action_map_night.png
new file mode 100644
index 0000000000..e17bb1fa92
Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_map_night.png differ
diff --git a/OsmAnd/res/drawable-mdpi/ic_action_map_routes.png b/OsmAnd/res/drawable-mdpi/ic_action_map_routes.png
new file mode 100644
index 0000000000..bf86f2024c
Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_map_routes.png differ
diff --git a/OsmAnd/res/drawable-mdpi/ic_action_map_sunst.png b/OsmAnd/res/drawable-mdpi/ic_action_map_sunst.png
new file mode 100644
index 0000000000..61906a8013
Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_map_sunst.png differ
diff --git a/OsmAnd/res/drawable-mdpi/ic_action_map_text_size.png b/OsmAnd/res/drawable-mdpi/ic_action_map_text_size.png
new file mode 100644
index 0000000000..240a536c66
Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_map_text_size.png differ
diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_map_day.png b/OsmAnd/res/drawable-xhdpi/ic_action_map_day.png
new file mode 100644
index 0000000000..8489accb49
Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_map_day.png differ
diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_map_language.png b/OsmAnd/res/drawable-xhdpi/ic_action_map_language.png
new file mode 100644
index 0000000000..014104daf0
Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_map_language.png differ
diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_map_light_sensor.png b/OsmAnd/res/drawable-xhdpi/ic_action_map_light_sensor.png
new file mode 100644
index 0000000000..9d1775951a
Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_map_light_sensor.png differ
diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_map_magnifier.png b/OsmAnd/res/drawable-xhdpi/ic_action_map_magnifier.png
new file mode 100644
index 0000000000..327a998338
Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_map_magnifier.png differ
diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_map_night.png b/OsmAnd/res/drawable-xhdpi/ic_action_map_night.png
new file mode 100644
index 0000000000..0a678936d6
Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_map_night.png differ
diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_map_routes.png b/OsmAnd/res/drawable-xhdpi/ic_action_map_routes.png
new file mode 100644
index 0000000000..a713e98b19
Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_map_routes.png differ
diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_map_sunst.png b/OsmAnd/res/drawable-xhdpi/ic_action_map_sunst.png
new file mode 100644
index 0000000000..60087939d6
Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_map_sunst.png differ
diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_map_text_size.png b/OsmAnd/res/drawable-xhdpi/ic_action_map_text_size.png
new file mode 100644
index 0000000000..6d7ff42906
Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_map_text_size.png differ
diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_map_day.png b/OsmAnd/res/drawable-xxhdpi/ic_action_map_day.png
new file mode 100644
index 0000000000..f1a1bf1736
Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_map_day.png differ
diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_map_language.png b/OsmAnd/res/drawable-xxhdpi/ic_action_map_language.png
new file mode 100644
index 0000000000..4f1db80563
Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_map_language.png differ
diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_map_light_sensor.png b/OsmAnd/res/drawable-xxhdpi/ic_action_map_light_sensor.png
new file mode 100644
index 0000000000..c18293711a
Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_map_light_sensor.png differ
diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_map_magnifier.png b/OsmAnd/res/drawable-xxhdpi/ic_action_map_magnifier.png
new file mode 100644
index 0000000000..3e73f6e28d
Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_map_magnifier.png differ
diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_map_night.png b/OsmAnd/res/drawable-xxhdpi/ic_action_map_night.png
new file mode 100644
index 0000000000..4c539aebb6
Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_map_night.png differ
diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_map_routes.png b/OsmAnd/res/drawable-xxhdpi/ic_action_map_routes.png
new file mode 100644
index 0000000000..0b8041b0d3
Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_map_routes.png differ
diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_map_sunst.png b/OsmAnd/res/drawable-xxhdpi/ic_action_map_sunst.png
new file mode 100644
index 0000000000..d0734a9ba4
Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_map_sunst.png differ
diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_map_text_size.png b/OsmAnd/res/drawable-xxhdpi/ic_action_map_text_size.png
new file mode 100644
index 0000000000..5237f7d066
Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_map_text_size.png differ
diff --git a/OsmAnd/res/menu/vidget_visibility_menu.xml b/OsmAnd/res/menu/vidget_visibility_menu.xml
new file mode 100644
index 0000000000..9974a9d044
--- /dev/null
+++ b/OsmAnd/res/menu/vidget_visibility_menu.xml
@@ -0,0 +1,15 @@
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values-es/phrases.xml b/OsmAnd/res/values-es/phrases.xml
index 3642877899..0d3cf13ed5 100644
--- a/OsmAnd/res/values-es/phrases.xml
+++ b/OsmAnd/res/values-es/phrases.xml
@@ -64,7 +64,7 @@
Mueblería
Vivero
Gas líquido
- Tienda general
+ "Con tienda"
Tienda de regalos
Vidriería
Herboristería
@@ -350,7 +350,7 @@
Pintor
Fotógrafo
Laboratorio fotográfico
- Plomero/Fontanero
+ Fontanero
Escultor
Salón de belleza
Peluquería
@@ -365,7 +365,7 @@
Crematorio
Banco
Cajero automático
- Contable/Contador
+ Contable
Entrada a cueva
Volcán
Cráter
@@ -729,7 +729,7 @@
Alicatador
Fábrica de ventanas
- Montaje de computadoras/ordenadores
+ Montaje de ordenadores
Collado
Cabo
Fondeadero
@@ -1003,7 +1003,7 @@
Tetrapak
Escombros
CDs
- Aceite usado
+ Restos de aceite
Botellas
Corcho
Cartuchos de impresora
@@ -2676,4 +2676,40 @@
Aspiradora: no
Aspiradora
+Aire comprimido: sí
+ Aire comprimido: no
+
+ Vuelo libre (deporte)
+ "Estación de autoreparación de bicicletas"
+ Grifo de agua
+ Funciona con botón: sí
+ Funciona con botón: no
+
+ Sitio de vuelo libre: despegue
+ Sitio de vuelo libre: aterrizaje
+ Sitio de vuelo libre: aterrizaje elevado
+ Sitio de vuelo libre: remolcador
+ Sitio de vuelo libre: formación
+ Oficial de vuelo libre: sí
+ Oficial de vuelo libre: no
+ Parapente: sí
+ Parapente: no
+ Ala delta: sí
+ Ala delta: no
+ Vuelo libre rígido: sí
+ Vuelo libre rígido: no
+ "Orientación del sitio de vuelo libre: N"
+ "Orientación del sitio de vuelo libre: NE"
+ "Orientación del sitio de vuelo libre: E"
+ "Orientación del sitio de vuelo libre: SE"
+ "Orientación del sitio de vuelo libre: S"
+ "Orientación del sitio de vuelo libre: SO"
+ "Orientación del sitio de vuelo libre: O"
+ "Orientación del sitio de vuelo libre: NO"
+ Sin tiempo de vuelo (vuelo libre)
+ Directrices de huésped para vuelo libre: sí
+ Directrices de huésped para vuelo libre: no
+
+ Solárium
+
diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml
index 5153345015..55e5e579da 100644
--- a/OsmAnd/res/values-nb/strings.xml
+++ b/OsmAnd/res/values-nb/strings.xml
@@ -836,7 +836,7 @@
Avbryt musikk
Offentlig
Optimaliser kart for
- Vis fra zoom-nivå (krever kote-data):
+ Vis fra zoom-nivå (krever kotedata):
Klikk på et eksisterende element for å se flere detaljer, trykk og hold for å deaktivere eller slette. Gjeldende data på enheten (%1$s ledig):
Sende GPX-filer til OSM?
Tidlig
@@ -1536,4 +1536,17 @@
Det anbefales å slå av opptegning av polygoner.
Foto %1$s %2$s
Velg måned og land
-
+ Den valgte datalagringsmappe er skrivebeskyttet. Lagringsmappen har midlertidig skiftet til internminnet. Velg en gyldig lagringsmappe.
+ Snu rekkefølgen
+ Skjul objekter som er under bakken
+ Element fjernet
+ Elementer fjernet
+ Ikke valgt
+ Velg taleveiledning
+ Velg eller last ned taleveiledning for ditt språk
+ Ingen adresse funnet
+ Nær
+ Ser etter adresse
+ Forkast rute
+ Filnavn inneholder ulovlig tegn
+
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index d0686bc84b..400d65ded4 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -1676,7 +1676,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
Initializing native library…
Auto-center map view
Time until map view synchronizes with current position
- Never (tap \'Go\' to start guidance manually)
+
Only manually (tap arrow)
Re-announce navigation instructions at regular intervals
Repeat navigation instructions
diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
index 67725813e4..092e85918e 100644
--- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
@@ -40,36 +40,15 @@ public class ContextMenuAdapter {
R.layout.list_menu_item : R.layout.list_menu_item_native;
List items = new ArrayList<>();
private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
- //neded to detect whether user opened all modes or not
public int length() {
return items.size();
}
- @Deprecated
- public int getElementId(int position) {
- return items.get(position).getTitleId();
- }
-
- @Deprecated
- public OnContextMenuClick getClickAdapter(int position) {
- return items.get(position).getCheckBoxListener();
- }
-
- @Deprecated
- public String getItemName(int position) {
- return items.get(position).getTitle();
- }
-
- @Deprecated
- public Boolean getSelection(int position) {
- return items.get(position).getSelected();
- }
-
@Deprecated
public Drawable getImage(OsmandApplication ctx, int position, boolean light) {
@DrawableRes
- int lst = items.get(position).getIcon();
+ int lst = items.get(position).getLightIcon();
if (lst != -1) {
return ContextCompat.getDrawable(ctx, lst);
}
@@ -81,20 +60,6 @@ public class ContextMenuAdapter {
return null;
}
- @Deprecated
- public void setItemName(int position, String str) {
- items.get(position).setTitle(str);
- }
-
- @Deprecated
- public void setItemDescription(int position, String str) {
- items.get(position).setDescription(str);
- }
-
- public void setSelection(int position, boolean s) {
- items.get(position).setSelected(s);
- }
-
// Adapter related
public String[] getItemNames() {
String[] itemNames = new String[items.size()];
@@ -108,12 +73,12 @@ public class ContextMenuAdapter {
items.add(item);
}
- public ContextMenuItem getItem(int pos) {
- return items.get(pos);
+ public ContextMenuItem getItem(int position) {
+ return items.get(position);
}
- public void removeItem(int pos) {
- items.remove(pos);
+ public void removeItem(int position) {
+ items.remove(position);
}
public void setDefaultLayoutId(int defaultLayoutId) {
@@ -126,7 +91,7 @@ public class ContextMenuAdapter {
}
- public ArrayAdapter> createListAdapter(final Activity activity, final boolean holoLight) {
+ public ArrayAdapter createListAdapter(final Activity activity, final boolean holoLight) {
final int layoutId = DEFAULT_LAYOUT_ID;
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
return new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
@@ -241,7 +206,7 @@ public class ContextMenuAdapter {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- OnContextMenuClick ca = item.getCheckBoxListener();
+ ItemClickListener ca = item.getItemClickListener();
item.setSelected(isChecked);
if (ca != null) {
ca.onContextMenuClick(la, item.getTitleId(), position, isChecked);
@@ -305,28 +270,25 @@ public class ContextMenuAdapter {
}
}
- public interface OnContextMenuClick {
+ public interface ItemClickListener {
//boolean return type needed to desribe if drawer needed to be close or not
- boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked);
+ boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked);
}
public interface OnIntegerValueChangedListener {
boolean onIntegerValueChangedListener(int newValue);
}
- public static abstract class OnRowItemClick implements OnContextMenuClick {
+ public static abstract class OnRowItemClick implements ItemClickListener {
- public OnRowItemClick() {
- }
-
- //boolean return type needed to desribe if drawer needed to be close or not
- public boolean onRowItemClick(ArrayAdapter> adapter, View view, int itemId, int pos) {
+ //boolean return type needed to describe if drawer needed to be close or not
+ public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int position) {
CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
if (btn != null && btn.getVisibility() == View.VISIBLE) {
btn.setChecked(!btn.isChecked());
return false;
} else {
- return onContextMenuClick(adapter, itemId, pos, false);
+ return onContextMenuClick(adapter, itemId, position, false);
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java
index cc88096ce2..430d9a8332 100644
--- a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java
+++ b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java
@@ -6,9 +6,6 @@ import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
-/**
- * Created by GaidamakUA on 3/25/16.
- */
public class ContextMenuItem {
@StringRes
private final int titleId;
@@ -27,12 +24,14 @@ public class ContextMenuItem {
private final boolean category;
private final int pos;
private String description;
- private ContextMenuAdapter.OnContextMenuClick checkBoxListener;
- private ContextMenuAdapter.OnIntegerValueChangedListener integerListener;
+ private final ContextMenuAdapter.ItemClickListener itemClickListener;
+ private final ContextMenuAdapter.OnIntegerValueChangedListener integerListener;
- private ContextMenuItem(int titleId, String title, int icon, int lightIcon, int secondaryIcon,
- Boolean selected, int progress, int layout, boolean loading, boolean category,
- int pos, String description, ContextMenuAdapter.OnContextMenuClick checkBoxListener,
+ private ContextMenuItem(int titleId, String title, int icon, int lightIcon,
+ int secondaryIcon, Boolean selected, int progress,
+ int layout, boolean loading, boolean category,
+ int pos, String description,
+ ContextMenuAdapter.ItemClickListener itemClickListener,
ContextMenuAdapter.OnIntegerValueChangedListener integerListener) {
this.titleId = titleId;
this.title = title;
@@ -46,7 +45,7 @@ public class ContextMenuItem {
this.category = category;
this.pos = pos;
this.description = description;
- this.checkBoxListener = checkBoxListener;
+ this.itemClickListener = itemClickListener;
this.integerListener = integerListener;
}
@@ -58,6 +57,7 @@ public class ContextMenuItem {
return title;
}
+ @Deprecated
public int getIcon() {
return icon;
}
@@ -98,8 +98,8 @@ public class ContextMenuItem {
return description;
}
- public ContextMenuAdapter.OnContextMenuClick getCheckBoxListener() {
- return checkBoxListener;
+ public ContextMenuAdapter.ItemClickListener getItemClickListener() {
+ return itemClickListener;
}
public ContextMenuAdapter.OnIntegerValueChangedListener getIntegerListener() {
@@ -126,14 +126,6 @@ public class ContextMenuItem {
this.description = description;
}
- public void setCheckBoxListener(ContextMenuAdapter.OnContextMenuClick checkBoxListener) {
- this.checkBoxListener = checkBoxListener;
- }
-
- public void setIntegerListener(ContextMenuAdapter.OnIntegerValueChangedListener integerListener) {
- this.integerListener = integerListener;
- }
-
public static ItemBuilder createBuilder(String title) {
return new ItemBuilder().setTitle(title);
}
@@ -151,7 +143,7 @@ public class ContextMenuItem {
private boolean mCat = false;
private int mPos = -1;
private String mDescription = null;
- private ContextMenuAdapter.OnContextMenuClick mCheckBoxListener = null;
+ private ContextMenuAdapter.ItemClickListener mItemClickListener = null;
private ContextMenuAdapter.OnIntegerValueChangedListener mIntegerListener = null;
public ItemBuilder setTitleId(int titleId, @Nullable Context context) {
@@ -168,6 +160,7 @@ public class ContextMenuItem {
return this;
}
+ @Deprecated
public ItemBuilder setIcon(int icon) {
mIcon = icon;
return this;
@@ -218,8 +211,8 @@ public class ContextMenuItem {
return this;
}
- public ItemBuilder setListener(ContextMenuAdapter.OnContextMenuClick checkBoxListener) {
- mCheckBoxListener = checkBoxListener;
+ public ItemBuilder setListener(ContextMenuAdapter.ItemClickListener checkBoxListener) {
+ mItemClickListener = checkBoxListener;
return this;
}
@@ -229,7 +222,9 @@ public class ContextMenuItem {
}
public ContextMenuItem createItem() {
- return new ContextMenuItem(mTitleId, mTitle, mIcon, mLightIcon, mSecondaryIcon, mSelected, mProgress, mLayout, mLoading, mCat, mPos, mDescription, mCheckBoxListener, mIntegerListener);
+ return new ContextMenuItem(mTitleId, mTitle, mIcon, mLightIcon, mSecondaryIcon,
+ mSelected, mProgress, mLayout, mLoading, mCat, mPos, mDescription,
+ mItemClickListener, mIntegerListener);
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java
index 3be87954b3..d2bb39805f 100644
--- a/OsmAnd/src/net/osmand/plus/NavigationService.java
+++ b/OsmAnd/src/net/osmand/plus/NavigationService.java
@@ -144,6 +144,9 @@ public class NavigationService extends Service implements LocationListener {
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
try {
locationManager.requestLocationUpdates(serviceOffProvider, 0, 0, NavigationService.this);
+ } catch (SecurityException e) {
+ Toast.makeText(this, R.string.no_location_permission, Toast.LENGTH_LONG).show();
+ Log.d(PlatformUtil.TAG, "Location service permission not granted"); //$NON-NLS-1$
} catch (IllegalArgumentException e) {
Toast.makeText(this, R.string.gps_not_available, Toast.LENGTH_LONG).show();
Log.d(PlatformUtil.TAG, "GPS location provider not available"); //$NON-NLS-1$
@@ -202,7 +205,11 @@ public class NavigationService extends Service implements LocationListener {
usedBy = 0;
// remove updates
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
- locationManager.removeUpdates(this);
+ try {
+ locationManager.removeUpdates(this);
+ } catch (SecurityException e) {
+ Log.d(PlatformUtil.TAG, "Location service permission not granted"); //$NON-NLS-1$
+ }
if (!isContinuous()) {
WakeLock lock = getLock(this);
@@ -225,7 +232,11 @@ public class NavigationService extends Service implements LocationListener {
if (!isContinuous()) {
// unregister listener and wait next time
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
- locationManager.removeUpdates(this);
+ try {
+ locationManager.removeUpdates(this);
+ } catch (SecurityException e) {
+ Log.d(PlatformUtil.TAG, "Location service permission not granted"); //$NON-NLS-1$
+ }
WakeLock lock = getLock(this);
if (lock.isHeld()) {
lock.release();
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
index 09d57ab8cf..23588ecf43 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java
@@ -6,6 +6,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.view.ViewGroup;
@@ -29,7 +30,7 @@ import net.osmand.data.RotatedTileBox;
import net.osmand.map.ITileSource;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
@@ -295,14 +296,15 @@ public class MapActivityActions implements DialogProvider {
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
- final ArrayAdapter> listAdapter =
+ final ArrayAdapter listAdapter =
adapter.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContent());
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- int standardId = adapter.getElementId(which);
- OnContextMenuClick click = adapter.getClickAdapter(which);
+ ContextMenuItem item = adapter.getItem(which);
+ int standardId = item.getTitleId();
+ ItemClickListener click = item.getItemClickListener();
if (click != null) {
click.onContextMenuClick(listAdapter, standardId, which, false);
} else if (standardId == R.string.context_menu_item_last_intermediate_point) {
@@ -357,7 +359,7 @@ public class MapActivityActions implements DialogProvider {
final boolean useIntermediatePointsByDefault = true;
List selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper()
.getSelectedGPXFiles();
- final List gpxFiles = new ArrayList();
+ final List gpxFiles = new ArrayList<>();
for (SelectedGpxFile gs : selectedGPXFiles) {
if (!gs.isShowCurrentTrack() && !gs.notShowNavigationDialog) {
if (gs.getGpxFile().hasRtePt() || gs.getGpxFile().hasTrkpt()) {
@@ -598,9 +600,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.home, mapActivity)
.setColorIcon(R.drawable.map_dashboard)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.closeDrawer();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
@@ -610,9 +612,9 @@ public class MapActivityActions implements DialogProvider {
if (settings.USE_MAP_MARKERS.get()) {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_markers, mapActivity)
.setColorIcon(R.drawable.ic_action_flag_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.MAP_MARKERS);
return false;
@@ -621,9 +623,9 @@ public class MapActivityActions implements DialogProvider {
} else {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.waypoints, mapActivity)
.setColorIcon(R.drawable.ic_action_intermediate)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
return false;
@@ -632,9 +634,9 @@ public class MapActivityActions implements DialogProvider {
}
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
.setColorIcon(R.drawable.ic_action_gdirections_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
if (settings.USE_MAP_MARKERS.get()) {
@@ -651,9 +653,9 @@ public class MapActivityActions implements DialogProvider {
// Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.search_button, mapActivity)
.setColorIcon(R.drawable.ic_action_search_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getSearchActivity());
LatLon loc = mapActivity.getMapLocation();
@@ -670,9 +672,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
.setColorIcon(R.drawable.ic_action_fav_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getFavoritesActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@@ -684,9 +686,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.show_point_options, mapActivity)
.setColorIcon(R.drawable.ic_action_marker_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getMapLayers().getContextMenuLayer().showContextMenu(mapView.getLatitude(), mapView.getLongitude(), true);
return true;
@@ -695,9 +697,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
.setColorIcon(R.drawable.ic_action_layers_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
return false;
@@ -706,9 +708,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
.setColorIcon(R.drawable.ic_configure_screen_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN);
return false;
@@ -724,9 +726,9 @@ public class MapActivityActions implements DialogProvider {
}
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.index_settings, null)
.setTitle(d).setColorIcon(R.drawable.ic_type_archive)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getDownloadActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@@ -738,9 +740,9 @@ public class MapActivityActions implements DialogProvider {
if (Version.isGooglePlayEnabled(app)) {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.osm_live, mapActivity)
.setColorIcon(R.drawable.ic_action_osm_live)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
@@ -751,9 +753,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
.setColorIcon(R.drawable.ic_extension_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getPluginsActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@@ -765,9 +767,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
.setColorIcon(R.drawable.ic_action_settings)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization()
.getSettingsActivity());
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@@ -777,9 +779,9 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity)
.setColorIcon(R.drawable.ic_action_help)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
Intent intent = new Intent(mapActivity, HelpActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
@@ -793,7 +795,7 @@ public class MapActivityActions implements DialogProvider {
// 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) {
+// public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
// // 1. Work for almost all cases when user open apps from main menu
//// Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMapActivity());
//// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -855,7 +857,7 @@ public class MapActivityActions implements DialogProvider {
public void whereAmIDialog() {
- final List items = new ArrayList();
+ final List items = new ArrayList<>();
items.add(getString(R.string.show_location));
items.add(getString(R.string.shared_string_show_details));
AlertDialog.Builder menu = new AlertDialog.Builder(mapActivity);
@@ -883,23 +885,23 @@ public class MapActivityActions implements DialogProvider {
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final ListView menuItemsListView = (ListView) mapActivity.findViewById(R.id.menuItems);
if (nightMode) {
- menuItemsListView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
+ menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_dark));
} else {
- menuItemsListView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
+ menuItemsListView.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.bg_color_light));
}
menuItemsListView.setDivider(null);
final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu();
contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item);
- final ArrayAdapter> simpleListAdapter = contextMenuAdapter.createListAdapter(mapActivity,
+ final ArrayAdapter simpleListAdapter = contextMenuAdapter.createListAdapter(mapActivity,
!nightMode);
menuItemsListView.setAdapter(simpleListAdapter);
menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
- ContextMenuAdapter.OnContextMenuClick click =
- contextMenuAdapter.getClickAdapter(position);
- if (click.onContextMenuClick(simpleListAdapter,
- contextMenuAdapter.getElementId(position), position, false)) {
+ ContextMenuItem item = contextMenuAdapter.getItem(position);
+ ContextMenuAdapter.ItemClickListener click = item.getItemClickListener();
+ if (click.onContextMenuClick(simpleListAdapter, item.getTitleId(),
+ position, false)) {
mapActivity.closeDrawer();
}
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
index d50dad07e6..83880dfad7 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
@@ -115,7 +115,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
Integer[] intValues = new Integer[] { 0, 5, 10, 15, 20, 25, 30, 45, 60, 90};
entries = new String[intValues.length];
- entries[0] = getString(R.string.auto_follow_route_never);
+ entries[0] = getString(R.string.shared_string_never);
for (int i = 1; i < intValues.length; i++) {
entries[i] = (int) intValues[i] + " " + getString(R.string.int_seconds);
}
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
index 1ce3704ef9..ab724e6439 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
@@ -47,7 +47,7 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@@ -581,9 +581,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
@Override
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_recordings) {
SHOW_RECORDINGS.set(!SHOW_RECORDINGS.get());
updateLayers(mapView, mapActivity);
@@ -606,10 +606,10 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.recording_context_menu_arecord, app)
.setColorIcon(R.drawable.ic_action_micro_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
recordAudio(latitude, longitude, mapActivity);
return true;
}
@@ -618,10 +618,10 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.recording_context_menu_vrecord, app)
.setColorIcon(R.drawable.ic_action_video_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
recordVideo(latitude, longitude, mapActivity);
return true;
}
@@ -630,9 +630,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.recording_context_menu_precord, app)
.setColorIcon(R.drawable.ic_action_photo_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
takePhoto(latitude, longitude, mapActivity, false);
return true;
}
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index 67f63be019..98a4e61e85 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -29,6 +29,7 @@ import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
+import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
@@ -43,7 +44,6 @@ import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.IconsCache;
@@ -951,7 +951,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
this.nightMode = nightMode;
applyDayNightMode();
}
- final ArrayAdapter> listAdapter = cm.createListAdapter(mapActivity, !nightMode);
+ final ArrayAdapter listAdapter = cm.createListAdapter(mapActivity, !nightMode);
OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter);
updateListAdapter(listAdapter, listener);
}
@@ -965,7 +965,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
View v = listView.getChildAt(0);
int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
updateListAdapter();
- listView.setSelectionFromTop(index, top);
+ ((ListView) listView).setSelectionFromTop(index, top);
} else {
listAdapter.notifyDataSetChanged();
}
@@ -988,13 +988,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
private OnItemClickListener getOptionsMenuOnClickListener(final ContextMenuAdapter cm,
- final ArrayAdapter> listAdapter) {
+ final ArrayAdapter listAdapter) {
return new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view, int which, long id) {
ContextMenuItem item = cm.getItem(which);
- OnContextMenuClick click = item.getCheckBoxListener();
+ ContextMenuAdapter.ItemClickListener click = item.getItemClickListener();
if (click instanceof OnRowItemClick) {
boolean cl = ((OnRowItemClick) click).onRowItemClick(listAdapter, view, item.getTitleId(), which);
if (cl) {
diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java
index ec8f246ae5..00d2a80eb3 100644
--- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java
@@ -5,7 +5,6 @@ import android.content.Intent;
import android.widget.ArrayAdapter;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@@ -60,9 +59,9 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
helper.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.version_settings, mapActivity)
.setColorIcon(R.drawable.ic_action_gabout_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
final Intent mapIntent = new Intent(mapActivity, ContributionVersionActivity.class);
mapActivity.startActivityForResult(mapIntent, 0);
return true;
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
index 511c6744c7..006d6434e3 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
@@ -13,7 +13,7 @@ import net.osmand.PlatformUtil;
import net.osmand.access.AccessibleToast;
import net.osmand.core.android.MapRendererContext;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.GpxSelectionHelper;
@@ -100,11 +100,11 @@ public class ConfigureMapMenu {
}
@Override
- public boolean onRowItemClick(ArrayAdapter> adapter, View view, int itemId, int pos) {
+ public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int pos) {
if (itemId == R.string.layer_poi) {
selectPOILayer(ma.getMyApplication().getSettings());
return false;
- } else if (itemId == R.string.layer_gpx_layer && cm.getSelection(pos)) {
+ } else if (itemId == R.string.layer_gpx_layer && cm.getItem(pos).getSelected()) {
ma.getMapLayers().showGPXFileLayer(getAlreadySelectedGpx(), ma.getMapView());
return false;
} else {
@@ -113,7 +113,7 @@ public class ConfigureMapMenu {
}
@Override
- public boolean onContextMenuClick(final ArrayAdapter> adapter, int itemId, final int pos, boolean isChecked) {
+ public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int pos, boolean isChecked) {
final OsmandSettings settings = ma.getMyApplication().getSettings();
if (itemId == R.string.layer_poi) {
settings.SELECTED_POI_FILTER_FOR_MAP.set(null);
@@ -134,7 +134,7 @@ public class ConfigureMapMenu {
public void onDismiss(DialogInterface dialog) {
boolean areAnyGpxTracksVisible =
ma.getMyApplication().getSelectedGpxHelper().isShowingAnyGpxFiles();
- cm.setSelection(pos, areAnyGpxTracksVisible);
+ cm.getItem(pos).setSelected(areAnyGpxTracksVisible);
adapter.notifyDataSetChanged();
}
});
@@ -234,9 +234,10 @@ public class ConfigureMapMenu {
String descr = getRenderDescr(activity);
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.map_widget_renderer, activity)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(final ArrayAdapter> ad, int itemId, final int pos, boolean isChecked) {
+ public boolean onContextMenuClick(final ArrayAdapter ad,
+ int itemId, final int pos, boolean isChecked) {
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
bld.setTitle(R.string.renderers);
final OsmandApplication app = activity.getMyApplication();
@@ -265,7 +266,7 @@ public class ConfigureMapMenu {
} else {
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
}
- adapter.setItemDescription(pos, getRenderDescr(activity));
+ adapter.getItem(pos).setDescription(getRenderDescr(activity));
activity.getDashboard().refreshContent(true);
dialog.dismiss();
}
@@ -279,9 +280,10 @@ public class ConfigureMapMenu {
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.map_widget_day_night, activity)
.setDescription(getDayNightDescr(activity))
- .setListener(new OnContextMenuClick() {
+ .setListener(new ItemClickListener() {
@Override
- public boolean onContextMenuClick(final ArrayAdapter> ad, int itemId, final int pos, boolean isChecked) {
+ public boolean onContextMenuClick(final ArrayAdapter ad,
+ int itemId, final int pos, boolean isChecked) {
final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.daynight);
@@ -297,7 +299,7 @@ public class ConfigureMapMenu {
refreshMapComplete(activity);
dialog.dismiss();
activity.getDashboard().refreshContent(true);
- //adapter.setItemDescription(pos, getDayNightDescr(activity));
+ //adapter.getItem(pos).setDescription(s, getDayNightDescr(activity));
//ad.notifyDataSetInvalidated();
}
});
@@ -307,9 +309,10 @@ public class ConfigureMapMenu {
}).setLayout(R.layout.drawer_list_doubleitem).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.map_magnifier, activity).setListener(new OnContextMenuClick() {
+ .setTitleId(R.string.map_magnifier, activity).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(final ArrayAdapter> ad, int itemId, final int pos, boolean isChecked) {
+ public boolean onContextMenuClick(final ArrayAdapter ad,
+ int itemId, final int pos, boolean isChecked) {
final OsmandMapTileView view = activity.getMapView();
final OsmandSettings.OsmandPreference mapDensity = view.getSettings().MAP_DENSITY;
final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
@@ -347,7 +350,7 @@ public class ConfigureMapMenu {
if (mapContext != null) {
mapContext.updateMapSettings();
}
- adapter.setItemDescription(pos, String.format("%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %");
+ adapter.getItem(pos).setDescription(String.format("%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %");
ad.notifyDataSetInvalidated();
dialog.dismiss();
}
@@ -360,9 +363,10 @@ public class ConfigureMapMenu {
.createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.text_size, activity).setListener(new OnContextMenuClick() {
+ .setTitleId(R.string.text_size, activity).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(final ArrayAdapter> ad, int itemId, final int pos, boolean isChecked) {
+ public boolean onContextMenuClick(final ArrayAdapter ad,
+ int itemId, final int pos, boolean isChecked) {
final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
// test old descr as title
@@ -381,7 +385,7 @@ public class ConfigureMapMenu {
public void onClick(DialogInterface dialog, int which) {
view.getSettings().TEXT_SCALE.set(txtValues[which]);
refreshMapComplete(activity);
- adapter.setItemDescription(pos, getScale(activity));
+ adapter.getItem(pos).setDescription(getScale(activity));
ad.notifyDataSetInvalidated();
dialog.dismiss();
}
@@ -392,9 +396,10 @@ public class ConfigureMapMenu {
}).setDescription(getScale(activity)).setLayout(R.layout.drawer_list_doubleitem).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.map_locale, activity).setListener(new OnContextMenuClick() {
+ .setTitleId(R.string.map_locale, activity).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(final ArrayAdapter> ad, int itemId, final int pos, boolean isChecked) {
+ public boolean onContextMenuClick(final ArrayAdapter ad,
+ int itemId, final int pos, boolean isChecked) {
final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
// test old descr as title
@@ -413,7 +418,7 @@ public class ConfigureMapMenu {
public void onClick(DialogInterface dialog, int which) {
view.getSettings().MAP_PREFERRED_LOCALE.set(txtIds[which]);
refreshMapComplete(activity);
- adapter.setItemDescription(pos, txtIds[which]);
+ adapter.getItem(pos).setDescription(txtIds[which]);
ad.notifyDataSetInvalidated();
dialog.dismiss();
}
@@ -511,10 +516,11 @@ public class ConfigureMapMenu {
.setTitleId(strId, activity)
.setDescription(descr)
.setLayout(R.layout.drawer_list_doubleitem)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> a, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter a,
+ int itemId, int pos, boolean isChecked) {
showPreferencesDialog(adapter, a, pos, activity, activity.getString(strId), ps, prefs);
return false;
}
@@ -573,7 +579,7 @@ public class ConfigureMapMenu {
for (int i = 0; i < prefs.size(); i++) {
prefs.get(i).set(tempPrefs[i]);
}
- adapter.setItemDescription(pos, getDescription(prefs));
+ adapter.getItem(pos).setDescription(getDescription(prefs));
a.notifyDataSetInvalidated();
refreshMapComplete(activity);
activity.getMapLayers().updateLayers(activity.getMapView());
@@ -619,10 +625,10 @@ public class ConfigureMapMenu {
final OsmandSettings.CommonPreference pref = view.getApplication().getSettings()
.getCustomRenderBooleanProperty(p.getAttrName());
adapter.addItem(ContextMenuItem.createBuilder(propertyName)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
pref.set(!pref.get());
refreshMapComplete(activity);
return false;
@@ -640,10 +646,11 @@ public class ConfigureMapMenu {
descr = SettingsActivity.getStringPropertyValue(view.getContext(),
p.getDefaultValueDescription());
}
- adapter.addItem(ContextMenuItem.createBuilder(propertyName).setListener(new OnContextMenuClick() {
+ adapter.addItem(ContextMenuItem.createBuilder(propertyName).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(final ArrayAdapter> ad, int itemId, final int pos, boolean isChecked) {
+ public boolean onContextMenuClick(final ArrayAdapter ad,
+ int itemId, final int pos, boolean isChecked) {
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
// test old descr as title
b.setTitle(propertyDescr);
@@ -673,7 +680,7 @@ public class ConfigureMapMenu {
pref.set(p.getPossibleValues()[which - 1]);
}
refreshMapComplete(activity);
- adapter.setItemDescription(pos, SettingsActivity.getStringPropertyValue(activity, pref.get()));
+ adapter.getItem(pos).setDescription(SettingsActivity.getStringPropertyValue(activity, pref.get()));
dialog.dismiss();
ad.notifyDataSetInvalidated();
}
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java
index 4407debc33..3b07b09f61 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java
@@ -72,7 +72,8 @@ public class RasterMapMenu {
final MapActivityLayers mapLayers = mapActivity.getMapLayers();
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
@Override
- public boolean onRowItemClick(ArrayAdapter> adapter, View view, int itemId, int pos) {
+ public boolean onRowItemClick(ArrayAdapter adapter,
+ View view, int itemId, int pos) {
if (itemId == mapTypeString) {
if (selected) {
plugin.selectMapOverlayLayer(mapActivity.getMapView(), mapTypePreference,
@@ -84,7 +85,7 @@ public class RasterMapMenu {
}
@Override
- public boolean onContextMenuClick(final ArrayAdapter> adapter,
+ public boolean onContextMenuClick(final ArrayAdapter adapter,
int itemId, int pos, boolean isChecked) {
if (itemId == toggleActionStringId) {
if (isChecked) {
diff --git a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java
index 65dbd05d88..8b7520114b 100644
--- a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java
@@ -33,7 +33,6 @@ import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
@@ -655,10 +654,10 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
}
}
if (containsPoint) {
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.delete_point) {
for (int i = 0; i < measurementPoints.size(); i++) {
Iterator it = measurementPoints.get(i).iterator();
diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java
index 42a0462ed4..3133df75d8 100644
--- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java
@@ -4,11 +4,11 @@ import android.app.Activity;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
@@ -39,7 +39,7 @@ import android.widget.Toast;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
@@ -87,16 +87,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
private boolean selectionMode = false;
private Set selectedItems = new LinkedHashSet<>();
- protected static final int DELETE_OPERATION = 1;
- protected static final int BACKUP_OPERATION = 2;
- protected static final int RESTORE_OPERATION = 3;
-
private ContextMenuAdapter optionsMenuAdapter;
private ActionMode actionMode;
- Drawable sdcard;
- Drawable planet;
-
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.local_index, container, false);
@@ -108,7 +101,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
listView.setAdapter(listAdapter);
expandAllGroups();
setListView(listView);
- colorDrawables();
return view;
}
@@ -128,13 +120,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
setHasOptionsMenu(true);
}
- private void colorDrawables() {
- boolean light = getMyApplication().getSettings().isLightContent();
- sdcard = getActivity().getResources().getDrawable(R.drawable.ic_sdcard);
- sdcard.mutate();
- sdcard.setColorFilter(getActivity().getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
- }
-
@Override
public void onResume() {
super.onResume();
@@ -180,9 +165,10 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
builder.setItems(values, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- OnContextMenuClick clk = adapter.getClickAdapter(which);
- if (clk != null) {
- clk.onContextMenuClick(null, adapter.getElementId(which), which, false);
+ ContextMenuItem item = adapter.getItem(which);
+ if (item.getItemClickListener() != null) {
+ item.getItemClickListener().onContextMenuClick(null,
+ item.getTitleId(), which, false);
}
}
@@ -192,9 +178,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
private void basicFileOperation(final LocalIndexInfo info, ContextMenuAdapter adapter) {
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ItemClickListener listener = new ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int resId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked) {
return performBasicOperation(resId, info);
}
};
@@ -594,29 +580,30 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
//hide action bar from downloadindexfragment
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
optionsMenuAdapter = new ContextMenuAdapter();
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter,
+ int itemId, int pos, boolean isChecked) {
localOptionsMenu(itemId);
return true;
}
};
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.local_index_mi_reload,getContext())
- .setIcon(R.drawable.ic_action_refresh_dark)
+ .setTitleId(R.string.local_index_mi_reload, getContext())
+ .setColorIcon(R.drawable.ic_action_refresh_dark)
.setListener(listener)
.createItem());
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.shared_string_delete,getContext())
- .setIcon(R.drawable.ic_action_delete_dark)
+ .setTitleId(R.string.shared_string_delete, getContext())
+ .setColorIcon(R.drawable.ic_action_delete_dark)
.setListener(listener)
.createItem());
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.local_index_mi_backup,getContext())
+ .setTitleId(R.string.local_index_mi_backup, getContext())
.setListener(listener)
.createItem());
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.local_index_mi_restore,getContext())
+ .setTitleId(R.string.local_index_mi_restore, getContext())
.setListener(listener)
.createItem());
// doesn't work correctly
@@ -625,6 +612,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
SubMenu split = null;
for (int j = 0; j < optionsMenuAdapter.length(); j++) {
MenuItem item;
+ ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(j);
if (j + 1 >= max && optionsMenuAdapter.length() > max) {
if (split == null) {
split = menu.addSubMenu(0, 1, j + 1, R.string.shared_string_more_actions);
@@ -632,15 +620,14 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
split.getItem();
MenuItemCompat.setShowAsAction(split.getItem(), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
}
- item = split.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
+ item = split.add(0, contextMenuItem.getTitleId(), j + 1, contextMenuItem.getTitle());
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
} else {
- item = menu.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
+ item = menu.add(0, contextMenuItem.getTitleId(), j + 1, contextMenuItem.getTitle());
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
}
- OsmandApplication app = getMyApplication();
- if (optionsMenuAdapter.getImage(app, j, isLightActionBar()) != null) {
- item.setIcon(optionsMenuAdapter.getImage(app, j, isLightActionBar()));
+ if (contextMenuItem.getLightIcon() != -1) {
+ item.setIcon(contextMenuItem.getLightIcon());
}
}
@@ -656,8 +643,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
for (int i = 0; i < optionsMenuAdapter.length(); i++) {
- if (itemId == optionsMenuAdapter.getElementId(i)) {
- optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(null, itemId, i, false);
+ ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(i);
+ if (itemId == contextMenuItem.getTitleId()) {
+ contextMenuItem.getItemClickListener().onContextMenuClick(null, itemId, i, false);
return true;
}
}
@@ -809,11 +797,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
public LocalIndexesAdapter(DownloadActivity ctx) {
this.ctx = ctx;
- warningColor = ctx.getResources().getColor(R.color.color_warning);
- okColor = ctx.getResources().getColor(R.color.color_ok);
+ warningColor = ContextCompat.getColor(ctx, R.color.color_warning);
+ okColor = ContextCompat.getColor(ctx, R.color.color_ok);
TypedArray ta = ctx.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary});
ta.recycle();
- corruptedColor = ctx.getResources().getColor(R.color.color_invalid);
+ corruptedColor = ContextCompat.getColor(ctx, R.color.color_invalid);
}
public void clear() {
diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
index de2afa2e57..5ec620ab11 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
@@ -5,6 +5,7 @@ import android.app.Application;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
+import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.util.TypedValue;
import android.view.View;
@@ -68,11 +69,11 @@ public class GpxUiHelper {
public static String getDescription(OsmandApplication app, GPXTrackAnalysis analysis, boolean html) {
StringBuilder description = new StringBuilder();
String nl = html ? "
" : "\n";
- String timeSpanClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_time_span_color));
- String distanceClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_distance_color));
- String speedClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_speed));
- String ascClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_altitude_asc));
- String descClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_altitude_desc));
+ String timeSpanClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_time_span_color));
+ String distanceClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_distance_color));
+ String speedClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_speed));
+ String ascClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_altitude_asc));
+ String descClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_altitude_desc));
// OUTPUT:
// 1. Total distance, Start time, End time
description.append(app.getString(R.string.gpx_info_distance, getColorValue(distanceClr,
@@ -221,15 +222,16 @@ public class GpxUiHelper {
}
protected static void updateSelection(List selectedGpxList, boolean showCurrentTrack,
- final ContextMenuAdapter adapter, int i, String fileName) {
- if (i == 0 && showCurrentTrack) {
+ final ContextMenuAdapter adapter, int position, String fileName) {
+ ContextMenuItem item = adapter.getItem(position);
+ if (position == 0 && showCurrentTrack) {
if (selectedGpxList.contains("")) {
- adapter.setSelection(i, true);
+ item.setSelected(true);
}
} else {
for (String file : selectedGpxList) {
if (file.endsWith(fileName)) {
- adapter.setSelection(i, true);
+ item.setSelected(true);
break;
}
}
@@ -244,7 +246,8 @@ public class GpxUiHelper {
@Override
public boolean processResult(GPXFile[] result) {
- cmAdapter.setItemName(position, cmAdapter.getItemName(position) + "\n" + getDescription((OsmandApplication) app, result[0], f, false));
+ ContextMenuItem item = cmAdapter.getItem(position);
+ item.setTitle(item.getTitle() + "\n" + getDescription((OsmandApplication) app, result[0], f, false));
adapter.notifyDataSetInvalidated();
return true;
}
@@ -270,6 +273,7 @@ public class GpxUiHelper {
if (v == null) {
v = activity.getLayoutInflater().inflate(layout, null);
}
+ final ContextMenuItem item = adapter.getItem(position);
ImageView icon = (ImageView) v.findViewById(R.id.icon);
icon.setImageDrawable(adapter.getImage(app, position, light));
final ArrayAdapter arrayAdapter = this;
@@ -279,11 +283,11 @@ public class GpxUiHelper {
if (showCurrentGpx && position == 0) {
return;
}
- int nline = adapter.getItemName(position).indexOf('\n');
+ int nline = item.getTitle().indexOf('\n');
if (nline == -1) {
setDescripionInDialog(arrayAdapter, adapter, activity, dir, list.get(position), position);
} else {
- adapter.setItemName(position, adapter.getItemName(position).substring(0, nline));
+ item.setTitle(item.getTitle().substring(0, nline));
arrayAdapter.notifyDataSetInvalidated();
}
}
@@ -295,7 +299,7 @@ public class GpxUiHelper {
icon.setVisibility(View.VISIBLE);
}
TextView tv = (TextView) v.findViewById(R.id.title);
- tv.setText(adapter.getItemName(position));
+ tv.setText(item.getTitle());
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
// Put the image on the TextView
@@ -304,15 +308,15 @@ public class GpxUiHelper {
// }
// tv.setCompoundDrawablePadding(padding);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item));
- if (adapter.getSelection(position) == null) {
+ if (item.getSelected() == null) {
ch.setVisibility(View.INVISIBLE);
} else {
ch.setOnCheckedChangeListener(null);
- ch.setChecked(adapter.getSelection(position));
+ ch.setChecked(item.getSelected());
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- adapter.setSelection(position, isChecked);
+ item.setSelected(isChecked);
}
});
}
@@ -338,12 +342,12 @@ public class GpxUiHelper {
if (app != null && app.getSelectedGpxHelper() != null) {
app.getSelectedGpxHelper().clearAllGpxFileToShow();
}
- if (showCurrentGpx && adapter.getSelection(0)) {
+ if (showCurrentGpx && adapter.getItem(0).getSelected()) {
currentGPX = app.getSavingTrackHelper().getCurrentGpx();
}
List s = new ArrayList<>();
for (int i = (showCurrentGpx ? 1 : 0); i < adapter.length(); i++) {
- if (adapter.getSelection(i)) {
+ if (adapter.getItem(i).getSelected()) {
s.add(list.get(i));
}
}
@@ -361,7 +365,8 @@ public class GpxUiHelper {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
if (multipleChoice) {
- adapter.setSelection(position, !adapter.getSelection(position));
+ ContextMenuItem item = adapter.getItem(position);
+ item.setSelected(!item.getSelected());
listAdapter.notifyDataSetInvalidated();
} else {
dlg.dismiss();
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
index 2fa0154b5f..79a7b3970f 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java
@@ -22,7 +22,6 @@ import net.osmand.Location;
import net.osmand.ValueHolder;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.NavigationService;
@@ -130,9 +129,9 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
@Override
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude,
ContextMenuAdapter adapter, Object selectedObj) {
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int resId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_add_waypoint) {
mapActivity.getContextMenu().addWptPt();
} else if (resId == R.string.context_menu_item_edit_waypoint) {
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java
index 43980a45b2..70fe9b7048 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java
@@ -10,6 +10,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
+import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ActionMode;
@@ -35,7 +36,7 @@ import android.widget.Toast;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
@@ -96,7 +97,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private boolean showOnMapMode;
@Override
- public void onAttach(Activity activity) {
+ public void onAttach(Context activity) {
super.onAttach(activity);
this.app = (OsmandApplication) getActivity().getApplication();
final Collator collator = Collator.getInstance();
@@ -104,7 +105,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
currentRecording = new GpxInfo(getMyApplication().getSavingTrackHelper().getCurrentGpx(), getString(R.string.shared_string_currently_recording_track));
currentRecording.currentlyRecordingTrack = true;
asyncLoader = new LoadGpxTask();
- selectedGpxHelper = ((OsmandApplication) activity.getApplication()).getSelectedGpxHelper();
+ selectedGpxHelper = ((OsmandApplication) activity.getApplicationContext()).getSelectedGpxHelper();
allGpxAdapter = new GpxIndexesAdapter(getActivity());
setAdapter(allGpxAdapter);
}
@@ -197,11 +198,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public void onClick(View v) {
if (isRecording) {
plugin.stopRecording();
- } else if(plugin != null){
+ } else
if (app.getLocationProvider().checkGPSEnabled(ctx)) {
plugin.startGPXMonitoring(ctx);
}
- }
}
});
SavingTrackHelper sth = app.getSavingTrackHelper();
@@ -209,8 +209,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- final OsmandMonitoringPlugin plugin = OsmandPlugin
- .getEnabledPlugin(OsmandMonitoringPlugin.class);
plugin.saveCurrentTrack();
}
});
@@ -221,7 +219,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
save.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_action_gsave_dark));
- ((TextView) v.findViewById(R.id.points_count)).setText(sth.getPoints() + "");
+ ((TextView) v.findViewById(R.id.points_count)).setText(String.valueOf(sth.getPoints()));
((TextView) v.findViewById(R.id.distance))
.setText(OsmAndFormatter.getFormattedDistance(sth.getDistance(), app));
v.findViewById(R.id.points_icon).setVisibility(View.VISIBLE);
@@ -327,10 +325,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
((FavoritesActivity) getActivity()).getClearToolbar(false);
}
+ // TODO Rewrite without ContextMenuAdapter
optionsMenuAdapter = new ContextMenuAdapter();
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, final int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, final int itemId, int pos, boolean isChecked) {
if (itemId == R.string.local_index_mi_reload) {
asyncLoader = new LoadGpxTask();
asyncLoader.execute(getActivity());
@@ -350,16 +349,17 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
};
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_show_on_map, getActivity())
- .setIcon(R.drawable.ic_show_on_map)
+ .setColorIcon(R.drawable.ic_show_on_map)
.setListener(listener).createItem());
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_delete, getActivity())
- .setIcon(R.drawable.ic_action_delete_dark).setListener(listener).createItem());
+ .setColorIcon(R.drawable.ic_action_delete_dark).setListener(listener).createItem());
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.local_index_mi_reload, getActivity())
- .setIcon(R.drawable.ic_action_refresh_dark).setListener(listener).createItem());
+ .setColorIcon(R.drawable.ic_action_refresh_dark).setListener(listener).createItem());
OsmandPlugin.onOptionsMenuActivity(getActivity(), this, optionsMenuAdapter);
for (int j = 0; j < optionsMenuAdapter.length(); j++) {
final MenuItem item;
- item = menu.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
+ ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(j);
+ item = menu.add(0, contextMenuItem.getTitleId(), j + 1, contextMenuItem.getTitle());
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@@ -370,9 +370,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
});
}
- OsmandApplication app = getMyApplication();
- if (optionsMenuAdapter.getImage(app, j, isLightActionBar()) != null) {
- item.setIcon(optionsMenuAdapter.getImage(app, j, isLightActionBar()));
+ if (contextMenuItem.getLightIcon() != -1) {
+ item.setIcon(contextMenuItem.getLightIcon());
}
}
@@ -394,8 +393,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
for (int i = 0; i < optionsMenuAdapter.length(); i++) {
- if (itemId == optionsMenuAdapter.getElementId(i)) {
- optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(null, itemId, i, false);
+ ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(i);
+ if (itemId == contextMenuItem.getTitleId()) {
+ contextMenuItem.getItemClickListener().onContextMenuClick(null, itemId, i, false);
return true;
}
}
@@ -548,7 +548,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private void showGpxOnMap(GpxInfo info) {
info.setGpx(GPXUtilities.loadGPXFile(app, info.file));
boolean e = true;
- if (info != null && info.gpx != null) {
+ if (info.gpx != null) {
WptPt loc = info.gpx.findPointToShow();
OsmandSettings settings = getMyApplication().getSettings();
if (loc != null) {
@@ -676,9 +676,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private SearchFilter filter;
public GpxIndexesAdapter(Context ctx) {
- warningColor = ctx.getResources().getColor(R.color.color_warning);
+ warningColor = ContextCompat.getColor(ctx, R.color.color_warning);
TypedArray ta = ctx.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary});
- defaultColor = ta.getColor(0, ctx.getResources().getColor(R.color.color_unknown));
+ defaultColor = ta.getColor(0, ContextCompat.getColor(ctx, R.color.color_unknown));
ta.recycle();
}
@@ -1133,7 +1133,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
String cs = constraint.toString();
List res = new ArrayList<>();
for (GpxInfo r : raw) {
- if (r.getName().toLowerCase().indexOf(cs) != -1) {
+ if (r.getName().toLowerCase().contains(cs)) {
res.add(r);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
index 68d6ca1746..bf66e867df 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
@@ -20,7 +20,7 @@ import net.osmand.data.Amenity;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.Node;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@@ -182,9 +182,9 @@ public class OsmEditingPlugin extends OsmandPlugin {
final double longitude,
ContextMenuAdapter adapter,
final Object selectedObj) {
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int resId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_create_poi) {
//getPoiActions(mapActivity).showCreateDialog(latitude, longitude);
EditPoiDialogFragment editPoiDialogFragment =
@@ -260,17 +260,17 @@ public class OsmEditingPlugin extends OsmandPlugin {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_osm_bugs, mapActivity)
.setSelected(settings.SHOW_OSM_BUGS.get())
.setColorIcon(R.drawable.ic_action_bug_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
- @Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
- if (itemId == R.string.layer_osm_bugs) {
- settings.SHOW_OSM_BUGS.set(isChecked);
- updateLayers(mapActivity.getMapView(), mapActivity);
- }
- return true;
- }
- })
+ @Override
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
+ if (itemId == R.string.layer_osm_bugs) {
+ settings.SHOW_OSM_BUGS.set(isChecked);
+ updateLayers(mapActivity.getMapView(), mapActivity);
+ }
+ return true;
+ }
+ })
.setPosition(16)
.createItem());
@@ -286,10 +286,10 @@ public class OsmEditingPlugin extends OsmandPlugin {
if (fragment instanceof AvailableGPXFragment) {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.local_index_mi_upload_gpx, la)
.setColorIcon(R.drawable.ic_action_export)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
sendGPXFiles(la, (AvailableGPXFragment) fragment, (GpxInfo) info);
return true;
}
@@ -303,10 +303,10 @@ public class OsmEditingPlugin extends OsmandPlugin {
final AvailableGPXFragment f = ((AvailableGPXFragment) fragment);
optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.local_index_mi_upload_gpx, activity)
.setIcon(R.drawable.ic_action_export)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
f.openSelectionMode(R.string.local_index_mi_upload_gpx, R.drawable.ic_action_export,
R.drawable.ic_action_export, new OnClickListener() {
@Override
diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java
index c681b18c93..87760b8c69 100644
--- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java
@@ -12,7 +12,6 @@ import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
@@ -277,9 +276,9 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
helper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.osmo_groups, mapActivity)
.setColorIcon(R.drawable.ic_osmo_dark)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
Intent intent = new Intent(mapActivity, OsMoGroupsActivity.class);
mapActivity.startActivity(intent);
return true;
diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java
index 19ad36e18b..57e9b0cc94 100644
--- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java
@@ -18,7 +18,7 @@ import android.widget.TimePicker;
import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
@@ -217,9 +217,9 @@ public class ParkingPositionPlugin extends OsmandPlugin {
final double latitude, final double longitude,
ContextMenuAdapter adapter, Object selectedObj) {
- OnContextMenuClick addListener = new OnContextMenuClick() {
+ ItemClickListener addListener = new ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int resId,
+ public boolean onContextMenuClick(ArrayAdapter adapter, int resId,
int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_add_parking_point) {
showAddParkingDialog(mapActivity, latitude, longitude);
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java
index 840ed58608..9dc57cf869 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java
@@ -23,7 +23,7 @@ import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@@ -236,9 +236,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
ContextMenuAdapter adapter,
final MapActivity mapActivity) {
final MapActivityLayers layers = mapActivity.getMapLayers();
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ContextMenuAdapter.ItemClickListener listener = new ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
if (itemId == R.string.layer_map) {
layers.selectMapLayer(mapView);
@@ -279,9 +279,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
Object selectedObj) {
final OsmandMapTileView mapView = mapActivity.getMapView();
if (mapView.getMainLayer() instanceof MapTileLayer) {
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int resId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_update_map) {
mapActivity.getMapActions().reloadTile(mapView.getZoom(), latitude, longitude);
} else if (resId == R.string.shared_string_download_map) {
diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java
index 9b9786f347..87886f46ae 100644
--- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java
+++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java
@@ -87,9 +87,9 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter, MapActivity mapActivity) {
if (o != null && o instanceof GPXUtilities.WptPt && plugin.getCurrentRoute() != null){
final GPXUtilities.WptPt point = (GPXUtilities.WptPt) o;
- ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
+ ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.mark_as_not_visited){
plugin.getCurrentRoute().markPoint(point,false);
plugin.saveCurrentRoute();
diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
index 8d14fc8e3b..ca7cce652d 100644
--- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
@@ -5,7 +5,7 @@ import android.widget.ArrayAdapter;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
+import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@@ -105,9 +105,9 @@ public class SRTMPlugin extends OsmandPlugin {
@Override
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
- OnContextMenuClick listener = new OnContextMenuClick() {
+ ItemClickListener listener = new ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_hillshade) {
HILLSHADE.set(!HILLSHADE.get());
updateLayers(mapView, mapActivity);
diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java
index c6c681ba66..bd5d71e857 100644
--- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java
@@ -134,9 +134,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
@Override
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter, MapActivity mapActivity) {
if (menu.hasHiddenBottomInfo()) {
- ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
+ ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.shared_string_show_description) {
menu.openMenuFullScreen();
}
diff --git a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java
index 9e870f8d5e..5d3b0b7182 100644
--- a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java
@@ -165,9 +165,9 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
if (latLon != null && o == null
&& (routingHelper.isRoutePlanningMode() || routingHelper.isFollowingMode())) {
- ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
+ ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> adapter, int itemId, int pos, boolean isChecked) {
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.avoid_road) {
activity.getMyApplication().getAvoidSpecificRoads().addImpassableRoad(
activity, latLon, false);
diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java
index 463d87a678..79b38767ff 100644
--- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java
+++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java
@@ -5,12 +5,16 @@ import android.content.DialogInterface;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.PopupMenu;
+import android.view.Gravity;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.MapMarkersMode;
@@ -32,8 +36,12 @@ import java.util.TreeSet;
public class MapWidgetRegistry {
- private Set left = new TreeSet();
- private Set right = new TreeSet();
+ public static final String COLLAPSED_PREFIX = "+";
+ public static final String HIDE_PREFIX = "-";
+ public static final String SHOW_PREFIX = "";
+ public static final String SETTINGS_SEPARATOR = ";";
+ private Set left = new TreeSet<>();
+ private Set right = new TreeSet<>();
private Map> visibleElementsFromSettings = new LinkedHashMap>();
private final OsmandSettings settings;
@@ -43,12 +51,12 @@ public class MapWidgetRegistry {
for (ApplicationMode ms : ApplicationMode.values(settings)) {
String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms);
- if (mpf.equals("")) {
+ if (mpf.equals(SHOW_PREFIX)) {
visibleElementsFromSettings.put(ms, null);
} else {
LinkedHashSet set = new LinkedHashSet();
visibleElementsFromSettings.put(ms, set);
- Collections.addAll(set, mpf.split(";"));
+ Collections.addAll(set, mpf.split(SETTINGS_SEPARATOR));
}
}
}
@@ -143,10 +151,10 @@ public class MapWidgetRegistry {
if (set.contains(key)) {
def = true;
collapse = false;
- } else if (set.contains("-" + key)) {
+ } else if (set.contains(HIDE_PREFIX + key)) {
def = false;
collapse = false;
- } else if (set.contains("+" + key)) {
+ } else if (set.contains(COLLAPSED_PREFIX + key)) {
def = false;
collapse = true;
}
@@ -173,53 +181,33 @@ public class MapWidgetRegistry {
if (m.visibleModes.contains(mode)) {
set.add(m.key);
} else if (m.visibleCollapsible != null && m.visibleCollapsible.contains(mode)) {
- set.add("+" + m.key);
+ set.add(COLLAPSED_PREFIX + m.key);
} else {
- set.add("-" + m.key);
+ set.add(HIDE_PREFIX + m.key);
}
}
}
- public void changeVisibility(MapWidgetRegInfo m) {
+ private void setVisibility(MapWidgetRegInfo m, boolean visible, boolean collapsed) {
ApplicationMode mode = settings.APPLICATION_MODE.get();
- boolean visible = m.visible(mode);
- boolean collapse = m.visibleCollapsed(mode);
defineDefaultSettingsElement(mode);
// clear everything
this.visibleElementsFromSettings.get(mode).remove(m.key);
- this.visibleElementsFromSettings.get(mode).remove("+" + m.key);
- this.visibleElementsFromSettings.get(mode).remove("-" + m.key);
+ this.visibleElementsFromSettings.get(mode).remove(COLLAPSED_PREFIX + m.key);
+ this.visibleElementsFromSettings.get(mode).remove(HIDE_PREFIX + m.key);
m.visibleModes.remove(mode);
m.visibleCollapsible.remove(mode);
- if (visible || collapse) {
- if (!collapse) {
- m.visibleCollapsible.add(mode);
- this.visibleElementsFromSettings.get(mode).add("+" + m.key);
- } else {
- this.visibleElementsFromSettings.get(mode).add("-" + m.key);
- }
+ if (visible && collapsed) {
+ // Set "collapsed" state
+ m.visibleCollapsible.add(mode);
+ this.visibleElementsFromSettings.get(mode).add(COLLAPSED_PREFIX + m.key);
+ } else if (visible) {
+ // Set "visible" state
+ m.visibleModes.add(mode);
+ this.visibleElementsFromSettings.get(mode).add(SHOW_PREFIX + m.key);
} else {
- m.visibleModes.add(mode);
- this.visibleElementsFromSettings.get(mode).add("" + m.key);
- }
- saveVisibleElementsToSettings(mode);
- if (m.stateChangeListener != null) {
- m.stateChangeListener.run();
- }
- }
-
- public void changeVisibility(MapWidgetRegInfo m, boolean visible) {
- ApplicationMode mode = settings.APPLICATION_MODE.get();
- defineDefaultSettingsElement(mode);
- // clear everything
- this.visibleElementsFromSettings.get(mode).remove(m.key);
- this.visibleElementsFromSettings.get(mode).remove("+" + m.key);
- this.visibleElementsFromSettings.get(mode).remove("-" + m.key);
- m.visibleModes.remove(mode);
- m.visibleCollapsible.remove(mode);
- if (visible) {
- m.visibleModes.add(mode);
- this.visibleElementsFromSettings.get(mode).add("" + m.key);
+ // Set "hidden" state
+ this.visibleElementsFromSettings.get(mode).add(HIDE_PREFIX + m.key);
}
saveVisibleElementsToSettings(mode);
if (m.stateChangeListener != null) {
@@ -239,7 +227,7 @@ public class MapWidgetRegistry {
private void saveVisibleElementsToSettings(ApplicationMode mode) {
StringBuilder bs = new StringBuilder();
for (String ks : this.visibleElementsFromSettings.get(mode)) {
- bs.append(ks).append(";");
+ bs.append(ks).append(SETTINGS_SEPARATOR);
}
settings.MAP_INFO_CONTROLS.set(bs.toString());
}
@@ -265,7 +253,7 @@ public class MapWidgetRegistry {
resetDefault(appMode, right);
resetDefaultAppearance(appMode);
this.visibleElementsFromSettings.put(appMode, null);
- settings.MAP_INFO_CONTROLS.set("");
+ settings.MAP_INFO_CONTROLS.set(SHOW_PREFIX);
}
private void resetDefaultAppearance(ApplicationMode appMode) {
@@ -278,7 +266,6 @@ public class MapWidgetRegistry {
}
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);
@@ -288,9 +275,10 @@ public class MapWidgetRegistry {
if (settings.USE_MAP_MARKERS.get()) {
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_markers, map)
.setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map))
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
- public boolean onContextMenuClick(final ArrayAdapter> ad, int itemId, final int pos, boolean isChecked) {
+ public boolean onContextMenuClick(final ArrayAdapter ad,
+ int itemId, final int pos, boolean isChecked) {
final OsmandMapTileView view = map.getMapView();
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.map_markers);
@@ -305,7 +293,7 @@ public class MapWidgetRegistry {
settings.MAP_MARKERS_MODE.set(MapMarkersMode.values()[which]);
for (MapWidgetRegInfo info : right) {
if ("map_marker_1st".equals(info.key) || "map_marker_2nd".equals(info.key)) {
- changeVisibility(info, settings.MAP_MARKERS_MODE.get().isWidgets());
+ setVisibility(info, settings.MAP_MARKERS_MODE.get().isWidgets(), false);
}
}
MapInfoLayer mil = map.getMapLayers().getMapInfoLayer();
@@ -314,7 +302,7 @@ public class MapWidgetRegistry {
}
map.refreshMap();
dialog.dismiss();
- cm.setItemDescription(pos, settings.MAP_MARKERS_MODE.get().toHumanString(map));
+ cm.getItem(pos).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map));
ad.notifyDataSetChanged();
}
});
@@ -329,21 +317,22 @@ public class MapWidgetRegistry {
@StringRes int stringId, OsmandPreference pref) {
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(stringId, map)
.setSelected(pref.get())
- .setListener(new ApearanceOnContextMenuClick(pref, map)).createItem());
+ .setListener(new ApearanceItemClickListener(pref, map)).createItem());
}
- class ApearanceOnContextMenuClick implements OnContextMenuClick {
+ class ApearanceItemClickListener implements ContextMenuAdapter.ItemClickListener {
private MapActivity map;
private OsmandPreference pref;
- public ApearanceOnContextMenuClick(OsmandPreference pref, MapActivity map) {
+ public ApearanceItemClickListener(OsmandPreference pref, MapActivity map) {
this.pref = pref;
this.map = map;
}
@Override
- 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());
map.updateApplicationModeSettings();
a.notifyDataSetChanged();
@@ -389,7 +378,7 @@ public class MapWidgetRegistry {
return left;
}
- private void addControls(final MapActivity map, final ContextMenuAdapter adapter,
+ private void addControls(final MapActivity map, final ContextMenuAdapter contextMenuAdapter,
Set top, final ApplicationMode mode) {
for (final MapWidgetRegInfo r : top) {
if (mode == ApplicationMode.DEFAULT) {
@@ -400,25 +389,61 @@ public class MapWidgetRegistry {
if ("map_marker_1st".equals(r.key) || "map_marker_2nd".equals(r.key)) {
continue;
}
- adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.messageId, map)
+ contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.messageId, map)
.setSelected(r.visibleCollapsed(mode) || r.visible(mode))
.setColorIcon(r.drawableMenu)
.setSecondaryIcon(R.drawable.ic_action_additional_option)
- .setListener(new OnContextMenuClick() {
+ .setListener(new ContextMenuAdapter.OnRowItemClick() {
@Override
- public boolean onContextMenuClick(ArrayAdapter> a, int itemId, int pos, boolean isChecked) {
- changeVisibility(r);
+ public boolean onRowItemClick(final ArrayAdapter adapter,
+ final View view,
+ final int itemId,
+ final int pos) {
+ PopupMenu popup = new PopupMenu(view.getContext(), view, Gravity.CENTER_VERTICAL);
+ MenuInflater inflater = popup.getMenuInflater();
+ inflater.inflate(R.menu.vidget_visibility_menu, popup.getMenu());
+ popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem menuItem) {
+
+ switch (menuItem.getItemId()) {
+ case R.id.action_show:
+ setVisibility(adapter, pos, true, false);
+ return true;
+ case R.id.action_hide:
+ setVisibility(adapter, pos, false, false);
+ return true;
+ case R.id.action_collapse:
+ setVisibility(adapter, pos, true, true);
+ return true;
+ }
+ return false;
+ }
+ });
+ popup.show();
+ return false;
+ }
+
+ @Override
+ public boolean onContextMenuClick(ArrayAdapter a,
+ int itemId, int pos, boolean isChecked) {
+ setVisibility(a, pos, isChecked, false);
+ return false;
+ }
+
+ private void setVisibility(ArrayAdapter adapter,
+ int position,
+ boolean visible,
+ boolean collapsed) {
+ MapWidgetRegistry.this.setVisibility(r, visible, collapsed);
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));
- a.notifyDataSetChanged();
- return false;
+ adapter.getItem(position).setSelected(visible);
+ adapter.notifyDataSetChanged();
}
}).createItem());
- adapter.setItemName(adapter.length() - 1, getText(map, mode, r));
}
}