Updated drawer layout. Fixed compatibility issue
This commit is contained in:
parent
ec64baeda7
commit
b4961d3401
4 changed files with 70 additions and 66 deletions
|
@ -459,7 +459,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
}
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
|
||||
mapActions.openOptionsMenuAsList();
|
||||
mapActions.openOptionsMenuAsDrawer();
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
||||
Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization().getSearchActivity());
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.helpers;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
|
@ -47,7 +48,7 @@ import android.widget.TextView;
|
|||
public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||
private MapActivity mapActivity;
|
||||
private OsmandApplication app;
|
||||
private FrameLayout mainLayout;
|
||||
private DrawerLayout mainLayout;
|
||||
private WaypointHelper waypointHelper;
|
||||
|
||||
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
||||
|
@ -59,7 +60,8 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
this.app = mapActivity.getMyApplication();
|
||||
waypointHelper = this.app.getWaypointHelper();
|
||||
this.mapActivity = mapActivity;
|
||||
this.mainLayout = (FrameLayout) ((FrameLayout) mapActivity.getLayout()).getChildAt(0);
|
||||
this.mainLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout);
|
||||
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
@ -68,7 +70,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
if(mapActivity != null) {
|
||||
if (mapActivity != null) {
|
||||
updateDialog();
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +102,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
all.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showWaypointsDialog(mapActivity);
|
||||
showWaypointsDialog(mapActivity);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -120,7 +122,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
}
|
||||
|
||||
private static void updatePointInfoView(final OsmandApplication app, final Activity ctx,
|
||||
View localView, final LocationPointWrapper ps, final DialogFragment dialog) {
|
||||
View localView, final LocationPointWrapper ps, final DialogFragment dialog) {
|
||||
WaypointHelper wh = app.getWaypointHelper();
|
||||
final LocationPoint point = ps.getPoint();
|
||||
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
||||
|
@ -224,15 +226,15 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
if(getArguments() != null && getArguments().getBoolean(FLAT_ARG)) {
|
||||
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())) {
|
||||
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);
|
||||
|
@ -240,7 +242,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if(selected != null) {
|
||||
if (selected != null) {
|
||||
enableType(running, listAdapter, type, enable);
|
||||
}
|
||||
}
|
||||
|
@ -251,11 +253,13 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
}
|
||||
|
||||
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||
final boolean enable) {
|
||||
final boolean enable) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
|
||||
protected void onPreExecute() {
|
||||
};
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
|
@ -266,9 +270,11 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
protected void onPostExecute(Void result) {
|
||||
running[0] = -1;
|
||||
listAdapter.clear();
|
||||
listAdapter.addAll(getPoints());
|
||||
for (Object point : getPoints()) {
|
||||
listAdapter.add(point);
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
};
|
||||
}
|
||||
}.execute((Void) null);
|
||||
}
|
||||
|
||||
|
@ -276,27 +282,27 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
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;
|
||||
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){
|
||||
public AlertDialog createWaypointsDialogFlat(final List<LocationPointWrapper> points) {
|
||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||
final FragmentActivity ctx = getActivity();
|
||||
final ArrayAdapter<LocationPointWrapper> listAdapter = new ArrayAdapter<LocationPointWrapper>(ctx, R.layout.waypoint_reached, R.id.title,
|
||||
|
@ -311,7 +317,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
updatePointInfoView(app, ctx, v, 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:
|
||||
app.getSettings().isLightContent() ? R.drawable.ic_action_gremove_light :
|
||||
R.drawable.ic_action_gremove_dark));
|
||||
remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -382,7 +388,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
running[0] = position;
|
||||
thisAdapter.notifyDataSetInvalidated();
|
||||
if(type == WaypointHelper.POI && isChecked) {
|
||||
if (type == WaypointHelper.POI && isChecked) {
|
||||
selectPoi(running, thisAdapter, type, isChecked);
|
||||
} else {
|
||||
enableType(running, thisAdapter, type, isChecked);
|
||||
|
@ -416,7 +422,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
||||
if(listAdapter.getItem(item) instanceof LocationPointWrapper) {
|
||||
if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
|
||||
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
|
||||
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
|
||||
}
|
||||
|
@ -460,7 +466,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
|
||||
|
||||
private static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, DialogFragment dialog) {
|
||||
if(!(a instanceof MapActivity)) {
|
||||
if (!(a instanceof MapActivity)) {
|
||||
return;
|
||||
}
|
||||
MapActivity ctx = (MapActivity) a;
|
||||
|
@ -475,12 +481,12 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
||||
locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||
double t = 10;
|
||||
if(dist < t) {
|
||||
if (dist < t) {
|
||||
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
||||
} else {
|
||||
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
||||
}
|
||||
if(di) {
|
||||
if (di) {
|
||||
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
||||
ctx.getMapLayers()
|
||||
.getContextMenuLayer()
|
||||
|
@ -492,6 +498,4 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MapMenuControls extends MapControls {
|
|||
// double lat = activity.getMapView().getLatitude();
|
||||
// double lon = activity.getMapView().getLongitude();
|
||||
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
||||
mapActivity.getMapActions().openOptionsMenuAsList();
|
||||
mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||
notifyClicked();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -27,7 +27,7 @@ public class SmallMapMenuControls extends MapControls {
|
|||
public void onClick(View v) {
|
||||
notifyClicked();
|
||||
//mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||
mapActivity.getMapActions().openOptionsMenuAsList();
|
||||
mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue