Merge remote-tracking branch 'origin/master'
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB |
|
@ -1,47 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp">
|
||||
<ImageButton android:id="@+id/back"
|
||||
android:focusable="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
android:layout_marginRight="10dp"/>
|
||||
<ImageView android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginTop="10dp">
|
||||
<TextView android:id="@+id/name"
|
||||
android:textSize="16sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView android:id="@+id/descr"
|
||||
android:textSize="12sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox android:id="@+id/check"
|
||||
android:focusable="false"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/ProgressBar"
|
||||
android:layout_marginLeft="4dp"/>
|
||||
|
||||
<TextView android:id="@+id/header"
|
||||
android:text="@string/search_radius_proximity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<TextView android:id="@+id/radius"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/sherpafy_selection"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="8dp"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -4,8 +4,8 @@
|
|||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:layout_marginRight="3dp">
|
||||
<ProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -25,12 +25,4 @@
|
|||
android:textSize="20sp"/>
|
||||
|
||||
<include layout="@layout/check_item_rel"/>
|
||||
<ImageView
|
||||
android:id="@+id/sort"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginRight="8dp"/>
|
||||
</LinearLayout>
|
|
@ -9,8 +9,6 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="configure_map">Configure map</string>
|
||||
<string name="search_radius_proximity">In proximity of</string>
|
||||
<string name="osmo_device_not_found">Device not found</string>
|
||||
<string name="osmo_no_connection_msg">OsMo service is not available:\n- check the connection;\n- check the settings;\n- check out our Twitter: https://twitter.com/OsMomobi</string>
|
||||
<string name="anonymous_user_hint">An anonymous user can not:\n- create groups;\n- synchronize groups and devices with the server;\n- manage groups and devices in a private office.</string>
|
||||
|
|
|
@ -17,8 +17,8 @@ import android.widget.TextView;
|
|||
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, DialogInterface dialog);
|
||||
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog);
|
||||
}
|
||||
|
||||
private final Context ctx;
|
||||
|
|
|
@ -159,7 +159,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(final int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.local_index_mi_reload) {
|
||||
asyncLoader = new LoadGpxTask();
|
||||
asyncLoader.execute(getActivity());
|
||||
|
@ -175,7 +175,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
optionsMenuAdapter.item(R.string.show_gpx_route)
|
||||
|
@ -396,7 +395,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.local_index_mi_rename) {
|
||||
renameFile(info);
|
||||
} else if (resId == R.string.local_index_unselect_gpx_file ||
|
||||
|
@ -442,7 +441,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
AccessibleToast.makeText(getActivity(), R.string.gpx_file_is_empty, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if (info.gpx != null && info.file == null) {
|
||||
|
|
|
@ -176,9 +176,8 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
|||
new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
editPoint(point);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
Item delete = qa.item(R.string.favourites_context_menu_delete).icons(
|
||||
|
@ -187,9 +186,8 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
|||
new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
deletePoint(point);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
MapActivityActions.showObjectContextMenu(qa, getActivity(), onshow);
|
||||
|
|
|
@ -124,12 +124,11 @@ public class MapActivity extends AccessibleActivity {
|
|||
settings = app.getSettings();
|
||||
app.applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
|
||||
|
||||
mapActions = new MapActivityActions(this);
|
||||
mapLayers = new MapActivityLayers(this);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// Full screen is not used here
|
||||
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.main);
|
||||
|
@ -275,7 +274,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!mapActions.onBackPressed()) {
|
||||
if (!mapActions.onBackPressed()){
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,11 +47,9 @@ import net.osmand.plus.activities.actions.ShareLocation;
|
|||
import net.osmand.plus.activities.actions.StartGPSStatus;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.configuremap.ConfigureSettingsMenu;
|
||||
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.routing.RouteProvider.GPXRouteParamsBuilder;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.BaseMapLayer;
|
||||
|
@ -97,22 +95,17 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
DrawerLayout mDrawerLayout;
|
||||
ListView mDrawerList;
|
||||
private WaypointDialogHelper waypointDialogHelper;
|
||||
private ConfigureSettingsMenu configureSettingsMenu;
|
||||
|
||||
|
||||
public MapActivityActions(MapActivity mapActivity){
|
||||
this.mapActivity = mapActivity;
|
||||
settings = mapActivity.getMyApplication().getSettings();
|
||||
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
||||
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
|
||||
configureSettingsMenu = new ConfigureSettingsMenu(mapActivity.getMyApplication());
|
||||
waypointDialogHelper.init();
|
||||
}
|
||||
|
||||
protected void addFavouritePoint(final double latitude, final double longitude){
|
||||
String name = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObjectName();
|
||||
enhance(dialogBundle, latitude, longitude, name);
|
||||
enhance(dialogBundle,latitude,longitude, name);
|
||||
mapActivity.showDialog(DIALOG_ADD_FAVORITE);
|
||||
}
|
||||
|
||||
|
@ -209,7 +202,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
@Override
|
||||
public int compare(FavouritePoint o1, FavouritePoint o2) {
|
||||
if (distance && activity instanceof MapActivity) {
|
||||
if(distance && activity instanceof MapActivity) {
|
||||
float f1 = (float) MapUtils.getDistance(((MapActivity) activity).getMapLocation(), o1.getLatitude(),
|
||||
o1.getLongitude());
|
||||
float f2 = (float) MapUtils.getDistance(((MapActivity) activity).getMapLocation(), o2.getLatitude(),
|
||||
|
@ -441,6 +434,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
return dlg;
|
||||
}
|
||||
|
||||
|
||||
private static class SaveDirectionsAsyncTask extends AsyncTask<File, Void, String> {
|
||||
|
||||
private final OsmandApplication app;
|
||||
|
@ -752,11 +746,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
public void createOptionsMenuAsDrawer(boolean show){
|
||||
final ContextMenuAdapter cm = createOptionsMenu();
|
||||
if (mDrawerLayout == null){
|
||||
mDrawerLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout);
|
||||
mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||
}
|
||||
ListAdapter listAdapter;
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){
|
||||
listAdapter =
|
||||
|
@ -778,13 +770,10 @@ 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.getItemId(which), which, false, null)){
|
||||
mDrawerLayout.closeDrawer(mDrawerList);
|
||||
click.onContextMenuClick(cm.getItemId(which), which, false, null);
|
||||
}
|
||||
} else {
|
||||
mDrawerLayout.closeDrawer(mDrawerList);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (show){
|
||||
|
@ -830,13 +819,12 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (getMyApplication().accessibilityEnabled()) {
|
||||
whereAmIDialog();
|
||||
} else {
|
||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
|
@ -857,9 +845,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
optionsMenuHelper.item(t).icons(icon, iconLight)
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute());
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -868,9 +855,8 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
enterRoutePlanningMode(null, null, false);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
} else if(routingHelper.isRouteCalculated()) {
|
||||
|
@ -880,7 +866,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if(routingHelper.isRoutePlanningMode()) {
|
||||
routingHelper.setRoutePlanningMode(false);
|
||||
routingHelper.setFollowingMode(true);
|
||||
|
@ -891,7 +877,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||
mapActivity.refreshMap();
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -907,13 +892,12 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
stopNavigationActionConfirm(mapView);
|
||||
OsMoPositionLayer osMoPositionLayer = mapActivity.getMapView().getLayerByClass(OsMoPositionLayer.class);
|
||||
if (osMoPositionLayer != null) {
|
||||
OsMoPositionLayer.setFollowDestination(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -921,56 +905,46 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
|
||||
|
||||
final List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
ArrayAdapter<Object> adapter = waypointDialogHelper.getWaypointsAdapter(app.getMapActivity(), deletedPoints);
|
||||
mDrawerList.setAdapter(adapter);
|
||||
return false;
|
||||
WaypointDialogHelper.showWaypointsDialog(mapActivity);
|
||||
} else {
|
||||
openIntermediatePointsDialog();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
||||
// 5-9. Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
|
||||
optionsMenuHelper.item(R.string.configure_map).icons(R.drawable.ic_action_layers_dark, R.drawable.ic_action_layers_light)
|
||||
optionsMenuHelper.item(R.string.menu_layers).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, DialogInterface dialog) {
|
||||
configureSettingsMenu.setListView(mDrawerList);
|
||||
return false;
|
||||
//mapActivity.getMapLayers().openLayerSelectionDialog(mapView);
|
||||
//return true;
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
mapActivity.getMapLayers().openLayerSelectionDialog(mapView);
|
||||
}
|
||||
}).reg();
|
||||
|
||||
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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
mapActivity.getMapLayers().getMapInfoLayer().openViewConfigureDialog();
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
final Intent intentSettings = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSettingsActivity());
|
||||
mapActivity.startActivity(intentSettings);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
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();
|
||||
|
@ -978,26 +952,23 @@ public class MapActivityActions implements DialogProvider {
|
|||
newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getFavoritesActivity());
|
||||
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
//////////// Others
|
||||
|
@ -1006,9 +977,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
new StartGPSStatus(mapActivity).run();
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -1017,7 +987,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (MainMenuActivity.TIPS_AND_TRICKS) {
|
||||
TipsAndTricksActivity tactivity = new TipsAndTricksActivity(mapActivity);
|
||||
Dialog dlg = tactivity.getDialogToShowTips(false, true);
|
||||
|
@ -1026,7 +996,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
final Intent helpIntent = new Intent(mapActivity, HelpActivity.class);
|
||||
mapActivity.startActivity(helpIntent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
final OsmAndLocationProvider loc = app.getLocationProvider();
|
||||
|
@ -1038,11 +1007,10 @@ public class MapActivityActions implements DialogProvider {
|
|||
.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked,
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked,
|
||||
DialogInterface dialog) {
|
||||
// animate moving on route
|
||||
loc.getLocationSimulation().startStopRouteAnimation(mapActivity);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -1052,7 +1020,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
// 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);
|
||||
|
@ -1060,7 +1028,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
mapActivity.startActivity(newIntent);
|
||||
// In future when map will be main screen this should change
|
||||
// app.closeApplication(mapActivity);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
|
@ -1163,9 +1130,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
MapActivityActions.directionsToDialogAndLaunchMap(activity, location.getLatitude(), location.getLongitude(), name);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
Item intermediate;
|
||||
|
@ -1178,9 +1144,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
intermediate.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
addWaypointDialogAndLaunchMap(activity, location.getLatitude(), location.getLongitude(), name);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
|
@ -1190,11 +1155,10 @@ public class MapActivityActions implements DialogProvider {
|
|||
new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
app.getSettings().setMapLocationToShow(location.getLatitude(), location.getLongitude(), z, saveHistory ? name : null, name,
|
||||
obj); //$NON-NLS-1$
|
||||
MapActivity.launchMapActivityMoveToTop(activity);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
if (favorite) {
|
||||
|
@ -1203,13 +1167,13 @@ public class MapActivityActions implements DialogProvider {
|
|||
addToFavorite.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
Bundle args = new Bundle();
|
||||
Dialog dlg = createAddFavouriteDialog(activity, args);
|
||||
dlg.show();
|
||||
prepareAddFavouriteDialog(activity, dlg, args, location.getLatitude(), location.getLongitude(),
|
||||
name);
|
||||
return true;
|
||||
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ public class MapActivityLayers {
|
|||
adapter.item(R.string.layer_transport).selected( settings.SHOW_TRANSPORT_OVER_MAP.get() ? 1 : 0)
|
||||
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).reg();
|
||||
if(TransportRouteHelper.getInstance().routeIsCalculated()){
|
||||
adapter.item(R.string.layer_transport_route).selected(1)
|
||||
adapter.item(R.string.layer_transport_route).selected(1 )
|
||||
.icons(R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light).reg();
|
||||
}
|
||||
|
||||
|
@ -601,10 +601,6 @@ public class MapActivityLayers {
|
|||
return builder.show();
|
||||
}
|
||||
|
||||
public void setPoiFilter(PoiFilter f){
|
||||
poiMapLayer.setFilter(f);
|
||||
}
|
||||
|
||||
public void selectMapLayer(final OsmandMapTileView mapView){
|
||||
if(OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
||||
AccessibleToast.makeText(activity, R.string.map_online_plugin_is_not_installed, Toast.LENGTH_LONG).show();
|
||||
|
|
|
@ -188,14 +188,13 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.show_gpx_route) {
|
||||
OsmandSettings settings = app.getSettings();
|
||||
settings.setMapLocationToShow(gpxDisplayItem.locationStart.lat, gpxDisplayItem.locationStart.lon,
|
||||
settings.getLastKnownMapZoom(), Html.fromHtml(gpxDisplayItem.name).toString());
|
||||
MapActivity.launchMapActivityMoveToTop(getMyActivity());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if (gpxDisplayItem.locationStart != null) {
|
||||
|
|
|
@ -9,8 +9,6 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import android.os.Build;
|
||||
import android.preference.*;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -27,8 +25,14 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Toast;
|
||||
|
@ -42,7 +46,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
|
|||
|
||||
protected OsmandSettings settings;
|
||||
protected final boolean profileSettings ;
|
||||
protected List<ApplicationMode> modes = new ArrayList<ApplicationMode>();
|
||||
private List<ApplicationMode> modes = new ArrayList<ApplicationMode>();
|
||||
private ApplicationMode previousAppMode;
|
||||
|
||||
private Map<String, Preference> screenPreferences = new LinkedHashMap<String, Preference>();
|
||||
|
@ -70,23 +74,6 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
|
|||
return p;
|
||||
}
|
||||
|
||||
public CheckBoxPreference createCheckBoxPreference(OsmandPreference<Boolean> b, int title, int darkIcon, int lightIcon){
|
||||
CheckBoxPreference p = new CheckBoxPreference(this);
|
||||
p.setTitle(title);
|
||||
p.setKey(b.getId());
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
if (getMyApplication().getSettings().isLightContent()) {
|
||||
p.setIcon(lightIcon);
|
||||
} else {
|
||||
p.setIcon(darkIcon);
|
||||
}
|
||||
}
|
||||
screenPreferences.put(b.getId(), p);
|
||||
booleanPreferences.put(b.getId(), b);
|
||||
return p;
|
||||
}
|
||||
|
||||
public CheckBoxPreference createCheckBoxPreference(OsmandPreference<Boolean> b, int title, int summary) {
|
||||
CheckBoxPreference p = new CheckBoxPreference(this);
|
||||
p.setTitle(title);
|
||||
|
|
|
@ -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, DialogInterface dlg) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dlg) {
|
||||
// Build text(amenity)
|
||||
|
||||
// Find and format links
|
||||
|
@ -598,7 +598,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
TextView textView = (TextView) dialog.findViewById(android.R.id.message);
|
||||
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
textView.setLinksClickable(true);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -607,9 +606,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
showDetails.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dlg) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dlg) {
|
||||
showPOIDetails(amenity, settings.usingEnglishNames());
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
|
|
@ -118,14 +118,13 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.recording_context_menu_play ||
|
||||
itemId == R.string.recording_context_menu_show) {
|
||||
plugin.playRecording(view.getContext(), r);
|
||||
} else if (itemId == R.string.recording_context_menu_delete) {
|
||||
deleteRecording(r);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -414,13 +414,12 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.layer_recordings) {
|
||||
dialog.dismiss();
|
||||
SHOW_RECORDINGS.set(!SHOW_RECORDINGS.get());
|
||||
updateLayers(mapView, mapActivity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.layer_recordings).selected(SHOW_RECORDINGS.get() ? 1 : 0)
|
||||
|
@ -434,26 +433,23 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
recordAudio(latitude, longitude, mapActivity);
|
||||
return true;
|
||||
}
|
||||
}).position(6).reg();
|
||||
adapter.item(R.string.recording_context_menu_vrecord).icons(R.drawable.ic_action_video_dark, R.drawable.ic_action_video_light)
|
||||
.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
recordVideo(latitude, longitude, mapActivity);
|
||||
return true;
|
||||
}
|
||||
}).position(7).reg();
|
||||
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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
takePhoto(latitude, longitude, mapActivity);
|
||||
return true;
|
||||
}
|
||||
|
||||
}).position(8).reg();
|
||||
|
@ -1105,9 +1101,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
final RecordingLocalIndexInfo ri = (RecordingLocalIndexInfo) info;
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
playRecording(la, ri.rec);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if (ri.rec.isPhoto()) {
|
||||
|
@ -1123,13 +1118,13 @@ 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 void onContextMenuClick(int itemId, int pos, boolean isChecked,
|
||||
DialogInterface dialog) {
|
||||
SHOW_RECORDINGS.set(true);
|
||||
app.getSettings().setMapLocationToShow(ri.rec.lat, ri.rec.lon,
|
||||
app.getSettings().getLastKnownMapZoom());
|
||||
MapActivity.launchMapActivityMoveToTop(la);
|
||||
return true;
|
||||
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
|
|
@ -1,527 +0,0 @@
|
|||
package net.osmand.plus.configuremap;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.preference.*;
|
||||
import android.util.TypedValue;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.AmenityType;
|
||||
import net.osmand.plus.*;
|
||||
import net.osmand.plus.activities.*;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.views.mapwidgets.AppearanceWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||
import net.osmand.render.RenderingRuleProperty;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Denis on 14.10.2014.
|
||||
*/
|
||||
public class ConfigureSettingsMenu {
|
||||
|
||||
public static final int BACK_HEADER = 0;
|
||||
public static final int HEADER = 1;
|
||||
public static final int LAYER = 2;
|
||||
public static final int MAP_REDNDER = 3;
|
||||
public static final int RENDERING_PROPERTY = 4;
|
||||
|
||||
|
||||
private ListView listView;
|
||||
private OsmandApplication app;
|
||||
List<ConfigureMapMenuItem> items = new ArrayList<ConfigureMapMenuItem>();
|
||||
|
||||
public class ConfigureMapMenuItem {
|
||||
int nameId;
|
||||
int type;
|
||||
int darkIcon = -1;
|
||||
int lightIcon = -1;
|
||||
Object preference;
|
||||
|
||||
|
||||
ConfigureMapMenuItem(int type, int name, int darkIcon, int whiteIcon, Object preference) {
|
||||
this.type = type;
|
||||
this.nameId = name;
|
||||
this.darkIcon = darkIcon;
|
||||
this.lightIcon = whiteIcon;
|
||||
this.preference = preference;
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigureSettingsMenu(OsmandApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public void setListView(ListView list) {
|
||||
this.listView = list;
|
||||
listView.setAdapter(createSettingsAdapter());
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
|
||||
onMenuItemClick(items.get(pos), (CheckBox) view.findViewById(R.id.check));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//checkBox should be set only if u have checkBox preference
|
||||
private void onMenuItemClick(ConfigureMapMenuItem item, CheckBox ch) {
|
||||
if (item.type == BACK_HEADER){
|
||||
app.getMapActivity().getMapActions().createOptionsMenuAsDrawer(false);
|
||||
} else if (item.type == LAYER) {
|
||||
if (ch != null){
|
||||
ch.setChecked(!ch.isChecked());
|
||||
}
|
||||
|
||||
if (item.nameId == R.string.layer_poi) {
|
||||
final OsmandSettings.OsmandPreference<Boolean> pref = (OsmandSettings.OsmandPreference<Boolean>) item.preference;
|
||||
boolean value = !pref.get();
|
||||
if (value) {
|
||||
selectPOIFilterLayer(null);
|
||||
}
|
||||
pref.set(!pref.get());
|
||||
} else if (item.nameId == R.string.layer_gpx_layer) {
|
||||
if(app.getSelectedGpxHelper().isShowingAnyGpxFiles()){
|
||||
app.getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
} else {
|
||||
showGPXFileDialog(null);
|
||||
}
|
||||
} else {
|
||||
final OsmandSettings.OsmandPreference<Boolean> pref = (OsmandSettings.OsmandPreference<Boolean>) item.preference;
|
||||
pref.set(!pref.get());
|
||||
}
|
||||
} else if (item.type == MAP_REDNDER) {
|
||||
if (item.nameId == R.string.map_widget_renderer) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(app.getMapActivity());
|
||||
bld.setTitle(R.string.renderers);
|
||||
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
|
||||
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
|
||||
final String[] visibleNames = new String[items.length];
|
||||
int selected = -1;
|
||||
final String selectedName = app.getRendererRegistry().getCurrentSelectedRenderer().getName();
|
||||
for (int j = 0; j < items.length; j++) {
|
||||
if (items[j].equals(selectedName)) {
|
||||
selected = j;
|
||||
}
|
||||
visibleNames[j] = items[j].replace('_', ' ').replace(
|
||||
'-', ' ');
|
||||
}
|
||||
bld.setSingleChoiceItems(visibleNames, selected, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String renderer = items[which];
|
||||
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
|
||||
if (loaded != null) {
|
||||
app.getSettings().RENDERER.set(renderer);
|
||||
app.getRendererRegistry().setCurrentSelectedRender(loaded);
|
||||
app.getResourceManager().getRenderer().clearCache();
|
||||
listView.setAdapter(createSettingsAdapter());
|
||||
} else {
|
||||
AccessibleToast.makeText(app, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
dialog.dismiss();
|
||||
createSettingsAdapter();
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
} else if (item.nameId == R.string.map_widget_day_night) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(app.getMapActivity());
|
||||
bld.setTitle(R.string.daynight);
|
||||
final String[] items = new String[OsmandSettings.DayNightMode.values().length];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(app);
|
||||
}
|
||||
int i = app.getSettings().DAYNIGHT_MODE.get().ordinal();
|
||||
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
app.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
|
||||
app.getResourceManager().getRenderer().clearCache();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
}
|
||||
} else if (item.type == RENDERING_PROPERTY) {
|
||||
if (ch != null){
|
||||
ch.setChecked(!ch.isChecked());
|
||||
}
|
||||
final RenderingRuleProperty p = (RenderingRuleProperty) item.preference;
|
||||
final String propertyDescription = SettingsActivity.getStringPropertyDescription(app, p.getAttrName(), p.getName());
|
||||
if (p.isBoolean()) {
|
||||
final OsmandSettings.CommonPreference<Boolean> pref = app.getSettings().getCustomRenderBooleanProperty(p.getAttrName());
|
||||
pref.set(!pref.get());
|
||||
app.getResourceManager().getRenderer().clearCache();
|
||||
} else {
|
||||
final OsmandSettings.CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(p.getAttrName());
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(app.getMapActivity());
|
||||
//test old descr as title
|
||||
b.setTitle(propertyDescription);
|
||||
|
||||
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
|
||||
|
||||
String[] possibleValuesString = new String[p.getPossibleValues().length];
|
||||
|
||||
for (int j = 0; j < p.getPossibleValues().length; j++) {
|
||||
possibleValuesString[j] = SettingsActivity.getStringPropertyValue(app, p.getPossibleValues()[j]);
|
||||
}
|
||||
|
||||
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
pref.set(p.getPossibleValues()[which]);
|
||||
app.getResourceManager().getRenderer().clearCache();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
b.show();
|
||||
|
||||
}
|
||||
}
|
||||
app.getMapActivity().getMapLayers().updateLayers(app.getMapActivity().getMapView());
|
||||
app.getMapActivity().getMapView().refreshMap();
|
||||
}
|
||||
|
||||
private ArrayAdapter<ConfigureMapMenuItem> createSettingsAdapter() {
|
||||
items.clear();
|
||||
items.add(new ConfigureMapMenuItem(BACK_HEADER, R.string.configure_map, R.drawable.ic_back_drawer_dark, R.drawable.ic_back_drawer_white, null));
|
||||
createLayersItems(items);
|
||||
createRenderingAttributeItems(items);
|
||||
return new ArrayAdapter<ConfigureMapMenuItem>(app, R.layout.map_settings_item, items) {
|
||||
@Override
|
||||
public View getView(int position,View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = app.getMapActivity().getLayoutInflater().inflate(R.layout.map_settings_item, null);
|
||||
}
|
||||
final ConfigureMapMenuItem item = getItem(position);
|
||||
prepareView(convertView, item);
|
||||
if (item.type == BACK_HEADER) {
|
||||
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
|
||||
ImageButton button = (ImageButton) convertView.findViewById(R.id.back);
|
||||
button.setImageResource(getIcon(item));
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
app.getMapActivity().getMapActions().createOptionsMenuAsDrawer(false);
|
||||
}
|
||||
});
|
||||
} else if (item.type == HEADER) {
|
||||
((TextView) convertView.findViewById(R.id.name)).setText((String) item.preference);
|
||||
} else if (item.type == LAYER) {
|
||||
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
|
||||
final CheckBox ch = (CheckBox) convertView.findViewById(R.id.check);
|
||||
ch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onMenuItemClick(item, null);
|
||||
}
|
||||
});
|
||||
if (item.nameId == R.string.layer_gpx_layer){
|
||||
ch.setChecked(app.getSelectedGpxHelper().isShowingAnyGpxFiles());
|
||||
} else {
|
||||
OsmandSettings.OsmandPreference<Boolean> pref = (OsmandSettings.OsmandPreference<Boolean>) item.preference;
|
||||
ch.setChecked(pref.get());
|
||||
}
|
||||
} else if (item.type == MAP_REDNDER) {
|
||||
((TextView) convertView.findViewById(R.id.name)).setText(item.nameId);
|
||||
if (item.nameId == R.string.map_widget_renderer) {
|
||||
((TextView) convertView.findViewById(R.id.descr)).setText(app.getSettings().RENDERER.get());
|
||||
} else if (item.nameId == R.string.map_widget_day_night) {
|
||||
((TextView) convertView.findViewById(R.id.descr)).setText(app.getSettings().DAYNIGHT_MODE.get().toHumanString(app));
|
||||
}
|
||||
} else if (item.type == RENDERING_PROPERTY) {
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
final RenderingRuleProperty p = (RenderingRuleProperty) item.preference;
|
||||
String propertyName = SettingsActivity.getStringPropertyName(app, p.getAttrName(), p.getName());
|
||||
TextView header = (TextView) convertView.findViewById(R.id.name);
|
||||
header.setText(propertyName);
|
||||
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
final String propertyDescription = SettingsActivity.getStringPropertyDescription(app, p.getAttrName(), p.getName());
|
||||
if (p.isBoolean()) {
|
||||
OsmandSettings.CommonPreference<Boolean> pref = app.getSettings().getCustomRenderBooleanProperty(p.getAttrName());
|
||||
final CheckBox ch = (CheckBox) convertView.findViewById(R.id.check);
|
||||
ch.setChecked(pref.get());
|
||||
ch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onMenuItemClick(item, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
//Hiding and showing items based on current item
|
||||
//setting proper visual property
|
||||
private void prepareView(View convertView, ConfigureMapMenuItem item) {
|
||||
((TextView) convertView.findViewById(R.id.descr)).setTypeface(null, Typeface.ITALIC);
|
||||
|
||||
int type = item.type;
|
||||
//setting name textview
|
||||
if (type == BACK_HEADER) {
|
||||
TextView header = (TextView) convertView.findViewById(R.id.name);
|
||||
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
|
||||
header.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
} else if (type == HEADER) {
|
||||
TextView header = (TextView) convertView.findViewById(R.id.name);
|
||||
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
|
||||
header.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
} else {
|
||||
TextView header = ((TextView) convertView.findViewById(R.id.name));
|
||||
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
header.setTypeface(Typeface.DEFAULT);
|
||||
|
||||
}
|
||||
|
||||
//setting backbutton
|
||||
if (type == BACK_HEADER) {
|
||||
convertView.findViewById(R.id.back).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
convertView.findViewById(R.id.back).setVisibility(View.GONE);
|
||||
}
|
||||
//other elements
|
||||
if (type == BACK_HEADER) {
|
||||
convertView.findViewById(R.id.check).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.descr).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
} else if (type == HEADER) {
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.check).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.descr).setVisibility(View.GONE);
|
||||
} else if (type == LAYER) {
|
||||
((ImageView) convertView.findViewById(R.id.icon)).setImageResource(getIcon(item));
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
|
||||
convertView.findViewById(R.id.check).setVisibility(View.VISIBLE);
|
||||
} else if (type == MAP_REDNDER) {
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.check).setVisibility(View.GONE);
|
||||
convertView.findViewById(R.id.descr).setVisibility(View.VISIBLE);
|
||||
} else if (type == RENDERING_PROPERTY) {
|
||||
final RenderingRuleProperty p = (RenderingRuleProperty) item.preference;
|
||||
if (p.isBoolean()) {
|
||||
convertView.findViewById(R.id.check).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
convertView.findViewById(R.id.check).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private int getIcon(ConfigureMapMenuItem item) {
|
||||
if (app.getSettings().isLightContent()) {
|
||||
return item.lightIcon;
|
||||
} else {
|
||||
return item.darkIcon;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private void createLayersItems(List<ConfigureMapMenuItem> items) {
|
||||
items.add(new ConfigureMapMenuItem(HEADER, -1, -1, -1, "Show:"));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_poi, R.drawable.ic_action_info_dark,
|
||||
R.drawable.ic_action_info_light, app.getSettings().SHOW_POI_OVER_MAP));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_amenity_label, R.drawable.ic_action_text_dark,
|
||||
R.drawable.ic_action_text_light, app.getSettings().SHOW_POI_LABEL));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_favorites, R.drawable.ic_action_fav_dark,
|
||||
R.drawable.ic_action_fav_light, app.getSettings().SHOW_FAVORITES));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_gpx_layer, R.drawable.ic_action_polygom_dark,
|
||||
R.drawable.ic_action_polygom_light, null));
|
||||
items.add(new ConfigureMapMenuItem(LAYER, R.string.layer_transport, R.drawable.ic_action_bus_dark,
|
||||
R.drawable.ic_action_bus_light, app.getSettings().SHOW_TRANSPORT_OVER_MAP));
|
||||
if (TransportRouteHelper.getInstance().routeIsCalculated()) {
|
||||
items.add(new ConfigureMapMenuItem(R.string.layer_transport, LAYER,
|
||||
R.drawable.ic_action_bus_dark, R.drawable.ic_action_bus_light, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void createRenderingAttributeItems(List<ConfigureMapMenuItem> items) {
|
||||
items.add(new ConfigureMapMenuItem(HEADER, -1, -1, -1, app.getString(R.string.map_widget_map_rendering)));
|
||||
items.add(new ConfigureMapMenuItem(MAP_REDNDER, R.string.map_widget_renderer, -1, -1, null));
|
||||
items.add(new ConfigureMapMenuItem(MAP_REDNDER, R.string.map_widget_day_night, -1, -1, null));
|
||||
|
||||
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
if (renderer != null && AppearanceWidgetsFactory.EXTRA_SETTINGS) {
|
||||
createMapRenderingPreferences(items);
|
||||
}
|
||||
}
|
||||
|
||||
private void createMapRenderingPreferences(List<ConfigureMapMenuItem> items) {
|
||||
items.add(new ConfigureMapMenuItem(HEADER, -1, -1, -1, app.getString(R.string.map_widget_vector_attributes)));
|
||||
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
List<RenderingRuleProperty> customRules = renderer.PROPS.getCustomRules();
|
||||
for (RenderingRuleProperty p : customRules) {
|
||||
items.add(new ConfigureMapMenuItem(RENDERING_PROPERTY, -1, -1, -1, p));
|
||||
}
|
||||
}
|
||||
|
||||
public AlertDialog selectPOIFilterLayer(final PoiFilter[] selected) {
|
||||
final List<PoiFilter> userDefined = new ArrayList<PoiFilter>();
|
||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(app.getMapActivity());
|
||||
|
||||
ContextMenuAdapter.Item is = adapter.item(app.getString(R.string.any_poi));
|
||||
if (RenderingIcons.containsBigIcon("null")) {
|
||||
is.icon(RenderingIcons.getBigIconResourceId("null"));
|
||||
}
|
||||
is.reg();
|
||||
// 2nd custom
|
||||
adapter.item(app.getString(R.string.poi_filter_custom_filter)).icon(RenderingIcons.getBigIconResourceId("user_defined")).reg();
|
||||
|
||||
for (PoiFilter f : poiFilters.getUserDefinedPoiFilters()) {
|
||||
ContextMenuAdapter.Item it = adapter.item(f.getName());
|
||||
if (RenderingIcons.containsBigIcon(f.getSimplifiedId())) {
|
||||
it.icon(RenderingIcons.getBigIconResourceId(f.getSimplifiedId()));
|
||||
} else {
|
||||
it.icon(RenderingIcons.getBigIconResourceId("user_defined"));
|
||||
}
|
||||
it.reg();
|
||||
userDefined.add(f);
|
||||
}
|
||||
final AmenityType[] categories = AmenityType.getCategories();
|
||||
for (AmenityType t : categories) {
|
||||
ContextMenuAdapter.Item it = adapter.item(OsmAndFormatter.toPublicString(t, app));
|
||||
if (RenderingIcons.containsBigIcon(t.toString().toLowerCase())) {
|
||||
it.icon(RenderingIcons.getBigIconResourceId(t.toString().toLowerCase()));
|
||||
}
|
||||
it.reg();
|
||||
}
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(app.getMapActivity());
|
||||
final ListAdapter listAdapter;
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||
listAdapter =
|
||||
adapter.createListAdapter(app.getMapActivity(), R.layout.list_menu_item, app.getSettings().isLightContentMenu());
|
||||
} else {
|
||||
listAdapter =
|
||||
adapter.createListAdapter(app.getMapActivity(), R.layout.list_menu_item_native, app.getSettings().isLightContentMenu());
|
||||
}
|
||||
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == 1) {
|
||||
String filterId = PoiFilter.CUSTOM_FILTER_ID;
|
||||
app.getSettings().setPoiFilterForMap(filterId);
|
||||
Intent newIntent = new Intent(app, EditPOIFilterActivity.class);
|
||||
newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, filterId);
|
||||
newIntent.putExtra(EditPOIFilterActivity.SEARCH_LAT, app.getMapActivity().getMapView().getLatitude());
|
||||
newIntent.putExtra(EditPOIFilterActivity.SEARCH_LON, app.getMapActivity().getMapView().getLongitude());
|
||||
app.getMapActivity().startActivity(newIntent);
|
||||
} else {
|
||||
String filterId;
|
||||
if (which == 0) {
|
||||
filterId = PoiFiltersHelper.getOsmDefinedFilterId(null);
|
||||
} else if (which <= userDefined.size() + 1) {
|
||||
filterId = userDefined.get(which - 2).getFilterId();
|
||||
} else {
|
||||
filterId = PoiFiltersHelper.getOsmDefinedFilterId(categories[which - userDefined.size() - 2]);
|
||||
}
|
||||
app.getSettings().setPoiFilterForMap(filterId);
|
||||
PoiFilter f = poiFilters.getFilterById(filterId);
|
||||
if (f != null) {
|
||||
f.clearNameFilter();
|
||||
}
|
||||
app.getMapActivity().getMapLayers().setPoiFilter(f);
|
||||
app.getMapActivity().getMapView().refreshMap();
|
||||
if (selected != null && selected.length > 0) {
|
||||
selected[0] = f;
|
||||
}
|
||||
listView.setAdapter(createSettingsAdapter());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent event) {
|
||||
if (i == KeyEvent.KEYCODE_BACK &&
|
||||
event.getAction() == KeyEvent.ACTION_UP &&
|
||||
!event.isCanceled()) {
|
||||
dialogInterface.cancel();
|
||||
app.getSettings().SHOW_POI_OVER_MAP.set(false);
|
||||
listView.setAdapter(createSettingsAdapter());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return builder.show();
|
||||
}
|
||||
|
||||
public void showGPXFileDialog(List<String> files) {
|
||||
CallbackWithObject<GPXUtilities.GPXFile[]> callbackWithObject = new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||
@Override
|
||||
public boolean processResult(GPXUtilities.GPXFile[] result) {
|
||||
GPXUtilities.WptPt locToShow = null;
|
||||
for (GPXUtilities.GPXFile g : result) {
|
||||
if (g.showCurrentTrack) {
|
||||
if (!app.getSettings().SAVE_TRACK_TO_GPX.get() && !
|
||||
app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
||||
AccessibleToast.makeText(app.getMapActivity(), R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!g.showCurrentTrack || locToShow == null) {
|
||||
locToShow = g.findPointToShow();
|
||||
}
|
||||
}
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(result);
|
||||
listView.setAdapter(createSettingsAdapter());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
AlertDialog dialog;
|
||||
if (files == null) {
|
||||
dialog = GpxUiHelper.selectGPXFile(app.getMapActivity(), true, true, callbackWithObject);
|
||||
} else {
|
||||
dialog = GpxUiHelper.selectGPXFile(files, app.getMapActivity(), true, true, callbackWithObject);
|
||||
}
|
||||
if (dialog != null) {
|
||||
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent event) {
|
||||
if (i == KeyEvent.KEYCODE_BACK &&
|
||||
event.getAction() == KeyEvent.ACTION_UP &&
|
||||
!event.isCanceled()) {
|
||||
dialogInterface.cancel();
|
||||
listView.setAdapter(createSettingsAdapter());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getAlreadySelectedGpx() {
|
||||
GpxSelectionHelper gpxSelectionHelper = app.getSelectedGpxHelper();
|
||||
if (gpxSelectionHelper == null) {
|
||||
return null;
|
||||
}
|
||||
List<GpxSelectionHelper.SelectedGpxFile> selectedGpxFiles = gpxSelectionHelper.getSelectedGPXFiles();
|
||||
List<String> files = new ArrayList<String>();
|
||||
for (GpxSelectionHelper.SelectedGpxFile file : selectedGpxFiles) {
|
||||
files.add(file.getGpxFile().path);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
}
|
|
@ -584,7 +584,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.delete_point) {
|
||||
for (int i = 0; i < measurementPoints.size(); i++) {
|
||||
Iterator<WptPt> it = measurementPoints.get(i).iterator();
|
||||
|
@ -596,7 +596,6 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
}
|
||||
calculateDistance();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.delete_point).icons(R.drawable.ic_action_delete_dark,
|
||||
|
|
|
@ -158,7 +158,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.local_index_mi_rename) {
|
||||
renameFile(info);
|
||||
} else if (resId == R.string.local_index_mi_restore) {
|
||||
|
@ -177,7 +177,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
} else if (resId == R.string.local_index_mi_backup) {
|
||||
new LocalIndexOperationTask(BACKUP_OPERATION).execute(info);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if(info.getType() == LocalIndexType.MAP_DATA || info.getType() == LocalIndexType.SRTM_DATA){
|
||||
|
@ -476,9 +475,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
|||
optionsMenuAdapter = new ContextMenuAdapter(getDownloadActivity());
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
localOptionsMenu(itemId);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
optionsMenuAdapter.item(R.string.local_index_mi_reload)
|
||||
|
|
|
@ -128,7 +128,7 @@ public class GpxUiHelper {
|
|||
return description.toString();
|
||||
}
|
||||
|
||||
public static AlertDialog selectGPXFile(List<String> selectedGpxList, final Activity activity,
|
||||
public static void selectGPXFile(List<String> selectedGpxList, final Activity activity,
|
||||
final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject<GPXFile[]> callbackWithObject){
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
|
@ -142,12 +142,11 @@ public class GpxUiHelper {
|
|||
allGpxList.add(0, activity.getString(R.string.show_current_gpx_title));
|
||||
}
|
||||
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity,allGpxList, selectedGpxList, multipleChoice);
|
||||
return createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, allGpxList, adapter);
|
||||
createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, allGpxList, adapter);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AlertDialog selectGPXFile(final Activity activity,
|
||||
public static void selectGPXFile(final Activity activity,
|
||||
final boolean showCurrentGpx, final boolean multipleChoice, final CallbackWithObject<GPXFile[]> callbackWithObject) {
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
|
@ -161,9 +160,8 @@ public class GpxUiHelper {
|
|||
}
|
||||
|
||||
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, list, null, multipleChoice);
|
||||
return createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, list, adapter);
|
||||
createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, list, adapter);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ContextMenuAdapter createGpxContextMenuAdapter(Activity activity, List<String> allGpxList, List<String> selectedGpxList, boolean multipleChoice) {
|
||||
|
@ -209,7 +207,7 @@ public class GpxUiHelper {
|
|||
}, dir, null, filename);
|
||||
}
|
||||
|
||||
private static AlertDialog createDialog(final Activity activity, final boolean showCurrentGpx,
|
||||
private static void createDialog(final Activity activity, final boolean showCurrentGpx,
|
||||
final boolean multipleChoice, final CallbackWithObject<GPXFile[]> callbackWithObject,
|
||||
final List<String> list, final ContextMenuAdapter adapter) {
|
||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
|
@ -338,7 +336,6 @@ public class GpxUiHelper {
|
|||
// java.lang.ClassCastException: com.android.internal.widget.RoundCornerListAdapter
|
||||
// Unknown reason but on some devices fail
|
||||
}
|
||||
return dlg;
|
||||
}
|
||||
|
||||
private static List<String> getSortedGPXFilenames(File dir,String sub) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.helpers;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.widget.*;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -12,7 +13,6 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.PoiFilter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.IntermediatePointsDialog;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
|
@ -44,9 +44,6 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
private LinearLayout mainLayout;
|
||||
private WaypointHelper waypointHelper;
|
||||
|
||||
private final static String POI_RADIUS = "poi_radius";
|
||||
private final static String SEARCH_RADIUS = "favorite_radius";
|
||||
|
||||
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
||||
private View closePointDialog;
|
||||
private List<LocationPointWrapper> many = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
|
@ -194,16 +191,14 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
public static void showWaypointsDialogFlat(FragmentActivity fragmentActivity) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(WaypointDialogFragment.FLAT_ARG, true);
|
||||
//TODO remove this method totally
|
||||
WaypointDialogFragment wdf = new WaypointDialogFragment(new WaypointDialogHelper(null));
|
||||
WaypointDialogFragment wdf = new WaypointDialogFragment();
|
||||
wdf.setArguments(args);
|
||||
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
||||
}
|
||||
|
||||
public static void showWaypointsDialog(FragmentActivity fragmentActivity) {
|
||||
Bundle args = new Bundle();
|
||||
//TODO remove this method totally
|
||||
WaypointDialogFragment wdf = new WaypointDialogFragment(new WaypointDialogHelper(null));
|
||||
WaypointDialogFragment wdf = new WaypointDialogFragment();
|
||||
wdf.setArguments(args);
|
||||
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
||||
}
|
||||
|
@ -212,14 +207,9 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
|
||||
WaypointHelper waypointHelper;
|
||||
private OsmandApplication app;
|
||||
private WaypointDialogHelper dialogHelper;
|
||||
|
||||
public static final String FLAT_ARG = "FLAT_ARG";
|
||||
|
||||
public WaypointDialogFragment(WaypointDialogHelper helper){
|
||||
this.dialogHelper = helper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
@ -229,8 +219,81 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
if (getArguments() != null && getArguments().getBoolean(FLAT_ARG)) {
|
||||
return createWaypointsDialogFlat(waypointHelper.getAllPoints());
|
||||
}
|
||||
return createWaypointsDialog();
|
||||
}
|
||||
|
||||
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||
final boolean enable) {
|
||||
if (getActivity() instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
|
||||
MapActivity map = (MapActivity) getActivity();
|
||||
final PoiFilter[] selected = new PoiFilter[1];
|
||||
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
||||
dlg.setOnDismissListener(new OnDismissListener() {
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (selected != null) {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
}
|
||||
|
||||
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||
final boolean enable) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
protected void onPreExecute() {
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
app.getWaypointHelper().enableWaypointType(type, enable);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
running[0] = -1;
|
||||
listAdapter.clear();
|
||||
for (Object point : getPoints()) {
|
||||
listAdapter.add(point);
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}.execute((Void) null);
|
||||
}
|
||||
|
||||
protected String getHeader(int type, boolean checked) {
|
||||
FragmentActivity ctx = getActivity();
|
||||
String str = ctx.getString(R.string.waypoints);
|
||||
switch (type) {
|
||||
case WaypointHelper.TARGETS:
|
||||
str = ctx.getString(R.string.targets);
|
||||
break;
|
||||
case WaypointHelper.ALARMS:
|
||||
str = ctx.getString(R.string.way_alarms);
|
||||
break;
|
||||
case WaypointHelper.FAVORITES:
|
||||
str = ctx.getString(R.string.my_favorites);
|
||||
break;
|
||||
case WaypointHelper.WAYPOINTS:
|
||||
str = ctx.getString(R.string.waypoints);
|
||||
break;
|
||||
case WaypointHelper.POI:
|
||||
str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper
|
||||
.getPoiFilter().getName();
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public AlertDialog createWaypointsDialogFlat(final List<LocationPointWrapper> points) {
|
||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
|
@ -285,6 +348,113 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
return builder.create();
|
||||
}
|
||||
|
||||
public AlertDialog createWaypointsDialog() {
|
||||
final List<Object> points = getPoints();
|
||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
final FragmentActivity ctx = getActivity();
|
||||
final ListView listView = new ListView(ctx);
|
||||
final int[] running = new int[]{-1};
|
||||
final ArrayAdapter<Object> listAdapter = new ArrayAdapter<Object>(ctx,
|
||||
R.layout.waypoint_reached, R.id.title, points) {
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = convertView;
|
||||
final ArrayAdapter<Object> thisAdapter = this;
|
||||
boolean labelView = (getItem(position) instanceof Integer);
|
||||
boolean viewText = v != null && v.findViewById(R.id.info_close) == null;
|
||||
if (v == null || viewText != labelView) {
|
||||
v = ctx.getLayoutInflater().inflate(labelView ? R.layout.waypoint_header : R.layout.waypoint_reached, null);
|
||||
}
|
||||
if (labelView) {
|
||||
final int type = (Integer) getItem(position);
|
||||
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
|
||||
btn.setVisibility(waypointHelper.isTypeConfigurable(type) ? View.VISIBLE : View.GONE);
|
||||
btn.setOnCheckedChangeListener(null);
|
||||
final boolean checked = waypointHelper.isTypeEnabled(type);
|
||||
btn.setChecked(checked);
|
||||
btn.setEnabled(running[0] == -1);
|
||||
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
|
||||
btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
running[0] = position;
|
||||
thisAdapter.notifyDataSetInvalidated();
|
||||
if (type == WaypointHelper.POI && isChecked) {
|
||||
selectPoi(running, thisAdapter, type, isChecked);
|
||||
} else {
|
||||
enableType(running, thisAdapter, type, isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
TextView tv = (TextView) v.findViewById(R.id.header_text);
|
||||
tv.setText(getHeader(type, checked));
|
||||
} else {
|
||||
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position), WaypointDialogFragment.this);
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
((ImageButton) remove).setImageDrawable(ctx.getResources().getDrawable(
|
||||
app.getSettings().isLightContent() ? R.drawable.ic_action_gremove_light
|
||||
: R.drawable.ic_action_gremove_dark));
|
||||
remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LocationPointWrapper point = (LocationPointWrapper) points.get(position);
|
||||
remove(point);
|
||||
deletedPoints.add(point);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
listView.setAdapter(listAdapter);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
||||
if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
|
||||
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
|
||||
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||
builder.setView(listView);
|
||||
builder.setNeutralButton(R.string.flat_list_waypoints, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
showWaypointsDialogFlat(getActivity());
|
||||
}
|
||||
|
||||
});
|
||||
builder.setPositiveButton(R.string.default_buttons_ok, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
waypointHelper.removeVisibleLocationPoint(deletedPoints);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
protected List<Object> getPoints() {
|
||||
final List<Object> points = new ArrayList<Object>();
|
||||
for (int i = 0; i < WaypointHelper.MAX; i++) {
|
||||
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
|
||||
if (waypointHelper.isTypeVisible(i)) {
|
||||
points.add(new Integer(i));
|
||||
if (tp != null && tp.size() > 0) {
|
||||
points.addAll(tp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,257 +490,5 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
}
|
||||
}
|
||||
|
||||
public ArrayAdapter<Object> getWaypointsAdapter(final Activity ctx, final List<LocationPointWrapper> deletedPoints){
|
||||
final List<Object> points = getPoints();
|
||||
final int[] running = new int[]{-1};
|
||||
return new ArrayAdapter<Object>(ctx,
|
||||
R.layout.waypoint_reached, R.id.title, points) {
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = convertView;
|
||||
final ArrayAdapter<Object> thisAdapter = this;
|
||||
boolean labelView = (getItem(position) instanceof Integer);
|
||||
boolean viewText = v != null && v.findViewById(R.id.info_close) == null;
|
||||
if (v == null || viewText != labelView) {
|
||||
v = ctx.getLayoutInflater().inflate(labelView ? R.layout.waypoint_header : R.layout.waypoint_reached, null);
|
||||
}
|
||||
if (getItem(position) instanceof String && getItem(position).equals(POI_RADIUS)){
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.radius_search_list_element, null);
|
||||
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
|
||||
final TextView radius = (TextView) v.findViewById(R.id.radius);
|
||||
radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getPoiSearchDeviationRadius(), app));
|
||||
radius.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
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] = position;
|
||||
thisAdapter.notifyDataSetInvalidated();
|
||||
waypointHelper.setPoiSearchDeviationRadius(value);
|
||||
radius.setText(OsmAndFormatter.getFormattedDistance(value, app));
|
||||
recalculatePoints(running, thisAdapter, WaypointHelper.POI);
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}
|
||||
}).setTitle(app.getString(R.string.search_radius_proximity)+ " " + app.getString(R.string.poi))
|
||||
.setNegativeButton(R.string.default_buttons_cancel, null)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
} else if (getItem(position) instanceof String && getItem(position).equals(SEARCH_RADIUS)){
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.radius_search_list_element, null);
|
||||
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
|
||||
final TextView radius = (TextView) v.findViewById(R.id.radius);
|
||||
radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(), app));
|
||||
radius.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
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] = position;
|
||||
thisAdapter.notifyDataSetInvalidated();
|
||||
waypointHelper.setSearchDeviationRadius(value);
|
||||
radius.setText(OsmAndFormatter.getFormattedDistance(value, app));
|
||||
recalculatePoints(running, thisAdapter, -1);
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
}
|
||||
}).setTitle(app.getString(R.string.search_radius_proximity))
|
||||
.setNegativeButton(R.string.default_buttons_cancel, null)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
} else if (labelView) {
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_header, null);
|
||||
final int type = (Integer) getItem(position);
|
||||
ImageView sort = (ImageView) v.findViewById(R.id.sort);
|
||||
//sort button in Destination header
|
||||
if (type == 0 && sort != null){
|
||||
sort.setVisibility(View.VISIBLE);
|
||||
if (app.getSettings().isLightContent()){
|
||||
sort.setImageResource(R.drawable.ic_sort_waypoint_white);
|
||||
} else {
|
||||
sort.setImageResource(R.drawable.ic_sort_waypoint_dark);
|
||||
}
|
||||
sort.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
|
||||
btn.setVisibility(waypointHelper.isTypeConfigurable(type) ? View.VISIBLE : View.GONE);
|
||||
btn.setOnCheckedChangeListener(null);
|
||||
final boolean checked = waypointHelper.isTypeEnabled(type);
|
||||
btn.setChecked(checked);
|
||||
btn.setEnabled(running[0] == -1);
|
||||
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
|
||||
btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
running[0] = position;
|
||||
thisAdapter.notifyDataSetInvalidated();
|
||||
if (type == WaypointHelper.POI && isChecked) {
|
||||
selectPoi(running, thisAdapter, type, isChecked, mapActivity);
|
||||
} else {
|
||||
enableType(running, thisAdapter, type, isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
TextView tv = (TextView) v.findViewById(R.id.header_text);
|
||||
tv.setText(getHeader(ctx, type, checked));
|
||||
} else {
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position), null);
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
((ImageButton) remove).setImageDrawable(ctx.getResources().getDrawable(
|
||||
app.getSettings().isLightContent() ? R.drawable.ic_action_gremove_light
|
||||
: R.drawable.ic_action_gremove_dark));
|
||||
remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LocationPointWrapper point = (LocationPointWrapper) points.get(position);
|
||||
remove(point);
|
||||
deletedPoints.add(point);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
return v;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected String getHeader(Activity ctx, int type, boolean checked) {
|
||||
String str = ctx.getString(R.string.waypoints);
|
||||
switch (type) {
|
||||
case WaypointHelper.TARGETS:
|
||||
str = ctx.getString(R.string.targets);
|
||||
break;
|
||||
case WaypointHelper.ALARMS:
|
||||
str = ctx.getString(R.string.way_alarms);
|
||||
break;
|
||||
case WaypointHelper.FAVORITES:
|
||||
str = ctx.getString(R.string.my_favorites);
|
||||
break;
|
||||
case WaypointHelper.WAYPOINTS:
|
||||
str = ctx.getString(R.string.waypoints);
|
||||
break;
|
||||
case WaypointHelper.POI:
|
||||
str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper
|
||||
.getPoiFilter().getName();
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||
final boolean enable, MapActivity map) {
|
||||
if (!PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
|
||||
final PoiFilter[] selected = new PoiFilter[1];
|
||||
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
||||
dlg.setOnDismissListener(new OnDismissListener() {
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (selected != null) {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
}
|
||||
|
||||
private void recalculatePoints(final int[] running, final ArrayAdapter<Object> listAdapter, final int type){
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
app.getWaypointHelper().recalculatePoints(type);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
running[0] = -1;
|
||||
listAdapter.clear();
|
||||
for (Object point : getPoints()) {
|
||||
listAdapter.add(point);
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}.execute((Void) null);
|
||||
}
|
||||
|
||||
protected List<Object> getPoints() {
|
||||
final List<Object> points = new ArrayList<Object>();
|
||||
for (int i = 0; i < WaypointHelper.MAX; i++) {
|
||||
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
|
||||
if (waypointHelper.isTypeVisible(i)) {
|
||||
points.add(new Integer(i));
|
||||
if (i == WaypointHelper.POI && waypointHelper.isTypeEnabled(WaypointHelper.POI)){
|
||||
points.add(POI_RADIUS);
|
||||
} else if (i == WaypointHelper.FAVORITES && waypointHelper.isTypeEnabled(WaypointHelper.FAVORITES)){
|
||||
points.add(SEARCH_RADIUS);
|
||||
}
|
||||
if (tp != null && tp.size() > 0) {
|
||||
points.addAll(tp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||
final boolean enable) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
app.getWaypointHelper().enableWaypointType(type, enable);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
running[0] = -1;
|
||||
listAdapter.clear();
|
||||
for (Object point : getPoints()) {
|
||||
listAdapter.add(point);
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}.execute((Void) null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ public class WaypointHelper {
|
|||
private static final int ANNOUNCED_DONE = 2;
|
||||
|
||||
private int searchDeviationRadius = 500;
|
||||
private int poiSearchDeviationRadius = 150;
|
||||
private static final int LONG_ANNOUNCE_RADIUS = 700;
|
||||
private static final int SHORT_ANNOUNCE_RADIUS = 150;
|
||||
private static final int ALARMS_ANNOUNCE_RADIUS = 150;
|
||||
|
@ -57,7 +56,6 @@ public class WaypointHelper {
|
|||
public static final int FAVORITES = 3;
|
||||
public static final int ALARMS = 4;
|
||||
public static final int MAX = 5;
|
||||
public static final int[] SEARCH_RADIUS_VALUES = {50, 100, 250, 500, 1000, 1500};
|
||||
|
||||
private List<List<LocationPointWrapper>> locationPoints = new ArrayList<List<LocationPointWrapper>>();
|
||||
private ConcurrentHashMap<LocationPoint, Integer> locationPointsStates = new ConcurrentHashMap<LocationPoint, Integer>();
|
||||
|
@ -212,9 +210,7 @@ public class WaypointHelper {
|
|||
recalculatePoints(route, type, locationPoints);
|
||||
}
|
||||
|
||||
public void recalculatePoints(int type){
|
||||
recalculatePoints(route, type, locationPoints);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isTypeConfigurable(int waypointType) {
|
||||
|
@ -510,7 +506,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, getSearchRadius(POI),
|
||||
pf, new ResultMatcher<Amenity>() {
|
||||
|
||||
@Override
|
||||
|
@ -537,6 +533,12 @@ public class WaypointHelper {
|
|||
}
|
||||
|
||||
|
||||
protected int getSearchRadius(int type) {
|
||||
// app.getAppCustomization().getWaypointSearchRadius(searchDeviationRadius, type);
|
||||
return searchDeviationRadius;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void calculateAlarms(RouteCalculationResult route, List<LocationPointWrapper> array) {
|
||||
for(AlarmInfo i : route.getAlarmInfo()) {
|
||||
|
@ -575,7 +577,7 @@ public class WaypointHelper {
|
|||
int[] ind = new int[1];
|
||||
for(LocationPoint p : points) {
|
||||
float dist = dist(p, immutableAllLocations, ind);
|
||||
if(dist <= getSearchDeviationRadius() && type != POI) {
|
||||
if(dist <= getSearchRadius(type)) {
|
||||
LocationPointWrapper lpw = new LocationPointWrapper(rt, type, p, dist, ind[0]);
|
||||
lpw.setAnnounce(announce);
|
||||
locationPoints.add(lpw);
|
||||
|
@ -704,22 +706,6 @@ public class WaypointHelper {
|
|||
|
||||
}
|
||||
|
||||
public int getSearchDeviationRadius(){
|
||||
return searchDeviationRadius;
|
||||
}
|
||||
|
||||
public void setSearchDeviationRadius(int radius){
|
||||
this.searchDeviationRadius = radius;
|
||||
}
|
||||
|
||||
public int getPoiSearchDeviationRadius() {
|
||||
return poiSearchDeviationRadius;
|
||||
}
|
||||
|
||||
public void setPoiSearchDeviationRadius(int radius) {
|
||||
this.poiSearchDeviationRadius = radius;
|
||||
}
|
||||
|
||||
private class AmenityLocationPoint implements LocationPoint {
|
||||
|
||||
Amenity a;
|
||||
|
|
|
@ -115,11 +115,10 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.context_menu_item_add_waypoint) {
|
||||
mapActivity.getMapActions().addWaypoint(latitude, longitude);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.context_menu_item_add_waypoint).icons(R.drawable.ic_action_gnew_label_dark, R.drawable.ic_action_gnew_label_light)
|
||||
|
@ -448,7 +447,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (view.getApplication().getNavigationService() == null) {
|
||||
final ValueHolder<Integer> vs = new ValueHolder<Integer>();
|
||||
final ValueHolder<Boolean> choice = new ValueHolder<Boolean>();
|
||||
|
@ -466,7 +465,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
|
|||
} else {
|
||||
view.getContext().stopService(serviceIntent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).position(0).reg();
|
||||
}
|
||||
|
|
|
@ -495,13 +495,12 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.osb_comment_menu_item) {
|
||||
commentBug(bug);
|
||||
} else if (itemId == R.string.osb_close_menu_item) {
|
||||
closeBug(bug);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.osb_comment_menu_item).icons(
|
||||
|
|
|
@ -122,7 +122,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
final Object selectedObj) {
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.context_menu_item_create_poi) {
|
||||
getPoiActions(mapActivity).showCreateDialog(latitude, longitude);
|
||||
} else if (resId == R.string.context_menu_item_open_bug) {
|
||||
|
@ -135,7 +135,6 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
} else if (resId == R.string.poi_context_menu_modify) {
|
||||
getPoiActions(mapActivity).showEditDialog((Amenity) selectedObj);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if(selectedObj instanceof Amenity) {
|
||||
|
@ -157,11 +156,10 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.layer_osm_bugs) {
|
||||
settings.SHOW_OSM_BUGS.set(isChecked);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).position(7).reg();
|
||||
|
||||
|
@ -180,9 +178,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
sendGPXFiles(la, (AvailableGPXFragment) fragment, (GpxInfo) info);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -197,7 +194,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
f.openSelectionMode(R.string.local_index_mi_upload_gpx, R.drawable.ic_action_gup_dark,
|
||||
R.drawable.ic_action_gup_light, new OnClickListener() {
|
||||
@Override
|
||||
|
@ -207,7 +204,6 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
selectedItems.toArray(new GpxInfo[selectedItems.size()]));
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}).position(5).reg();
|
||||
}
|
||||
|
|
|
@ -136,14 +136,13 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
OsMoDevice o = (OsMoDevice) selectedObj;
|
||||
double lat = o.getLastLocation() == null ? latitude : o.getLastLocation().getLatitude();
|
||||
double lon = o.getLastLocation() == null ? longitude : o.getLastLocation().getLongitude();
|
||||
mapActivity.getMapView().setLatLon(lat, lon);
|
||||
MapActivity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
OsMoPositionLayer.setFollowTrackerId(o);
|
||||
return true;
|
||||
}
|
||||
}).position(0).reg();
|
||||
if(OsMoPositionLayer.getFollowDestinationId() != null) {
|
||||
|
@ -151,10 +150,9 @@ 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 void onContextMenuClick(int itemId, int pos, boolean isChecked,
|
||||
DialogInterface dialog) {
|
||||
OsMoPositionLayer.setFollowDestination(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
}).position(0).reg();
|
||||
|
@ -163,14 +161,13 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
OsMoDevice o = (OsMoDevice) selectedObj;
|
||||
if(o.getLastLocation() != null) {
|
||||
TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
targets.navigateToPoint(new LatLon(o.getLastLocation().getLatitude(), o.getLastLocation().getLongitude()), true, -1);
|
||||
}
|
||||
OsMoPositionLayer.setFollowDestination(o);
|
||||
return true;
|
||||
}
|
||||
}).position(1).reg();
|
||||
}
|
||||
|
@ -294,11 +291,10 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
.listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
final double lat = view.getLatitude();
|
||||
final double lon = view.getLongitude();
|
||||
tracker.sendCoordinate(lat, lon);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -325,10 +321,9 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
Intent intent = new Intent(mapActivity, OsMoGroupsActivity.class);
|
||||
mapActivity.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
|
|
@ -200,12 +200,11 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
if (selectedObj == parkingPosition && parkingPosition != null) {
|
||||
OnContextMenuClick removeListener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int resId, int pos,
|
||||
public void onContextMenuClick(int resId, int pos,
|
||||
boolean isChecked, DialogInterface dialog) {
|
||||
if ((resId == R.string.context_menu_item_delete_parking_point)) {
|
||||
showDeleteDialog(mapActivity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.context_menu_item_delete_parking_point)
|
||||
|
@ -214,12 +213,11 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
|
||||
OnContextMenuClick addListener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int resId, int pos,
|
||||
public void onContextMenuClick(int resId, int pos,
|
||||
boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.context_menu_item_add_parking_point) {
|
||||
showAddParkingDialog(mapActivity, latitude, longitude);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.context_menu_item_add_parking_point)
|
||||
|
@ -421,9 +419,8 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
showDeleteDialog(mapActivity);
|
||||
return true;
|
||||
}
|
||||
|
||||
}).reg();
|
||||
|
|
|
@ -186,7 +186,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.layer_map) {
|
||||
dialog.dismiss();
|
||||
layers.selectMapLayer(mapView);
|
||||
|
@ -210,7 +210,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
mapActivity);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.layer_map).icons(R.drawable.ic_action_globus_dark, R.drawable.ic_action_globus_light)
|
||||
|
@ -229,14 +228,13 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
if (mapView.getMainLayer() instanceof MapTileLayer) {
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
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) {
|
||||
DownloadTilesDialog dlg = new DownloadTilesDialog(mapActivity, (OsmandApplication) mapActivity.getApplication(), mapView);
|
||||
dlg.openDialog();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.context_menu_item_update_map).icons(R.drawable.ic_action_refresh_dark, R.drawable.ic_action_refresh_light)
|
||||
|
|
|
@ -75,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.mark_as_not_visited){
|
||||
plugin.getCurrentRoute().markPoint(point,false);
|
||||
plugin.saveCurrentRoute();
|
||||
|
@ -91,7 +91,6 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
plugin.saveCurrentRoute();
|
||||
}
|
||||
map.refreshMap();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -513,9 +513,8 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
showFavoriteDialog(mapActivity, selectedStage, sf);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
|
||||
|
@ -565,21 +564,19 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
app.getSettings().SHOW_POI_OVER_MAP.set(false);
|
||||
mapActivity.getMapLayers().updateLayers(mapActivity.getMapView());
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
} else {
|
||||
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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
mapActivity.getMapLayers().selectPOIFilterLayer(mapActivity.getMapView(), null);
|
||||
app.getSettings().SHOW_POI_OVER_MAP.set(true);
|
||||
mapActivity.getMapLayers().updateLayers(mapActivity.getMapView());
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -587,11 +584,10 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
Intent newIntent = new Intent(mapActivity, TourViewActivity.class);
|
||||
// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
//complete stage
|
||||
|
@ -601,10 +597,9 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
markStageAsCompleted(stage);
|
||||
showCompleteStageFragment(mapActivity, stage, false);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
@ -612,13 +607,12 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (app.getLocationProvider().getLastKnownLocation() != null) {
|
||||
new ShareLocation(mapActivity).run();
|
||||
} else {
|
||||
Toast.makeText(app, R.string.unknown_location, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
|
|
@ -95,12 +95,11 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.layer_hillshade) {
|
||||
HILLSHADE.set(!HILLSHADE.get());
|
||||
updateLayers(mapView, mapActivity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.layer_hillshade).selected(HILLSHADE.get()? 1 : 0)
|
||||
|
|
|
@ -198,7 +198,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.favourites_context_menu_delete) {
|
||||
final Resources resources = view.getContext().getResources();
|
||||
Builder builder = new AlertDialog.Builder(view.getContext());
|
||||
|
@ -213,7 +213,6 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
});
|
||||
builder.create().show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.favourites_context_menu_delete)
|
||||
|
|
|
@ -65,11 +65,12 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private LinearLayout transparencyBarLayout;
|
||||
private static CommonPreference<Integer> settingsToTransparency;
|
||||
private OsmandSettings settings;
|
||||
|
||||
private WaypointDialogHelper waypointDialogHelper;
|
||||
|
||||
public MapControlsLayer(MapActivity activity){
|
||||
this.mapActivity = activity;
|
||||
settings = activity.getMyApplication().getSettings();
|
||||
waypointDialogHelper = new WaypointDialogHelper(activity);
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,6 +123,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
mapInfoNavigationControl.setMargin(mapSmallMenuControls.getWidth() + mapCancelNavigationControl.getWidth());
|
||||
mapAppModeControl.setMargin(mapNavigationControl.getWidth());
|
||||
|
||||
waypointDialogHelper.init();
|
||||
initTransparencyBar(view, parent);
|
||||
}
|
||||
|
||||
|
@ -148,7 +150,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
@Override
|
||||
public void destroyLayer() {
|
||||
|
||||
waypointDialogHelper.removeListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -335,6 +337,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
mapInfoNavigationControl.setShowDialog();
|
||||
}
|
||||
|
||||
public WaypointDialogHelper getWaypointDialogHelper() {
|
||||
return waypointDialogHelper;
|
||||
}
|
||||
|
||||
private int getScreenOrientation() {
|
||||
int rotation = mapActivity.getWindowManager().getDefaultDisplay().getRotation();
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
|
|
|
@ -256,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.poi_context_menu_call) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
|
@ -278,7 +278,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
} else if (itemId == R.string.poi_context_menu_showdescription) {
|
||||
showDescriptionDialog(a);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if (OsmAndFormatter.getAmenityDescriptionContent(view.getApplication(), a, false).length() > 0) {
|
||||
|
|
|
@ -220,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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.delete_target_point) {
|
||||
TargetPointsHelper targetPointsHelper = map.getMyApplication().getTargetPointsHelper();
|
||||
if(a.intermediate) {
|
||||
|
@ -230,7 +230,6 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu
|
|||
}
|
||||
}
|
||||
map.getMapLayers().getContextMenuLayer().setLocation(null, "");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -216,9 +216,8 @@ 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, DialogInterface dialog) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
showDescriptionDialog(a);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.poi_context_menu_showdescription)
|
||||
|
|