|
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
]
|
BIN
OsmAnd/res/drawable-hdpi/ic_action_map_day.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_action_map_language.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_action_map_light_sensor.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_action_map_magnifier.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_action_map_night.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_action_map_routes.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_action_map_sunst.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_action_map_text_size.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_map_day.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_map_language.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_map_light_sensor.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_map_magnifier.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_map_night.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_map_routes.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_map_sunst.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_map_text_size.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_map_day.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_map_language.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_map_light_sensor.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_map_magnifier.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_map_night.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_map_routes.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_map_sunst.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_map_text_size.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_map_day.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_map_language.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_map_light_sensor.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_map_magnifier.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_map_night.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_map_routes.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_map_sunst.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_map_text_size.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
15
OsmAnd/res/menu/vidget_visibility_menu.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_show"
|
||||
android:icon="@drawable/ic_action_view"
|
||||
android:title="@string/shared_string_show"/>
|
||||
<item
|
||||
android:id="@+id/action_hide"
|
||||
android:icon="@drawable/ic_action_hide"
|
||||
android:title="@string/shared_string_hide"/>
|
||||
<item
|
||||
android:id="@+id/action_collapse"
|
||||
android:icon="@drawable/ic_action_widget_collapse"
|
||||
android:title="@string/shared_string_collapse"/>
|
||||
</menu>
|
|
@ -64,7 +64,7 @@
|
|||
<string name="poi_furniture">Mueblería</string>
|
||||
<string name="poi_garden_centre">Vivero</string>
|
||||
<string name="poi_gas">Gas líquido</string>
|
||||
<string name="poi_shop_yes">Tienda general</string>
|
||||
<string name="poi_shop_yes">"Con tienda"</string>
|
||||
<string name="poi_gift">Tienda de regalos</string>
|
||||
<string name="poi_glaziery">Vidriería</string>
|
||||
<string name="poi_herbalist">Herboristería</string>
|
||||
|
@ -350,7 +350,7 @@
|
|||
<string name="poi_craft_painter">Pintor</string>
|
||||
<string name="poi_craft_photographer">Fotógrafo</string>
|
||||
<string name="poi_craft_photographic_laboratory">Laboratorio fotográfico</string>
|
||||
<string name="poi_craft_plumber">Plomero/Fontanero</string>
|
||||
<string name="poi_craft_plumber">Fontanero</string>
|
||||
<string name="poi_craft_sculptor">Escultor</string>
|
||||
<string name="poi_beauty">Salón de belleza</string>
|
||||
<string name="poi_hairdresser">Peluquería</string>
|
||||
|
@ -365,7 +365,7 @@
|
|||
<string name="poi_crematorium">Crematorio</string>
|
||||
<string name="poi_bank">Banco</string>
|
||||
<string name="poi_atm">Cajero automático</string>
|
||||
<string name="poi_accountant">Contable/Contador</string>
|
||||
<string name="poi_accountant">Contable</string>
|
||||
<string name="poi_cave_entrance">Entrada a cueva</string>
|
||||
<string name="poi_volcano">Volcán</string>
|
||||
<string name="poi_crater">Cráter</string>
|
||||
|
@ -729,7 +729,7 @@
|
|||
<string name="poi_craft_tiler">Alicatador</string>
|
||||
<string name="poi_craft_window_construction">Fábrica de ventanas</string>
|
||||
|
||||
<string name="poi_craft_computer">Montaje de computadoras/ordenadores</string>
|
||||
<string name="poi_craft_computer">Montaje de ordenadores</string>
|
||||
<string name="poi_saddle">Collado</string>
|
||||
<string name="poi_cape">Cabo</string>
|
||||
<string name="poi_anchor_berth">Fondeadero</string>
|
||||
|
@ -1003,7 +1003,7 @@
|
|||
<string name="poi_recycling_tetrapak">Tetrapak</string>
|
||||
<string name="poi_recycling_rubble">Escombros</string>
|
||||
<string name="poi_recycling_cds">CDs</string>
|
||||
<string name="poi_recycling_waste_oil">Aceite usado</string>
|
||||
<string name="poi_recycling_waste_oil">Restos de aceite</string>
|
||||
<string name="poi_recycling_bottles">Botellas</string>
|
||||
<string name="poi_recycling_cork">Corcho</string>
|
||||
<string name="poi_recycling_printer_cartridges">Cartuchos de impresora</string>
|
||||
|
@ -2676,4 +2676,40 @@
|
|||
<string name="poi_vacuum_cleaner_no">Aspiradora: no</string>
|
||||
<string name="poi_amenity_vacuum_cleaner">Aspiradora</string>
|
||||
|
||||
<string name="poi_compressed_air_yes">Aire comprimido: sí</string>
|
||||
<string name="poi_compressed_air_no">Aire comprimido: no</string>
|
||||
|
||||
<string name="poi_sport_free_flying">Vuelo libre (deporte)</string>
|
||||
<string name="poi_bicycle_repair_station">"Estación de autoreparación de bicicletas"</string>
|
||||
<string name="poi_water_tap">Grifo de agua</string>
|
||||
<string name="poi_button_operated_yes">Funciona con botón: sí</string>
|
||||
<string name="poi_button_operated_no">Funciona con botón: no</string>
|
||||
|
||||
<string name="poi_free_flying_site_takeoff">Sitio de vuelo libre: despegue</string>
|
||||
<string name="poi_free_flying_site_landing">Sitio de vuelo libre: aterrizaje</string>
|
||||
<string name="poi_free_flying_site_toplanding">Sitio de vuelo libre: aterrizaje elevado</string>
|
||||
<string name="poi_free_flying_site_towing">Sitio de vuelo libre: remolcador</string>
|
||||
<string name="poi_free_flying_site_training">Sitio de vuelo libre: formación</string>
|
||||
<string name="poi_free_flying_official_yes">Oficial de vuelo libre: sí</string>
|
||||
<string name="poi_free_flying_official_no">Oficial de vuelo libre: no</string>
|
||||
<string name="poi_free_flying_paragliding_yes">Parapente: sí</string>
|
||||
<string name="poi_free_flying_paragliding_no">Parapente: no</string>
|
||||
<string name="poi_free_flying_hanggliding_yes">Ala delta: sí</string>
|
||||
<string name="poi_free_flying_hanggliding_no">Ala delta: no</string>
|
||||
<string name="poi_free_flying_rigid_yes">Vuelo libre rígido: sí</string>
|
||||
<string name="poi_free_flying_rigid_no">Vuelo libre rígido: no</string>
|
||||
<string name="poi_free_flying_site_orientation_n">"Orientación del sitio de vuelo libre: N"</string>
|
||||
<string name="poi_free_flying_site_orientation_ne">"Orientación del sitio de vuelo libre: NE"</string>
|
||||
<string name="poi_free_flying_site_orientation_e">"Orientación del sitio de vuelo libre: E"</string>
|
||||
<string name="poi_free_flying_site_orientation_se">"Orientación del sitio de vuelo libre: SE"</string>
|
||||
<string name="poi_free_flying_site_orientation_s">"Orientación del sitio de vuelo libre: S"</string>
|
||||
<string name="poi_free_flying_site_orientation_sw">"Orientación del sitio de vuelo libre: SO"</string>
|
||||
<string name="poi_free_flying_site_orientation_w">"Orientación del sitio de vuelo libre: O"</string>
|
||||
<string name="poi_free_flying_site_orientation_nw">"Orientación del sitio de vuelo libre: NO"</string>
|
||||
<string name="poi_free_flying_no_flight_time">Sin tiempo de vuelo (vuelo libre)</string>
|
||||
<string name="poi_free_flying_guest_guidelines_yes">Directrices de huésped para vuelo libre: sí</string>
|
||||
<string name="poi_free_flying_guest_guidelines_no">Directrices de huésped para vuelo libre: no</string>
|
||||
|
||||
<string name="poi_solarium">Solárium</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -836,7 +836,7 @@
|
|||
<string name="interrupt_music">Avbryt musikk</string>
|
||||
<string name="gpxup_public">Offentlig</string>
|
||||
<string name="rendering_attr_appMode_description">Optimaliser kart for</string>
|
||||
<string name="rendering_attr_contourLines_description">Vis fra zoom-nivå (krever kote-data):</string>
|
||||
<string name="rendering_attr_contourLines_description">Vis fra zoom-nivå (krever kotedata):</string>
|
||||
<string name="local_index_description">Klikk på et eksisterende element for å se flere detaljer, trykk og hold for å deaktivere eller slette. Gjeldende data på enheten (%1$s ledig):</string>
|
||||
<string name="send_files_to_osm">Sende GPX-filer til OSM?</string>
|
||||
<string name="arrival_distance_factor_early">Tidlig</string>
|
||||
|
@ -1536,4 +1536,17 @@
|
|||
<string name="consider_turning_polygons_off">Det anbefales å slå av opptegning av polygoner.</string>
|
||||
<string name="recording_photo_description">Foto %1$s %2$s</string>
|
||||
<string name="select_month_and_country">Velg måned og land</string>
|
||||
</resources>
|
||||
<string name="storage_directory_readonly_desc">Den valgte datalagringsmappe er skrivebeskyttet. Lagringsmappen har midlertidig skiftet til internminnet. Velg en gyldig lagringsmappe.</string>
|
||||
<string name="shared_string_reverse_order">Snu rekkefølgen</string>
|
||||
<string name="rendering_attr_hideUnderground_name">Skjul objekter som er under bakken</string>
|
||||
<string name="item_removed">Element fjernet</string>
|
||||
<string name="n_items_removed">Elementer fjernet</string>
|
||||
<string name="shared_string_not_selected">Ikke valgt</string>
|
||||
<string name="select_voice_provider">Velg taleveiledning</string>
|
||||
<string name="select_voice_provider_descr">Velg eller last ned taleveiledning for ditt språk</string>
|
||||
<string name="no_address_found">Ingen adresse funnet</string>
|
||||
<string name="shared_string_near">Nær</string>
|
||||
<string name="looking_up_address">Ser etter adresse</string>
|
||||
<string name="cancel_route">Forkast rute</string>
|
||||
<string name="file_name_containes_illegal_char">Filnavn inneholder ulovlig tegn</string>
|
||||
</resources>
|
||||
|
|
|
@ -1676,7 +1676,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
|
|||
<string name="init_native_library">Initializing native library…</string>
|
||||
<string name="choose_auto_follow_route">Auto-center map view</string>
|
||||
<string name="choose_auto_follow_route_descr">Time until map view synchronizes with current position</string>
|
||||
<string name="auto_follow_route_never">Never (tap \'Go\' to start guidance manually)</string>
|
||||
<!-- string name="auto_follow_route_never">Never (tap \'Go\' to start guidance manually)</string -->
|
||||
<string name="keep_informing_never">Only manually (tap arrow)</string>
|
||||
<string name="keep_informing_descr">Re-announce navigation instructions at regular intervals</string>
|
||||
<string name="keep_informing">Repeat navigation instructions</string>
|
||||
|
|
|
@ -40,36 +40,15 @@ public class ContextMenuAdapter {
|
|||
R.layout.list_menu_item : R.layout.list_menu_item_native;
|
||||
List<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<ContextMenuItem> 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<SelectedGpxFile> selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper()
|
||||
.getSelectedGPXFiles();
|
||||
final List<GPXFile> gpxFiles = new ArrayList<GPXFile>();
|
||||
final List<GPXFile> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<String> items = new ArrayList<String>();
|
||||
final List<String> 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<ContextMenuItem> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
takePhoto(latitude, longitude, mapActivity, false);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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<ContextMenuItem> 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<ContextMenuItem> 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) {
|
||||
|
|
|
@ -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<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
final Intent mapIntent = new Intent(mapActivity, ContributionVersionActivity.class);
|
||||
mapActivity.startActivityForResult(mapIntent, 0);
|
||||
return true;
|
||||
|
|
|
@ -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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> ad,
|
||||
int itemId, final int pos, boolean isChecked) {
|
||||
final OsmandMapTileView view = activity.getMapView();
|
||||
final OsmandSettings.OsmandPreference<Float> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<Boolean> 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<ContextMenuItem> 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<ContextMenuItem> 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();
|
||||
}
|
||||
|
|
|
@ -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<ContextMenuItem> 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<ContextMenuItem> adapter,
|
||||
int itemId, int pos, boolean isChecked) {
|
||||
if (itemId == toggleActionStringId) {
|
||||
if (isChecked) {
|
||||
|
|
|
@ -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<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
if (itemId == R.string.delete_point) {
|
||||
for (int i = 0; i < measurementPoints.size(); i++) {
|
||||
Iterator<WptPt> it = measurementPoints.get(i).iterator();
|
||||
|
|
|
@ -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<LocalIndexInfo> 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<ContextMenuItem> 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<ContextMenuItem> 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() {
|
||||
|
|
|
@ -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 ? "<br/>" : "\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<String> 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<String> 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<String> 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();
|
||||
|
|
|
@ -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<ContextMenuItem> 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) {
|
||||
|
|
|
@ -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<ContextMenuItem> 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<GpxInfo> res = new ArrayList<>();
|
||||
for (GpxInfo r : raw) {
|
||||
if (r.getName().toLowerCase().indexOf(cs) != -1) {
|
||||
if (r.getName().toLowerCase().contains(cs)) {
|
||||
res.add(r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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<ContextMenuItem> 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
|
||||
|
|
|
@ -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<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent intent = new Intent(mapActivity, OsMoGroupsActivity.class);
|
||||
mapActivity.startActivity(intent);
|
||||
return true;
|
||||
|
|
|
@ -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<ContextMenuItem> adapter, int resId,
|
||||
int pos, boolean isChecked) {
|
||||
if (resId == R.string.context_menu_item_add_parking_point) {
|
||||
showAddParkingDialog(mapActivity, latitude, longitude);
|
||||
|
|
|
@ -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<ContextMenuItem> 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<ContextMenuItem> 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) {
|
||||
|
|
|
@ -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<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
if (itemId == R.string.mark_as_not_visited){
|
||||
plugin.getCurrentRoute().markPoint(point,false);
|
||||
plugin.saveCurrentRoute();
|
||||
|
|
|
@ -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<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
if (itemId == R.string.layer_hillshade) {
|
||||
HILLSHADE.set(!HILLSHADE.get());
|
||||
updateLayers(mapView, mapActivity);
|
||||
|
|
|
@ -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<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
if (itemId == R.string.shared_string_show_description) {
|
||||
menu.openMenuFullScreen();
|
||||
}
|
||||
|
|
|
@ -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<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
if (itemId == R.string.avoid_road) {
|
||||
activity.getMyApplication().getAvoidSpecificRoads().addImpassableRoad(
|
||||
activity, latLon, false);
|
||||
|
|
|
@ -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<MapWidgetRegInfo> left = new TreeSet<MapWidgetRegistry.MapWidgetRegInfo>();
|
||||
private Set<MapWidgetRegInfo> right = new TreeSet<MapWidgetRegistry.MapWidgetRegInfo>();
|
||||
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<MapWidgetRegInfo> left = new TreeSet<>();
|
||||
private Set<MapWidgetRegInfo> right = new TreeSet<>();
|
||||
private Map<ApplicationMode, Set<String>> visibleElementsFromSettings = new LinkedHashMap<ApplicationMode, Set<String>>();
|
||||
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<String> set = new LinkedHashSet<String>();
|
||||
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<ContextMenuItem> 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<Boolean> 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<Boolean> pref;
|
||||
|
||||
public ApearanceOnContextMenuClick(OsmandPreference<Boolean> pref, MapActivity map) {
|
||||
public ApearanceItemClickListener(OsmandPreference<Boolean> 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<ContextMenuItem> 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<MapWidgetRegInfo> 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<ContextMenuItem> 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<ContextMenuItem> a,
|
||||
int itemId, int pos, boolean isChecked) {
|
||||
setVisibility(a, pos, isChecked, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setVisibility(ArrayAdapter<ContextMenuItem> 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|