Update landscape layout

This commit is contained in:
Victor Shcherb 2015-04-23 00:45:10 +02:00
parent f74c332d41
commit 63490cbfd7
7 changed files with 75 additions and 24 deletions

View file

@ -6,6 +6,15 @@
android:layout_height="@dimen/map_route_buttons_height"
android:layout_gravity="bottom" >
<ImageButton
android:id="@+id/map_dashboard_route_button"
android:layout_width="@dimen/map_route_buttons_width"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="?attr/btn_flat_bg"
android:visibility="gone"
android:src="@drawable/ic_action_test_light" />
<ImageButton
android:id="@+id/map_cancel_route_button"
android:layout_width="@dimen/map_route_buttons_width"

View file

@ -9,7 +9,7 @@
<dimen name="map_route_buttons_height_land">72dp</dimen>
<dimen name="map_route_planning_max_height">400dp</dimen>
<dimen name="map_minwidth_widget">160dp</dimen>
<dimen name="map_route_planning_land_width">440dp</dimen>
<dimen name="map_route_planning_land_width">510dp</dimen>
<dimen name="map_address_height">60dp</dimen>
<dimen name="map_button_size">78dp</dimen>

View file

@ -85,7 +85,7 @@
<dimen name="map_button_rect_rad">3dp</dimen>
<dimen name="map_button_stroke">1dp</dimen>
<dimen name="map_button_stroke_dark">1dp</dimen>
<dimen name="map_route_planning_land_width">280dp</dimen>
<dimen name="map_route_planning_land_width">320dp</dimen>
<dimen name="map_route_planning_max_height">280dp</dimen>
<dimen name="map_minwidth_widget">100dp</dimen>

View file

@ -91,7 +91,8 @@ public class AndroidUiHelper {
}
public static boolean isLargeDevice(Activity ctx) {
return (ctx.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE;
return (ctx.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
== Configuration.SCREENLAYOUT_SIZE_LARGE;
}
public static boolean isOrientationPortrait(Activity ctx) {

View file

@ -19,6 +19,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchAddressFragment;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.controls.MapRouteInfoControl;
import net.osmand.plus.views.controls.MapRoutePreferencesControl;
@ -83,6 +84,10 @@ public class MapControlsLayer extends OsmandMapLayer {
private View mapAppModeShadow;
private MapHudButton routePlanningBtn;
private long touchEvent;
private MapHudButton mapZoomOut;
private MapHudButton mapZoomIn;
private MapHudButton layersHud;
private MapHudButton mapDashControl;
public MapControlsLayer(MapActivity activity) {
this.mapActivity = activity;
@ -173,9 +178,10 @@ public class MapControlsLayer extends OsmandMapLayer {
private void initTopControls() {
View configureMap = mapActivity.findViewById(R.id.map_layers_button);
controls.add(createHudButton((ImageView) configureMap, R.drawable.map_layer_dark)
.setIconsId(R.drawable.map_layer_dark, R.drawable.map_layer_night)
.setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night));
layersHud = createHudButton((ImageView) configureMap, R.drawable.map_layer_dark)
.setIconsId(R.drawable.map_layer_dark, R.drawable.map_layer_night)
.setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night);
controls.add(layersHud);
configureMap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -201,6 +207,20 @@ public class MapControlsLayer extends OsmandMapLayer {
private void initRouteControls() {
routePreparationLayout = mapActivity.findViewById(R.id.map_route_preparation_layout);
View dashRouteButton = mapActivity.findViewById(R.id.map_dashboard_route_button);
mapDashControl = createHudButton((ImageView) dashRouteButton, R.drawable.map_dashboard).setBg(
R.drawable.btn_flat, R.drawable.btn_flat_night);
controls.add(mapDashControl);
dashRouteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
}
});
View cancelRouteButton = mapActivity.findViewById(R.id.map_cancel_route_button);
controls.add(createHudButton((ImageView) cancelRouteButton, R.drawable.map_action_cancel).setBg(
R.drawable.btn_flat, R.drawable.btn_flat_night));
@ -256,6 +276,18 @@ public class MapControlsLayer extends OsmandMapLayer {
}
public void updateRouteButtons(View main, boolean routeInfo) {
ImageView dashButton = (ImageView) main.findViewById(R.id.map_dashboard_route_button);
dashButton.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.map_dashboard));
dashButton.setVisibility(AndroidUiHelper.isOrientationPortrait(mapActivity) ?
View.GONE : View.VISIBLE);
dashButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mapRouteInfoControlDialog.hideDialog();
optionsRouteControlDialog.hideDialog();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
}
});
ImageView cancelRouteButton = (ImageView) main.findViewById(R.id.map_cancel_route_button);
cancelRouteButton.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.map_action_cancel));
cancelRouteButton.setOnClickListener(new View.OnClickListener() {
@ -417,8 +449,9 @@ public class MapControlsLayer extends OsmandMapLayer {
private void initZooms() {
final OsmandMapTileView view = mapActivity.getMapView();
View zoomInButton = mapActivity.findViewById(R.id.map_zoom_in_button);
controls.add(createHudButton((ImageView) zoomInButton, R.drawable.map_zoom_in).
setIconsId(R.drawable.map_zoom_in, R.drawable.map_zoom_in_night).setRoundTransparent());
mapZoomIn = createHudButton((ImageView) zoomInButton, R.drawable.map_zoom_in).
setIconsId(R.drawable.map_zoom_in, R.drawable.map_zoom_in_night).setRoundTransparent();
controls.add(mapZoomIn);
zoomInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -434,8 +467,9 @@ public class MapControlsLayer extends OsmandMapLayer {
final View.OnLongClickListener listener = MapControlsLayer.getOnClickMagnifierListener(view);
zoomInButton.setOnLongClickListener(listener);
View zoomOutButton = mapActivity.findViewById(R.id.map_zoom_out_button);
controls.add(createHudButton((ImageView) zoomOutButton, R.drawable.map_zoom_out).
setIconsId(R.drawable.map_zoom_out, R.drawable.map_zoom_out_night).setRoundTransparent());
mapZoomOut = createHudButton((ImageView) zoomOutButton, R.drawable.map_zoom_out).
setIconsId(R.drawable.map_zoom_out, R.drawable.map_zoom_out_night).setRoundTransparent();
controls.add(mapZoomOut);
zoomOutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -527,6 +561,7 @@ public class MapControlsLayer extends OsmandMapLayer {
// TODO
// updatextColor(textColor, shadw, rulerControl, zoomControls, mapMenuControls);
}
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
// default buttons
boolean routePlanningMode = false;
RoutingHelper rh = mapActivity.getRoutingHelper();
@ -536,16 +571,22 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanningMode = true;
}
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
boolean dialogOpened = optionsRouteControlDialog.isDialogVisible() || mapRouteInfoControlDialog.isDialogVisible();
boolean showRouteCalculationControls = routePlanningMode ||
((System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS) && routeFollowingMode);
boolean showMenuButton = showRouteCalculationControls || !routeFollowingMode;
updateMyLocation(rh);
boolean showMenuButton = (showRouteCalculationControls && portrait) ||
(!routeFollowingMode && !routePlanningMode);
updateMyLocation(rh, dialogOpened);
// routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions );
// routePlanningBtn.updateVisibility(showButtons && !routePlanningMode);
routePlanningBtn.setIconResId(R.drawable.map_directions );
routePlanningBtn.updateVisibility(!routeFollowingMode && !routePlanningMode);
menuControl.updateVisibility(showMenuButton);
menuControl.updateVisibility(showMenuButton && !dialogOpened);
mapZoomIn.updateVisibility(!dialogOpened);
mapZoomOut.updateVisibility(!dialogOpened);
compassHud.updateVisibility(!dialogOpened);
layersHud.updateVisibility(!dialogOpened);
if(routeFollowingMode || routePlanningMode) {
mapAppModeShadow.setVisibility(View.GONE);
@ -566,18 +607,17 @@ public class MapControlsLayer extends OsmandMapLayer {
int vis = showRouteCalculationControls ? View.VISIBLE : View.GONE;
if (showRouteCalculationControls) {
((TextView) routeGoControl.iv).setTextColor(textColor);
final String text;
String text = portrait ? mapActivity.getString(R.string.shared_string_go) : "";
if (startCounter > 0) {
int get = (int) ((startCounter - System.currentTimeMillis()) / 1000l);
text = mapActivity.getString(R.string.shared_string_go) + " (" + get + ")";
} else {
text = mapActivity.getString(R.string.shared_string_go);
text += " (" + get + ")";
}
((TextView) routeGoControl.iv).setText(text);
}
if (routePreparationLayout.getVisibility() != vis) {
routePreparationLayout.setVisibility(vis);
mapDashControl.updateVisibility(showRouteCalculationControls && !portrait);
mapRouteInfoControlDialog.setVisible(showRouteCalculationControls);
if (showRouteCalculationControls) {
if (!mapActivity.getRoutingHelper().isFollowingMode()
@ -612,7 +652,7 @@ public class MapControlsLayer extends OsmandMapLayer {
}
}
private void updateMyLocation(RoutingHelper rh) {
private void updateMyLocation(RoutingHelper rh, boolean dialogOpened) {
boolean enabled = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null;
boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
@ -627,7 +667,7 @@ public class MapControlsLayer extends OsmandMapLayer {
backToLocationControl.setBg(R.drawable.btn_circle_blue);
}
boolean visible = !(tracked && rh.isFollowingMode());
backToLocationControl.updateVisibility(visible);
backToLocationControl.updateVisibility(visible && !dialogOpened);
}

View file

@ -546,7 +546,7 @@ public class MapRouteInfoControl implements IRouteInformationListener {
public void hideDialog() {
if (dialog != null) {
dialog.hide();
dialog.dismiss();
dialog = null;
}
}

View file

@ -21,8 +21,8 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.activities.SettingsNavigationActivity;
import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.routing.RoutingHelper;
@ -195,7 +195,7 @@ public class MapRoutePreferencesControl {
if(!portrait) {
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), true);
}
dialog.setOnDismissListener(new OnDismissListener() {
OnDismissListener dismissList = new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dlg) {
mapActivity.getMapView().setMapPositionX(0);
@ -210,7 +210,8 @@ public class MapRoutePreferencesControl {
dismiss.onDismiss(dialog);
}
}
});
};
dialog.setOnDismissListener(dismissList);
return dialog;
}
@ -555,7 +556,7 @@ public class MapRoutePreferencesControl {
public void hideDialog() {
if(dialog != null) {
dialog.hide();
dialog.dismiss();
dialog = null;
}
}