From ccad661057d8decf09322a6372053703d9be2bf6 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 26 Oct 2014 00:03:34 +0200 Subject: [PATCH] Fix layout issues --- OsmAnd/res/drawable/drawer_divider.xml | 18 +++++++++++++ OsmAnd/res/layout/drawer_list_doubleitem.xml | 15 +++++++---- OsmAnd/res/layout/drawer_list_item.xml | 21 +++++---------- OsmAnd/res/layout/drawer_list_sub_header.xml | 4 +-- .../osmand/plus/activities/MapActivity.java | 9 +++---- .../plus/activities/MapActivityActions.java | 1 + .../plus/helpers/WaypointDialogHelper.java | 4 ++- .../net/osmand/plus/views/MapInfoLayer.java | 26 +++++++------------ .../mapwidgets/AppearanceWidgetsFactory.java | 8 +++--- .../views/mapwidgets/MapWidgetRegistry.java | 9 ++++--- 10 files changed, 63 insertions(+), 52 deletions(-) create mode 100644 OsmAnd/res/drawable/drawer_divider.xml diff --git a/OsmAnd/res/drawable/drawer_divider.xml b/OsmAnd/res/drawable/drawer_divider.xml new file mode 100644 index 0000000000..dc1fb17fb0 --- /dev/null +++ b/OsmAnd/res/drawable/drawer_divider.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/drawer_list_doubleitem.xml b/OsmAnd/res/layout/drawer_list_doubleitem.xml index dd0a14a768..830f4f124f 100644 --- a/OsmAnd/res/layout/drawer_list_doubleitem.xml +++ b/OsmAnd/res/layout/drawer_list_doubleitem.xml @@ -10,22 +10,27 @@ + android:layout_height="32dp" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp"> - - - - - - + android:paddingBottom="4dp"> -x` + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 282166649f..03d1cc8ce0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -126,14 +126,13 @@ public class MapActivity extends AccessibleActivity { app.applyTheme(this); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); - - - - mapActions = new MapActivityActions(this); - mapLayers = new MapActivityLayers(this); // Full screen is not used here //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); + + mapActions = new MapActivityActions(this); + mapLayers = new MapActivityLayers(this); + startProgressDialog = new ProgressDialog(this); startProgressDialog.setCancelable(true); app.checkApplicationIsBeingInitialized(this, startProgressDialog); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 32c0977327..03ae1b5eab 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -768,6 +768,7 @@ public class MapActivityActions implements DialogProvider { final ArrayAdapter listAdapter = cm.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContentMenu()); mDrawerList.setAdapter(listAdapter); + mDrawerList.setDivider(mapActivity.getResources().getDrawable(R.drawable.drawer_shadow)); mDrawerList.setBackgroundColor(cm.getBackgroundColor(mapActivity, getMyApplication().getSettings().isLightContentMenu())); mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index afb066a090..8d0876e3cd 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -62,7 +62,9 @@ public class WaypointDialogHelper implements OsmAndLocationListener { waypointHelper = this.app.getWaypointHelper(); this.mapActivity = mapActivity; this.mainLayout = (LinearLayout) mapActivity.findViewById(R.id.dialog_layout); - + if(mainLayout == null) { + throw new IllegalStateException(); + } } public void init() { diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index ba23d2895f..e8e035358b 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -2,19 +2,17 @@ package net.osmand.plus.views; import java.lang.reflect.Field; -import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.Set; import net.osmand.data.RotatedTileBox; import net.osmand.plus.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.actions.AppModeDialog; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.views.mapwidgets.AppearanceWidgetsFactory; import net.osmand.plus.views.mapwidgets.BaseMapWidget; @@ -28,7 +26,6 @@ import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.StackWidgetView; import net.osmand.plus.views.mapwidgets.TextInfoWidget; import net.osmand.plus.views.mapwidgets.UpdateableWidget; -import net.osmand.util.Algorithms; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; @@ -39,17 +36,10 @@ import android.graphics.drawable.Drawable; import android.view.Gravity; import android.view.View; import android.view.View.MeasureSpec; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.TextView; public class MapInfoLayer extends OsmandMapLayer { @@ -232,6 +222,11 @@ public class MapInfoLayer extends OsmandMapLayer { public void createControls() { // 1. Create view groups and controls statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top)); + + // form measurement + ImageView iv = new ImageView(map); + iv.setImageDrawable(map.getResources().getDrawable(R.drawable.la_backtoloc_disabled)); + statusBar.addView(iv); rightStack = new StackWidgetView(view.getContext()); leftStack = new StackWidgetView(view.getContext()); @@ -239,7 +234,6 @@ public class MapInfoLayer extends OsmandMapLayer { Rect topRectPadding = new Rect(); view.getResources().getDrawable(R.drawable.box_top).getPadding(topRectPadding); // for measurement - //statusBar.addView(backToLocation); STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient); statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); Rect statusBarPadding = new Rect(); @@ -310,7 +304,7 @@ public class MapInfoLayer extends OsmandMapLayer { }).reg(); cm.item(R.string.map_widget_reset) - .icons(R.drawable.widget_reset_to_default_light, R.drawable.widget_reset_to_default_dark).listen(new OnContextMenuClick() { + .icons(R.drawable.widget_reset_to_default_dark, R.drawable.widget_reset_to_default_light).listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { @@ -353,8 +347,8 @@ public class MapInfoLayer extends OsmandMapLayer { for(final MapWidgetRegInfo r : top){ // String s = mi.visibleCollapsed(mode)? " - " : " "; // tv.setText(s +map.getString(mi.messageId) +s); - adapter.item(r.messageId) - .icons(r.drawableLight, r.drawableDark).listen(new OnContextMenuClick() { + adapter.item(r.messageId).selected(r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0) + .icons(r.drawableDark, r.drawableLight).listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java index 3e262ba06c..bbdbe1656a 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java @@ -26,7 +26,7 @@ public class AppearanceWidgetsFactory { // } // }); - final MapWidgetRegistry.MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.drawable.widget_ruler, R.string.map_widget_show_ruler, + final MapWidgetRegistry.MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(0, 0, /*R.drawable.widget_ruler, R.drawable.widget_ruler, */R.string.map_widget_show_ruler, "showRuler", view.getSettings().SHOW_RULER); showRuler.setStateChangeListener(new Runnable() { @Override @@ -35,7 +35,7 @@ public class AppearanceWidgetsFactory { view.refreshMap(); } }); - final MapWidgetRegistry.MapWidgetRegInfo showDestinationArrow = mapInfoControls.registerAppearanceWidget(R.drawable.widget_show_destination_arrow, R.drawable.widget_show_destination_arrow, R.string.map_widget_show_destination_arrow, + final MapWidgetRegistry.MapWidgetRegInfo showDestinationArrow = mapInfoControls.registerAppearanceWidget(0, 0, /*R.drawable.widget_show_destination_arrow, R.drawable.widget_show_destination_arrow, */R.string.map_widget_show_destination_arrow, "show_destination_arrow", view.getSettings().SHOW_DESTINATION_ARROW); showDestinationArrow.setStateChangeListener(new Runnable() { @Override @@ -45,7 +45,7 @@ public class AppearanceWidgetsFactory { } }); - final MapWidgetRegistry.MapWidgetRegInfo transparent = mapInfoControls.registerAppearanceWidget(R.drawable.widget_transparent_skin, R.drawable.widget_transparent_skin, R.string.map_widget_transparent, + final MapWidgetRegistry.MapWidgetRegInfo transparent = mapInfoControls.registerAppearanceWidget(0, 0, /*R.drawable.widget_transparent_skin, R.drawable.widget_transparent_skin, */R.string.map_widget_transparent, "transparent", view.getSettings().TRANSPARENT_MAP_THEME); transparent.setStateChangeListener(new Runnable() { @Override @@ -54,7 +54,7 @@ public class AppearanceWidgetsFactory { mapInfoLayer.recreateControls(); } }); - final MapWidgetRegistry.MapWidgetRegInfo centerPosition = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.drawable.widget_position_marker, + final MapWidgetRegistry.MapWidgetRegInfo centerPosition = mapInfoControls.registerAppearanceWidget(0, 0, /*R.drawable.widget_position_marker, R.drawable.widget_position_marker,*/ R.string.always_center_position_on_map, "centerPosition", view.getSettings().CENTER_POSITION_ON_MAP); centerPosition.setStateChangeListener(new Runnable() { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index 43661cfcbd..0c07f99ae6 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -82,12 +82,13 @@ public class MapWidgetRegistry { } - public MapWidgetRegInfo registerTopWidget(View m, int drawableDark,int drawableLight, int messageId, String key, int left, int priorityOrder) { + public MapWidgetRegInfo registerTopWidget(View m, int drawableDark, int drawableLight, int messageId, String key, + int left, int priorityOrder) { MapWidgetRegInfo ii = new MapWidgetRegInfo(); ii.key = key; - ii.visibleModes = new LinkedHashSet(); + ii.visibleModes = new LinkedHashSet(); ii.visibleCollapsible = null; - for(ApplicationMode ms : ApplicationMode.values(settings) ) { + for (ApplicationMode ms : ApplicationMode.values(settings)) { boolean def = ms.isWidgetVisible(key); Set set = visibleElementsFromSettings.get(ms); if (set != null) { @@ -97,7 +98,7 @@ public class MapWidgetRegistry { def = false; } } - if(def){ + if (def) { ii.visibleModes.add(ms); } }