From 6422a8aa56ac27b47c190c26de0227c67e5ffd8d Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 8 Mar 2015 12:30:12 +0100 Subject: [PATCH] Update dashboard --- OsmAnd/res/layout-land/dashboard_over_map.xml | 19 +++++- OsmAnd/res/layout/dashboard_over_map.xml | 20 +++++-- OsmAnd/res/values/strings.xml | 1 + .../osmand/plus/dashboard/DashboardOnMap.java | 59 +++++++++++++++++-- 4 files changed, 86 insertions(+), 13 deletions(-) diff --git a/OsmAnd/res/layout-land/dashboard_over_map.xml b/OsmAnd/res/layout-land/dashboard_over_map.xml index b530ce66f4..a01fec4345 100644 --- a/OsmAnd/res/layout-land/dashboard_over_map.xml +++ b/OsmAnd/res/layout-land/dashboard_over_map.xml @@ -16,15 +16,28 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main_scroll" android:layout_width="360dp" - android:layout_gravity="start" android:layout_height="match_parent" + android:layout_gravity="start" android:fadeScrollbars="true" > + android:id="@+id/animateContent" + android:orientation="vertical" > + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/dashboard_over_map.xml b/OsmAnd/res/layout/dashboard_over_map.xml index 49f6f801c5..1cdfc6e4c2 100644 --- a/OsmAnd/res/layout/dashboard_over_map.xml +++ b/OsmAnd/res/layout/dashboard_over_map.xml @@ -20,12 +20,24 @@ android:fadeScrollbars="true" > + android:id="@+id/animateContent" + android:orientation="vertical" > + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 857b255fd4..ba39cf3e48 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Flat list Lat %1$s\n Lon %2$s Frequently asked questions, recent changes and others Navigation settings diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index dead8adfc1..6e11018a22 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -6,13 +6,14 @@ import net.osmand.plus.audionotes.DashAudioVideoNotesFragment; import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.monitoring.DashTrackFragment; import net.osmand.plus.views.controls.FloatingActionButton; -import android.content.res.Resources; -import android.graphics.Color; import android.os.Build; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; -import android.util.TypedValue; +import android.support.v4.view.MenuItemCompat; +import android.support.v7.widget.Toolbar; import android.view.Gravity; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.animation.Animation; @@ -28,6 +29,10 @@ import android.widget.ScrollView; public class DashboardOnMap { + private static final int LIST_ID = 1; + private static final int WAYPOINTS_ID = 2; + private static final int CONFIGURE_SCREEN_ID = 3; + private static final int SETTINGS_ID = 4; private MapActivity ma; FloatingActionButton fabButton; boolean floatingButtonVisible = true; @@ -80,21 +85,59 @@ public class DashboardOnMap { this.visible = visible; if (visible) { addDashboardFragments(); + setupActionBar(); dashboardView.setVisibility(View.VISIBLE); fabButton.showFloatingActionButton(); - open(dashboardView.findViewById(R.id.content)); + open(dashboardView.findViewById(R.id.animateContent)); ma.getMapActions().disableDrawer(); ma.findViewById(R.id.MapInfoControls).setVisibility(View.GONE); ma.findViewById(R.id.MapButtons).setVisibility(View.GONE); } else { ma.getMapActions().enableDrawer(); - hide(dashboardView.findViewById(R.id.content)); + hide(dashboardView.findViewById(R.id.animateContent)); ma.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE); ma.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE); fabButton.hideFloatingActionButton(); } } + private void setupActionBar() { + final Toolbar tb = (Toolbar) ma.findViewById(R.id.bottomControls); + tb.setTitle(null); + tb.getMenu().clear(); + Menu menu = tb.getMenu(); + createMenuItem(menu, LIST_ID, R.string.drawer, + R.drawable.ic_flat_list_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + createMenuItem(menu, WAYPOINTS_ID, R.string.waypoints, + R.drawable.ic_action_flage_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + createMenuItem(menu, CONFIGURE_SCREEN_ID, R.string.layer_map_appearance, + R.drawable.ic_configure_screen_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + createMenuItem(menu, SETTINGS_ID, R.string.settings_activity, + R.drawable.ic_action_settings_enabled_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + } + + public MenuItem createMenuItem(Menu m, int id, int titleRes, int icon, int menuItemType) { + int r = icon; + MenuItem menuItem = m.add(0, id, 0, titleRes); + if (r != 0) { + menuItem.setIcon(r); + } + menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + return onOptionsItemSelected(item); + } + }); + MenuItemCompat.setShowAsAction(menuItem, menuItemType); + return menuItem; + } + + + protected boolean onOptionsItemSelected(MenuItem item) { + return false; + } + + // To animate view slide out from right to left private void open(View view){ TranslateAnimation animate = new TranslateAnimation(-ma.findViewById(R.id.ParentLayout).getWidth(),0,0,0); @@ -165,7 +208,11 @@ public class DashboardOnMap { private NotifyingScrollView.OnScrollChangedListener onScrollChangedListener = new NotifyingScrollView.OnScrollChangedListener() { public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { - //making background of actionbar transparent with scroll + int sy = who.getScrollY(); + double scale = who.getContext().getResources().getDisplayMetrics().density; + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) fabButton.getLayoutParams(); + lp.topMargin = (int) Math.max(30 * scale, 160 * scale - sy); + ((FrameLayout) fabButton.getParent()).updateViewLayout(fabButton, lp); // TODO } };