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;
|
return true;
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
|
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
|
||||||
mapActions.openOptionsMenuAsList();
|
mapActions.openOptionsMenuAsDrawer();
|
||||||
return true;
|
return true;
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
||||||
Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization().getSearchActivity());
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.LocationPoint;
|
import net.osmand.data.LocationPoint;
|
||||||
|
@ -47,7 +48,7 @@ import android.widget.TextView;
|
||||||
public class WaypointDialogHelper implements OsmAndLocationListener {
|
public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
private MapActivity mapActivity;
|
private MapActivity mapActivity;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private FrameLayout mainLayout;
|
private DrawerLayout mainLayout;
|
||||||
private WaypointHelper waypointHelper;
|
private WaypointHelper waypointHelper;
|
||||||
|
|
||||||
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
||||||
|
@ -59,7 +60,8 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
this.app = mapActivity.getMyApplication();
|
this.app = mapActivity.getMyApplication();
|
||||||
waypointHelper = this.app.getWaypointHelper();
|
waypointHelper = this.app.getWaypointHelper();
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
this.mainLayout = (FrameLayout) ((FrameLayout) mapActivity.getLayout()).getChildAt(0);
|
this.mainLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -68,7 +70,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateLocation(Location location) {
|
public void updateLocation(Location location) {
|
||||||
if(mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
updateDialog();
|
updateDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +102,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
all.setOnClickListener(new View.OnClickListener() {
|
all.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
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,
|
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();
|
WaypointHelper wh = app.getWaypointHelper();
|
||||||
final LocationPoint point = ps.getPoint();
|
final LocationPoint point = ps.getPoint();
|
||||||
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
||||||
|
@ -224,15 +226,15 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
if(getArguments() != null && getArguments().getBoolean(FLAT_ARG)) {
|
if (getArguments() != null && getArguments().getBoolean(FLAT_ARG)) {
|
||||||
return createWaypointsDialogFlat(waypointHelper.getAllPoints());
|
return createWaypointsDialogFlat(waypointHelper.getAllPoints());
|
||||||
}
|
}
|
||||||
return createWaypointsDialog();
|
return createWaypointsDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||||
final boolean enable) {
|
final boolean enable) {
|
||||||
if(getActivity() instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
|
if (getActivity() instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
|
||||||
MapActivity map = (MapActivity) getActivity();
|
MapActivity map = (MapActivity) getActivity();
|
||||||
final PoiFilter[] selected = new PoiFilter[1];
|
final PoiFilter[] selected = new PoiFilter[1];
|
||||||
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
||||||
|
@ -240,7 +242,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
if(selected != null) {
|
if (selected != null) {
|
||||||
enableType(running, listAdapter, type, enable);
|
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,
|
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||||
final boolean enable) {
|
final boolean enable) {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
};
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
|
@ -266,9 +270,11 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
protected void onPostExecute(Void result) {
|
protected void onPostExecute(Void result) {
|
||||||
running[0] = -1;
|
running[0] = -1;
|
||||||
listAdapter.clear();
|
listAdapter.clear();
|
||||||
listAdapter.addAll(getPoints());
|
for (Object point : getPoints()) {
|
||||||
|
listAdapter.add(point);
|
||||||
|
}
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
};
|
}
|
||||||
}.execute((Void) null);
|
}.execute((Void) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,27 +282,27 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
FragmentActivity ctx = getActivity();
|
FragmentActivity ctx = getActivity();
|
||||||
String str = ctx.getString(R.string.waypoints);
|
String str = ctx.getString(R.string.waypoints);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WaypointHelper.TARGETS:
|
case WaypointHelper.TARGETS:
|
||||||
str = ctx.getString(R.string.targets);
|
str = ctx.getString(R.string.targets);
|
||||||
break;
|
break;
|
||||||
case WaypointHelper.ALARMS:
|
case WaypointHelper.ALARMS:
|
||||||
str = ctx.getString(R.string.way_alarms);
|
str = ctx.getString(R.string.way_alarms);
|
||||||
break;
|
break;
|
||||||
case WaypointHelper.FAVORITES:
|
case WaypointHelper.FAVORITES:
|
||||||
str = ctx.getString(R.string.my_favorites);
|
str = ctx.getString(R.string.my_favorites);
|
||||||
break;
|
break;
|
||||||
case WaypointHelper.WAYPOINTS:
|
case WaypointHelper.WAYPOINTS:
|
||||||
str = ctx.getString(R.string.waypoints);
|
str = ctx.getString(R.string.waypoints);
|
||||||
break;
|
break;
|
||||||
case WaypointHelper.POI:
|
case WaypointHelper.POI:
|
||||||
str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper
|
str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper
|
||||||
.getPoiFilter().getName();
|
.getPoiFilter().getName();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return str;
|
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 List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||||
final FragmentActivity ctx = getActivity();
|
final FragmentActivity ctx = getActivity();
|
||||||
final ArrayAdapter<LocationPointWrapper> listAdapter = new ArrayAdapter<LocationPointWrapper>(ctx, R.layout.waypoint_reached, R.id.title,
|
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);
|
updatePointInfoView(app, ctx, v, getItem(position), WaypointDialogFragment.this);
|
||||||
View remove = v.findViewById(R.id.info_close);
|
View remove = v.findViewById(R.id.info_close);
|
||||||
((ImageButton) remove).setImageDrawable(ctx.getResources().getDrawable(
|
((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));
|
R.drawable.ic_action_gremove_dark));
|
||||||
remove.setOnClickListener(new View.OnClickListener() {
|
remove.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -382,7 +388,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
running[0] = position;
|
running[0] = position;
|
||||||
thisAdapter.notifyDataSetInvalidated();
|
thisAdapter.notifyDataSetInvalidated();
|
||||||
if(type == WaypointHelper.POI && isChecked) {
|
if (type == WaypointHelper.POI && isChecked) {
|
||||||
selectPoi(running, thisAdapter, type, isChecked);
|
selectPoi(running, thisAdapter, type, isChecked);
|
||||||
} else {
|
} else {
|
||||||
enableType(running, thisAdapter, type, isChecked);
|
enableType(running, thisAdapter, type, isChecked);
|
||||||
|
@ -416,7 +422,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
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);
|
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
|
||||||
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
|
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) {
|
private static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, DialogFragment dialog) {
|
||||||
if(!(a instanceof MapActivity)) {
|
if (!(a instanceof MapActivity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MapActivity ctx = (MapActivity) a;
|
MapActivity ctx = (MapActivity) a;
|
||||||
|
@ -475,12 +481,12 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
||||||
locationPoint.getLatitude(), locationPoint.getLongitude());
|
locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||||
double t = 10;
|
double t = 10;
|
||||||
if(dist < t) {
|
if (dist < t) {
|
||||||
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
||||||
} else {
|
} else {
|
||||||
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
||||||
}
|
}
|
||||||
if(di) {
|
if (di) {
|
||||||
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
||||||
ctx.getMapLayers()
|
ctx.getMapLayers()
|
||||||
.getContextMenuLayer()
|
.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 lat = activity.getMapView().getLatitude();
|
||||||
// double lon = activity.getMapView().getLongitude();
|
// double lon = activity.getMapView().getLongitude();
|
||||||
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
||||||
mapActivity.getMapActions().openOptionsMenuAsList();
|
mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||||
notifyClicked();
|
notifyClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class SmallMapMenuControls extends MapControls {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
notifyClicked();
|
notifyClicked();
|
||||||
//mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
//mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||||
mapActivity.getMapActions().openOptionsMenuAsList();
|
mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue