Fix landscape tablet layout

This commit is contained in:
Alexey Kulish 2016-08-03 17:16:58 +03:00
parent 7667943c3b
commit 5dcf1faa3a
13 changed files with 33 additions and 41 deletions

View file

@ -2,7 +2,7 @@
<LinearLayout
android:id="@+id/main_view"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp"
android:layout_width="@dimen/dashboard_land_width"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="?attr/left_menu_view_bg"

View file

@ -9,7 +9,7 @@
<LinearLayout
android:id="@+id/main_view"
android:layout_width="@dimen/map_route_planning_land_width"
android:layout_width="@dimen/dashboard_land_width"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="@drawable/bg_left_menu_dark"

View file

@ -2,7 +2,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/point_edit_layout"
android:layout_width="366dp"
android:layout_width="@dimen/dashboard_land_width"
android:layout_height="match_parent"
android:background="?attr/left_menu_view_bg">
@ -65,7 +65,7 @@
android:layout_marginTop="2dp"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:scaleType="center"
android:scaleType="centerInside"
android:src="@drawable/ic_action_building_number"/>
</LinearLayout>
@ -122,7 +122,7 @@
android:layout_marginTop="2dp"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:scaleType="center"
android:scaleType="centerInside"
android:src="@drawable/ic_action_building_number"/>
</LinearLayout>

View file

@ -14,7 +14,7 @@
android:id="@+id/toolbar_back"
android:contentDescription="@string/back_to_map"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
@ -25,17 +25,18 @@
android:id="@+id/toolbar_list"
android:contentDescription="@string/backToMenu"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
android:src="@drawable/ic_navigation_drawer"/>
android:src="@drawable/ic_navigation_drawer"
tools:visibility="gone"/>
<ImageView
android:id="@+id/toolbar_settings"
android:contentDescription="@string/shared_string_settings"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
@ -48,15 +49,15 @@
android:layout_gravity="left"
android:scaleType="center"
android:textColor="@color/abc_primary_text_material_dark"
android:textSize="@dimen/abc_text_size_headline_material"
android:textSize="@dimen/abc_text_size_large_material"
tools:text="Toolbar"
tools:visibility="gone"/>
tools:visibility="visible"/>
<ImageView
android:id="@+id/toolbar_ok"
android:contentDescription="@string/shared_string_ok"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
@ -66,7 +67,7 @@
android:id="@+id/toolbar_sort"
android:contentDescription="@string/intermediate_points_change_order"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
@ -77,7 +78,7 @@
android:id="@+id/toolbar_flat"
android:contentDescription="@string/drawer"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
@ -88,7 +89,7 @@
android:id="@+id/toolbar_edit"
android:contentDescription="@string/shared_string_edit"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"

View file

@ -72,7 +72,7 @@
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="2dp"
android:scaleType="center"
android:scaleType="centerInside"
android:src="@drawable/ic_action_building_number"/>
</LinearLayout>
@ -130,7 +130,7 @@
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="2dp"
android:scaleType="center"
android:scaleType="centerInside"
android:src="@drawable/ic_action_building_number"/>
</LinearLayout>

View file

@ -30,7 +30,6 @@ public class AudioVideoNoteRecordingMenu {
protected long startTime;
protected Handler handler;
protected boolean portraitMode;
protected boolean largeDevice;
protected Timer recTimer;
protected double lat;
@ -50,7 +49,6 @@ public class AudioVideoNoteRecordingMenu {
MapActivity mapActivity = plugin.getMapActivity();
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
initView(mapActivity);
viewfinder = (LinearLayout) view.findViewById(R.id.viewfinder);
@ -106,7 +104,7 @@ public class AudioVideoNoteRecordingMenu {
}
public boolean isLandscapeLayout() {
return !portraitMode && !largeDevice;
return !portraitMode;
}
public void show() {

View file

@ -9,12 +9,10 @@ import net.osmand.plus.helpers.AndroidUiHelper;
public abstract class BaseMenuController {
public final static float LANDSCAPE_WIDTH_DP = 366f;
private MapActivity mapActivity;
private boolean portraitMode;
private boolean largeDevice;
private boolean nightMode;
private int landscapeWidthPx;
public BaseMenuController(MapActivity mapActivity) {
this.mapActivity = mapActivity;
@ -23,7 +21,7 @@ public abstract class BaseMenuController {
private void init() {
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
landscapeWidthPx = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_land_width);
updateNightMode();
}
@ -48,8 +46,8 @@ public abstract class BaseMenuController {
return !portraitMode;
}
public float getLandscapeWidthDp() {
return LANDSCAPE_WIDTH_DP;
public int getLandscapeWidthPx() {
return landscapeWidthPx;
}
public float getHalfScreenMaxHeightKoef() {

View file

@ -714,11 +714,11 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return menuController != null && menuController.isLandscapeLayout();
}
public float getLandscapeWidthDp() {
public int getLandscapeWidthPx() {
if (menuController != null) {
return menuController.getLandscapeWidthDp();
return menuController.getLandscapeWidthPx();
} else {
return 0f;
return 0;
}
}

View file

@ -228,10 +228,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
final TypedValue typedValueAttr = new TypedValue();
getMapActivity().getTheme().resolveAttribute(R.attr.left_menu_view_bg, typedValueAttr, true);
mainView.setBackgroundResource(typedValueAttr.resourceId);
mainView.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),
mainView.setLayoutParams(new FrameLayout.LayoutParams(menu.getLandscapeWidthPx(),
ViewGroup.LayoutParams.MATCH_PARENT));
View fabContainer = view.findViewById(R.id.context_menu_fab_container);
fabContainer.setLayoutParams(new FrameLayout.LayoutParams(dpToPx(menu.getLandscapeWidthDp()),
fabContainer.setLayoutParams(new FrameLayout.LayoutParams(menu.getLandscapeWidthPx(),
ViewGroup.LayoutParams.MATCH_PARENT));
}
@ -1098,7 +1098,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
latlon = box.getLatLonFromPixel(markerMapCenterX, markerMapCenterY);
}
if (menu.isLandscapeLayout()) {
int x = dpToPx(menu.getLandscapeWidthDp());
int x = menu.getLandscapeWidthPx();
if (markerX - markerPaddingXPx < x || markerX > origMarkerX) {
int dx = (x + markerPaddingXPx) - markerX;
int dy = 0;

View file

@ -31,7 +31,7 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP;
public class MenuBuilder {
public static final float SHADOW_HEIGHT_TOP_DP = 16f;
public static final float SHADOW_HEIGHT_TOP_DP = 17f;
protected OsmandApplication app;
protected LinkedList<PlainMenuItem> plainMenuItems;

View file

@ -15,13 +15,11 @@ public abstract class PointEditor {
protected boolean isNew;
private boolean portraitMode;
private boolean largeDevice;
private boolean nightMode;
public PointEditor(MapActivity mapActivity) {
this.app = mapActivity.getMyApplication();
this.mapActivity = mapActivity;
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
updateLandscapePortrait();
updateNightMode();
}
@ -35,7 +33,7 @@ public abstract class PointEditor {
}
public boolean isLandscapeLayout() {
return !portraitMode && !largeDevice;
return !portraitMode;
}
public boolean isLight() {

View file

@ -115,8 +115,7 @@ public class MapRouteInfoMenuFragment extends Fragment {
public void applyDayNightMode() {
MapActivity ctx = getMapActivity();
boolean portraitMode = AndroidUiHelper.isOrientationPortrait(ctx);
boolean largeDevice = AndroidUiHelper.isXLargeDevice(ctx);
boolean landscapeLayout = !portraitMode && !largeDevice;
boolean landscapeLayout = !portraitMode;
boolean nightMode = ctx.getMyApplication().getDaynightHelper().isNightModeForMapControls();
if (!landscapeLayout) {
AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);

View file

@ -36,7 +36,6 @@ public class MapMarkersWidgetsFactory {
private MapMarkersHelper helper;
private int screenOrientation;
private boolean portraitMode;
private boolean largeDevice;
private View topBar;
private View addressTopBar;
@ -62,7 +61,6 @@ public class MapMarkersWidgetsFactory {
helper = map.getMyApplication().getMapMarkersHelper();
screenOrientation = DashLocationFragment.getScreenOrientation(map);
portraitMode = AndroidUiHelper.isOrientationPortrait(map);
largeDevice = AndroidUiHelper.isXLargeDevice(map);
addressTopBar = map.findViewById(R.id.map_top_bar);
topBar = map.findViewById(R.id.map_markers_top_bar);
@ -304,7 +302,7 @@ public class MapMarkersWidgetsFactory {
}
public boolean isLandscapeLayout() {
return !portraitMode && !largeDevice;
return !portraitMode;
}
public abstract static class DistanceToMapMarkerControl extends TextInfoWidget {