Update dashboard/toolbar

This commit is contained in:
Victor Shcherb 2015-03-25 15:54:24 +01:00
parent 78154fc70d
commit 53f0a7fba3
17 changed files with 313 additions and 338 deletions

View file

@ -3,7 +3,6 @@
android:id="@+id/dashboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#70000000"
android:orientation="vertical"
android:visibility="gone" >
@ -18,9 +17,16 @@
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="360dp"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="@layout/dashboard_toolbar" />
<net.osmand.plus.dashboard.NotifyingScrollView
android:id="@+id/main_scroll"
android:layout_width="360dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fadeScrollbars="true" >
@ -40,7 +46,7 @@
<FrameLayout
android:id="@+id/dash_list_view_layout"
android:layout_width="360dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:visibility="gone" >
@ -49,25 +55,16 @@
android:id="@+id/dash_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/card_bg"
android:background="?attr/card_bg_color"
android:fadeScrollbars="true" >
</com.github.ksoichiro.android.observablescrollview.ObservableListView>
</FrameLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/map_part_dashboard"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/map_part_dashboard">
<ImageButton
android:id="@+id/map_menu_button"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:layout_gravity="top|left"
android:layout_marginLeft="@dimen/map_button_margin"
android:layout_marginTop="@dimen/map_button_margin"
android:background="@drawable/btn_inset_circle"
android:src="@drawable/ic_action_remove_light" />
android:layout_height="fill_parent" >
<Button
android:id="@+id/map_download_button"

View file

@ -3,7 +3,6 @@
android:id="@+id/dashboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#70000000"
android:orientation="vertical"
android:visibility="gone" >
@ -60,7 +59,7 @@
android:id="@+id/dash_list_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/card_bg" />
android:background="?attr/card_bg_color" />
<com.github.ksoichiro.android.observablescrollview.ObservableListView
android:id="@+id/dash_list_view"
@ -70,21 +69,8 @@
</com.github.ksoichiro.android.observablescrollview.ObservableListView>
</FrameLayout>
<ImageButton
android:id="@+id/map_menu_button"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:layout_gravity="top|left"
android:layout_marginLeft="@dimen/map_button_margin"
android:layout_marginTop="@dimen/map_button_margin"
android:background="@drawable/btn_inset_circle"
android:src="@drawable/ic_action_remove_light" />
<include layout="@layout/dashboard_toolbar"/>
<net.osmand.plus.activities.search.toolbar.SplitToolbar
android:id="@+id/toolbar"
android:background="@drawable/gradient_toolbar"
android:layout_width="fill_parent"
android:layout_height="65dp"/>
</FrameLayout>

View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="65dp"
app:contentInsetStart="4dp"
app:contentInsetLeft="4dp"
android:background="@drawable/gradient_toolbar" >
<ImageView
android:id="@+id/toolbar_back"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="left"
android:scaleType="center"
android:background="@drawable/dashboard_button_light"
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha" />
<TextView
android:id="@+id/toolbar_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:textSize="@dimen/abc_text_size_headline_material"
android:textColor="@color/abc_primary_text_material_dark"
android:scaleType="center"
android:text="Toolbar" />
<ImageView
android:id="@+id/toolbar_list"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
android:src="@drawable/ic_navigation_drawer" />
<ImageView
android:id="@+id/toolbar_settings"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
android:src="@drawable/ic_action_settings_dark" />
<ImageView
android:id="@+id/toolbar_edit"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="right"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
android:src="@drawable/ic_action_edit_dark" />
</android.support.v7.widget.Toolbar>

View file

@ -33,8 +33,8 @@
<ImageView
android:id="@+id/favourite_icon"
android:layout_width="@dimen/favorite_icon_size"
android:layout_height="@dimen/favorite_icon_size"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/favorites_icon_right_margin" />

View file

@ -22,8 +22,8 @@
<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/favorite_icon_size"
android:layout_height="@dimen/favorite_icon_size"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical" />
<TextView

View file

@ -9,6 +9,7 @@
<attr name="bottomToolBarColor" format="color" />
<attr name="downloadButtonBackground" format="reference" />
<attr name="card_bg" format="reference" />
<attr name="card_bg_color" format="reference" />
<attr name="ic_action_overflow" format="reference" />
<attr name="dashboardGeneralButtonStyle" format="reference" />
<attr name="options_button_background" format="reference"/>

View file

@ -39,7 +39,7 @@
<dimen name="dialog_content_margin">24dp</dimen>
<dimen name="dialog_content_bottom_margin">16dp</dimen>
<dimen name="local_size_height">34dp</dimen>
<dimen name="favorite_icon_size">24dp</dimen>
<dimen name="standard_icon_size">24dp</dimen>
<dimen name="gpx_small_icon_margin">3dp</dimen>
<dimen name="gpx_small_text_margin">14dp</dimen>
<dimen name="gpx_text_top_margin">6dp</dimen>
@ -83,6 +83,7 @@
<dimen name="map_button_rect_rad">3dp</dimen>
<dimen name="map_button_stroke">1px</dimen>
<!-- TextSizes -->
<dimen name="list_header_text_size">14sp</dimen>
<dimen name="showAllButtonTextSize">12sp</dimen>

View file

@ -133,6 +133,7 @@
<item name="actionModeBackground">@color/actionbar_light_color</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
<item name="actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
<item name="card_bg_color">@color/card_bg_color_light</item>
<item name="card_bg">@drawable/bg_card_light</item>
<item name="dashboardGeneralButtonStyle">@style/DashboardGeneralButton.Light</item>
<item name="dashboardSubHeaderStyle">@style/DashboardSubHeader.Light</item>
@ -178,6 +179,7 @@
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
<item name="actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
<item name="card_bg">@drawable/bg_card_dark</item>
<item name="card_bg_color">@color/card_bg_color_dark</item>
<item name="dashboardGeneralButtonStyle">@style/DashboardGeneralButton.Dark</item>
<item name="dashboardSubHeaderStyle">@style/DashboardSubHeader.Dark</item>
<item name="dashboard_divider">@color/dashboard_divider_dark</item>

View file

@ -66,7 +66,6 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
@ -143,8 +142,6 @@ public class MapActivity extends AccessibleActivity {
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
}
dashboardOnMap.createDashboardView();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setVisibility(View.GONE);
checkAppInitialization();
parseLaunchIntentLocation();
mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener() {
@ -189,7 +186,6 @@ public class MapActivity extends AccessibleActivity {
addDialogProvider(mapActions);
OsmandPlugin.onMapActivityCreate(this);
gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView());
mapActions.prepareStartOptionsMenu();
wakeLockHelper = new WakeLockHelper(getMyApplication());
if(System.currentTimeMillis() - tm > 50) {
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
@ -199,7 +195,7 @@ public class MapActivity extends AccessibleActivity {
private void checkAppInitialization() {
if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) {
dashboardOnMap.setDashboardVisibility(true);
dashboardOnMap.setDashboardVisibility(true, DashboardOnMap.staticVisibleType);
}
if (app.isApplicationInitializing()) {
findViewById(R.id.init_progress).setVisibility(View.VISIBLE);
@ -465,12 +461,12 @@ public class MapActivity extends AccessibleActivity {
loc.setLongitude(mapView.getLongitude());
getMapActions().enterRoutePlanningMode(null, null, status == OsmandSettings.NAVIGATE_CURRENT_GPX);
if(dashboardOnMap.isVisible()) {
dashboardOnMap.setDashboardVisibility(false);
dashboardOnMap.hideDashboard();
}
}
if (latLonToShow != null) {
if(dashboardOnMap.isVisible()) {
dashboardOnMap.setDashboardVisibility(false);
dashboardOnMap.hideDashboard();
}
if (mapLabelToShow != null) {
mapLayers.getContextMenuLayer().setSelectedObject(toShow);
@ -606,21 +602,6 @@ public class MapActivity extends AccessibleActivity {
return super.onTrackballEvent(event);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
MapActivityActions.DrawerType drawerState = mapActions.getDrawerType();
outState.putSerializable("drawer_state", drawerState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
if (savedInstanceState != null) {
mapActions
.setDrawerType((MapActivityActions.DrawerType) savedInstanceState.getSerializable("drawer_state"));
}
}
@Override
protected void onStart() {
@ -875,8 +856,7 @@ public class MapActivity extends AccessibleActivity {
public static void launchMapActivityMoveToTop(Context activity) {
if (activity instanceof MapActivity) {
if (((MapActivity) activity).getDashboard().isVisible()) {
((MapActivity) activity).getDashboard().saveBackAction();
((MapActivity) activity).getDashboard().setDashboardVisibility(false);
((MapActivity) activity).getDashboard().hideDashboard();
}
((MapActivity) activity).readLocationToShow();
} else {

View file

@ -21,7 +21,6 @@ import net.osmand.plus.AppInitializer;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
@ -34,6 +33,7 @@ import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.actions.OsmAndDialogs;
import net.osmand.plus.activities.actions.ShareLocation;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.helpers.WaypointDialogHelper;
@ -56,11 +56,9 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@ -86,18 +84,8 @@ public class MapActivityActions implements DialogProvider {
private OsmandSettings settings;
private RoutingHelper routingHelper;
private boolean refreshDrawer = false;
private WaypointDialogHelper waypointDialogHelper;
public enum DrawerType{
WAYPOINTS,
CONFIGURE_SCREEN,
CONFIGURE_MAP,
MAIN_MENU
}
private DrawerType currentDrawer = DrawerType.MAIN_MENU;
public MapActivityActions(MapActivity mapActivity){
this.mapActivity = mapActivity;
settings = mapActivity.getMyApplication().getSettings();
@ -170,15 +158,6 @@ public class MapActivityActions implements DialogProvider {
mapActivity.showDialog(DIALOG_RELOAD_TITLE);
}
public DrawerType getDrawerType(){
return currentDrawer;
}
public void setDrawerType(DrawerType type){
this.currentDrawer = type;
prepareStartOptionsMenu();
}
protected String getString(int res){
return mapActivity.getString(res);
}
@ -566,85 +545,11 @@ public class MapActivityActions implements DialogProvider {
}
}
public void prepareStartOptionsMenu(){
refreshDrawer();
}
public void refreshDrawer(){
switch (currentDrawer){
case MAIN_MENU:
prepareOptionsMenu(createMainOptionsMenu());
break;
case CONFIGURE_MAP:
prepareConfigureMap();
break;
case CONFIGURE_SCREEN:
prepareConfigureScreen();
break;
case WAYPOINTS:
showWaypointsInDrawer(false);
break;
}
}
public void prepareOptionsMenu(final ContextMenuAdapter cm) {
refreshDrawer = false;
final ArrayAdapter<?> listAdapter =
cm.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContent());
OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter);
mapActivity.getDashboard().setListAdapter(listAdapter, listener);
}
private OnItemClickListener getOptionsMenuOnClickListener(final ContextMenuAdapter cm,
final ArrayAdapter<?> listAdapter) {
return new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int which, long id) {
OnContextMenuClick click = cm.getClickAdapter(which);
if(click instanceof OnRowItemClick) {
boolean cl = ((OnRowItemClick) click).onRowItemClick(listAdapter, view, cm.getElementId(which), which);
if(cl) {
closeDrawer();
}
} else if (click != null) {
CompoundButton btn = (CompoundButton) view.findViewById(R.id.check_item);
if (btn != null && btn.getVisibility() == View.VISIBLE) {
btn.setChecked(!btn.isChecked());
} else {
if (click.onContextMenuClick(listAdapter, cm.getElementId(which), which, false)) {
closeDrawer();
}
}
} else {
closeDrawer();
}
}
};
}
public void closeDrawer() {
mapActivity.getDashboard().setDashboardVisibility(false);
}
public void prepareConfigureMap() {
currentDrawer = DrawerType.CONFIGURE_MAP;
//mapActivity.getClearToolbar(true);
prepareOptionsMenu(new ConfigureMapMenu().createListAdapter(mapActivity, true));
}
public void onDrawerBack() {
currentDrawer = DrawerType.MAIN_MENU;
prepareStartOptionsMenu();
}
private ContextMenuAdapter createMainOptionsMenu() {
final OsmandMapTileView mapView = mapActivity.getMapView();
final OsmandApplication app = mapActivity.getMyApplication();
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
currentDrawer = DrawerType.MAIN_MENU;
// 2-4. Navigation related (directions, mute, cancel navigation)
boolean muteVisible = routingHelper.getFinalLocation() != null && routingHelper.isFollowingMode();
@ -787,7 +692,8 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
prepareConfigureMap();
mapActivity.getDashboard().setListAdapter(new ConfigureMapMenu().createListAdapter(mapActivity),
DashboardType.CONFIGURE_MAP);
return false;
}
}).reg();
@ -796,7 +702,8 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
prepareConfigureScreen();
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
mapActivity.getDashboard().setListAdapter(cm, DashboardType.CONFIGURE_SCREEN);
return false;
}
}).reg();
@ -860,20 +767,12 @@ public class MapActivityActions implements DialogProvider {
return optionsMenuHelper;
}
public void prepareConfigureScreen() {
currentDrawer = DrawerType.CONFIGURE_SCREEN;
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
prepareOptionsMenu(cm);
}
public void showWaypointsInDrawer(boolean flat) {
currentDrawer = DrawerType.WAYPOINTS;
final int[] running = new int[] { -1 };
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(mapActivity, running, flat);
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
listAdapter, null);
refreshDrawer = false;
mapActivity.getDashboard().setListAdapter(listAdapter, listener);
mapActivity.getDashboard().setListAdapter(listAdapter, listener, DashboardType.WAYPOINTS);
}
public void showWaypointsDialog(boolean flat) {

View file

@ -212,9 +212,6 @@ public class MapActivityLayers {
}
public AlertDialog showGPXFileLayer(List<String> files, final OsmandMapTileView mapView) {
final OsmandSettings settings = getApplication().getSettings();
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
@ -241,7 +238,7 @@ public class MapActivityLayers {
mapView.getZoom(), true);
}
mapView.refreshMap();
activity.getMapActions().refreshDrawer();
activity.getDashboard().refreshContent();
return true;
}
};

View file

@ -6,9 +6,12 @@ import java.util.LinkedList;
import java.util.List;
import net.osmand.data.LatLon;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
@ -24,13 +27,13 @@ import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.OsmandMapTileView;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
@ -43,10 +46,12 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
@ -60,14 +65,18 @@ import com.software.shell.fab.ActionButton;
public class DashboardOnMap implements ObservableScrollViewCallbacks {
public static boolean staticVisible = false;
public static DashboardType staticVisibleType = DashboardType.DASHBOARD;
private MapActivity mapActivity;
private ActionButton actionButton;
private FrameLayout dashboardView;
private ArrayAdapter<?> listAdapter;
private OnItemClickListener listAdapterOnClickListener;
private boolean visible = false;
private DashboardType visibleType;
private boolean landscape;
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<WeakReference<DashBaseFragment>>();
private net.osmand.Location myLocation;
@ -76,43 +85,27 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
private boolean mapLinkedToLocation;
private float mapRotation;
private boolean inLocationUpdate = false;
private boolean saveBackAction;
private ImageView switchButton;
private NotifyingScrollView scrollView;
private View listViewLayout;
private ListView listView;
private View listBackgroundView;
private View paddingView;
private int mFlexibleSpaceImageHeight;
public enum DashboardType {
WAYPOINTS,
WAYPOINTS_EDIT,
WAYPOINTS_SORT,
CONFIGURE_SCREEN,
CONFIGURE_MAP,
LIST_MENU,
DASHBOARD
}
public DashboardOnMap(MapActivity ma) {
this.mapActivity = ma;
}
public Toolbar getClearToolbar(boolean visible) {
final Toolbar tb = (Toolbar) dashboardView.findViewById(R.id.toolbar);
if (tb == null) {
return null;
}
tb.setTitle(null);
tb.getMenu().clear();
setToolbarVisibility(visible);
return tb;
}
public void setToolbarVisibility(boolean visible){
int visibility = visible? View.VISIBLE : View.GONE;
View toolbar = dashboardView.findViewById(R.id.toolbar);
if (toolbar != null) {
toolbar.setVisibility(visibility);
}
View buttons = dashboardView.findViewById(R.id.map_menu_button);
if (buttons != null) {
buttons.setVisibility(visibility);
}
actionButton.setVisibility(visibility);
}
public void createDashboardView() {
landscape = !ScreenOrientationHelper.isOrientationPortrait(mapActivity);
@ -120,11 +113,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
setDashboardVisibility(false);
hideDashboard();
}
};
scrollView = ((NotifyingScrollView) dashboardView.findViewById(R.id.main_scroll));
listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
listView = (ListView) dashboardView.findViewById(R.id.dash_list_view);
scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() {
public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
@ -137,7 +129,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
mFlexibleSpaceImageHeight = mapActivity.getResources().getDimensionPixelSize(
R.dimen.dashboard_map_top_padding);
// Set padding view for ListView. This is the flexible space.
View paddingView = new View(mapActivity);
paddingView = new View(mapActivity);
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
mFlexibleSpaceImageHeight);
paddingView.setLayoutParams(lp);
@ -146,8 +138,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
paddingView.setOnClickListener(listener);
listView.addHeaderView(paddingView);
// Toolbar tb = (Toolbar) mapActivity.findViewById(R.id.dash_toolbar);
// tb.setLogo(R.drawable.icon);
listBackgroundView = mapActivity.findViewById(R.id.dash_list_background);
final View contentView = mapActivity.getWindow().getDecorView().findViewById(android.R.id.content);
contentView.post(new Runnable() {
@ -165,6 +155,64 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
dashboardView.findViewById(R.id.animateContent).setOnClickListener(listener);
dashboardView.findViewById(R.id.map_part_dashboard).setOnClickListener(listener);
initActionButton();
dashboardView.addView(actionButton);
}
private void initToolbarActions() {
TextView tv = (TextView) dashboardView.findViewById(R.id.toolbar_text);
ImageView back = (ImageView) dashboardView.findViewById(R.id.toolbar_back);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideDashboard();
}
});
ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit);
edit.setVisibility(View.GONE);
edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
ImageView settings = (ImageView) dashboardView.findViewById(R.id.toolbar_settings);
settings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Class<? extends Activity> sta = mapActivity.getMyApplication().getAppCustomization().getSettingsActivity();
visible = false;
mapActivity.startActivity(new Intent(mapActivity, sta));
}
});
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list);
lst.setVisibility(View.VISIBLE);
if(visibleType == DashboardType.DASHBOARD) {
lst.setImageDrawable(iconsCache.getActionBarIcon(R.drawable.ic_navigation_drawer));
} else if(visibleType == DashboardType.LIST_MENU) {
lst.setImageDrawable(iconsCache.getActionBarIcon(R.drawable.ic_dashboard_dark));
} else {
lst.setVisibility(View.GONE);
}
lst.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(visibleType == DashboardType.DASHBOARD) {
setDashboardVisibility(true, DashboardType.LIST_MENU);
} else {
setDashboardVisibility(true, DashboardType.DASHBOARD);
}
}
});
}
private void initActionButton() {
actionButton = new ActionButton(mapActivity);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int marginRight = convertPixelsToDp(16, mapActivity);
@ -184,19 +232,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
} else {
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
}
setDashboardVisibility(false);
hideDashboard();
}
});
dashboardView.addView(actionButton);
}
private void switchBtnAction() {
setDashboardVisibility(false);
CommonPreference<Boolean> st = mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER;
st.set(!st.get());
setDashboardVisibility(true);
// mapActivity.getMapActions().toggleDrawer();
}
public static int convertPixelsToDp(float dp, Context context){
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
@ -235,37 +275,18 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
return listAdapterOnClickListener;
}
public void setListAdapter(ArrayAdapter<?> listAdapter, final OnItemClickListener optionsMenuOnClickListener) {
if(!isVisible()) {
mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.set(false);
}
this.listAdapter = listAdapter;
this.listAdapterOnClickListener = optionsMenuOnClickListener;
if(this.listView != null) {
listView.setAdapter(listAdapter);
if(listBackgroundView == null) {
listView.setOnItemClickListener(optionsMenuOnClickListener);
} else if (optionsMenuOnClickListener != null) {
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
optionsMenuOnClickListener.onItemClick(parent, view, position - 1, id);
}
});
} else {
listView.setOnItemClickListener(null);
}
}
setDashboardVisibility(true);
public void hideDashboard() {
setDashboardVisibility(false, DashboardType.DASHBOARD);
}
public void setDashboardVisibility(boolean visible) {
if(visible == this.visible) {
public void setDashboardVisibility(boolean visible, DashboardType type) {
if(visible == this.visible && type == visibleType) {
return;
}
this.visible = visible;
this.visibleType = type;
DashboardOnMap.staticVisible = visible;
DashboardOnMap.staticVisibleType = type;
if (visible) {
mapViewLocation = mapActivity.getMapLocation();
mapRotation = mapActivity.getMapRotate();
@ -275,28 +296,18 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
dashboardView.setVisibility(View.VISIBLE);
actionButton.show();
updateDownloadBtn();
switchButton = (ImageView) dashboardView.findViewById(R.id.map_menu_button);
if(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get()) {
View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
if(visibleType == DashboardType.DASHBOARD) {
addOrUpdateDashboardFragments();
scrollView.setVisibility(View.VISIBLE);
listViewLayout.setVisibility(View.GONE);
switchButton.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_navigation_drawer,
R.color.icon_color_light));
} else {
scrollView.setVisibility(View.GONE);
listViewLayout.setVisibility(View.VISIBLE);
switchButton.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_dashboard_dark,
R.color.icon_color_light));
}
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
switchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switchBtnAction();
}
});
initToolbarActions();
//fabButton.showFloatingActionButton();
open(dashboardView.findViewById(R.id.animateContent));
updateLocation(true, true, false);
@ -315,6 +326,34 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
}
private OnItemClickListener getOptionsMenuOnClickListener(final ContextMenuAdapter cm,
final ArrayAdapter<?> listAdapter) {
return new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int which, long id) {
OnContextMenuClick click = cm.getClickAdapter(which);
if(click instanceof OnRowItemClick) {
boolean cl = ((OnRowItemClick) click).onRowItemClick(listAdapter, view, cm.getElementId(which), which);
if(cl) {
hideDashboard();
}
} else if (click != null) {
CompoundButton btn = (CompoundButton) view.findViewById(R.id.check_item);
if (btn != null && btn.getVisibility() == View.VISIBLE) {
btn.setChecked(!btn.isChecked());
} else {
if (click.onContextMenuClick(listAdapter, cm.getElementId(which), which, false)) {
hideDashboard();
}
}
} else {
hideDashboard();
}
}
};
}
private void updateDownloadBtn() {
Button btn = (Button) dashboardView.findViewById(R.id.map_download_button);
String filter = null;
@ -342,7 +381,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
@Override
public void onClick(View v) {
setDashboardVisibility(false);
hideDashboard();
final Intent intent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getDownloadIndexActivity());
intent.putExtra(DownloadActivity.FILTER_KEY, f.toString());
@ -468,11 +507,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
}
public boolean isVisible() {
return visible;
}
@ -526,31 +560,18 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
public void saveBackAction() {
saveBackAction = true;
}
public boolean clearBackAction() {
if(saveBackAction) {
saveBackAction = false;
return true;
}
return false;
}
public void onMenuPressed() {
if (!isVisible()) {
setDashboardVisibility(true);
setDashboardVisibility(true, DashboardType.DASHBOARD);
} else {
setDashboardVisibility(false);
hideDashboard();
}
}
public boolean onBackPressed() {
if (isVisible()) {
setDashboardVisibility(false);
hideDashboard();
return true;
}
return false;
@ -570,10 +591,48 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
private void updateTopButton(int scrollY) {
if (actionButton != null) {
double scale = mapActivity.getResources().getDisplayMetrics().density;
int originalPosition = (int) (160 * scale);
int minTop = (int) (65 * scale);
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) actionButton.getLayoutParams();
lp.topMargin = (int) Math.max(30 * scale, 160 * scale - scrollY);
if(minTop > originalPosition - scrollY) {
actionButton.hide();
} else {
actionButton.show();
lp.topMargin = originalPosition - scrollY;
((FrameLayout) actionButton.getParent()).updateViewLayout(actionButton, lp);
}
}
}
public void setListAdapter(ArrayAdapter<?> listAdapter, OnItemClickListener listener, DashboardType type) {
this.listAdapter = listAdapter;
this.listAdapterOnClickListener = listener;
if(this.listView != null) {
listView.setAdapter(listAdapter);
if(listBackgroundView == null) {
listView.setOnItemClickListener(this.listAdapterOnClickListener);
} else if (this.listAdapterOnClickListener != null) {
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
listAdapterOnClickListener.onItemClick(parent, view, position - 1, id);
}
});
} else {
listView.setOnItemClickListener(null);
}
}
setDashboardVisibility(true, type);
}
public void setListAdapter(ContextMenuAdapter cm, DashboardType type) {
final ArrayAdapter<?> listAdapter = cm.createListAdapter(mapActivity, getMyApplication().getSettings()
.isLightContent());
OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter);
setListAdapter(listAdapter, listener, type);
}
@ -610,5 +669,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
public void refreshContent() {
// TODO Auto-generated method stub
// ?? This method might not be needed
}
}

View file

@ -51,7 +51,7 @@ public class DashSimulateFragment extends DashBaseFragment {
public void onClick(View v) {
if (getActivity() instanceof MapActivity) {
loc.getLocationSimulation().startStopRouteAnimation((MapActivity) getActivity());
dashboard.setDashboardVisibility(false);
dashboard.hideDashboard();
}
}
};

View file

@ -19,6 +19,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.activities.TransportRouteHelper;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.poi.PoiLegacyFilter;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.render.RenderingRuleProperty;
@ -41,7 +42,7 @@ public class ConfigureMapMenu {
private boolean allModes = false;
public ContextMenuAdapter createListAdapter(final MapActivity ma, final boolean advanced) {
public ContextMenuAdapter createListAdapter(final MapActivity ma) {
ContextMenuAdapter adapter = new ContextMenuAdapter(ma, allModes);
adapter.setDefaultLayoutId(R.layout.drawer_list_item);
adapter.item(R.string.configure_map).iconColor(R.drawable.ic_back_drawer_dark)
@ -49,8 +50,7 @@ public class ConfigureMapMenu {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
ma.getMapActions().onDrawerBack();
return false;
return true;
}
}).reg();
adapter.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
@ -58,26 +58,11 @@ public class ConfigureMapMenu {
@Override
public void onClick(boolean result) {
allModes = true;
ma.getMapActions().prepareOptionsMenu(createListAdapter(ma, advanced));
ma.getDashboard().setListAdapter(createListAdapter(ma), DashboardType.CONFIGURE_MAP);
}
});
createLayersItems(adapter, ma);
if (!advanced){
adapter.item(R.string.btn_advanced_mode).iconColor(R.drawable.ic_action_settings_enabled_dark)
.selected(advanced ? 1 : 0)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
ma.getMapActions().prepareOptionsMenu(createListAdapter(ma, isChecked));
return false;
}
}).reg();
}
if (advanced) {
createRenderingAttributeItems(adapter, ma);
}
return adapter;
}
@ -157,7 +142,6 @@ public class ConfigureMapMenu {
if(selected[0] == null) {
settings.SHOW_POI_OVER_MAP.set(selected[0] != null);
}
ma.getMapActions().refreshDrawer();
}
});
}
@ -230,7 +214,6 @@ public class ConfigureMapMenu {
}
adapter.setItemDescription(pos, getRenderDescr(activity));
dialog.dismiss();
activity.getMapActions().prepareOptionsMenu(createListAdapter(activity, true));
}
});

View file

@ -243,8 +243,7 @@ public class WaypointDialogHelper {
if (dlg != null) {
dlg.dismiss();
} else if(a instanceof MapActivity){
((MapActivity) a).getMapActions().onDrawerBack();
((MapActivity) a).getMapActions().closeDrawer();
((MapActivity) a).onBackPressed();
}
}
});
@ -260,8 +259,8 @@ public class WaypointDialogHelper {
if (dlg != null) {
dlg.dismiss();
} else if(a instanceof MapActivity){
((MapActivity) a).getMapActions().onDrawerBack();
((MapActivity) a).getMapActions().closeDrawer();
// to close drawer
((MapActivity) a).onBackPressed();
}
}
});
@ -429,7 +428,8 @@ public class WaypointDialogHelper {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
if (item == 0) {
mapActivity.getMapActions().onDrawerBack();
// TODO
//mapActivity.getMapActions().onDrawerBack();
} else if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
showOnMap(app, ctx, ps.getPoint(), dialog);

View file

@ -16,6 +16,8 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.controls.MapRouteInfoControl;
import net.osmand.plus.views.controls.MapRoutePreferencesControl;
@ -174,8 +176,8 @@ public class MapControlsLayer extends OsmandMapLayer {
@Override
public void onClick(View v) {
notifyClicked();
mapActivity.getMapActions().prepareConfigureMap();
mapActivity.getDashboard().setDashboardVisibility(true);
mapActivity.getDashboard().setListAdapter(new ConfigureMapMenu().createListAdapter(mapActivity),
DashboardType.CONFIGURE_MAP);
}
});
@ -286,7 +288,7 @@ public class MapControlsLayer extends OsmandMapLayer {
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
notifyClicked();
// if (mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get()) {
mapActivity.getDashboard().setDashboardVisibility(true);
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
// } else {
// mapActivity.getMapActions().onDrawerBack();
// mapActivity.getMapActions().toggleDrawer();

View file

@ -11,6 +11,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
@ -311,8 +312,7 @@ public class MapInfoLayer extends OsmandMapLayer {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
map.getMapActions().onDrawerBack();
return false;
return true;
}
}).reg();
cm.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
@ -320,7 +320,7 @@ public class MapInfoLayer extends OsmandMapLayer {
@Override
public void onClick(boolean allModes) {
map.getMapActions().prepareOptionsMenu(getViewConfigureMenuAdapter());
map.getDashboard().setListAdapter(getViewConfigureMenuAdapter(), DashboardType.CONFIGURE_MAP);
}
});
cm.item(R.string.map_widget_reset)