From b118e9f5a3785daff06f854dfc977ddca1623171 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Sat, 22 Aug 2015 15:55:28 +0300 Subject: [PATCH 1/3] icons without paddings --- OsmAnd/res/layout/fragment_edit_poi.xml | 3 +- OsmAnd/res/layout/list_menu_item.xml | 23 ++- OsmAnd/res/layout/main.xml | 100 +++++---- OsmAnd/res/layout/simple_list_menu_item.xml | 14 ++ .../net/osmand/plus/ContextMenuAdapter.java | 193 ++++++++++-------- .../osmand/plus/activities/MapActivity.java | 4 + 6 files changed, 201 insertions(+), 136 deletions(-) create mode 100644 OsmAnd/res/layout/simple_list_menu_item.xml diff --git a/OsmAnd/res/layout/fragment_edit_poi.xml b/OsmAnd/res/layout/fragment_edit_poi.xml index 15f10cc0bc..3da904aca7 100644 --- a/OsmAnd/res/layout/fragment_edit_poi.xml +++ b/OsmAnd/res/layout/fragment_edit_poi.xml @@ -6,7 +6,8 @@ android:layout_height="match_parent" android:background="@color/dashboard_background" android:orientation="vertical" - tools:context="net.osmand.plus.osmedit.EditPoiFragment"> + tools:context="net.osmand.plus.osmedit.EditPoiFragment" + android:clickable="true"> + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/LinearLayout1" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_marginLeft="5dip" + android:layout_marginRight="5dip" + android:background="@color/color_white"> + android:layout_gravity="center_vertical" + tools:visibility="visible" + tools:background="@drawable/ic_action_delete_dark"/> - + android:layout_height="match_parent"> + android:id="@+id/drawer_layout" + android:layout_width="match_parent" + android:layout_height="match_parent"> - + + + + + + + + + + + android:layout_height="match_parent"> - + - + + + + + + - - - - - - + android:layout_gravity="left" + android:background="@color/dashboard_background"/> - - - \ No newline at end of file + \ No newline at end of file diff --git a/OsmAnd/res/layout/simple_list_menu_item.xml b/OsmAnd/res/layout/simple_list_menu_item.xml new file mode 100644 index 0000000000..a827bdda7a --- /dev/null +++ b/OsmAnd/res/layout/simple_list_menu_item.xml @@ -0,0 +1,14 @@ + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index 3c4f0c33ef..f5ac92efed 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -289,91 +289,116 @@ public class ContextMenuAdapter { public ArrayAdapter createListAdapter(final Activity activity, final boolean holoLight) { final int layoutId = defaultLayoutId; final OsmandApplication app = ((OsmandApplication) activity.getApplication()); - ArrayAdapter listAdapter = new ArrayAdapter(activity, layoutId, R.id.title, - getItemNames()) { - @Override - public View getView(final int position, View convertView, ViewGroup parent) { - // User super class to create the View - View v = convertView; - Integer lid = getLayoutId(position); - if (lid == R.layout.mode_toggles){ - final Set selected = new LinkedHashSet(); - return AppModeDialog.prepareAppModeDrawerView(activity, visibleModes, selected, allModes, new View.OnClickListener() { - @Override - public void onClick(View view) { - if (selected.size() > 0) { - app.getSettings().APPLICATION_MODE.set(selected.iterator().next()); - notifyDataSetChanged(); - } - if (changeAppModeListener != null) { - changeAppModeListener.onClick(allModes.getResult()); - } - } - }); - } - if (v == null || (v.getTag() != lid)) { - v = activity.getLayoutInflater().inflate(lid, null); - v.setTag(lid); - } - TextView tv = (TextView) v.findViewById(R.id.title); - tv.setText(isCategory(position) ? getItemName(position).toUpperCase() : getItemName(position)); - - Drawable imageId = getImage(app, position, holoLight); - if (imageId != null) { - ((ImageView) v.findViewById(R.id.icon)).setImageDrawable(imageId); - v.findViewById(R.id.icon).setVisibility(View.VISIBLE); - } else if (v.findViewById(R.id.icon) != null){ - v.findViewById(R.id.icon).setVisibility(View.GONE); - } - - if(isCategory(position)) { - tv.setTypeface(Typeface.DEFAULT_BOLD); - } else { - tv.setTypeface(null); - } - - if (v.findViewById(R.id.check_item) != null) { - final CompoundButton ch = (CompoundButton) v.findViewById(R.id.check_item); - if(selectedList.get(position) != -1) { - ch.setOnCheckedChangeListener(null); - ch.setVisibility(View.VISIBLE); - ch.setChecked(selectedList.get(position) > 0); - final ArrayAdapter la = this; - final OnCheckedChangeListener listener = new OnCheckedChangeListener() { - - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - OnContextMenuClick ca = getClickAdapter(position); - selectedList.set(position, isChecked ? 1 : 0); - if (ca != null) { - ca.onContextMenuClick(la, getElementId(position), position, isChecked); - } - } - }; - ch.setOnCheckedChangeListener(listener); - ch.setVisibility(View.VISIBLE); - } else if (ch != null) { - ch.setVisibility(View.GONE); - } - } - - if (v.findViewById(R.id.ProgressBar) != null){ - ProgressBar bar = (ProgressBar) v.findViewById(R.id.ProgressBar); - if(loadingList.get(position) == 1){ - bar.setVisibility(View.VISIBLE); - } else { - bar.setVisibility(View.INVISIBLE); - } - } - - String itemDescr = getItemDescr(position); - if (v.findViewById(R.id.descr) != null){ - ((TextView)v.findViewById(R.id.descr)).setText(itemDescr); - } - return v; - } - }; + ArrayAdapter listAdapter = new ContextMenuArrayAdapter(activity, layoutId, R.id.title, + getItemNames(), app, holoLight); return listAdapter; } + public ArrayAdapter createSimpleListAdapter(final Activity activity, final boolean holoLight) { + final int layoutId = R.layout.simple_list_menu_item; + final OsmandApplication app = ((OsmandApplication) activity.getApplication()); + ArrayAdapter listAdapter = new ContextMenuArrayAdapter(activity, layoutId, R.id.title, + getItemNames(), app, holoLight); + return listAdapter; + } + + public class ContextMenuArrayAdapter extends ArrayAdapter { + private Activity activity; + private OsmandApplication app; + private boolean holoLight; + private int layoutId; + public ContextMenuArrayAdapter(Activity context, int resource, int textViewResourceId, + String[] objects, OsmandApplication app, boolean holoLight) { + super(context, resource, textViewResourceId, objects); + activity = context; + this.app = app; + this.holoLight = holoLight; + layoutId = resource; + } + + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + // User super class to create the View + Integer lid = getLayoutId(position); + if (lid == R.layout.mode_toggles){ + final Set selected = new LinkedHashSet(); + return AppModeDialog.prepareAppModeDrawerView(activity, visibleModes, selected, allModes, new View.OnClickListener() { + @Override + public void onClick(View view) { + if (selected.size() > 0) { + app.getSettings().APPLICATION_MODE.set(selected.iterator().next()); + notifyDataSetChanged(); + } + if (changeAppModeListener != null) { + changeAppModeListener.onClick(allModes.getResult()); + } + } + }); + } + if (convertView == null || (convertView.getTag() != lid)) { + convertView = activity.getLayoutInflater().inflate(lid, null); + convertView.setTag(lid); + } + TextView tv = (TextView) convertView.findViewById(R.id.title); + tv.setText(isCategory(position) ? getItemName(position).toUpperCase() : getItemName(position)); + + Drawable imageId = getImage(app, position, holoLight); + if (imageId != null) { + if (layoutId == R.layout.simple_list_menu_item) { + tv.setCompoundDrawablesWithIntrinsicBounds(imageId, null, null, null); + } else { + ((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(imageId); + convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE); + } + } else if (convertView.findViewById(R.id.icon) != null){ + convertView.findViewById(R.id.icon).setVisibility(View.GONE); + } + + if(isCategory(position)) { + tv.setTypeface(Typeface.DEFAULT_BOLD); + } else { + tv.setTypeface(null); + } + + if (convertView.findViewById(R.id.check_item) != null) { + final CompoundButton ch = (CompoundButton) convertView.findViewById(R.id.check_item); + if(selectedList.get(position) != -1) { + ch.setOnCheckedChangeListener(null); + ch.setVisibility(View.VISIBLE); + ch.setChecked(selectedList.get(position) > 0); + final ArrayAdapter la = this; + final OnCheckedChangeListener listener = new OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + OnContextMenuClick ca = getClickAdapter(position); + selectedList.set(position, isChecked ? 1 : 0); + if (ca != null) { + ca.onContextMenuClick(la, getElementId(position), position, isChecked); + } + } + }; + ch.setOnCheckedChangeListener(listener); + ch.setVisibility(View.VISIBLE); + } else if (ch != null) { + ch.setVisibility(View.GONE); + } + } + + if (convertView.findViewById(R.id.ProgressBar) != null){ + ProgressBar bar = (ProgressBar) convertView.findViewById(R.id.ProgressBar); + if(loadingList.get(position) == 1){ + bar.setVisibility(View.VISIBLE); + } else { + bar.setVisibility(View.INVISIBLE); + } + } + + String itemDescr = getItemDescr(position); + if (convertView.findViewById(R.id.descr) != null){ + ((TextView)convertView.findViewById(R.id.descr)).setText(itemDescr); + } + return convertView; + } + } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 9e535713dc..6e17b51a66 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -22,6 +22,8 @@ import android.view.View; import android.view.ViewStub; import android.view.Window; import android.view.WindowManager; +import android.widget.LinearLayout; +import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; @@ -218,6 +220,8 @@ public class MapActivity extends AccessibleActivity { .add(R.id.fragmentContainer, new FirstUsageFragment(), FirstUsageFragment.TAG).commit(); } + ListView menuItemsListView = (ListView) findViewById(R.id.menuItems); + menuItemsListView.setAdapter(mapActions.createMainOptionsMenu().createSimpleListAdapter(this, true)); } private void checkAppInitialization() { From 2a856156cce8ca8be41bca6cc7c74ddfdd76d43b Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Sat, 22 Aug 2015 18:08:47 +0300 Subject: [PATCH 2/3] problem with drawable --- .../net/osmand/plus/ContextMenuAdapter.java | 11 ++++++++++- .../osmand/plus/activities/MapActivity.java | 1 + .../plus/activities/MapActivityActions.java | 18 +++++++++--------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index f5ac92efed..60d11a24f5 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -23,8 +23,12 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; +import org.apache.commons.logging.Log; + public class ContextMenuAdapter { +// Log log = + public interface OnContextMenuClick { //boolean return type needed to desribe if drawer needed to be close or not public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked); @@ -345,7 +349,12 @@ public class ContextMenuAdapter { Drawable imageId = getImage(app, position, holoLight); if (imageId != null) { if (layoutId == R.layout.simple_list_menu_item) { - tv.setCompoundDrawablesWithIntrinsicBounds(imageId, null, null, null); + float density = activity.getResources().getDisplayMetrics().density; + int paddingInPixels = (int) (24 * density); + int drawableSizeInPixels = (int) (50 * density); // 32 + imageId.setBounds(0, 0, drawableSizeInPixels, drawableSizeInPixels); + tv.setCompoundDrawables(imageId, null, null, null); + tv.setCompoundDrawablePadding(paddingInPixels); } else { ((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(imageId); convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 6e17b51a66..b5f8b31162 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -221,6 +221,7 @@ public class MapActivity extends AccessibleActivity { FirstUsageFragment.TAG).commit(); } ListView menuItemsListView = (ListView) findViewById(R.id.menuItems); + menuItemsListView.setDivider(null); menuItemsListView.setAdapter(mapActions.createMainOptionsMenu().createSimpleListAdapter(this, true)); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 8612790c83..02187a0059 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -544,6 +544,14 @@ public class MapActivityActions implements DialogProvider { final OsmandApplication app = mapActivity.getMyApplication(); ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app); + optionsMenuHelper.item(R.string.target_points).iconColor(R.drawable.ic_action_flage_dark) + .listen(new OnContextMenuClick() { + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); + return false; + } + }).reg(); optionsMenuHelper.item(R.string.get_directions).iconColor(R.drawable.ic_action_gdirections_dark) .listen(new OnContextMenuClick() { @Override @@ -557,15 +565,7 @@ public class MapActivityActions implements DialogProvider { return true; } }).reg(); - optionsMenuHelper.item(R.string.target_points).iconColor(R.drawable.ic_action_flage_dark) - .listen(new OnContextMenuClick() { - @Override - public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); - return false; - } - }).reg(); - // Default actions (Layers, Configure Map screen, Settings, Search, Favorites) + // Default actions (Layers, Configure Map screen, Settings, Search, Favorites) optionsMenuHelper.item(R.string.search_button) .iconColor(R.drawable.ic_action_search_dark) .listen(new OnContextMenuClick() { From 46d8531c21f6e97fbdb08c1d81bee047f7760ebd Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Mon, 24 Aug 2015 12:22:05 +0300 Subject: [PATCH 3/3] drawer is working --- OsmAnd/res/layout/dashboard_toolbar.xml | 75 ++++++------ OsmAnd/res/layout/main.xml | 2 +- .../net/osmand/plus/ContextMenuAdapter.java | 2 +- .../osmand/plus/activities/MapActivity.java | 108 ++++++++++++------ .../plus/activities/MapActivityActions.java | 11 +- .../osmand/plus/dashboard/DashboardOnMap.java | 27 +---- .../osmand/plus/views/MapControlsLayer.java | 5 +- 7 files changed, 130 insertions(+), 100 deletions(-) diff --git a/OsmAnd/res/layout/dashboard_toolbar.xml b/OsmAnd/res/layout/dashboard_toolbar.xml index a983b43a9f..28b85ac22c 100644 --- a/OsmAnd/res/layout/dashboard_toolbar.xml +++ b/OsmAnd/res/layout/dashboard_toolbar.xml @@ -1,63 +1,54 @@ - + app:contentInsetStart="4dp"> - - - + android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha" + tools:visibility="visible"/> + android:src="@drawable/ic_navigation_drawer"/> - - - - - + android:src="@drawable/ic_action_settings"/> + + + - + android:src="@drawable/ic_action_done"/> + - - + android:src="@drawable/ic_sort_waypoint_dark"/> + + + android:src="@drawable/ic_flat_list_dark" + android:visibility="gone"/> + android:src="@drawable/ic_action_edit_dark" + android:visibility="gone"/> \ No newline at end of file diff --git a/OsmAnd/res/layout/main.xml b/OsmAnd/res/layout/main.xml index 1b08bd647e..9908d51e14 100644 --- a/OsmAnd/res/layout/main.xml +++ b/OsmAnd/res/layout/main.xml @@ -1,11 +1,11 @@ diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index 60d11a24f5..96b4c70962 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -351,7 +351,7 @@ public class ContextMenuAdapter { if (layoutId == R.layout.simple_list_menu_item) { float density = activity.getResources().getDisplayMetrics().density; int paddingInPixels = (int) (24 * density); - int drawableSizeInPixels = (int) (50 * density); // 32 + int drawableSizeInPixels = (int) (32 * density); // 32 imageId.setBounds(0, 0, drawableSizeInPixels, drawableSizeInPixels); tv.setCompoundDrawables(imageId, null, null, null); tv.setCompoundDrawablePadding(paddingInPixels); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index b5f8b31162..58d64a3d6d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -15,14 +15,18 @@ import android.os.Environment; import android.os.Handler; import android.os.Message; import android.support.v4.app.NotificationCompat.Builder; +import android.support.v4.widget.DrawerLayout; import android.support.v7.app.NotificationCompat; +import android.util.Log; +import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewStub; import android.view.Window; import android.view.WindowManager; -import android.widget.LinearLayout; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; @@ -46,6 +50,7 @@ import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.InitEvents; import net.osmand.plus.ApplicationMode; import net.osmand.plus.BusyIndicator; +import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.FirstUsageFragment; import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmandApplication; @@ -91,7 +96,9 @@ public class MapActivity extends AccessibleActivity { private static MapViewTrackingUtilities mapViewTrackingUtilities; - /** Called when the activity is first created. */ + /** + * Called when the activity is first created. + */ private OsmandMapTileView mapView; private AtlasMapRendererView atlasMapRendererView; @@ -121,6 +128,7 @@ public class MapActivity extends AccessibleActivity { private DashboardOnMap dashboardOnMap = new DashboardOnMap(this); private AppInitializeListener initListener; private IMapDownloaderCallback downloaderCallback; + private DrawerLayout drawerLayout; private Notification getNotification() { Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity()); @@ -133,11 +141,11 @@ public class MapActivity extends AccessibleActivity { // pi); int smallIcon = app.getSettings().getApplicationMode().getSmallIconDark(); final Builder noti = new NotificationCompat.Builder( - this).setContentTitle(Version.getAppName(app)) - .setContentText(getString(R.string.go_back_to_osmand)) - .setSmallIcon(smallIcon ) + this).setContentTitle(Version.getAppName(app)) + .setContentText(getString(R.string.go_back_to_osmand)) + .setSmallIcon(smallIcon) // .setLargeIcon(Helpers.getBitmap(R.drawable.mirakel, getBaseContext())) - .setContentIntent(pi).setOngoing(true); + .setContentIntent(pi).setOngoing(true); return noti.build(); } @@ -210,19 +218,34 @@ public class MapActivity extends AccessibleActivity { OsmandPlugin.onMapActivityCreate(this); gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView()); wakeLockHelper = new WakeLockHelper(getMyApplication()); - if(System.currentTimeMillis() - tm > 50) { + if (System.currentTimeMillis() - tm > 50) { System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms"); } mapView.refreshMap(true); - if(getMyApplication().getAppInitializer().isFirstTime(this)) { + if (getMyApplication().getAppInitializer().isFirstTime(this)) { getSupportFragmentManager().beginTransaction() .add(R.id.fragmentContainer, new FirstUsageFragment(), FirstUsageFragment.TAG).commit(); } - ListView menuItemsListView = (ListView) findViewById(R.id.menuItems); + final ListView menuItemsListView = (ListView) findViewById(R.id.menuItems); menuItemsListView.setDivider(null); - menuItemsListView.setAdapter(mapActions.createMainOptionsMenu().createSimpleListAdapter(this, true)); + final ContextMenuAdapter contextMenuAdapter = mapActions.createMainOptionsMenu(); + final ArrayAdapter simpleListAdapter = contextMenuAdapter.createSimpleListAdapter(this, true); + menuItemsListView.setAdapter(simpleListAdapter); + menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + ContextMenuAdapter.OnContextMenuClick click = + contextMenuAdapter.getClickAdapter(position); + if (click.onContextMenuClick(simpleListAdapter, + contextMenuAdapter.getElementId(position), position, false)) { + closeDrawer(); + } + } + }); + + drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); } private void checkAppInitialization() { @@ -230,20 +253,21 @@ public class MapActivity extends AccessibleActivity { findViewById(R.id.init_progress).setVisibility(View.VISIBLE); initListener = new AppInitializeListener() { boolean openGlSetup = false; + @Override public void onProgress(AppInitializer init, InitEvents event) { String tn = init.getCurrentInitTaskName(); if (tn != null) { ((TextView) findViewById(R.id.ProgressMessage)).setText(tn); } - if(event == InitEvents.NATIVE_INITIALIZED) { + if (event == InitEvents.NATIVE_INITIALIZED) { setupOpenGLView(false); openGlSetup = true; } - if(event == InitEvents.MAPS_INITIALIZED) { + if (event == InitEvents.MAPS_INITIALIZED) { // TODO investigate if this false cause any issues! mapView.refreshMap(false); - if(dashboardOnMap != null) { + if (dashboardOnMap != null) { dashboardOnMap.updateLocation(true, true, false); } } @@ -251,11 +275,11 @@ public class MapActivity extends AccessibleActivity { @Override public void onFinish(AppInitializer init) { - if(!openGlSetup) { + if (!openGlSetup) { setupOpenGLView(false); } mapView.refreshMap(false); - if(dashboardOnMap != null) { + if (dashboardOnMap != null) { dashboardOnMap.updateLocation(true, true, false); } findViewById(R.id.init_progress).setVisibility(View.GONE); @@ -348,7 +372,7 @@ public class MapActivity extends AccessibleActivity { @Override public void onBackPressed() { - if(dashboardOnMap.onBackPressed()) { + if (dashboardOnMap.onBackPressed()) { return; } super.onBackPressed(); @@ -359,7 +383,7 @@ public class MapActivity extends AccessibleActivity { super.onResume(); long tm = System.currentTimeMillis(); if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) { - if(!dashboardOnMap.isVisible()) { + if (!dashboardOnMap.isVisible()) { dashboardOnMap.setDashboardVisibility(true, DashboardOnMap.staticVisibleType); } } @@ -400,7 +424,7 @@ public class MapActivity extends AccessibleActivity { RoutingHelper routingHelper = app.getRoutingHelper(); if (routingHelper.isFollowingMode() && (!Algorithms.objectEquals(targets.getPointToNavigate().point, routingHelper.getFinalLocation()) || !Algorithms - .objectEquals(targets.getIntermediatePointsLatLon(), routingHelper.getIntermediatePoints()))) { + .objectEquals(targets.getIntermediatePointsLatLon(), routingHelper.getIntermediatePoints()))) { targets.updateRouteAndReferesh(true); } app.getLocationProvider().resumeAllUpdates(); @@ -452,7 +476,7 @@ public class MapActivity extends AccessibleActivity { atlasMapRendererView.handleOnResume(); } getMyApplication().getAppCustomization().resumeActivity(MapActivity.class, this); - if(System.currentTimeMillis() - tm > 50) { + if (System.currentTimeMillis() - tm > 50) { System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms"); } } @@ -495,12 +519,12 @@ public class MapActivity extends AccessibleActivity { loc.setLatitude(mapView.getLatitude()); loc.setLongitude(mapView.getLongitude()); getMapActions().enterRoutePlanningMode(null, null, status == OsmandSettings.NAVIGATE_CURRENT_GPX); - if(dashboardOnMap.isVisible()) { + if (dashboardOnMap.isVisible()) { dashboardOnMap.hideDashboard(); } } if (latLonToShow != null) { - if(dashboardOnMap.isVisible()) { + if (dashboardOnMap.isVisible()) { dashboardOnMap.hideDashboard(); } if (mapLabelToShow != null) { @@ -567,7 +591,7 @@ public class MapActivity extends AccessibleActivity { AccessibleToast.makeText(this, R.string.edit_tilesource_maxzoom, Toast.LENGTH_SHORT).show(); //$NON-NLS-1$ return; } - if(newZoom < 1) { + if (newZoom < 1) { AccessibleToast.makeText(this, R.string.edit_tilesource_minzoom, Toast.LENGTH_SHORT).show(); //$NON-NLS-1$ return; } @@ -601,7 +625,7 @@ public class MapActivity extends AccessibleActivity { LatLon loc = getMapLocation(); newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude()); newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude()); - if(mapViewTrackingUtilities.isMapLinkedToLocation()) { + if (mapViewTrackingUtilities.isMapLinkedToLocation()) { newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true); } startActivity(newIntent); @@ -644,7 +668,7 @@ public class MapActivity extends AccessibleActivity { return super.onTrackballEvent(event); } - + @Override protected void onStart() { super.onStart(); @@ -695,14 +719,14 @@ public class MapActivity extends AccessibleActivity { } public LatLon getMapLocation() { - if(mapView == null) { + if (mapView == null) { return settings.getLastKnownMapLocation(); } return new LatLon(mapView.getLatitude(), mapView.getLongitude()); } - + public float getMapRotate() { - if(mapView == null) { + if (mapView == null) { return 0; } return mapView.getRotate(); @@ -763,7 +787,7 @@ public class MapActivity extends AccessibleActivity { } public void updateMapSettings() { - if(app.isApplicationInitializing()) { + if (app.isApplicationInitializing()) { return; } // update vector renderer @@ -786,9 +810,13 @@ public class MapActivity extends AccessibleActivity { } return null; } - protected void onPostExecute(Void result) {}; + + protected void onPostExecute(Void result) { + } + + ; }.execute((Void) null); - + } @Override @@ -826,7 +854,7 @@ public class MapActivity extends AccessibleActivity { } public void checkExternalStorage() { - if(Build.VERSION.SDK_INT >= 19) { + if (Build.VERSION.SDK_INT >= 19) { return; } String state = Environment.getExternalStorageState(); @@ -916,7 +944,7 @@ public class MapActivity extends AccessibleActivity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { OsmandPlugin.onMapActivityResult(requestCode, resultCode, data); MapControlsLayer mcl = mapView.getLayerByClass(MapControlsLayer.class); - if(mcl != null) { + if (mcl != null) { mcl.onActivityResult(requestCode, resultCode, data); } } @@ -932,4 +960,20 @@ public class MapActivity extends AccessibleActivity { public DashboardOnMap getDashboard() { return dashboardOnMap; } + + public void openDrawer() { + drawerLayout.openDrawer(Gravity.LEFT); + } + + public void disableDrawer() { + drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); + } + + public void enableDrawer() { + drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); + } + + public void closeDrawer() { + drawerLayout.closeDrawer(Gravity.LEFT); + } } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 02187a0059..69ec54b7fb 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -543,7 +543,16 @@ public class MapActivityActions implements DialogProvider { final OsmandMapTileView mapView = mapActivity.getMapView(); final OsmandApplication app = mapActivity.getMyApplication(); ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app); - + + optionsMenuHelper.item(R.string.home).iconColor(R.drawable.map_dashboard) + .listen(new OnContextMenuClick() { + @Override + public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + mapActivity.closeDrawer(); + mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); + return true; + } + }).reg(); optionsMenuHelper.item(R.string.target_points).iconColor(R.drawable.ic_action_flage_dark) .listen(new OnContextMenuClick() { @Override diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 704e506dc0..29825b8e15 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -1,6 +1,7 @@ package net.osmand.plus.dashboard; import android.annotation.SuppressLint; +import android.app.ActionBar; import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; @@ -239,8 +240,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { flat.setVisibility(View.GONE); ImageView settingsButton = (ImageView) dashboardView.findViewById(R.id.toolbar_settings); settingsButton.setVisibility(View.GONE); - ImageView configureScreen = (ImageView) dashboardView.findViewById(R.id.toolbar_configure_screen); - configureScreen.setVisibility(View.GONE); IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache(); ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list); lst.setVisibility(View.GONE); @@ -302,15 +301,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { }); } if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) { - configureScreen.setVisibility(View.VISIBLE); - configureScreen.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN); - } - }); - - settingsButton.setVisibility(View.VISIBLE); settingsButton.setOnClickListener(new View.OnClickListener() { @@ -321,19 +311,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { } }); lst.setVisibility(View.VISIBLE); - if (visibleType == DashboardType.DASHBOARD) { - lst.setImageDrawable(iconsCache.getIcon(R.drawable.ic_navigation_drawer)); - } else if (visibleType == DashboardType.LIST_MENU) { - lst.setImageDrawable(iconsCache.getIcon(R.drawable.ic_dashboard_dark)); - } lst.setOnClickListener(new View.OnClickListener() { + @Override public void onClick(View v) { - if (visibleType == DashboardType.DASHBOARD) { - setDashboardVisibility(true, DashboardType.LIST_MENU, null, true); - } else { - setDashboardVisibility(true, DashboardType.DASHBOARD, null, true); - } + hideDashboard(false); + mapActivity.openDrawer(); } }); } @@ -441,12 +424,14 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks { this.visibleType = type; DashboardOnMap.staticVisible = visible; DashboardOnMap.staticVisibleType = type; + mapActivity.enableDrawer(); if (visible) { mapViewLocation = mapActivity.getMapLocation(); mapRotation = mapActivity.getMapRotate(); mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation(); myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation(); mapActivity.getMapViewTrackingUtilities().setDashboard(this); + mapActivity.disableDrawer(); dashboardView.setVisibility(View.VISIBLE); if (isActionButtonVisible()) { actionButton.setVisibility(View.VISIBLE); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index ee9ee83caa..c8d7000743 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -385,7 +385,7 @@ public class MapControlsLayer extends OsmandMapLayer { View backToMenuButton = mapActivity.findViewById(R.id.map_menu_button); - menuControl = createHudButton((ImageView) backToMenuButton, R.drawable.map_dashboard).setBg( + menuControl = createHudButton((ImageView) backToMenuButton, R.drawable.ic_navigation_drawer).setBg( R.drawable.btn_round, R.drawable.btn_round_night); controls.add(menuControl); backToMenuButton.setOnClickListener(new View.OnClickListener() { @@ -395,7 +395,8 @@ public class MapControlsLayer extends OsmandMapLayer { // double lon = activity.getMapView().getLongitude(); // MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon)); notifyClicked(); - mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); + mapActivity.openDrawer(); +// mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); } }); mapAppModeShadow = mapActivity.findViewById(R.id.map_app_mode_shadow);