Search in sources :

Example 1 with MapWidgetRegistry

use of net.osmand.plus.views.mapwidgets.MapWidgetRegistry in project Osmand by osmandapp.

the class DashboardOnMap method updateToolbarActions.

private void updateToolbarActions() {
    TextView tv = (TextView) dashboardView.findViewById(R.id.toolbar_text);
    tv.setText("");
    boolean waypointsVisible = visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT;
    if (waypointsVisible) {
        tv.setText(R.string.waypoints);
    } else if (visibleType == DashboardType.CONFIGURE_MAP) {
        tv.setText(R.string.configure_map);
    } else if (visibleType == DashboardType.CONFIGURE_SCREEN) {
        tv.setText(R.string.layer_map_appearance);
    } else if (visibleType == DashboardType.ROUTE_PREFERENCES) {
        tv.setText(R.string.shared_string_settings);
    } else if (visibleType == DashboardType.UNDERLAY_MAP) {
        tv.setText(R.string.map_underlay);
    } else if (visibleType == DashboardType.OVERLAY_MAP) {
        tv.setText(R.string.map_overlay);
    } else if (visibleType == DashboardType.MAPILLARY) {
        tv.setText(R.string.mapillary);
    } else if (visibleType == DashboardType.CONTOUR_LINES) {
        tv.setText(R.string.srtm_plugin_name);
    } else if (visibleType == DashboardType.HILLSHADE) {
        tv.setText(R.string.layer_hillshade);
    } else if (visibleType == DashboardType.OSM_NOTES) {
        tv.setText(R.string.osm_notes);
    }
    ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit);
    edit.setVisibility(View.GONE);
    ImageView sort = (ImageView) dashboardView.findViewById(R.id.toolbar_sort);
    sort.setVisibility(View.GONE);
    ImageView ok = (ImageView) dashboardView.findViewById(R.id.toolbar_ok);
    ok.setVisibility(View.GONE);
    ImageView flat = (ImageView) dashboardView.findViewById(R.id.toolbar_flat);
    flat.setVisibility(View.GONE);
    ImageView settingsButton = (ImageView) dashboardView.findViewById(R.id.toolbar_settings);
    settingsButton.setVisibility(View.GONE);
    IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
    ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list);
    lst.setVisibility(View.GONE);
    ImageView back = (ImageView) dashboardView.findViewById(R.id.toolbar_back);
    back.setImageDrawable(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
    back.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            backPressed();
        }
    });
    if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) {
        if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
            flat.setVisibility(View.VISIBLE);
            final boolean flatNow = visibleType == DashboardType.WAYPOINTS_FLAT;
            flat.setImageDrawable(iconsCache.getIcon(flatNow ? R.drawable.ic_tree_list_dark : R.drawable.ic_flat_list_dark));
            flat.setContentDescription(mapActivity.getString(flatNow ? R.string.access_tree_list : R.string.drawer));
            flat.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS : DashboardType.WAYPOINTS_FLAT, previousVisibleType, false, AndroidUtils.getCenterViewCoordinates(v));
                }
            });
        }
    }
    if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) {
        settingsButton.setVisibility(View.VISIBLE);
        settingsButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                new DashboardSettingsDialogFragment().show(mapActivity.getSupportFragmentManager(), "dashboard_settings");
            }
        });
        lst.setVisibility(View.VISIBLE);
        lst.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                hideDashboard(false);
                mapActivity.openDrawer();
            }
        });
    }
    toolbar.getMenu().clear();
    if (visibleType == DashboardType.CONFIGURE_SCREEN) {
        toolbar.inflateMenu(R.menu.refresh_menu);
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                if (menuItem.getItemId() == R.id.action_refresh) {
                    MapWidgetRegistry registry = mapActivity.getMapLayers().getMapWidgetRegistry();
                    registry.resetToDefault();
                    MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
                    if (mil != null) {
                        mil.recreateControls();
                    }
                    updateListAdapter(registry.getViewConfigureMenuAdapter(mapActivity));
                }
                return false;
            }
        });
    }
}
Also used : MenuItem(android.view.MenuItem) ContextMenuItem(net.osmand.plus.ContextMenuItem) ImageView(android.widget.ImageView) DynamicListView(net.osmand.plus.views.controls.DynamicListView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) ScrollView(android.widget.ScrollView) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) MapWidgetRegistry(net.osmand.plus.views.mapwidgets.MapWidgetRegistry) MapInfoLayer(net.osmand.plus.views.MapInfoLayer) TextView(android.widget.TextView) DashboardSettingsDialogFragment(net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment) ImageView(android.widget.ImageView) IconsCache(net.osmand.plus.IconsCache) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Toolbar (android.support.v7.widget.Toolbar)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 ObservableScrollView (com.github.ksoichiro.android.observablescrollview.ObservableScrollView)1 ContextMenuItem (net.osmand.plus.ContextMenuItem)1 IconsCache (net.osmand.plus.IconsCache)1 DashboardSettingsDialogFragment (net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment)1 MapInfoLayer (net.osmand.plus.views.MapInfoLayer)1 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)1 DynamicListView (net.osmand.plus.views.controls.DynamicListView)1 MapWidgetRegistry (net.osmand.plus.views.mapwidgets.MapWidgetRegistry)1