Search in sources :

Example 1 with IconsCache

use of net.osmand.plus.IconsCache 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)

Example 2 with IconsCache

use of net.osmand.plus.IconsCache in project Osmand by osmandapp.

the class QuickSearchCoordinatesFragment method onCreateView.

@Override
@SuppressLint("PrivateResource")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final OsmandApplication app = getMyApplication();
    view = inflater.inflate(R.layout.search_advanced_coords, container, false);
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(app.getIconsCache().getIcon(R.drawable.ic_arrow_back));
    toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    screenOrientation = DashLocationFragment.getScreenOrientation(getActivity());
    myLocation = app.getLocationProvider().getLastKnownLocation();
    currentFormat = app.getSettings().COORDINATES_FORMAT.get();
    latEdit = ((EditText) view.findViewById(R.id.latitudeEditText));
    lonEdit = ((EditText) view.findViewById(R.id.longitudeEditText));
    northingEdit = ((EditText) view.findViewById(R.id.northingEditText));
    eastingEdit = ((EditText) view.findViewById(R.id.eastingEditText));
    zoneEdit = ((EditText) view.findViewById(R.id.zoneEditText));
    olcEdit = ((EditText) view.findViewById(R.id.olcEditText));
    olcInfo = ((TextView) view.findViewById(R.id.olcInfoTextView));
    formatEdit = ((EditText) view.findViewById(R.id.formatEditText));
    String defaultLat = "";
    String defaultZone = "";
    String defaultOlc = "";
    boolean coordinatesApplied = false;
    if (getArguments() != null) {
        String text = getArguments().getString(QUICK_SEARCH_COORDS_TEXT_KEY);
        if (!Algorithms.isEmpty(text)) {
            if (currentFormat == PointDescription.UTM_FORMAT) {
                defaultZone = text.trim();
            } else if (currentFormat == PointDescription.OLC_FORMAT) {
                defaultOlc = text.trim();
            } else {
                defaultLat = text.trim();
            }
        } else {
            double latitude = getArguments().getDouble(QUICK_SEARCH_COORDS_LATITUDE_KEY, Double.NaN);
            double longitude = getArguments().getDouble(QUICK_SEARCH_COORDS_LONGITUDE_KEY, Double.NaN);
            if (!Double.isNaN(latitude) && !Double.isNaN(longitude)) {
                currentLatLon = new LatLon(latitude, longitude);
                applyFormat(currentFormat, true);
                coordinatesApplied = true;
            }
        }
    }
    String latStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_LAT_KEY, defaultLat);
    String lonStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_LON_KEY, "");
    String northingStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_NORTH_KEY, "");
    String eastingStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_EAST_KEY, "");
    String zoneStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_ZONE_KEY, defaultZone);
    String olcStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_OLC_KEY, defaultOlc);
    String olcInfoStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_OLC_INFO_KEY, defaultOlc);
    if (savedInstanceState != null)
        currentFormat = savedInstanceState.getInt(QUICK_SEARCH_COORDS_FORMAT_KEY, -1);
    if (currentFormat == -1)
        currentFormat = getArguments().getInt(QUICK_SEARCH_COORDS_FORMAT_KEY, -1);
    if (currentFormat == -1)
        currentFormat = app.getSettings().COORDINATES_FORMAT.get();
    if (savedInstanceState != null && savedInstanceState.containsKey(QUICK_SEARCH_COORDS_USE_MAP_CENTER_KEY))
        useMapCenter = savedInstanceState.getBoolean(QUICK_SEARCH_COORDS_USE_MAP_CENTER_KEY);
    else if (getArguments().containsKey(QUICK_SEARCH_COORDS_USE_MAP_CENTER_KEY))
        useMapCenter = getArguments().getBoolean(QUICK_SEARCH_COORDS_USE_MAP_CENTER_KEY);
    if (!coordinatesApplied) {
        latEdit.setText(latStr);
        latEdit.setSelection(latStr.length());
        lonEdit.setText(lonStr);
        lonEdit.setSelection(lonStr.length());
        northingEdit.setText(northingStr);
        northingEdit.setSelection(northingStr.length());
        eastingEdit.setText(eastingStr);
        eastingEdit.setSelection(eastingStr.length());
        zoneEdit.setText(zoneStr);
        zoneEdit.setSelection(zoneStr.length());
        olcEdit.setText(olcStr);
        olcEdit.setSelection(olcStr.length());
        olcInfo.setText(olcInfoStr);
    }
    formatEdit.setText(PointDescription.formatToHumanString(app, currentFormat));
    formatEdit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new ChooseCoordsFormatDialogFragment().show(getChildFragmentManager(), "ChooseCoordinatesFormatFragment");
        }
    });
    TextWatcher textWatcher = new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            parseLocation();
        }
    };
    latEdit.addTextChangedListener(textWatcher);
    lonEdit.addTextChangedListener(textWatcher);
    northingEdit.addTextChangedListener(textWatcher);
    eastingEdit.addTextChangedListener(textWatcher);
    zoneEdit.addTextChangedListener(textWatcher);
    olcEdit.addTextChangedListener(textWatcher);
    OnEditorActionListener doneListener = new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                showOnMap();
                return true;
            } else {
                return false;
            }
        }
    };
    lonEdit.setOnEditorActionListener(doneListener);
    zoneEdit.setOnEditorActionListener(doneListener);
    olcEdit.setOnEditorActionListener(doneListener);
    IconsCache ic = app.getIconsCache();
    ((ImageView) view.findViewById(R.id.latitudeImage)).setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_coordinates_latitude));
    ((ImageView) view.findViewById(R.id.longitudeImage)).setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_coordinates_longitude));
    ((ImageView) view.findViewById(R.id.northingImage)).setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_coordinates_latitude));
    ((ImageView) view.findViewById(R.id.eastingImage)).setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_coordinates_longitude));
    ImageButton latitudeClearButton = (ImageButton) view.findViewById(R.id.latitudeClearButton);
    latitudeClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
    latitudeClearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            latEdit.setText("");
        }
    });
    ImageButton longitudeClearButton = (ImageButton) view.findViewById(R.id.longitudeClearButton);
    longitudeClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
    longitudeClearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            lonEdit.setText("");
        }
    });
    ImageButton northingClearButton = (ImageButton) view.findViewById(R.id.northingClearButton);
    northingClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
    northingClearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            northingEdit.setText("");
        }
    });
    ImageButton eastingClearButton = (ImageButton) view.findViewById(R.id.eastingClearButton);
    eastingClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
    eastingClearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            eastingEdit.setText("");
        }
    });
    ImageButton zoneClearButton = (ImageButton) view.findViewById(R.id.zoneClearButton);
    zoneClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
    zoneClearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            olcEdit.setText("");
        }
    });
    ImageButton olcClearButton = (ImageButton) view.findViewById(R.id.olcClearButton);
    olcClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark));
    olcClearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            olcEdit.setText("");
        }
    });
    ImageButton formatSelectButton = (ImageButton) view.findViewById(R.id.formatSelectButton);
    formatSelectButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_arrow_drop_down));
    formatSelectButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new ChooseCoordsFormatDialogFragment().show(getChildFragmentManager(), "ChooseCoordinatesFormatFragment");
        }
    });
    coordsView = view.findViewById(R.id.searchListItemLayout);
    view.findViewById(R.id.divider).setVisibility(View.GONE);
    TypedValue outValue = new TypedValue();
    app.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    coordsView.setBackgroundResource(outValue.resourceId);
    coordsView.setClickable(true);
    coordsView.findViewById(R.id.toggle_item).setVisibility(View.GONE);
    coordsView.findViewById(R.id.time_icon).setVisibility(View.GONE);
    coordsView.findViewById(R.id.time).setVisibility(View.GONE);
    coordsView.findViewById(R.id.type_name_icon).setVisibility(View.GONE);
    ((ImageView) coordsView.findViewById(R.id.imageView)).setImageDrawable(ic.getIcon(R.drawable.ic_action_world_globe, app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark));
    coordsView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showOnMap();
        }
    });
    errorView = view.findViewById(R.id.error_item);
    parseLocation();
    updateControlsVisibility();
    return view;
}
Also used : EditText(android.widget.EditText) OsmandApplication(net.osmand.plus.OsmandApplication) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) LatLon(net.osmand.data.LatLon) ImageButton(android.widget.ImageButton) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) IconsCache(net.osmand.plus.IconsCache) ImageView(android.widget.ImageView) Toolbar(android.support.v7.widget.Toolbar) TypedValue(android.util.TypedValue) SuppressLint(android.annotation.SuppressLint)

Example 3 with IconsCache

use of net.osmand.plus.IconsCache in project Osmand by osmandapp.

the class SearchPOIActivity method showOptionsMenu.

private void showOptionsMenu(View v) {
    // Show menu with search all, name finder, name finder poi
    IconsCache iconsCache = getMyApplication().getIconsCache();
    final PopupMenu optionsMenu = new PopupMenu(this, v);
    final PoiUIFilter f = this.filter;
    MenuItem item = optionsMenu.getMenu().add(R.string.shared_string_edit).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark));
    item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            PoiUIFilter custom = getMyApplication().getPoiFilters().getCustomPOIFilter();
            custom.replaceWithPoiFilter(f);
            showEditActivity(custom);
            return true;
        }
    });
    addFilter(optionsMenu, getString(R.string.shared_string_is_open));
    addFilter(optionsMenu, getString(R.string.shared_string_is_open_24_7));
    Map<String, PoiType> poiAdditionals = f.getPoiAdditionals();
    if (poiAdditionals != null) {
        TreeMap<String, PoiType> adds = new TreeMap<String, PoiType>();
        for (PoiType vtype : poiAdditionals.values()) {
            if (vtype.isTopVisible()) {
                adds.put(vtype.getTranslation().replace(' ', ':').toLowerCase(), vtype);
            }
        }
        for (String vtype : adds.keySet()) {
            addFilter(optionsMenu, vtype);
        }
    }
    optionsMenu.show();
}
Also used : OnMenuItemClickListener(android.view.MenuItem.OnMenuItemClickListener) PoiType(net.osmand.osm.PoiType) MenuItem(android.view.MenuItem) IconsCache(net.osmand.plus.IconsCache) TreeMap(java.util.TreeMap) PopupMenu(android.support.v7.widget.PopupMenu) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Example 4 with IconsCache

use of net.osmand.plus.IconsCache in project Osmand by osmandapp.

the class SearchPOIActivity method addFilter.

private void addFilter(PopupMenu optionsMenu, final String value) {
    IconsCache iconsCache = getMyApplication().getIconsCache();
    MenuItem item = optionsMenu.getMenu().add(getString(R.string.search_poi_filter) + ": " + value).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_filter_dark));
    item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (searchFilterLayout.getVisibility() == View.GONE) {
                searchFilterLayout.setVisibility(View.VISIBLE);
            }
            searchFilter.setText((searchFilter.getText().toString() + " " + value.replace(' ', '_').toLowerCase()).trim());
            return true;
        }
    });
}
Also used : OnMenuItemClickListener(android.view.MenuItem.OnMenuItemClickListener) MenuItem(android.view.MenuItem) IconsCache(net.osmand.plus.IconsCache)

Example 5 with IconsCache

use of net.osmand.plus.IconsCache in project Osmand by osmandapp.

the class SearchHistoryFragment method udpateHistoryItem.

public static void udpateHistoryItem(final HistoryEntry historyEntry, View row, LatLon location, Activity activity, OsmandApplication app) {
    TextView nameText = (TextView) row.findViewById(R.id.name);
    TextView distanceText = (TextView) row.findViewById(R.id.distance);
    ImageView direction = (ImageView) row.findViewById(R.id.direction);
    IconsCache ic = app.getIconsCache();
    direction.setImageDrawable(ic.getIcon(R.drawable.ic_direction_arrow, R.color.color_distance));
    String distance = "";
    if (location != null) {
        int dist = (int) (MapUtils.getDistance(location, historyEntry.getLat(), historyEntry.getLon()));
        distance = OsmAndFormatter.getFormattedDistance(dist, (OsmandApplication) activity.getApplication()) + "  ";
    }
    distanceText.setText(distance);
    PointDescription pd = historyEntry.getName();
    nameText.setText(pd.getSimpleName(activity, false), BufferType.SPANNABLE);
    ImageView icon = ((ImageView) row.findViewById(R.id.icon));
    icon.setImageDrawable(ic.getThemedIcon(getItemIcon(historyEntry.getName())));
    String typeName = historyEntry.getName().getTypeName();
    if (typeName != null && !typeName.isEmpty()) {
        ImageView group = (ImageView) row.findViewById(R.id.type_name_icon);
        group.setVisibility(View.VISIBLE);
        group.setImageDrawable(ic.getThemedIcon(R.drawable.ic_small_group));
        ((TextView) row.findViewById(R.id.type_name)).setText(typeName);
    } else {
        row.findViewById(R.id.type_name_icon).setVisibility(View.GONE);
        ((TextView) row.findViewById(R.id.type_name)).setText("");
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) TextView(android.widget.TextView) ImageView(android.widget.ImageView) IconsCache(net.osmand.plus.IconsCache)

Aggregations

IconsCache (net.osmand.plus.IconsCache)25 View (android.view.View)16 ImageView (android.widget.ImageView)13 TextView (android.widget.TextView)12 MenuItem (android.view.MenuItem)9 OsmandApplication (net.osmand.plus.OsmandApplication)8 PopupMenu (android.support.v7.widget.PopupMenu)6 RecyclerView (android.support.v7.widget.RecyclerView)5 LatLon (net.osmand.data.LatLon)5 ContextMenuItem (net.osmand.plus.ContextMenuItem)5 MotionEvent (android.view.MotionEvent)4 AdapterView (android.widget.AdapterView)4 ImageButton (android.widget.ImageButton)4 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)4 Intent (android.content.Intent)3 Toolbar (android.support.v7.widget.Toolbar)3 ListView (android.widget.ListView)3 File (java.io.File)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3