Search in sources :

Example 11 with FavoriteGroup

use of net.osmand.plus.myplaces.FavoriteGroup in project Osmand by osmandapp.

the class OsmandAidlApi method addFavoriteGroup.

boolean addFavoriteGroup(String name, String colorTag, boolean visible) {
    FavouritesHelper favoritesHelper = app.getFavoritesHelper();
    List<FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
    for (FavoriteGroup g : groups) {
        if (g.getName().equals(name)) {
            return false;
        }
    }
    int color = 0;
    if (!Algorithms.isEmpty(colorTag)) {
        color = ColorDialogs.getColorByTag(colorTag);
    }
    favoritesHelper.addEmptyCategory(name, color, visible);
    return true;
}
Also used : FavouritesHelper(net.osmand.plus.myplaces.FavouritesHelper) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) FavouritePoint(net.osmand.data.FavouritePoint) SuppressLint(android.annotation.SuppressLint)

Example 12 with FavoriteGroup

use of net.osmand.plus.myplaces.FavoriteGroup in project Osmand by osmandapp.

the class OsmandAidlApi method updateFavoriteGroup.

boolean updateFavoriteGroup(String prevGroupName, String newGroupName, String colorTag, boolean visible) {
    FavouritesHelper favoritesHelper = app.getFavoritesHelper();
    List<FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
    for (FavoriteGroup g : groups) {
        if (g.getName().equals(prevGroupName)) {
            int color = 0;
            if (!Algorithms.isEmpty(colorTag)) {
                color = ColorDialogs.getColorByTag(colorTag);
            }
            favoritesHelper.editFavouriteGroup(g, newGroupName, color, visible);
            return true;
        }
    }
    return false;
}
Also used : FavouritesHelper(net.osmand.plus.myplaces.FavouritesHelper) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) FavouritePoint(net.osmand.data.FavouritePoint) SuppressLint(android.annotation.SuppressLint)

Example 13 with FavoriteGroup

use of net.osmand.plus.myplaces.FavoriteGroup in project Osmand by osmandapp.

the class QuickSearchDialogFragment method onCreateView.

@Override
@SuppressLint("PrivateResource, ValidFragment")
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final MapActivity mapActivity = getMapActivity();
    final UiUtilities iconsCache = app.getUIUtilities();
    final View view = inflater.inflate(R.layout.search_dialog_fragment, container, false);
    toolbarController = new QuickSearchToolbarController();
    toolbarController.setOnBackButtonClickListener(v -> mapActivity.showQuickSearch(ShowQuickSearchMode.CURRENT, false));
    toolbarController.setOnTitleClickListener(v -> mapActivity.showQuickSearch(ShowQuickSearchMode.CURRENT, false));
    toolbarController.setOnCloseButtonClickListener(v -> mapActivity.closeQuickSearch());
    Bundle arguments = getArguments();
    if (savedInstanceState != null) {
        searchType = QuickSearchType.valueOf(savedInstanceState.getString(QUICK_SEARCH_TYPE_KEY, QuickSearchType.REGULAR.name()));
        searchQuery = savedInstanceState.getString(QUICK_SEARCH_QUERY_KEY);
        double lat = savedInstanceState.getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN);
        double lon = savedInstanceState.getDouble(QUICK_SEARCH_LON_KEY, Double.NaN);
        if (!Double.isNaN(lat) && !Double.isNaN(lon)) {
            centerLatLon = new LatLon(lat, lon);
        }
        interruptedSearch = savedInstanceState.getBoolean(QUICK_SEARCH_INTERRUPTED_SEARCH_KEY, false);
        hidden = savedInstanceState.getBoolean(QUICK_SEARCH_HIDDEN_KEY, false);
        toolbarTitle = savedInstanceState.getString(QUICK_SEARCH_TOOLBAR_TITLE_KEY);
        toolbarVisible = savedInstanceState.getBoolean(QUICK_SEARCH_TOOLBAR_VISIBLE_KEY, false);
        fabVisible = savedInstanceState.getBoolean(QUICK_SEARCH_FAB_VISIBLE_KEY, false);
    }
    if (searchQuery == null && arguments != null) {
        searchType = QuickSearchType.valueOf(arguments.getString(QUICK_SEARCH_TYPE_KEY, QuickSearchType.REGULAR.name()));
        searchQuery = arguments.getString(QUICK_SEARCH_QUERY_KEY);
        runSearchFirstTime = arguments.getBoolean(QUICK_SEARCH_RUN_SEARCH_FIRST_TIME_KEY, false);
        phraseDefined = arguments.getBoolean(QUICK_SEARCH_PHRASE_DEFINED_KEY, false);
        double lat = arguments.getDouble(QUICK_SEARCH_LAT_KEY, Double.NaN);
        double lon = arguments.getDouble(QUICK_SEARCH_LON_KEY, Double.NaN);
        if (!Double.isNaN(lat) && !Double.isNaN(lon)) {
            centerLatLon = new LatLon(lat, lon);
        }
        newSearch = true;
    }
    if (searchQuery == null)
        searchQuery = "";
    QuickSearchTab showSearchTab = QuickSearchTab.HISTORY;
    if (arguments != null) {
        showSearchTab = QuickSearchTab.valueOf(arguments.getString(QUICK_SEARCH_SHOW_TAB_KEY, QuickSearchTab.HISTORY.name()));
    }
    if (showSearchTab == QuickSearchTab.ADDRESS) {
        addressSearch = true;
    }
    tabToolbarView = view.findViewById(R.id.tab_toolbar_layout);
    tabsView = view.findViewById(R.id.tabs_view);
    searchView = view.findViewById(R.id.search_view);
    buttonToolbarView = view.findViewById(R.id.button_toolbar_layout);
    buttonToolbarImage = (ImageView) view.findViewById(R.id.buttonToolbarImage);
    buttonToolbarImage.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_marker_dark));
    buttonToolbarFilter = (ImageButton) view.findViewById(R.id.filterButton);
    buttonToolbarFilter.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_filter));
    buttonToolbarFilter.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            SearchPhrase searchPhrase = searchUICore.getPhrase();
            if (searchPhrase.isLastWord(POI_TYPE)) {
                String filterId = null;
                String filterByName = searchPhrase.getUnknownSearchPhrase().trim();
                Object object = searchPhrase.getLastSelectedWord().getResult().object;
                if (object instanceof PoiUIFilter) {
                    PoiUIFilter model = (PoiUIFilter) object;
                    if (!Algorithms.isEmpty(model.getSavedFilterByName())) {
                        model.setFilterByName(model.getSavedFilterByName());
                    }
                    filterId = model.getFilterId();
                } else if (object instanceof AbstractPoiType) {
                    AbstractPoiType abstractPoiType = (AbstractPoiType) object;
                    PoiUIFilter custom = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + abstractPoiType.getKeyName());
                    if (custom != null) {
                        custom.setFilterByName(null);
                        custom.clearFilter();
                        custom.updateTypesToAccept(abstractPoiType);
                        filterId = custom.getFilterId();
                    }
                }
                if (filterId != null) {
                    QuickSearchPoiFilterFragment.showDialog(QuickSearchDialogFragment.this, filterByName, filterId);
                }
            }
        }
    });
    buttonToolbarText = (TextView) view.findViewById(R.id.buttonToolbarTitle);
    view.findViewById(R.id.buttonToolbar).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            cancelSearch();
            SearchPhrase searchPhrase = searchUICore.getPhrase();
            if (foundPartialLocation) {
                QuickSearchCoordinatesFragment.showDialog(QuickSearchDialogFragment.this, searchPhrase.getFirstUnknownSearchWord());
            } else if (searchPhrase.isNoSelectedType() || searchPhrase.isLastWord(POI_TYPE)) {
                PoiUIFilter filter;
                if (searchPhrase.isNoSelectedType()) {
                    AbstractPoiType uselectedPoiType = searchUICore.getUnselectedPoiType();
                    if (isOnlineSearch() && !Algorithms.isEmpty(searchPhrase.getFirstUnknownSearchWord())) {
                        app.getPoiFilters().resetNominatimFilters();
                        filter = app.getPoiFilters().getNominatimPOIFilter();
                        filter.setFilterByName(searchPhrase.getUnknownSearchPhrase());
                        filter.clearCurrentResults();
                    } else if (uselectedPoiType != null) {
                        filter = new PoiUIFilter(uselectedPoiType, app, "");
                        String customName = searchUICore.getCustomNameFilter();
                        if (!Algorithms.isEmpty(customName)) {
                            filter.setFilterByName(customName);
                        }
                    } else {
                        filter = app.getPoiFilters().getSearchByNamePOIFilter();
                        if (!Algorithms.isEmpty(searchPhrase.getFirstUnknownSearchWord())) {
                            filter.setFilterByName(searchPhrase.getFirstUnknownSearchWord());
                            filter.clearCurrentResults();
                        }
                    }
                } else if (searchPhrase.getLastSelectedWord().getResult().object instanceof AbstractPoiType) {
                    if (searchPhrase.isNoSelectedType()) {
                        filter = new PoiUIFilter(null, app, "");
                    } else {
                        AbstractPoiType abstractPoiType = (AbstractPoiType) searchPhrase.getLastSelectedWord().getResult().object;
                        filter = new PoiUIFilter(abstractPoiType, app, "");
                    }
                    if (!Algorithms.isEmpty(searchPhrase.getFirstUnknownSearchWord())) {
                        filter.setFilterByName(searchPhrase.getFirstUnknownSearchWord());
                    }
                } else {
                    filter = (PoiUIFilter) searchPhrase.getLastSelectedWord().getResult().object;
                }
                app.getPoiFilters().clearSelectedPoiFilters();
                app.getPoiFilters().addSelectedPoiFilter(filter);
                mapActivity.getContextMenu().closeActiveToolbar();
                showToolbar();
                getMapActivity().updateStatusBarColor();
                getMapActivity().refreshMap();
                hide();
            } else {
                SearchWord word = searchPhrase.getLastSelectedWord();
                if (word != null) {
                    if (searchType.isTargetPoint() && word.getLocation() != null) {
                        if (mainSearchFragment != null) {
                            mainSearchFragment.showResult(word.getResult());
                        }
                    } else if (word.getLocation() != null) {
                        SearchResult searchResult = word.getResult();
                        String name = QuickSearchListItem.getName(app, searchResult);
                        String typeName = QuickSearchListItem.getTypeName(app, searchResult);
                        PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeName, name);
                        app.getSettings().setMapLocationToShow(searchResult.location.getLatitude(), searchResult.location.getLongitude(), searchResult.preferredZoom, pointDescription, true, searchResult.object);
                        hideToolbar();
                        MapActivity.launchMapActivityMoveToTop(getActivity());
                        reloadHistory();
                        hide();
                    } else if (word.getType() == ObjectType.FAVORITE_GROUP) {
                        FavoriteGroup group = (FavoriteGroup) word.getResult().object;
                        if (group.getPoints().size() > 1) {
                            double left = 0, right = 0;
                            double top = 0, bottom = 0;
                            for (FavouritePoint p : group.getPoints()) {
                                if (left == 0) {
                                    left = p.getLongitude();
                                    right = p.getLongitude();
                                    top = p.getLatitude();
                                    bottom = p.getLatitude();
                                } else {
                                    left = Math.min(left, p.getLongitude());
                                    right = Math.max(right, p.getLongitude());
                                    top = Math.max(top, p.getLatitude());
                                    bottom = Math.min(bottom, p.getLatitude());
                                }
                            }
                            getMapActivity().getMapView().fitRectToMap(left, right, top, bottom, 0, 0, 0);
                            hideToolbar();
                            MapActivity.launchMapActivityMoveToTop(getActivity());
                            hide();
                        } else if (group.getPoints().size() == 1) {
                            FavouritePoint p = group.getPoints().get(0);
                            app.getSettings().setMapLocationToShow(p.getLatitude(), p.getLongitude(), word.getResult().preferredZoom);
                            hideToolbar();
                            MapActivity.launchMapActivityMoveToTop(getActivity());
                            hide();
                        }
                    }
                }
            }
        }
    });
    toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    if (!app.getSettings().isLightContent()) {
        toolbar.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.app_bar_color_dark));
    }
    Drawable icBack = iconsCache.getThemedIcon(AndroidUtils.getNavigationIconResId(app));
    toolbar.setNavigationIcon(icBack);
    toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
    toolbar.setNavigationOnClickListener(v -> onBackButtonPressed());
    toolbarEdit = (Toolbar) view.findViewById(R.id.toolbar_edit);
    toolbarEdit.setNavigationIcon(iconsCache.getIcon(R.drawable.ic_action_remove_dark));
    toolbarEdit.setNavigationContentDescription(R.string.shared_string_cancel);
    toolbarEdit.setNavigationOnClickListener(v -> enableSelectionMode(false, -1));
    titleEdit = (TextView) view.findViewById(R.id.titleEdit);
    Drawable shareIcon = iconsCache.getIcon(R.drawable.ic_action_gshare_dark, R.color.color_white);
    shareIcon = AndroidUtils.getDrawableForDirection(app, shareIcon);
    ImageView shareButton = (ImageView) view.findViewById(R.id.shareButton);
    shareButton.setImageDrawable(shareIcon);
    shareButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            List<HistoryEntry> historyEntries = new ArrayList<HistoryEntry>();
            List<QuickSearchListItem> selectedItems = historySearchFragment.getListAdapter().getSelectedItems();
            for (QuickSearchListItem searchListItem : selectedItems) {
                Object object = searchListItem.getSearchResult().object;
                if (object instanceof HistoryEntry) {
                    historyEntries.add((HistoryEntry) object);
                }
            }
            if (historyEntries.size() > 0) {
                shareHistory(historyEntries);
                enableSelectionMode(false, -1);
            }
        }
    });
    view.findViewById(R.id.deleteButton).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            DeleteDialogFragment deleteDialog = new DeleteDialogFragment();
            deleteDialog.setSelectedItems(historySearchFragment.getListAdapter().getSelectedItems());
            deleteDialog.show(getChildFragmentManager(), "DeleteHistoryConfirmationFragment");
        }
    });
    viewPager = (LockableViewPager) view.findViewById(R.id.pager);
    viewPager.setOffscreenPageLimit(2);
    pagerAdapter = new SearchFragmentPagerAdapter(getChildFragmentManager(), getResources());
    viewPager.setAdapter(pagerAdapter);
    switch(showSearchTab) {
        case HISTORY:
            viewPager.setCurrentItem(0);
            break;
        case CATEGORIES:
            viewPager.setCurrentItem(1);
            break;
        case ADDRESS:
            viewPager.setCurrentItem(2);
            break;
    }
    tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
    tabLayout.setupWithViewPager(viewPager);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            hideKeyboard();
            addressSearch = position == 2;
            updateClearButtonAndHint();
            if (addressSearch && !citiesLoaded) {
                reloadCities();
            } else {
                restoreSearch();
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    searchEditText = (EditText) view.findViewById(R.id.searchEditText);
    searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                String newQueryText = searchQuery + " ";
                searchEditText.setText(newQueryText);
                searchEditText.setSelection(newQueryText.length());
                AndroidUtils.hideSoftKeyboard(getActivity(), searchEditText);
                return true;
            }
            return false;
        }
    });
    searchEditText.addTextChangedListener(new TextWatcher() {

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

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

        @Override
        public void afterTextChanged(Editable s) {
            String newQueryText = s.toString();
            updateClearButtonAndHint();
            updateClearButtonVisibility(true);
            boolean textEmpty = newQueryText.length() == 0;
            updateTabBarVisibility(textEmpty && !isOnlineSearch());
            updateSendEmptySearchBottomBar(false);
            if (textEmpty) {
                if (addressSearch) {
                    startAddressSearch();
                }
                if (poiFilterApplied) {
                    poiFilterApplied = false;
                    reloadCategories();
                    if (fabVisible) {
                        fabVisible = false;
                        updateFab();
                    }
                }
            }
            if (!searchQuery.equalsIgnoreCase(newQueryText)) {
                searchQuery = newQueryText;
                if (Algorithms.isEmpty(searchQuery)) {
                    cancelSearch();
                    setResultCollection(null);
                    searchUICore.resetPhrase();
                    mainSearchFragment.getAdapter().clear();
                } else {
                    runSearch();
                }
            } else if (runSearchFirstTime) {
                runSearchFirstTime = false;
                runSearch();
            }
        }
    });
    progressBar = (ProgressBar) view.findViewById(R.id.searchProgressBar);
    clearButton = (ImageButton) view.findViewById(R.id.clearButton);
    clearButton.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_remove_dark));
    clearButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (searchEditText.getText().length() > 0) {
                clearLastWord();
            } else if (useMapCenter && location != null) {
                useMapCenter = false;
                centerLatLon = null;
                updateUseMapCenterUI();
                LatLon centerLatLon = new LatLon(location.getLatitude(), location.getLongitude());
                SearchSettings ss = searchUICore.getSearchSettings().setOriginalLocation(new LatLon(centerLatLon.getLatitude(), centerLatLon.getLongitude()));
                searchUICore.updateSettings(ss);
                updateClearButtonAndHint();
                updateClearButtonVisibility(true);
                startLocationUpdate();
            }
            updateSendEmptySearchBottomBar(false);
            updateToolbarButton();
        }
    });
    fab = view.findViewById(R.id.fab);
    fab.setOnClickListener(v -> saveCustomFilter());
    updateFab();
    setupSearch(mapActivity);
    sendEmptySearchView = view.findViewById(R.id.no_search_results_bottom_bar);
    sendEmptySearchText = view.findViewById(R.id.no_search_results_description);
    sendEmptySearchButton = view.findViewById(R.id.send_empty_search_button);
    sendEmptySearchButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            OsmandApplication app = getMyApplication();
            if (app != null) {
                if (!app.getSettings().isInternetConnectionAvailable()) {
                    Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
                } else {
                    if (searchQuery != null) {
                        Bundle args = new Bundle();
                        SendSearchQueryBottomSheet fragment = new SendSearchQueryBottomSheet();
                        args.putString(MISSING_SEARCH_LOCATION_KEY, String.valueOf(location));
                        args.putString(MISSING_SEARCH_QUERY_KEY, searchQuery);
                        fragment.setArguments(args);
                        fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG);
                    }
                }
            }
        }
    });
    updateFab();
    return view;
}
Also used : FavouritePoint(net.osmand.data.FavouritePoint) OsmandApplication(net.osmand.plus.OsmandApplication) SearchWord(net.osmand.search.core.SearchWord) SpannableString(android.text.SpannableString) SearchPhrase(net.osmand.search.core.SearchPhrase) KeyEvent(android.view.KeyEvent) QuickSearchListItem(net.osmand.plus.search.listitems.QuickSearchListItem) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) SearchSettings(net.osmand.search.core.SearchSettings) ArrayList(java.util.ArrayList) List(java.util.List) TextView(android.widget.TextView) ImageView(android.widget.ImageView) MapActivity(net.osmand.plus.activities.MapActivity) Bundle(android.os.Bundle) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) Drawable(android.graphics.drawable.Drawable) SearchResult(net.osmand.search.core.SearchResult) AbstractPoiType(net.osmand.osm.AbstractPoiType) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ViewPager(androidx.viewpager.widget.ViewPager) LockableViewPager(net.osmand.plus.LockableViewPager) FavouritePoint(net.osmand.data.FavouritePoint) SuppressLint(android.annotation.SuppressLint) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) UiUtilities(net.osmand.plus.utils.UiUtilities) LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) SearchMoreItemOnClickListener(net.osmand.plus.search.listitems.QuickSearchMoreListItem.SearchMoreItemOnClickListener) OnClickListener(android.view.View.OnClickListener) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) SuppressLint(android.annotation.SuppressLint)

Example 14 with FavoriteGroup

use of net.osmand.plus.myplaces.FavoriteGroup in project Osmand by osmandapp.

the class ImportDuplicatesFragment method prepareDuplicates.

protected List<Object> prepareDuplicates(List<? super Object> duplicatesList) {
    List<? super Object> duplicates = new ArrayList<>();
    List<ApplicationMode.ApplicationModeBean> profiles = new ArrayList<>();
    List<QuickAction> actions = new ArrayList<>();
    List<PoiUIFilter> filters = new ArrayList<>();
    List<ITileSource> tileSources = new ArrayList<>();
    List<File> renderFilesList = new ArrayList<>();
    List<File> routingFilesList = new ArrayList<>();
    List<File> multimediaFilesList = new ArrayList<>();
    List<File> trackFilesList = new ArrayList<>();
    List<AvoidRoadInfo> avoidRoads = new ArrayList<>();
    List<FavoriteGroup> favoriteGroups = new ArrayList<>();
    List<OsmNotesPoint> osmNotesPointList = new ArrayList<>();
    List<OpenstreetmapPoint> osmEditsPointList = new ArrayList<>();
    List<File> ttsVoiceFilesList = new ArrayList<>();
    List<File> voiceFilesList = new ArrayList<>();
    List<File> mapFilesList = new ArrayList<>();
    List<MapMarker> mapMarkers = new ArrayList<>();
    List<MapMarker> mapMarkersHistory = new ArrayList<>();
    List<HistoryEntry> historyEntries = new ArrayList<>();
    List<OnlineRoutingEngine> onlineRoutingEngines = new ArrayList<>();
    List<MapMarkersGroup> itineraryGroups = new ArrayList<>();
    for (Object object : duplicatesList) {
        if (object instanceof ApplicationMode.ApplicationModeBean) {
            profiles.add((ApplicationMode.ApplicationModeBean) object);
        } else if (object instanceof QuickAction) {
            actions.add((QuickAction) object);
        } else if (object instanceof PoiUIFilter) {
            filters.add((PoiUIFilter) object);
        } else if (object instanceof ITileSource) {
            tileSources.add((ITileSource) object);
        } else if (object instanceof File) {
            File file = (File) object;
            FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
            if (fileSubtype == FileSubtype.RENDERING_STYLE) {
                renderFilesList.add(file);
            } else if (fileSubtype == FileSubtype.ROUTING_CONFIG) {
                routingFilesList.add(file);
            } else if (fileSubtype == FileSubtype.MULTIMEDIA_NOTES) {
                multimediaFilesList.add(file);
            } else if (fileSubtype == FileSubtype.GPX) {
                trackFilesList.add(file);
            } else if (fileSubtype.isMap()) {
                mapFilesList.add(file);
            } else if (fileSubtype == FileSubtype.TTS_VOICE) {
                ttsVoiceFilesList.add(file);
            } else if (fileSubtype == FileSubtype.VOICE) {
                voiceFilesList.add(file);
            }
        } else if (object instanceof AvoidRoadInfo) {
            avoidRoads.add((AvoidRoadInfo) object);
        } else if (object instanceof FavoriteGroup) {
            favoriteGroups.add((FavoriteGroup) object);
        } else if (object instanceof OsmNotesPoint) {
            osmNotesPointList.add((OsmNotesPoint) object);
        } else if (object instanceof OpenstreetmapPoint) {
            osmEditsPointList.add((OpenstreetmapPoint) object);
        } else if (object instanceof MapMarker) {
            MapMarker mapMarker = (MapMarker) object;
            if (mapMarker.history) {
                mapMarkersHistory.add(mapMarker);
            } else {
                mapMarkers.add(mapMarker);
            }
        } else if (object instanceof HistoryEntry) {
            historyEntries.add((HistoryEntry) object);
        } else if (object instanceof OnlineRoutingEngine) {
            onlineRoutingEngines.add((OnlineRoutingEngine) object);
        } else if (object instanceof MapMarkersGroup) {
            itineraryGroups.add((MapMarkersGroup) object);
        }
    }
    if (!profiles.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_profiles));
        duplicates.addAll(profiles);
    }
    if (!actions.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_quick_actions));
        duplicates.addAll(actions);
    }
    if (!filters.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_poi_types));
        duplicates.addAll(filters);
    }
    if (!tileSources.isEmpty()) {
        duplicates.add(getString(R.string.quick_action_map_source_title));
        duplicates.addAll(tileSources);
    }
    if (!routingFilesList.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_routing));
        duplicates.addAll(routingFilesList);
    }
    if (!renderFilesList.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_rendering_style));
        duplicates.addAll(renderFilesList);
    }
    if (!multimediaFilesList.isEmpty()) {
        duplicates.add(getString(R.string.audionotes_plugin_name));
        duplicates.addAll(multimediaFilesList);
    }
    if (!trackFilesList.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_tracks));
        duplicates.addAll(trackFilesList);
    }
    if (!avoidRoads.isEmpty()) {
        duplicates.add(getString(R.string.avoid_road));
        duplicates.addAll(avoidRoads);
    }
    if (!favoriteGroups.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_favorites));
        duplicates.addAll(favoriteGroups);
    }
    if (!osmNotesPointList.isEmpty()) {
        duplicates.add(getString(R.string.osm_notes));
        duplicates.addAll(osmNotesPointList);
    }
    if (!osmEditsPointList.isEmpty()) {
        duplicates.add(getString(R.string.osm_edits));
        duplicates.addAll(osmEditsPointList);
    }
    if (!mapFilesList.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_maps));
        duplicates.addAll(mapFilesList);
    }
    if (!ttsVoiceFilesList.isEmpty()) {
        duplicates.add(getString(R.string.local_indexes_cat_tts));
        duplicates.addAll(ttsVoiceFilesList);
    }
    if (!voiceFilesList.isEmpty()) {
        duplicates.add(getString(R.string.local_indexes_cat_voice));
        duplicates.addAll(voiceFilesList);
    }
    if (!mapMarkers.isEmpty()) {
        duplicates.add(getString(R.string.map_markers));
        duplicates.addAll(mapMarkers);
    }
    if (!mapMarkersHistory.isEmpty()) {
        duplicates.add(getString(R.string.markers_history));
        duplicates.addAll(mapMarkersHistory);
    }
    if (!onlineRoutingEngines.isEmpty()) {
        duplicates.add(getString(R.string.online_routing_engines));
        duplicates.addAll(onlineRoutingEngines);
    }
    if (!historyEntries.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_search_history));
        duplicates.addAll(historyEntries);
    }
    if (!itineraryGroups.isEmpty()) {
        duplicates.add(getString(R.string.shared_string_itinerary));
        duplicates.addAll(itineraryGroups);
    }
    return duplicates;
}
Also used : QuickAction(net.osmand.plus.quickaction.QuickAction) MapMarker(net.osmand.plus.mapmarkers.MapMarker) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) ArrayList(java.util.ArrayList) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) ITileSource(net.osmand.map.ITileSource) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) FileSubtype(net.osmand.plus.settings.backend.backup.items.FileSettingsItem.FileSubtype) File(java.io.File)

Example 15 with FavoriteGroup

use of net.osmand.plus.myplaces.FavoriteGroup in project Osmand by osmandapp.

the class AddFavouritesGroupBottomSheetDialogFragment method onItemClick.

@Override
protected void onItemClick(int position) {
    FavoriteGroup group = favouritesHelper.getFavoriteGroups().get(position - 1);
    if (!group.isVisible()) {
        favouritesHelper.editFavouriteGroup(group, group.getName(), group.getColor(), true);
    }
    getMyApplication().getMapMarkersHelper().addOrEnableGroup(group);
    dismiss();
}
Also used : FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup)

Aggregations

FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)29 FavouritePoint (net.osmand.data.FavouritePoint)15 ArrayList (java.util.ArrayList)10 FavouritesHelper (net.osmand.plus.myplaces.FavouritesHelper)9 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)8 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)7 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)7 File (java.io.File)6 MapMarker (net.osmand.plus.mapmarkers.MapMarker)6 QuickAction (net.osmand.plus.quickaction.QuickAction)6 NonNull (androidx.annotation.NonNull)5 ITileSource (net.osmand.map.ITileSource)5 MapActivity (net.osmand.plus.activities.MapActivity)5 AvoidRoadInfo (net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)5 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)5 OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)5 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)5 Context (android.content.Context)4 View (android.view.View)4 List (java.util.List)4