Search in sources :

Example 21 with IconsCache

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

the class DestinationReachedMenuFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dest_reached_menu_fragment, container, false);
    view.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismissMenu();
        }
    });
    IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
    ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton);
    closeImageButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, menu.isLight()));
    closeImageButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismissMenu();
        }
    });
    Button removeDestButton = (Button) view.findViewById(R.id.removeDestButton);
    removeDestButton.setCompoundDrawablesWithIntrinsicBounds(iconsCache.getIcon(R.drawable.ic_action_done, menu.isLight()), null, null, null);
    AndroidUtils.setTextPrimaryColor(view.getContext(), removeDestButton, !menu.isLight());
    removeDestButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getMapActivity().getMyApplication().getTargetPointsHelper().removeWayPoint(true, -1);
            Object contextMenuObj = getMapActivity().getContextMenu().getObject();
            if (getMapActivity().getContextMenu().isActive() && contextMenuObj != null && contextMenuObj instanceof TargetPoint) {
                TargetPoint targetPoint = (TargetPoint) contextMenuObj;
                if (!targetPoint.start && !targetPoint.intermediate) {
                    getMapActivity().getContextMenu().close();
                }
            }
            OsmandSettings settings = getMapActivity().getMyApplication().getSettings();
            settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
            getMapActivity().getMapActions().stopNavigationWithoutConfirm();
            dismissMenu();
        }
    });
    Button recalcDestButton = (Button) view.findViewById(R.id.recalcDestButton);
    recalcDestButton.setCompoundDrawablesWithIntrinsicBounds(iconsCache.getIcon(R.drawable.ic_action_gdirections_dark, menu.isLight()), null, null, null);
    AndroidUtils.setTextPrimaryColor(view.getContext(), recalcDestButton, !menu.isLight());
    recalcDestButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TargetPointsHelper helper = getMapActivity().getMyApplication().getTargetPointsHelper();
            TargetPoint target = helper.getPointToNavigate();
            dismissMenu();
            if (target != null) {
                helper.navigateToPoint(new LatLon(target.getLatitude(), target.getLongitude()), true, -1, target.getOriginalPointDescription());
                getMapActivity().getMapActions().recalculateRoute(false);
                getMapActivity().getMapLayers().getMapControlsLayer().startNavigation();
            }
        }
    });
    Button findParkingButton = (Button) view.findViewById(R.id.findParkingButton);
    ApplicationMode appMode = getMapActivity().getMyApplication().getRoutingHelper().getAppMode();
    if (!appMode.isDerivedRoutingFrom(appMode.CAR)) {
        findParkingButton.setVisibility(View.GONE);
    }
    findParkingButton.setCompoundDrawablesWithIntrinsicBounds(iconsCache.getIcon(R.drawable.ic_action_parking_dark, menu.isLight()), null, null, null);
    AndroidUtils.setTextPrimaryColor(view.getContext(), findParkingButton, !menu.isLight());
    findParkingButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            PoiFiltersHelper helper = getMapActivity().getMyApplication().getPoiFilters();
            // PoiType place = getMapActivity().getMyApplication().getPoiTypes().getPoiTypeByKey("parking");
            PoiUIFilter parkingFilter = helper.getFilterById(PoiUIFilter.STD_PREFIX + "parking");
            if (parkingFilter != null) {
                final Intent newIntent = new Intent(getActivity(), SearchPOIActivity.class);
                newIntent.putExtra(SearchPOIActivity.AMENITY_FILTER, parkingFilter.getFilterId());
                newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
                startActivityForResult(newIntent, 0);
            }
            dismissMenu();
        }
    });
    View mainView = view.findViewById(R.id.main_view);
    if (menu.isLandscapeLayout()) {
        AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(), R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
    } else {
        AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(), R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
    }
    TextView title = (TextView) view.findViewById(R.id.titleTextView);
    AndroidUtils.setTextPrimaryColor(view.getContext(), title, !menu.isLight());
    return view;
}
Also used : Intent(android.content.Intent) ApplicationMode(net.osmand.plus.ApplicationMode) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) TextView(android.widget.TextView) View(android.view.View) OsmandSettings(net.osmand.plus.OsmandSettings) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) LatLon(net.osmand.data.LatLon) ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) SearchPOIActivity(net.osmand.plus.activities.search.SearchPOIActivity) TextView(android.widget.TextView) IconsCache(net.osmand.plus.IconsCache) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) Nullable(android.support.annotation.Nullable)

Example 22 with IconsCache

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

the class LocalIndexesFragment method openPopUpMenu.

private void openPopUpMenu(View v, final LocalIndexInfo info) {
    IconsCache iconsCache = getMyApplication().getIconsCache();
    final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
    DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
    final boolean restore = info.isBackupedData();
    MenuItem item;
    if ((info.getType() == LocalIndexType.MAP_DATA) || (info.getType() == LocalIndexType.DEACTIVATED)) {
        item = optionsMenu.getMenu().add(restore ? R.string.local_index_mi_restore : R.string.local_index_mi_backup).setIcon(iconsCache.getThemedIcon(R.drawable.ic_type_archive));
        item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                performBasicOperation(restore ? R.string.local_index_mi_restore : R.string.local_index_mi_backup, info);
                return true;
            }
        });
    }
    item = optionsMenu.getMenu().add(R.string.shared_string_rename).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark));
    item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            performBasicOperation(R.string.shared_string_rename, info);
            return true;
        }
    });
    if (info.getType() == LocalIndexType.TILES_DATA && (info.getAttachedObject() instanceof ITileSource) && ((ITileSource) info.getAttachedObject()).couldBeDownloadedFromInternet()) {
        item = optionsMenu.getMenu().add(R.string.clear_tile_data).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_remove_dark));
        item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                performBasicOperation(R.string.clear_tile_data, info);
                return true;
            }
        });
    }
    final IndexItem update = filesToUpdate.get(info.getFileName());
    if (update != null) {
        item = optionsMenu.getMenu().add(R.string.update_tile).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_import));
        item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                getDownloadActivity().startDownload(update);
                return true;
            }
        });
    }
    item = optionsMenu.getMenu().add(R.string.shared_string_delete).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_delete_dark));
    item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            performBasicOperation(R.string.shared_string_delete, info);
            return true;
        }
    });
    optionsMenu.show();
}
Also used : ITileSource(net.osmand.map.ITileSource) MenuItem(android.view.MenuItem) ContextMenuItem(net.osmand.plus.ContextMenuItem) IconsCache(net.osmand.plus.IconsCache) IndexItem(net.osmand.plus.download.IndexItem) PopupMenu(android.support.v7.widget.PopupMenu)

Example 23 with IconsCache

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

the class ShowRouteInfoDialogFragment method buildMenuButtons.

private void buildMenuButtons() {
    IconsCache iconsCache = getMyApplication().getIconsCache();
    ImageButton printRoute = (ImageButton) view.findViewById(R.id.print_route);
    printRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gprint_dark));
    printRoute.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            print();
        }
    });
    ImageButton saveRoute = (ImageButton) view.findViewById(R.id.save_as_gpx);
    saveRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gsave_dark));
    saveRoute.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            MapActivityActions.createSaveDirections(getActivity(), helper).show();
        }
    });
    ImageButton shareRoute = (ImageButton) view.findViewById(R.id.share_as_gpx);
    shareRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gshare_dark));
    shareRoute.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final GPXFile gpx = helper.generateGPXFileWithRoute();
            final Uri fileUri = Uri.fromFile(new File(gpx.path));
            File dir = new File(getActivity().getCacheDir(), "share");
            if (!dir.exists()) {
                dir.mkdir();
            }
            File dst = new File(dir, "route.gpx");
            try {
                FileWriter fw = new FileWriter(dst);
                GPXUtilities.writeGpx(fw, gpx, getMyApplication());
                fw.close();
                final Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.ACTION_SEND);
                sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(generateHtml(adapter, helper.getGeneralRouteInformation()).toString()));
                sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_route_subject));
                sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
                sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(getActivity(), getActivity().getPackageName() + ".fileprovider", dst));
                sendIntent.setType("text/plain");
                startActivity(sendIntent);
            } catch (IOException e) {
                // Toast.makeText(getActivity(), "Error sharing favorites: " + e.getMessage(),
                // Toast.LENGTH_LONG).show();
                e.printStackTrace();
            }
        }
    });
}
Also used : ImageButton(android.widget.ImageButton) FileWriter(java.io.FileWriter) Intent(android.content.Intent) IconsCache(net.osmand.plus.IconsCache) IOException(java.io.IOException) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) Uri(android.net.Uri) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) File(java.io.File)

Example 24 with IconsCache

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

the class MapWidgetRegistry method addControls.

private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter, Set<MapWidgetRegInfo> groupTitle, final ApplicationMode mode) {
    for (final MapWidgetRegInfo r : groupTitle) {
        if (!mode.isWidgetAvailable(r.key)) {
            continue;
        }
        final boolean selected = r.visibleCollapsed(mode) || r.visible(mode);
        final String desc = mapActivity.getString(R.string.shared_string_collapse);
        ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder().setIcon(r.getDrawableMenu()).setSelected(selected).setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID).setSecondaryIcon(r.widget != null ? R.drawable.ic_action_additional_option : ContextMenuItem.INVALID_ID).setDescription(r.visibleCollapsed(mode) ? desc : null).setListener(new ContextMenuAdapter.OnRowItemClick() {

            @Override
            public boolean onRowItemClick(final ArrayAdapter<ContextMenuItem> adapter, final View view, final int itemId, final int pos) {
                if (r.widget == null) {
                    setVisibility(adapter, pos, !r.visible(mode), false);
                    return false;
                }
                View textWrapper = view.findViewById(R.id.text_wrapper);
                IconPopupMenu popup = new IconPopupMenu(view.getContext(), textWrapper);
                MenuInflater inflater = popup.getMenuInflater();
                final Menu menu = popup.getMenu();
                inflater.inflate(R.menu.widget_visibility_menu, menu);
                IconsCache ic = mapActivity.getMyApplication().getIconsCache();
                menu.findItem(R.id.action_show).setIcon(ic.getThemedIcon(R.drawable.ic_action_view));
                menu.findItem(R.id.action_hide).setIcon(ic.getThemedIcon(R.drawable.ic_action_hide));
                menu.findItem(R.id.action_collapse).setIcon(ic.getThemedIcon(R.drawable.ic_action_widget_collapse));
                final int[] menuIconIds = r.getDrawableMenuIds();
                final int[] menuTitleIds = r.getMessageIds();
                final int[] menuItemIds = r.getItemIds();
                int checkedId = r.getItemId();
                boolean selected = r.visibleCollapsed(mode) || r.visible(mode);
                if (menuIconIds != null && menuTitleIds != null && menuItemIds != null && menuIconIds.length == menuTitleIds.length && menuIconIds.length == menuItemIds.length) {
                    for (int i = 0; i < menuIconIds.length; i++) {
                        int iconId = menuIconIds[i];
                        int titleId = menuTitleIds[i];
                        int id = menuItemIds[i];
                        MenuItem menuItem = menu.add(R.id.single_selection_group, id, i, titleId).setChecked(id == checkedId);
                        menuItem.setIcon(menuItem.isChecked() && selected ? ic.getIcon(iconId, R.color.osmand_orange) : ic.getThemedIcon(iconId));
                    }
                    menu.setGroupCheckable(R.id.single_selection_group, true, true);
                    menu.setGroupVisible(R.id.single_selection_group, true);
                }
                popup.setOnMenuItemClickListener(new IconPopupMenu.OnMenuItemClickListener() {

                    @Override
                    public boolean onMenuItemClick(MenuItem menuItem) {
                        switch(menuItem.getItemId()) {
                            case R.id.action_show:
                                setVisibility(adapter, pos, true, false);
                                return true;
                            case R.id.action_hide:
                                setVisibility(adapter, pos, false, false);
                                return true;
                            case R.id.action_collapse:
                                setVisibility(adapter, pos, true, true);
                                return true;
                            default:
                                if (menuItemIds != null) {
                                    for (int menuItemId : menuItemIds) {
                                        if (menuItem.getItemId() == menuItemId) {
                                            r.changeState(menuItemId);
                                            MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
                                            if (mil != null) {
                                                mil.recreateControls();
                                            }
                                            ContextMenuItem item = adapter.getItem(pos);
                                            item.setIcon(r.getDrawableMenu());
                                            if (r.getMessage() != null) {
                                                item.setTitle(r.getMessage());
                                            } else {
                                                item.setTitle(mapActivity.getResources().getString(r.getMessageId()));
                                            }
                                            adapter.notifyDataSetChanged();
                                            return true;
                                        }
                                    }
                                }
                        }
                        return false;
                    }
                });
                popup.show();
                return false;
            }

            @Override
            public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> a, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
                setVisibility(a, pos, isChecked, false);
                return false;
            }

            private void setVisibility(ArrayAdapter<ContextMenuItem> adapter, int position, boolean visible, boolean collapsed) {
                MapWidgetRegistry.this.setVisibility(r, visible, collapsed);
                MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
                if (mil != null) {
                    mil.recreateControls();
                }
                ContextMenuItem item = adapter.getItem(position);
                item.setSelected(visible);
                item.setColorRes(visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
                item.setDescription(visible && collapsed ? desc : null);
                adapter.notifyDataSetChanged();
            }
        });
        if (r.getMessage() != null) {
            itemBuilder.setTitle(r.getMessage());
        } else {
            itemBuilder.setTitleId(r.getMessageId(), mapActivity);
        }
        contextMenuAdapter.addItem(itemBuilder.createItem());
    }
}
Also used : ContextMenuItem(net.osmand.plus.ContextMenuItem) MenuInflater(android.view.MenuInflater) MenuItem(android.view.MenuItem) ContextMenuItem(net.osmand.plus.ContextMenuItem) View(android.view.View) IconPopupMenu(net.osmand.plus.widgets.IconPopupMenu) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) MapInfoLayer(net.osmand.plus.views.MapInfoLayer) Menu(android.view.Menu) IconPopupMenu(net.osmand.plus.widgets.IconPopupMenu) ConfigureMapMenu(net.osmand.plus.dialogs.ConfigureMapMenu) IconsCache(net.osmand.plus.IconsCache)

Example 25 with IconsCache

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

the class QuickSearchPoiFilterFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final OsmandApplication app = getMyApplication();
    if (getArguments() != null) {
        filterId = getArguments().getString(QUICK_SEARCH_POI_FILTER_ID_KEY);
        nameFilterText = getArguments().getString(QUICK_SEARCH_POI_FILTER_BY_NAME_KEY);
    } else if (savedInstanceState != null) {
        filterId = savedInstanceState.getString(QUICK_SEARCH_POI_FILTER_ID_KEY);
        nameFilterText = savedInstanceState.getString(QUICK_SEARCH_POI_FILTER_BY_NAME_KEY);
        ArrayList<String> selectedList = savedInstanceState.getStringArrayList(QUICK_SEARCH_POI_FILTER_SELECTED_ADDITIONALS);
        if (selectedList != null) {
            selectedPoiAdditionals.addAll(selectedList);
        }
        ArrayList<String> collapsedList = savedInstanceState.getStringArrayList(QUICK_SEARCH_POI_FILTER_COLLAPSED_CATEGORIES);
        if (collapsedList != null) {
            collapsedCategories.addAll(collapsedList);
        }
        ArrayList<String> showAllList = savedInstanceState.getStringArrayList(QUICK_SEARCH_POI_FILTER_SHOW_ALL_CATEGORIES);
        if (showAllList != null) {
            showAllCategories.addAll(showAllList);
        }
    }
    nameFilterTextOrig = "" + nameFilterText;
    if (filterId != null) {
        filter = app.getPoiFilters().getFilterById(filterId);
    }
    if (filter == null) {
        filter = app.getPoiFilters().getCustomPOIFilter();
        filter.clearFilter();
    }
    if (selectedPoiAdditionals.size() == 0) {
        processFilterFields();
        initListItems();
    }
    selectedPoiAdditionalsOrig = new TreeSet<>(selectedPoiAdditionals);
    view = inflater.inflate(R.layout.search_poi_filter, container, false);
    TextView description = (TextView) view.findViewById(R.id.description);
    description.setText(filter.getName());
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark));
    toolbar.setNavigationContentDescription(R.string.shared_string_close);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    ImageButton moreButton = (ImageButton) view.findViewById(R.id.moreButton);
    moreButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            IconsCache iconsCache = app.getIconsCache();
            final PopupMenu optionsMenu = new PopupMenu(getContext(), v);
            DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
            MenuItem item;
            if (!filter.isStandardFilter()) {
                item = optionsMenu.getMenu().add(R.string.edit_filter).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_edit_dark));
                item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        editFilter();
                        return true;
                    }
                });
            }
            if (!filter.isStandardFilter()) {
                item = optionsMenu.getMenu().add(R.string.edit_filter_save_as_menu_item).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_save));
            } else {
                item = optionsMenu.getMenu().add(R.string.save_filter).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_save));
            }
            item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    saveFilter();
                    return true;
                }
            });
            if (!filter.isStandardFilter()) {
                item = optionsMenu.getMenu().add(R.string.delete_filter).setIcon(iconsCache.getThemedIcon(R.drawable.ic_action_delete_dark));
                item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        deleteFilter();
                        return true;
                    }
                });
            }
            optionsMenu.show();
        }
    });
    listView = (ListView) view.findViewById(android.R.id.list);
    listView.setBackgroundColor(getResources().getColor(app.getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light : R.color.ctx_menu_info_view_bg_dark));
    View editTextView = inflater.inflate(R.layout.poi_filter_list_item, listView, false);
    editText = (EditText) editTextView.findViewById(R.id.editText);
    editTextView.findViewById(R.id.divider).setVisibility(View.GONE);
    editText.setText(nameFilterText);
    editText.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) {
            nameFilterText = s.toString();
            updateApplyButton();
        }
    });
    editText.setVisibility(View.VISIBLE);
    final ImageView textEditIcon = (ImageView) editTextView.findViewById(R.id.icon);
    textEditIcon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_search_dark));
    textEditIcon.setVisibility(View.VISIBLE);
    editTextView.findViewById(R.id.titleBold).setVisibility(View.GONE);
    editTextView.findViewById(R.id.titleButton).setVisibility(View.GONE);
    editTextView.findViewById(R.id.expandItem).setVisibility(View.GONE);
    editTextView.findViewById(R.id.titleRegular).setVisibility(View.GONE);
    editTextView.findViewById(R.id.switchItem).setVisibility(View.GONE);
    editTextView.findViewById(R.id.checkboxItem).setVisibility(View.GONE);
    listView.addHeaderView(editTextView);
    View bottomShadowView = inflater.inflate(R.layout.list_shadow_footer, listView, false);
    listView.addFooterView(bottomShadowView, null, false);
    adapter = new PoiFilterListAdapter(app, getListItems());
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            PoiFilterListItem item = adapter.getItem(position - listView.getHeaderViewsCount());
            if (item != null) {
                switch(item.type) {
                    case GROUP_HEADER:
                        if (item.category != null) {
                            if (collapsedCategories.contains(item.category)) {
                                collapsedCategories.remove(item.category);
                            } else {
                                collapsedCategories.add(item.category);
                            }
                            updateListView();
                        }
                        break;
                    case CHECKBOX_ITEM:
                        CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkboxItem);
                        adapter.toggleCheckbox(item, checkBox, !checkBox.isChecked());
                        break;
                    case BUTTON_ITEM:
                        if (item.category != null) {
                            showAllCategories.add(item.category);
                            updateListView();
                        }
                        break;
                }
            }
        }
    });
    applyFilterButtonShadow = view.findViewById(R.id.bottomButtonShadow);
    applyFilterButton = (TextView) view.findViewById(R.id.bottomButton);
    applyFilterButton.setText(app.getString(R.string.apply_filters));
    applyFilterButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            applyFilterFields();
            if (!filter.isStandardFilter()) {
                filter.setSavedFilterByName(filter.getFilterByName());
                if (app.getPoiFilters().editPoiFilter(filter)) {
                    app.getSearchUICore().refreshCustomPoiFilters();
                    ((QuickSearchDialogFragment) getParentFragment()).replaceQueryWithUiFilter(filter, "");
                    ((QuickSearchDialogFragment) getParentFragment()).reloadCategories();
                    dismiss();
                }
            } else {
                ((QuickSearchDialogFragment) getParentFragment()).replaceQueryWithUiFilter(filter, nameFilterText.trim());
                dismiss();
            }
        }
    });
    updateApplyButton();
    return view;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ArrayList(java.util.ArrayList) ImageButton(android.widget.ImageButton) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Toolbar(android.support.v7.widget.Toolbar) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) CheckBox(android.widget.CheckBox) AdapterView(android.widget.AdapterView) IconsCache(net.osmand.plus.IconsCache) PopupMenu(android.support.v7.widget.PopupMenu)

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