Update layout
This commit is contained in:
parent
b4a6beee0c
commit
f483d1a244
4 changed files with 56 additions and 13 deletions
|
@ -90,9 +90,9 @@ public class AndroidUiHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLargeDevice(Activity ctx) {
|
public static boolean isXLargeDevice(Activity ctx) {
|
||||||
return (ctx.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
|
int lt = (ctx.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK);
|
||||||
== Configuration.SCREENLAYOUT_SIZE_LARGE;
|
return lt == Configuration.SCREENLAYOUT_SIZE_XLARGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOrientationPortrait(Activity ctx) {
|
public static boolean isOrientationPortrait(Activity ctx) {
|
||||||
|
|
|
@ -319,7 +319,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
TextView routeGoButton = (TextView) main.findViewById(R.id.map_go_route_button);
|
TextView routeGoButton = (TextView) main.findViewById(R.id.map_go_route_button);
|
||||||
routeGoButton.setCompoundDrawables(app.getIconsCache().getIcon(R.drawable.map_start_navigation, R.color.color_myloc_distance), null, null, null);
|
routeGoButton.setCompoundDrawables(app.getIconsCache().getIcon(R.drawable.map_start_navigation, R.color.color_myloc_distance), null, null, null);
|
||||||
routeGoButton.setText(mapActivity.getString(R.string.shared_string_go));
|
routeGoButton.setText(AndroidUiHelper.isOrientationPortrait(mapActivity) ?
|
||||||
|
mapActivity.getString(R.string.shared_string_go) : "");
|
||||||
routeGoButton.setOnClickListener(new View.OnClickListener() {
|
routeGoButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||||
import net.osmand.plus.views.ContextMenuLayer;
|
import net.osmand.plus.views.ContextMenuLayer;
|
||||||
import net.osmand.plus.views.MapControlsLayer;
|
import net.osmand.plus.views.MapControlsLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.plus.views.controls.MapRoutePreferencesControl.RoutePrepareDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnDismissListener;
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
|
@ -538,16 +539,22 @@ public class MapRouteInfoControl implements IRouteInformationListener {
|
||||||
dialog = MapRoutePreferencesControl.showDialog(mapControlsLayer, mapActivity, ll, new OnDismissListener() {
|
dialog = MapRoutePreferencesControl.showDialog(mapControlsLayer, mapActivity, ll, new OnDismissListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface d) {
|
||||||
dialog = null;
|
dialog = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideDialog() {
|
public void hideDialog() {
|
||||||
|
Dialog dialog = this.dialog;
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
|
if(dialog instanceof RoutePrepareDialog &&
|
||||||
|
((RoutePrepareDialog) dialog).getListener() != null) {
|
||||||
|
((RoutePrepareDialog) dialog).getListener().onDismiss(dialog);
|
||||||
|
((RoutePrepareDialog) dialog).cancelDismissListener();
|
||||||
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
dialog = null;
|
this.dialog = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,23 +128,52 @@ public class MapRoutePreferencesControl {
|
||||||
|
|
||||||
public void showAndHideDialog() {
|
public void showAndHideDialog() {
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
dialog.hide();
|
hideDialog();
|
||||||
dialog = null;
|
|
||||||
} else {
|
} else {
|
||||||
dialog = showDialog(controlsLayer, mapActivity, createLayout(), new OnDismissListener() {
|
dialog = showDialog(controlsLayer, mapActivity, createLayout(), new OnDismissListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface d) {
|
||||||
dialog = null;
|
dialog = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class RoutePrepareDialog extends Dialog {
|
||||||
|
|
||||||
|
private OnDismissListener listener;
|
||||||
|
|
||||||
|
public RoutePrepareDialog(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OnDismissListener getListener() {
|
||||||
|
return listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnDismissListener(OnDismissListener l) {
|
||||||
|
this.listener = l;
|
||||||
|
super.setOnDismissListener(new OnDismissListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
if(listener != null) {
|
||||||
|
listener.onDismiss(dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelDismissListener() {
|
||||||
|
this.listener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public static Dialog showDialog(final MapControlsLayer controlsLayer, final MapActivity mapActivity, final View ll,
|
public static Dialog showDialog(final MapControlsLayer controlsLayer, final MapActivity mapActivity, final View ll,
|
||||||
final OnDismissListener dismiss) {
|
final OnDismissListener dismiss) {
|
||||||
final boolean switched = controlsLayer.switchToRoutePlanningLayout();
|
final boolean switched = controlsLayer.switchToRoutePlanningLayout();
|
||||||
final Dialog dialog = new Dialog(mapActivity);
|
final RoutePrepareDialog dialog = new RoutePrepareDialog(mapActivity);
|
||||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
||||||
final int maxHeight ;
|
final int maxHeight ;
|
||||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||||
|
@ -188,7 +217,7 @@ public class MapRoutePreferencesControl {
|
||||||
mapActivity.getMapView().refreshMap();
|
mapActivity.getMapView().refreshMap();
|
||||||
}
|
}
|
||||||
dialog.show();
|
dialog.show();
|
||||||
if(!AndroidUiHelper.isLargeDevice(mapActivity)) {
|
if(!AndroidUiHelper.isXLargeDevice(mapActivity)) {
|
||||||
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), false);
|
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), false);
|
||||||
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), false);
|
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), false);
|
||||||
}
|
}
|
||||||
|
@ -555,9 +584,15 @@ public class MapRoutePreferencesControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideDialog() {
|
public void hideDialog() {
|
||||||
|
Dialog dialog = this.dialog;
|
||||||
if(dialog != null) {
|
if(dialog != null) {
|
||||||
|
if(dialog instanceof RoutePrepareDialog &&
|
||||||
|
((RoutePrepareDialog) dialog).getListener() != null) {
|
||||||
|
((RoutePrepareDialog) dialog).getListener().onDismiss(dialog);
|
||||||
|
((RoutePrepareDialog) dialog).cancelDismissListener();
|
||||||
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
dialog = null;
|
this.dialog = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue