Update dashboard
This commit is contained in:
parent
d9e773b61d
commit
6422a8aa56
4 changed files with 86 additions and 13 deletions
|
@ -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" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/animateContent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<net.osmand.plus.activities.search.toolbar.SplitToolbar
|
||||
android:id="@+id/bottomControls"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bottomToolBarColor" />
|
||||
</LinearLayout>
|
||||
</net.osmand.plus.dashboard.NotifyingScrollView>
|
||||
|
||||
</FrameLayout>
|
|
@ -19,13 +19,25 @@
|
|||
android:layout_height="match_parent"
|
||||
android:fadeScrollbars="true" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/animateContent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/dashboard_map_bottom_padding"
|
||||
android:paddingTop="@dimen/dashboard_map_top_padding" />
|
||||
|
||||
<net.osmand.plus.activities.search.toolbar.SplitToolbar
|
||||
android:id="@+id/bottomControls"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bottomToolBarColor" />
|
||||
</LinearLayout>
|
||||
</net.osmand.plus.dashboard.NotifyingScrollView>
|
||||
|
||||
</FrameLayout>
|
|
@ -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
|
||||
-->
|
||||
<string name="drawer">Flat list</string>
|
||||
<string name="short_location_on_map">Lat %1$s\n Lon %2$s</string>
|
||||
<string name="tips_and_tricks_descr">Frequently asked questions, recent changes and others</string>
|
||||
<string name="routing_settings_2">Navigation settings</string>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue