Change interface

This commit is contained in:
Victor Shcherb 2014-10-25 23:22:20 +02:00
parent eefc6393de
commit 38192aae64
30 changed files with 278 additions and 430 deletions

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>

View file

@ -30,14 +30,13 @@ public class ContextMenuAdapter {
public interface OnContextMenuClick {
//boolean return type needed to desribe if drawer needed to be close or not
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked);
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked);
}
private final Context ctx;
private View anchor;
private int defaultLayoutId = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ?
R.layout.list_menu_item : R.layout.list_menu_item_native;
private ArrayAdapter listAdapter;
final TIntArrayList items = new TIntArrayList();
final TIntArrayList isCategory = new TIntArrayList();
final ArrayList<String> itemNames = new ArrayList<String>();
@ -90,12 +89,6 @@ public class ContextMenuAdapter {
itemNames.set(pos, str);
}
public void notifyDataSetChanged(){
if (listAdapter != null){
listAdapter.notifyDataSetChanged();
}
}
public void setItemDescription(int pos, String str) {
itemDescription.set(pos, str);
}
@ -158,8 +151,6 @@ public class ContextMenuAdapter {
int pos = -1;
String description = "";
private OnContextMenuClick checkBoxListener;
private OnContextMenuClick itemClickListener;
boolean enabled = false;
private Item() {
}
@ -205,11 +196,6 @@ public class ContextMenuAdapter {
return this;
}
public Item itemClickListen(OnContextMenuClick l) {
this.itemClickListener = l;
return this;
}
public void reg() {
if (pos >= items.size() || pos < 0) {
pos = items.size();
@ -231,10 +217,6 @@ public class ContextMenuAdapter {
return this;
}
public Item enabled(boolean checked) {
this.enabled = checked;
return this;
}
}
public String[] getItemNames() {
@ -245,13 +227,12 @@ public class ContextMenuAdapter {
items.removeAt(pos);
itemNames.remove(pos);
selectedList.removeAt(pos);
loadingList.clear();
iconList.removeAt(pos);
iconListLight.removeAt(pos);
checkListeners.remove(pos);
isCategory.removeAt(pos);
layoutIds.removeAt(pos);
loadingList.clear();
loadingList.removeAt(pos);
}
public int getLayoutId(int position) {
@ -267,10 +248,9 @@ public class ContextMenuAdapter {
this.defaultLayoutId = defaultLayoutId;
}
public ListAdapter createListAdapter(final Activity activity, final boolean holoLight) {
final int padding = (int) (12 * activity.getResources().getDisplayMetrics().density + 0.5f);
public ArrayAdapter<?> createListAdapter(final Activity activity, final boolean holoLight) {
final int layoutId = defaultLayoutId;
listAdapter = new ArrayAdapter<String>(activity, layoutId, R.id.title,
ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(activity, layoutId, R.id.title,
getItemNames()) {
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
@ -291,7 +271,6 @@ public class ContextMenuAdapter {
} else if (v.findViewById(R.id.icon) != null){
v.findViewById(R.id.icon).setVisibility(View.GONE);
}
tv.setCompoundDrawablePadding(padding);
if(isCategory(position)) {
tv.setTypeface(Typeface.DEFAULT_BOLD);
@ -311,7 +290,7 @@ public class ContextMenuAdapter {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
OnContextMenuClick ca = getClickAdapter(position);
if(ca != null) {
ca.onContextMenuClick(getElementId(position), position, isChecked);
ca.onContextMenuClick(null, getElementId(position), position, isChecked);
}
}
});

View file

@ -44,6 +44,7 @@ import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ExpandableListView;
@ -159,7 +160,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
optionsMenuAdapter = new ContextMenuAdapter(getActivity());
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(final int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, final int itemId, int pos, boolean isChecked) {
if (itemId == R.string.local_index_mi_reload) {
asyncLoader = new LoadGpxTask();
asyncLoader.execute(getActivity());
@ -214,7 +215,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
int itemId = item.getItemId();
for (int i = 0; i < optionsMenuAdapter.length(); i++) {
if (itemId == optionsMenuAdapter.getElementId(i)) {
optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(itemId, i, false);
optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(null, itemId, i, false);
return true;
}
}
@ -396,7 +397,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private void basicFileOperation(final GpxInfo info, ContextMenuAdapter adapter) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.local_index_mi_rename) {
renameFile(info);
} else if (resId == R.string.local_index_unselect_gpx_file ||
@ -479,7 +480,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = adapter.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(adapter.getElementId(which), which, false);
clk.onContextMenuClick(null, adapter.getElementId(which), which, false);
}
}

View file

@ -176,7 +176,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
editPoint(point);
return true;
}
@ -187,7 +187,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
deletePoint(point);
return true;
}

View file

@ -10,9 +10,6 @@ import java.util.Date;
import java.util.Iterator;
import java.util.List;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.widget.*;
import net.londatiga.android.ActionItem;
import net.londatiga.android.QuickAction;
import net.osmand.AndroidUtils;
@ -50,8 +47,8 @@ import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.configuremap.ConfigureMapMenu;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.osmo.OsMoPositionLayer;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.osmo.OsMoPositionLayer;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.BaseMapLayer;
@ -68,11 +65,26 @@ import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.util.TypedValue;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class MapActivityActions implements DialogProvider {
@ -315,13 +327,6 @@ public class MapActivityActions implements DialogProvider {
mapActivity.showDialog(DIALOG_ADD_WAYPOINT);
}
public void openViewConfigureDrawer(){
if (!mDrawerLayout.isDrawerOpen(mDrawerList)){
mDrawerLayout.openDrawer(mDrawerList);
}
mapActivity.getMapLayers().getMapInfoLayer().openViewConfigureDrawer(mDrawerList);
}
private Dialog createAddWaypointDialog(final Bundle args) {
Builder builder = new AlertDialog.Builder(mapActivity);
builder.setTitle(R.string.add_waypoint_dialog_title);
@ -507,7 +512,7 @@ public class MapActivityActions implements DialogProvider {
getMyApplication().getAppCustomization().prepareLocationMenu(mapActivity, adapter);
final Builder builder = new AlertDialog.Builder(mapActivity);
ListAdapter listAdapter =
final ArrayAdapter<?> listAdapter =
adapter.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContentMenu());
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@ -516,7 +521,7 @@ public class MapActivityActions implements DialogProvider {
int standardId = adapter.getElementId(which);
OnContextMenuClick click = adapter.getClickAdapter(which);
if (click != null) {
click.onContextMenuClick(standardId, which, false);
click.onContextMenuClick(listAdapter, standardId, which, false);
} else if (standardId == R.string.context_menu_item_search) {
Intent intent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSearchActivity());
intent.putExtra(SearchActivity.SEARCH_LAT, latitude);
@ -760,7 +765,7 @@ public class MapActivityActions implements DialogProvider {
}
public void prepareOptionsMenu(final ContextMenuAdapter cm) {
ListAdapter listAdapter =
final ArrayAdapter<?> listAdapter =
cm.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContentMenu());
mDrawerList.setAdapter(listAdapter);
mDrawerList.setBackgroundColor(cm.getBackgroundColor(mapActivity, getMyApplication().getSettings().isLightContentMenu()));
@ -770,7 +775,7 @@ public class MapActivityActions implements DialogProvider {
public void onItemClick(AdapterView<?> parent, View view, int which, long id) {
OnContextMenuClick click = cm.getClickAdapter(which);
if (click != null) {
if (click.onContextMenuClick(cm.getElementId(which), which, false)) {
if (click.onContextMenuClick(listAdapter, cm.getElementId(which), which, false)) {
mDrawerLayout.closeDrawer(mDrawerList);
}
} else {
@ -803,7 +808,7 @@ public class MapActivityActions implements DialogProvider {
icons(R.drawable.ic_action_gloc_dark, R.drawable.ic_action_gloc_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (getMyApplication().accessibilityEnabled()) {
whereAmIDialog();
} else {
@ -830,7 +835,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(t).icons(icon, iconLight)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute());
return true;
}
@ -841,7 +846,7 @@ public class MapActivityActions implements DialogProvider {
.icons(R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
enterRoutePlanningMode(null, null, false);
return true;
}
@ -853,7 +858,7 @@ public class MapActivityActions implements DialogProvider {
.icons(R.drawable.ic_action_gdirections_dark, R.drawable.ic_action_gdirections_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if(routingHelper.isRoutePlanningMode()) {
routingHelper.setRoutePlanningMode(false);
routingHelper.setFollowingMode(true);
@ -880,7 +885,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(nav).icons(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
stopNavigationActionConfirm(mapView);
OsMoPositionLayer osMoPositionLayer = mapActivity.getMapView().getLayerByClass(OsMoPositionLayer.class);
if (osMoPositionLayer != null) {
@ -894,7 +899,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.target_points).icons(R.drawable.ic_action_flage_dark, R.drawable.ic_action_flage_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
final List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
@ -913,7 +918,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.configure_map).icons(R.drawable.ic_action_layers_dark, R.drawable.ic_action_layers_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
prepareConfigureMap();
return false;
}
@ -922,8 +927,9 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.layer_map_appearance).icons(R.drawable.ic_action_settings_dark, R.drawable.ic_action_settings_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
mapActivity.getMapLayers().getMapInfoLayer().openViewConfigureDrawer(mDrawerList);
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().openViewConfigureDrawer();
prepareOptionsMenu(cm);
return false;
}
}).reg();
@ -931,7 +937,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.settings_Button).icons(R.drawable.ic_action_settings2_dark, R.drawable.ic_action_settings2_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
final Intent intentSettings = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSettingsActivity());
mapActivity.startActivity(intentSettings);
return true;
@ -941,7 +947,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.search_button).icons(R.drawable.ic_action_search_dark, R.drawable.ic_action_search_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSearchActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
LatLon loc = mapActivity.getMapLocation();
@ -956,7 +962,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.favorites_Button).icons( R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getFavoritesActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
@ -966,7 +972,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.show_point_options).icons(R.drawable.ic_action_marker_dark, R.drawable.ic_action_marker_light )
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
return true;
}
@ -977,7 +983,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
new StartGPSStatus(mapActivity).run();
return true;
}
@ -988,7 +994,7 @@ public class MapActivityActions implements DialogProvider {
listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (MainMenuActivity.TIPS_AND_TRICKS) {
TipsAndTricksActivity tactivity = new TipsAndTricksActivity(mapActivity);
Dialog dlg = tactivity.getDialogToShowTips(false, true);
@ -1009,7 +1015,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
// animate moving on route
loc.getLocationSimulation().startStopRouteAnimation(mapActivity);
return true;
@ -1022,7 +1028,7 @@ public class MapActivityActions implements DialogProvider {
optionsMenuHelper.item(R.string.exit_Button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light )
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
// 1. Work for almost all cases when user open apps from main menu
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@ -1133,7 +1139,7 @@ public class MapActivityActions implements DialogProvider {
new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivityActions.directionsToDialogAndLaunchMap(activity, location.getLatitude(), location.getLongitude(), name);
return true;
}
@ -1148,7 +1154,7 @@ public class MapActivityActions implements DialogProvider {
}
intermediate.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
addWaypointDialogAndLaunchMap(activity, location.getLatitude(), location.getLongitude(), name);
return true;
}
@ -1160,7 +1166,7 @@ public class MapActivityActions implements DialogProvider {
new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
app.getSettings().setMapLocationToShow(location.getLatitude(), location.getLongitude(), z, saveHistory ? name : null, name,
obj); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(activity);
@ -1173,7 +1179,7 @@ public class MapActivityActions implements DialogProvider {
addToFavorite.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
Bundle args = new Bundle();
Dialog dlg = createAddFavouriteDialog(activity, args);
dlg.show();
@ -1196,7 +1202,7 @@ public class MapActivityActions implements DialogProvider {
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = qa.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(qa.getElementId(which), which, false);
clk.onContextMenuClick(null, qa.getElementId(which), which, false);
}
}
@ -1221,7 +1227,7 @@ public class MapActivityActions implements DialogProvider {
onShow.onClick(v);
}
view.dismiss();
qa.getClickAdapter(ki).onContextMenuClick(qa.getElementId(ki), ki, false);
qa.getClickAdapter(ki).onContextMenuClick(null, qa.getElementId(ki), ki, false);
}
});

View file

@ -177,7 +177,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = adapter.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(adapter.getElementId(which), which, false);
clk.onContextMenuClick(null, adapter.getElementId(which), which, false);
}
}
@ -188,7 +188,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
private void basicFileOperation(final GpxDisplayItem gpxDisplayItem, ContextMenuAdapter adapter) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.show_gpx_route) {
OsmandSettings settings = app.getSettings();
settings.setMapLocationToShow(gpxDisplayItem.locationStart.lat, gpxDisplayItem.locationStart.lon,

View file

@ -580,7 +580,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
poiDescr.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
// Build text(amenity)
// Find and format links
@ -607,7 +607,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
showDetails.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
showPOIDetails(amenity, settings.usingEnglishNames());
return true;
}

View file

@ -26,6 +26,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PointF;
import android.widget.ArrayAdapter;
import android.widget.Toast;
public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvider {
@ -118,7 +119,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
final Recording r = (Recording) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.recording_context_menu_play ||
itemId == R.string.recording_context_menu_show) {
plugin.playRecording(view.getContext(), r);

View file

@ -83,6 +83,7 @@ import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Toast;
@ -414,7 +415,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_recordings) {
SHOW_RECORDINGS.set(!SHOW_RECORDINGS.get());
updateLayers(mapView, mapActivity);
@ -433,7 +434,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
recordAudio(latitude, longitude, mapActivity);
return true;
}
@ -442,7 +443,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
recordVideo(latitude, longitude, mapActivity);
return true;
}
@ -450,7 +451,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
adapter.item(R.string.recording_context_menu_precord).icons(R.drawable.ic_action_photo_dark, R.drawable.ic_action_photo_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
takePhoto(latitude, longitude, mapActivity);
return true;
}
@ -1104,7 +1105,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
final RecordingLocalIndexInfo ri = (RecordingLocalIndexInfo) info;
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
playRecording(la, ri.rec);
return true;
}
@ -1122,7 +1123,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.icons(R.drawable.ic_action_marker_dark, R.drawable.ic_action_marker_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
SHOW_RECORDINGS.set(true);
app.getSettings().setMapLocationToShow(ri.rec.lat, ri.rec.lon,
app.getSettings().getLastKnownMapZoom());

View file

@ -21,6 +21,7 @@ import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRulesStorage;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.ArrayAdapter;
import android.widget.Toast;
public class ConfigureMapMenu {
@ -32,7 +33,7 @@ public class ConfigureMapMenu {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
ma.getMapActions().prepareStartOptionsMenu();
return false;
}
@ -61,7 +62,7 @@ public class ConfigureMapMenu {
}
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
OsmandSettings settings = ma.getMyApplication().getSettings();
if (itemId == R.string.layer_poi) {
if (isChecked) {
@ -127,7 +128,7 @@ public class ConfigureMapMenu {
String descr = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer().getName();
adapter.item(R.string.map_widget_renderer).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
bld.setTitle(R.string.renderers);
final OsmandApplication app = activity.getMyApplication();
@ -167,7 +168,7 @@ public class ConfigureMapMenu {
adapter.item(R.string.map_widget_day_night).description(activity.getMyApplication().getSettings().DAYNIGHT_MODE.get().toHumanString(activity)).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
bld.setTitle(R.string.daynight);
@ -192,7 +193,7 @@ public class ConfigureMapMenu {
int scale = (int)(activity.getMyApplication().getSettings().TEXT_SCALE.get() * 100);
adapter.item(R.string.text_size).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
// test old descr as title
@ -242,7 +243,7 @@ public class ConfigureMapMenu {
adapter.item(propertyName).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
pref.set(!pref.get());
refreshMapComplete(activity);
return false;
@ -255,7 +256,7 @@ public class ConfigureMapMenu {
adapter.item(propertyName).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
// test old descr as title
b.setTitle(propertyDescr);

View file

@ -56,6 +56,7 @@ import android.os.AsyncTask;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -584,7 +585,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.delete_point) {
for (int i = 0; i < measurementPoints.size(); i++) {
Iterator<WptPt> it = measurementPoints.get(i).iterator();

View file

@ -40,6 +40,7 @@ import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ExpandableListView;
@ -141,7 +142,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = adapter.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(adapter.getElementId(which), which, false);
clk.onContextMenuClick(null, adapter.getElementId(which), which, false);
}
}
@ -153,7 +154,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
private void basicFileOperation(final LocalIndexInfo info, ContextMenuAdapter adapter) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.local_index_mi_rename) {
renameFile(info);
} else if (resId == R.string.local_index_mi_restore) {
@ -471,7 +472,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
optionsMenuAdapter = new ContextMenuAdapter(getDownloadActivity());
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
localOptionsMenu(itemId);
return true;
}
@ -526,7 +527,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
int itemId = item.getItemId();
for (int i = 0; i < optionsMenuAdapter.length(); i++) {
if (itemId == optionsMenuAdapter.getElementId(i)) {
optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(itemId, i, false);
optionsMenuAdapter.getClickAdapter(i).onContextMenuClick(null, itemId, i, false);
return true;
}
}

View file

@ -7,6 +7,7 @@ import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.plus.*;
import net.osmand.plus.ContextMenuAdapter.Item;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
@ -520,7 +521,6 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
private void recalculatePoints(final int[] running, final ContextMenuAdapter menuAdapter, final int type, final ListView mDrawerList){
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
app.getWaypointHelper().recalculatePoints(type);
@ -539,15 +539,16 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
protected void registerPoints(final ContextMenuAdapter adapter, final Activity ctx, final ListView drawerList) {
final int[] running = new int[] { -1 };
for (int i = 0; i < WaypointHelper.MAX; i++) {
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
if (waypointHelper.isTypeVisible(i)) {
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
final boolean checked = waypointHelper.isTypeEnabled(i);
final int type = i;
adapter.item(getHeader(ctx, i, checked)).enabled(checked).layout(R.layout.drawer_list_poi_header).itemClickListen(new ContextMenuAdapter.OnContextMenuClick() {
adapter.item(getHeader(ctx, i, checked)).layout(R.layout.drawer_list_poi_header)
.listen(new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> ra, int itemId, int pos, boolean isChecked) {
running[0] = pos;
adapter.notifyDataSetChanged();
ra.notifyDataSetChanged();
if (type == WaypointHelper.POI && isChecked) {
selectPoi(running, adapter, type, isChecked, mapActivity, drawerList);
} else {
@ -557,71 +558,12 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
}
}).loading(0).reg();
if (i == WaypointHelper.POI && waypointHelper.isTypeEnabled(WaypointHelper.POI)){
adapter.item(ctx.getString(R.string.search_radius_proximity)).itemClickListen(new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, final int pos, boolean isChecked) {
int length = WaypointHelper.SEARCH_RADIUS_VALUES.length;
String[] names = new String[length];
int selected = 0;
for (int i = 0; i < length; i++) {
names[i] = OsmAndFormatter.getFormattedDistance(WaypointHelper.SEARCH_RADIUS_VALUES[i], app);
if (WaypointHelper.SEARCH_RADIUS_VALUES[i] == waypointHelper.getPoiSearchDeviationRadius()) {
selected = i;
}
}
new AlertDialog.Builder(ctx)
.setSingleChoiceItems(names, selected, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int value = WaypointHelper.SEARCH_RADIUS_VALUES[i];
if (waypointHelper.getPoiSearchDeviationRadius() != value) {
running[0] = pos;
adapter.notifyDataSetChanged();
waypointHelper.setPoiSearchDeviationRadius(value);
//radius.setText(OsmAndFormatter.getFormattedDistance(value, app));
recalculatePoints(running, adapter, WaypointHelper.POI, drawerList);
dialogInterface.dismiss();
}
}
}).setTitle(app.getString(R.string.search_radius_proximity) + " " + app.getString(R.string.poi))
.setNegativeButton(R.string.default_buttons_cancel, null)
.show();
return false;
}
}).loading(0).selected(app.getSettings().SHOW_POI_OVER_MAP.get() ? 1 : 0).reg();
} else if (i == WaypointHelper.FAVORITES && waypointHelper.isTypeEnabled(WaypointHelper.FAVORITES)){
adapter.item(ctx.getString(R.string.search_radius_proximity)).itemClickListen(new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, final int pos, boolean isChecked) {
int length = WaypointHelper.SEARCH_RADIUS_VALUES.length;
String[] names = new String[length];
int selected = 0;
for (int i = 0; i < length; i++) {
names[i] = OsmAndFormatter.getFormattedDistance(WaypointHelper.SEARCH_RADIUS_VALUES[i], app);
if (WaypointHelper.SEARCH_RADIUS_VALUES[i] == waypointHelper.getSearchDeviationRadius()){
selected = i;
}
}
new AlertDialog.Builder(ctx)
.setSingleChoiceItems(names, selected, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int value = WaypointHelper.SEARCH_RADIUS_VALUES[i];
if (waypointHelper.getSearchDeviationRadius() != value){
running[0] = pos;
waypointHelper.setSearchDeviationRadius(value);
//radius.setText(OsmAndFormatter.getFormattedDistance(value, app));
recalculatePoints(running, adapter, -1, drawerList);
dialogInterface.dismiss();
}
}
}).setTitle(app.getString(R.string.search_radius_proximity))
.setNegativeButton(R.string.default_buttons_cancel, null)
.show();
return false;
}
}).loading(0).selected(app.getSettings().SHOW_FAVORITES.get() ? 1 : 0).reg();
if (i == WaypointHelper.POI && checked) {
Item item = createRadiusProximityItem(adapter, ctx, drawerList, running, WaypointHelper.POI);
item.loading(0).selected(app.getSettings().SHOW_POI_OVER_MAP.get() ? 1 : 0).reg();
} else if (i == WaypointHelper.FAVORITES && checked) {
Item item = createRadiusProximityItem(adapter, ctx, drawerList, running, WaypointHelper.FAVORITES);
item.loading(0).selected(app.getSettings().SHOW_FAVORITES.get() ? 1 : 0).reg();
}
if (tp != null && tp.size() > 0) {
for (LocationPointWrapper p : tp) {
@ -631,7 +573,8 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
if (p.deviationDistance > 0) {
dd += "\n+" + OsmAndFormatter.getFormattedDistance(p.deviationDistance, app);
}
adapter.item(p.getPoint().getName(ctx)).icon(p.getDrawableId(ctx)).description(dd).layout(R.layout.drawer_list_waypoint).reg();
adapter.item(p.getPoint().getName(ctx)).icon(p.getDrawableId(ctx)).description(dd)
.layout(R.layout.drawer_list_waypoint).reg();
}
// points.addAll(tp);
}
@ -639,6 +582,41 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
}
}
protected Item createRadiusProximityItem(final ContextMenuAdapter adapter, final Activity ctx,
final ListView drawerList, final int[] running, final int type) {
return adapter.item(ctx.getString(R.string.search_radius_proximity)).listen(
new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> ra, int itemId, final int pos, boolean isChecked) {
int length = WaypointHelper.SEARCH_RADIUS_VALUES.length;
String[] names = new String[length];
int selected = 0;
for (int i = 0; i < length; i++) {
names[i] = OsmAndFormatter
.getFormattedDistance(WaypointHelper.SEARCH_RADIUS_VALUES[i], app);
if (WaypointHelper.SEARCH_RADIUS_VALUES[i] == waypointHelper.getSearchDeviationRadius(type)) {
selected = i;
}
}
new AlertDialog.Builder(ctx).setSingleChoiceItems(names, selected, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int value = WaypointHelper.SEARCH_RADIUS_VALUES[i];
if (waypointHelper.getSearchDeviationRadius(type) != value) {
running[0] = pos;
waypointHelper.setSearchDeviationRadius(value, type);
// radius.setText(OsmAndFormatter.getFormattedDistance(value, app));
recalculatePoints(running, adapter, -1, drawerList);
dialogInterface.dismiss();
}
}
}).setTitle(app.getString(R.string.search_radius_proximity))
.setNegativeButton(R.string.default_buttons_cancel, null).show();
return false;
}
});
}
private void enableType(final int[] running, final ContextMenuAdapter menuAdapter, final int type,
final boolean enable, final ListView drawerList) {
new AsyncTask<Void, Void, Void>() {
@ -653,11 +631,6 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
running[0] = -1;
menuAdapter.clearAll();
registerPoints(menuAdapter, mapActivity, drawerList);
// menuAdapter.clear();
// for (Object point : registerPoints()) {
// menuAdapter.add(point);
// }
// menuAdapter.notifyDataSetChanged();
}
}.execute((Void) null);
}

View file

@ -510,7 +510,7 @@ public class WaypointHelper {
PoiFilter pf = getPoiFilter();
if (pf != null) {
final List<Location> locs = route.getImmutableAllLocations();
List<Amenity> amenities = app.getResourceManager().searchAmenitiesOnThePath(locs, getPoiSearchDeviationRadius(),
List<Amenity> amenities = app.getResourceManager().searchAmenitiesOnThePath(locs, poiSearchDeviationRadius,
pf, new ResultMatcher<Amenity>() {
@Override
@ -575,7 +575,7 @@ public class WaypointHelper {
int[] ind = new int[1];
for(LocationPoint p : points) {
float dist = dist(p, immutableAllLocations, ind);
int rad = type == POI ? getPoiSearchDeviationRadius() : getSearchDeviationRadius();
int rad = getSearchDeviationRadius(type);
if(dist <= rad) {
LocationPointWrapper lpw = new LocationPointWrapper(rt, type, p, dist, ind[0]);
lpw.setAnnounce(announce);
@ -737,20 +737,16 @@ public class WaypointHelper {
}
public int getSearchDeviationRadius(){
return searchDeviationRadius;
public int getSearchDeviationRadius(int type){
return type == POI ? poiSearchDeviationRadius : searchDeviationRadius;
}
public void setSearchDeviationRadius(int radius){
public void setSearchDeviationRadius(int type, int radius){
if(type == POI) {
this.poiSearchDeviationRadius = radius;
} else {
this.searchDeviationRadius = radius;
}
public int getPoiSearchDeviationRadius() {
return poiSearchDeviationRadius;
}
public void setPoiSearchDeviationRadius(int radius) {
this.poiSearchDeviationRadius = radius;
}
private class AmenityLocationPoint implements LocationPoint {

View file

@ -38,6 +38,7 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
@ -115,7 +116,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
ContextMenuAdapter adapter, Object selectedObj) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_add_waypoint) {
mapActivity.getMapActions().addWaypoint(latitude, longitude);
}
@ -448,7 +449,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
int draw = !bgoff ? R.drawable.monitoring_rec_big : R.drawable.monitoring_rec_inactive;
qa.item(msgId).icon(draw).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (view.getApplication().getNavigationService() == null) {
final ValueHolder<Integer> vs = new ValueHolder<Integer>();
final ValueHolder<Boolean> choice = new ValueHolder<Boolean>();

View file

@ -43,6 +43,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Xml;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Toast;
@ -495,7 +496,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.osb_comment_menu_item) {
commentBug(bug);
} else if (itemId == R.string.osb_close_menu_item) {

View file

@ -30,6 +30,7 @@ import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
@ -122,7 +123,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
final Object selectedObj) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_create_poi) {
getPoiActions(mapActivity).showCreateDialog(latitude, longitude);
} else if (resId == R.string.context_menu_item_open_bug) {
@ -157,7 +158,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
.icons(R.drawable.ic_action_bug_dark, R.drawable.ic_action_bug_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_osm_bugs) {
settings.SHOW_OSM_BUGS.set(isChecked);
}
@ -180,7 +181,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
sendGPXFiles(la, (AvailableGPXFragment) fragment, (GpxInfo) info);
return true;
}
@ -197,7 +198,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
f.openSelectionMode(R.string.local_index_mi_upload_gpx, R.drawable.ic_action_gup_dark,
R.drawable.ic_action_gup_light, new OnClickListener() {
@Override

View file

@ -49,6 +49,7 @@ import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.view.View;
import android.widget.ArrayAdapter;
public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlServices, OsMoReactor {
@ -135,7 +136,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
R.drawable.ic_action_gloc_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
OsMoDevice o = (OsMoDevice) selectedObj;
double lat = o.getLastLocation() == null ? latitude : o.getLastLocation().getLatitude();
double lon = o.getLastLocation() == null ? longitude : o.getLastLocation().getLongitude();
@ -150,7 +151,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
R.drawable.ic_action_close_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
OsMoPositionLayer.setFollowDestination(null);
return true;
}
@ -161,7 +162,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
R.drawable.ic_action_flag_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
OsMoDevice o = (OsMoDevice) selectedObj;
if(o.getLastLocation() != null) {
TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
@ -292,7 +293,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
final double lat = view.getLatitude();
final double lon = view.getLongitude();
tracker.sendCoordinate(lat, lon);
@ -323,7 +324,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
helper.item(R.string.osmo_groups).icons(R.drawable.ic_action_eye_dark, R.drawable.ic_action_eye_light).position(6)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
Intent intent = new Intent(mapActivity, OsMoGroupsActivity.class);
mapActivity.startActivity(intent);
return true;

View file

@ -27,6 +27,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Paint;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.TextView;
@ -200,8 +201,8 @@ public class ParkingPositionPlugin extends OsmandPlugin {
if (selectedObj == parkingPosition && parkingPosition != null) {
OnContextMenuClick removeListener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos,
boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId,
int pos, boolean isChecked) {
if ((resId == R.string.context_menu_item_delete_parking_point)) {
showDeleteDialog(mapActivity);
}
@ -214,8 +215,8 @@ public class ParkingPositionPlugin extends OsmandPlugin {
OnContextMenuClick addListener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos,
boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId,
int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_add_parking_point) {
showAddParkingDialog(mapActivity, latitude, longitude);
}
@ -421,7 +422,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
helper.item(R.string.osmand_parking_delete)
.icons(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
showDeleteDialog(mapActivity);
return true;
}

View file

@ -185,7 +185,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
final MapActivityLayers layers = mapActivity.getMapLayers();
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_map) {
layers.selectMapLayer(mapView);
} else if(itemId == R.string.layer_overlay){
@ -225,7 +225,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
if (mapView.getMainLayer() instanceof MapTileLayer) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int resId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int resId, int pos, boolean isChecked) {
if (resId == R.string.context_menu_item_update_map) {
mapActivity.getMapActions().reloadTile(mapView.getZoom(), latitude, longitude);
} else if (resId == R.string.context_menu_item_download_map) {

View file

@ -3,6 +3,7 @@ package net.osmand.plus.routepointsnavigation;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.os.AsyncTask;
import android.widget.ArrayAdapter;
import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ContextMenuAdapter;
@ -74,7 +75,7 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
final GPXUtilities.WptPt point = (GPXUtilities.WptPt) o;
ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.mark_as_not_visited){
plugin.getCurrentRoute().markPoint(point,false);
plugin.saveCurrentRoute();

View file

@ -57,6 +57,7 @@ import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
@ -513,7 +514,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
adapter.item(R.string.show_waypoint_information).icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light ).position(0)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
showFavoriteDialog(mapActivity, selectedStage, sf);
return true;
}
@ -565,7 +566,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
R.drawable.ic_action_gremove_dark, R.drawable.ic_action_gremove_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
app.getSettings().SHOW_POI_OVER_MAP.set(false);
mapActivity.getMapLayers().updateLayers(mapActivity.getMapView());
return true;
@ -575,7 +576,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
adapter.item(R.string.poi).icons(R.drawable.ic_action_layers_dark, R.drawable.ic_action_layers_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
mapActivity.getMapLayers().selectPOIFilterLayer(mapActivity.getMapView(), null);
app.getSettings().SHOW_POI_OVER_MAP.set(true);
mapActivity.getMapLayers().updateLayers(mapActivity.getMapView());
@ -587,7 +588,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
adapter.item(R.string.sherpafy_tour_info_txt).icons(R.drawable.ic_action_info_dark, R.drawable.ic_action_info_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, TourViewActivity.class);
// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mapActivity.startActivity(newIntent);
@ -601,7 +602,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
.icons(R.drawable.ic_action_finish_flag_dark, R.drawable.ic_action_finish_flag_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
markStageAsCompleted(stage);
showCompleteStageFragment(mapActivity, stage, false);
return true;
@ -612,7 +613,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
adapter.item(R.string.context_menu_item_share_location).icons(
R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_light).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (app.getLocationProvider().getLastKnownLocation() != null) {
new ShareLocation(mapActivity).run();
} else {

View file

@ -1,5 +1,6 @@
package net.osmand.plus.srtmplugin;
import android.widget.ArrayAdapter;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
@ -94,7 +95,7 @@ public class SRTMPlugin extends OsmandPlugin {
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
OnContextMenuClick listener = new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.layer_hillshade) {
HILLSHADE.set(!HILLSHADE.get());
updateLayers(mapView, mapActivity);

View file

@ -22,6 +22,7 @@ import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PointF;
import android.widget.ArrayAdapter;
import android.widget.Toast;
public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider, MapTextProvider<LocationPoint> {
@ -198,7 +199,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
final FavouritePoint a = (FavouritePoint) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.favourites_context_menu_delete) {
final Resources resources = view.getContext().getResources();
Builder builder = new AlertDialog.Builder(view.getContext());

View file

@ -8,9 +8,11 @@ import java.util.Set;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.plus.routing.RoutingHelper;
@ -293,173 +295,80 @@ public class MapInfoLayer extends OsmandMapLayer {
recreateControls();
}
public Set<String> getSpecificVisibleCategories(Set<MapWidgetRegInfo> m) {
Set<String> s = new LinkedHashSet<String>();
for(MapWidgetRegInfo ms : m){
if(ms.getCategory() != null) {
s.add(ms.getCategory());
}
}
return s;
}
public void fillAppearanceWidgets(Set<MapWidgetRegInfo> widgets, String category, ArrayList<Object> registry) {
for(MapWidgetRegInfo w : widgets ) {
if(Algorithms.objectEquals(w.getCategory(), category)) {
registry.add(w);
}
}
}
public void openViewConfigureDrawer(ListView listView) {
public ContextMenuAdapter openViewConfigureDrawer() {
final OsmandSettings settings = view.getSettings();
final ArrayList<Object> list = new ArrayList<Object>();
list.add(map.getString(R.string.layer_map_appearance));
list.add(map.getString(R.string.map_widget_reset));
list.add(map.getString(R.string.map_widget_top));
list.addAll(mapInfoControls.getTop());
list.add(map.getString(R.string.map_widget_right));
list.addAll(mapInfoControls.getRight());
list.add(map.getString(R.string.map_widget_left));
list.addAll(mapInfoControls.getLeft());
Set<MapWidgetRegInfo> widgets = mapInfoControls.getAppearanceWidgets();
Set<String> cats = getSpecificVisibleCategories(widgets);
list.add(map.getString(R.string.map_widget_appearance_rem));
fillAppearanceWidgets(widgets, null, list);
for(String cat : cats) {
list.add(cat);
fillAppearanceWidgets(widgets, cat, list);
}
// final LayerMenuListener listener = new LayerMenuListener(adapter, mapView, settings);
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
final ArrayAdapter<Object> listAdapter = new ArrayAdapter<Object>(map, R.layout.layers_list_activity_item, R.id.title, list) {
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ApplicationMode mode = settings.getApplicationMode();
View v = convertView;
if (v == null) {
v = map.getLayoutInflater().inflate(R.layout.drawer_list_item, null);
}
final TextView tv = (TextView) v.findViewById(R.id.title);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
Object o = list.get(position);
if(o instanceof MapWidgetRegInfo) {
final MapWidgetRegInfo mi = (MapWidgetRegInfo) o;
String s = mi.visibleCollapsed(mode)? " - " : " ";
if(mi.message != null) {
tv.setText(s +mi.message +s);
} else {
tv.setText(s +map.getString(mi.messageId) +s);
}
int drawable = 0;
if (map.getMyApplication().getSettings().isLightContent()){
drawable = mi.drawableLight;
} else {
drawable = mi.drawableDark;
}
// Put the image on the TextView
if (drawable != 0) {
tv.setPadding((int) (12 *scaleCoefficient), 0, 0, 0);
tv.setCompoundDrawablesWithIntrinsicBounds(drawable, 0, 0, 0);
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
tv.setPadding((int) (30 *scaleCoefficient), 0, 0, 0);
}
final boolean selecteable = mi.selecteable();
ch.setOnCheckedChangeListener(null);
if(!mi.selecteable()) {
ch.setVisibility(View.GONE);
} else {
boolean check = mi.visibleCollapsed(mode) || mi.visible(mode);
ch.setChecked(check);
ch.setVisibility(View.VISIBLE);
}
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mapInfoControls.changeVisibility(mi);
if (selecteable) {
ch.setChecked(mi.visible(mode) || mi.visibleCollapsed(mode));
}
String s = mi.visibleCollapsed(mode) ? " - " : " ";
if(mi.message != null) {
tv.setText(s +mi.message +s);
} else {
tv.setText(s +map.getString(mi.messageId) +s);
}
recreateControls();
}
});
} else {
tv.setText(o.toString());
tv.setPadding((int) (5 *scaleCoefficient), 0, 0, 0);
// reset
if (position == 0) {
if (map.getMyApplication().getSettings().isLightContent()){
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_back_drawer_white, 0, 0, 0);
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_back_drawer_dark, 0, 0, 0);
}
} else if (position == 1) {
if (map.getMyApplication().getSettings().isLightContent()) {
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.widget_reset_to_default_light, 0, 0, 0);
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.widget_reset_to_default_dark, 0, 0, 0);
}
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
ch.setVisibility(View.INVISIBLE);
}
return v;
}
};
View confirmDialog = View.inflate(view.getContext(), R.layout.configuration_dialog, null);
AppModeDialog.prepareAppModeView(map, selected, true,
(ViewGroup) confirmDialog.findViewById(R.id.TopBar), true,
new View.OnClickListener() {
@Override
public void onClick(View v) {
if(selected.size() > 0) {
view.getSettings().APPLICATION_MODE.set(selected.iterator().next());
listAdapter.notifyDataSetChanged();
}
}
});
listView.setOnItemClickListener(new OnItemClickListener() {
ContextMenuAdapter cm = new ContextMenuAdapter(view.getContext());
cm.setDefaultLayoutId(R.layout.drawer_list_item);
cm.item(R.string.layer_map_appearance).icons(R.drawable.ic_back_drawer_dark, R.drawable.ic_back_drawer_white)
.listen(new OnContextMenuClick() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final ApplicationMode mode = settings.getApplicationMode();
Object o = list.get(position);
if (o instanceof MapWidgetRegInfo) {
final MapWidgetRegInfo mi = (MapWidgetRegInfo) o;
final boolean selecteable = mi.selecteable();
boolean check = mi.visibleCollapsed(mode) || mi.visible(mode);
if (check || selecteable) {
mapInfoControls.changeVisibility(mi);
}
recreateControls();
listAdapter.notifyDataSetInvalidated();
} else if(position == 0) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
map.getMapActions().prepareStartOptionsMenu();
} else if (position == 1) {
return false;
}
}).reg();
cm.item(R.string.map_widget_reset)
.icons(R.drawable.widget_reset_to_default_light, R.drawable.widget_reset_to_default_dark).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
mapInfoControls.resetToDefault();
recreateControls();
listAdapter.notifyDataSetInvalidated();
adapter.notifyDataSetInvalidated();
return false;
}
}).reg();
final ApplicationMode mode = settings.getApplicationMode();
cm.item(R.string.map_widget_top).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
addControls(cm, mapInfoControls.getTop(), mode);
cm.item(R.string.map_widget_right).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
addControls(cm, mapInfoControls.getRight(), mode);
cm.item(R.string.map_widget_left).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
addControls(cm, mapInfoControls.getLeft(), mode);
cm.item(R.string.map_widget_appearance_rem).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
addControls(cm, mapInfoControls.getAppearanceWidgets(), mode);
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
// TODO add profiles
// View confirmDialog = View.inflate(view.getContext(), R.layout.configuration_dialog, null);
// AppModeDialog.prepareAppModeView(map, selected, true,
// (ViewGroup) confirmDialog.findViewById(R.id.TopBar), true,
// new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if(selected.size() > 0) {
// view.getSettings().APPLICATION_MODE.set(selected.iterator().next());
// listAdapter.notifyDataSetChanged();
// }
// }
// });
return cm;
}
private void addControls(ContextMenuAdapter adapter, Set<MapWidgetRegInfo> top, final ApplicationMode mode) {
for(final MapWidgetRegInfo r : top){
// String s = mi.visibleCollapsed(mode)? " - " : " ";
// tv.setText(s +map.getString(mi.messageId) +s);
adapter.item(r.messageId)
.icons(r.drawableLight, r.drawableDark).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
final boolean selecteable = r.selecteable();
boolean check = r.visibleCollapsed(mode) || r.visible(mode);
if (check || selecteable) {
mapInfoControls.changeVisibility(r);
}
recreateControls();
adapter.notifyDataSetInvalidated();
return false;
}
}).reg();
}
});
listView.setAdapter(listAdapter);
}
private int themeId = -1;

View file

@ -81,7 +81,7 @@ public class MonitoringInfoControl {
ai.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ca.getClickAdapter(ij).onContextMenuClick(ca.getElementId(ij), ij, false);
ca.getClickAdapter(ij).onContextMenuClick(null, ca.getElementId(ij), ij, false);
qa.dismiss();
}
});

View file

@ -35,6 +35,7 @@ import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PointF;
import android.net.Uri;
import android.widget.ArrayAdapter;
import android.widget.Toast;
public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider,
@ -255,7 +256,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
final Amenity a = (Amenity) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.poi_context_menu_call) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);

View file

@ -20,6 +20,7 @@ import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.PointF;
import android.widget.ArrayAdapter;
public class PointNavigationLayer extends OsmandMapLayer implements IContextMenuProvider {
protected final static int DIST_TO_SHOW = 80;
@ -219,7 +220,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
final TargetPoint a = (TargetPoint) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.delete_target_point) {
TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper();
if(a.intermediate) {

View file

@ -20,6 +20,7 @@ import android.graphics.Paint;
import android.graphics.PointF;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.Toast;
public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
@ -215,7 +216,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
final TransportStop a = (TransportStop) o;
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
showDescriptionDialog(a);
return true;
}

View file

@ -1,13 +1,18 @@
package net.osmand.plus.views.mapwidgets;
import java.util.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
@ -76,30 +81,6 @@ public class MapWidgetRegistry {
return ii;
}
public void removeApperanceWidgets(String category) {
Iterator<MapWidgetRegInfo> it = appearanceWidgets.iterator();
while(it.hasNext()) {
if(Algorithms.objectEquals(it.next().category, category)) {
it.remove();
}
}
}
public MapWidgetRegInfo registerAppearanceWidget(int drawableDark,int drawableLight, String message, String key,
CommonPreference<?> pref, String subcategory) {
MapWidgetRegInfo ii = new MapWidgetRegInfo();
ii.key = key;
ii.category = subcategory;
ii.preference = pref;
ii.visibleModes = new LinkedHashSet<ApplicationMode>();
ii.visibleCollapsible = null;
ii.drawableDark = drawableDark;
ii.drawableLight = drawableLight;
ii.messageId = message.hashCode();
ii.message = message;
this.appearanceWidgets.add(ii);
return ii;
}
public MapWidgetRegInfo registerTopWidget(View m, int drawableDark,int drawableLight, int messageId, String key, int left, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo();
@ -318,10 +299,8 @@ public class MapWidgetRegistry {
public int drawableDark;
public int drawableLight;
public int messageId;
public String message;
private String key;
private int position;
private String category;
private Set<ApplicationMode> visibleModes;
private Set<ApplicationMode> visibleCollapsible;
private OsmandPreference<?> preference = null;
@ -336,10 +315,6 @@ public class MapWidgetRegistry {
return visibleCollapsible != null && preference == null;
}
public String getCategory() {
return category;
}
public boolean selecteable(){
return preference == null || (preference.get() instanceof Boolean);
}