Search in sources :

Example 1 with ProfileIconColors

use of net.osmand.plus.profiles.ProfileIconColors in project Osmand by osmandapp.

the class ExportItemsBottomSheet method setupBottomSheetItem.

private void setupBottomSheetItem(BottomSheetItemWithCompoundButton item, Object object) {
    if (object instanceof ApplicationModeBean) {
        ApplicationModeBean modeBean = (ApplicationModeBean) object;
        String profileName = modeBean.userProfileName;
        if (Algorithms.isEmpty(profileName)) {
            ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
            if (appMode != null) {
                profileName = appMode.toHumanString();
            } else {
                profileName = Algorithms.capitalizeFirstLetter(modeBean.stringKey);
            }
        }
        item.setTitle(profileName);
        String routingProfile = "";
        String routingProfileValue = modeBean.routingProfile;
        if (!routingProfileValue.isEmpty()) {
            try {
                routingProfile = getString(RoutingProfilesResources.valueOf(routingProfileValue.toUpperCase()).getStringRes());
                routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfile);
            } catch (IllegalArgumentException e) {
                routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfileValue);
                LOG.error("Error trying to get routing resource for " + routingProfileValue + "\n" + e);
            }
        }
        if (!Algorithms.isEmpty(routingProfile)) {
            item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.nav_type_hint), routingProfile));
        } else {
            item.setDescription(getString(R.string.profile_type_osmand_string));
        }
        int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName);
        ProfileIconColors iconColor = modeBean.iconColor;
        Integer customIconColor = modeBean.customIconColor;
        int actualIconColor;
        if (selectedItems.contains(object)) {
            actualIconColor = customIconColor != null ? customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode));
        } else {
            actualIconColor = ContextCompat.getColor(app, secondaryColorRes);
        }
        int iconRes = profileIconRes != 0 ? profileIconRes : R.drawable.ic_world_globe_dark;
        item.setIcon(uiUtilities.getPaintedIcon(iconRes, actualIconColor));
    } else if (object instanceof QuickAction) {
        QuickAction quickAction = (QuickAction) object;
        item.setTitle(quickAction.getName(app));
        item.setIcon(uiUtilities.getIcon(quickAction.getIconRes(), getItemIconColor(object)));
    } else if (object instanceof PoiUIFilter) {
        PoiUIFilter poiUIFilter = (PoiUIFilter) object;
        item.setTitle(poiUIFilter.getName());
        int iconRes = RenderingIcons.getBigIconResourceId(poiUIFilter.getIconId());
        item.setIcon(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_action_user, activeColorRes));
    } else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) {
        ITileSource tileSource = (ITileSource) object;
        item.setTitle(tileSource.getName());
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_map, getItemIconColor(object)));
    } else if (object instanceof File) {
        setupBottomSheetItemForFile(item, (File) object);
    } else if (object instanceof GpxSettingsItem) {
        GpxSettingsItem settingsItem = (GpxSettingsItem) object;
        setupBottomSheetItemForGpx(item, settingsItem.getFile(), settingsItem.getAppearanceInfo());
    } else if (object instanceof FileSettingsItem) {
        FileSettingsItem settingsItem = (FileSettingsItem) object;
        setupBottomSheetItemForFile(item, settingsItem.getFile());
    } else if (object instanceof AvoidRoadInfo) {
        AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) object;
        item.setTitle(avoidRoadInfo.name);
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_alert, getItemIconColor(object)));
    } else if (object instanceof OsmNotesPoint) {
        OsmNotesPoint osmNotesPoint = (OsmNotesPoint) object;
        item.setTitle(osmNotesPoint.getText());
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_osm_note_add, getItemIconColor(object)));
    } else if (object instanceof OpenstreetmapPoint) {
        OpenstreetmapPoint openstreetmapPoint = (OpenstreetmapPoint) object;
        item.setTitle(OsmEditingPlugin.getTitle(openstreetmapPoint, app));
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_info_dark, getItemIconColor(object)));
    } else if (object instanceof FavoriteGroup) {
        FavoriteGroup group = (FavoriteGroup) object;
        item.setTitle(group.getDisplayName(app));
        int color;
        if (selectedItems.contains(object)) {
            color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor();
        } else {
            color = ContextCompat.getColor(app, secondaryColorRes);
        }
        item.setIcon(uiUtilities.getPaintedIcon(R.drawable.ic_action_folder, color));
        int points = group.getPoints().size();
        String itemsDescr = getString(R.string.shared_string_gpx_points);
        item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, points));
    } else if (object instanceof GlobalSettingsItem) {
        GlobalSettingsItem globalSettingsItem = (GlobalSettingsItem) object;
        item.setTitle(globalSettingsItem.getPublicName(app));
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_settings, getItemIconColor(object)));
    } else if (object instanceof MapMarkersGroup) {
        MapMarkersGroup markersGroup = (MapMarkersGroup) object;
        if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) {
            item.setTitle(getString(R.string.map_markers));
            item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, getItemIconColor(object)));
        } else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) {
            item.setTitle(getString(R.string.markers_history));
            item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object)));
        } else {
            String groupName = markersGroup.getName();
            if (Algorithms.isEmpty(groupName)) {
                if (markersGroup.getType() == ItineraryType.FAVOURITES) {
                    groupName = app.getString(R.string.shared_string_favorites);
                } else if (markersGroup.getType() == ItineraryType.MARKERS) {
                    groupName = app.getString(R.string.map_markers);
                }
            }
            item.setTitle(groupName);
            item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, getItemIconColor(object)));
        }
        int selectedMarkers = markersGroup.getMarkers().size();
        String itemsDescr = getString(R.string.shared_string_items);
        item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, selectedMarkers));
    } else if (object instanceof HistoryEntry) {
        HistoryEntry historyEntry = (HistoryEntry) object;
        item.setTitle(historyEntry.getName().getName());
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object)));
    } else if (object instanceof OnlineRoutingEngine) {
        OnlineRoutingEngine onlineRoutingEngine = (OnlineRoutingEngine) object;
        item.setTitle(onlineRoutingEngine.getName(app));
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_world_globe_dark, getItemIconColor(object)));
    }
}
Also used : QuickAction(net.osmand.plus.quickaction.QuickAction) ProfileIconColors(net.osmand.plus.profiles.ProfileIconColors) TileSourceTemplate(net.osmand.map.TileSourceManager.TileSourceTemplate) ApplicationModeBean(net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) GpxSettingsItem(net.osmand.plus.settings.backend.backup.items.GpxSettingsItem) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) SQLiteTileSource(net.osmand.plus.resources.SQLiteTileSource) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) GlobalSettingsItem(net.osmand.plus.settings.backend.backup.items.GlobalSettingsItem) FileSettingsItem(net.osmand.plus.settings.backend.backup.items.FileSettingsItem) ITileSource(net.osmand.map.ITileSource) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) File(java.io.File)

Example 2 with ProfileIconColors

use of net.osmand.plus.profiles.ProfileIconColors in project Osmand by osmandapp.

the class ProfileAppearanceFragment method createColorsCard.

private void createColorsCard(PreferenceViewHolder holder) {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity == null) {
        return;
    }
    FlowLayout colorsCardContainer = (FlowLayout) holder.findViewById(R.id.color_items);
    colorsCardContainer.removeAllViews();
    int selectedColor = changedProfile.getActualColor();
    List<Integer> colors = new ArrayList<>();
    for (ProfileIconColors color : ProfileIconColors.values()) {
        colors.add(ContextCompat.getColor(app, color.getColor(isNightMode())));
    }
    colorsCard = new ColorsCard(mapActivity, getSelectedAppMode(), this, selectedColor, colors, app.getSettings().CUSTOM_ICON_COLORS, false);
    colorsCard.setListener(this);
    colorsCardContainer.addView(colorsCard.build(app));
    updateColorName();
}
Also used : FlowLayout(net.osmand.plus.widgets.FlowLayout) ProfileIconColors(net.osmand.plus.profiles.ProfileIconColors) ColorsCard(net.osmand.plus.track.cards.ColorsCard) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) MapActivity(net.osmand.plus.activities.MapActivity)

Example 3 with ProfileIconColors

use of net.osmand.plus.profiles.ProfileIconColors in project Osmand by osmandapp.

the class DuplicatesSettingsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
    Object currentItem = items.get(position);
    if (holder instanceof HeaderViewHolder) {
        HeaderViewHolder headerHolder = (HeaderViewHolder) holder;
        headerHolder.title.setText((String) currentItem);
        headerHolder.subTitle.setText(String.format(app.getString(R.string.listed_exist), currentItem));
        headerHolder.divider.setVisibility(View.VISIBLE);
    } else if (holder instanceof ItemViewHolder) {
        ItemViewHolder itemHolder = (ItemViewHolder) holder;
        itemHolder.subTitle.setVisibility(View.GONE);
        if (currentItem instanceof ApplicationModeBean) {
            ApplicationModeBean modeBean = (ApplicationModeBean) currentItem;
            String profileName = modeBean.userProfileName;
            if (Algorithms.isEmpty(profileName)) {
                ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
                if (appMode != null) {
                    profileName = appMode.toHumanString();
                } else {
                    profileName = Algorithms.capitalizeFirstLetter(modeBean.stringKey);
                }
            }
            itemHolder.title.setText(profileName);
            String routingProfile = "";
            String routingProfileValue = modeBean.routingProfile;
            if (!routingProfileValue.isEmpty()) {
                try {
                    routingProfile = app.getString(RoutingProfilesResources.valueOf(routingProfileValue.toUpperCase()).getStringRes());
                    routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfile);
                } catch (IllegalArgumentException e) {
                    routingProfile = Algorithms.capitalizeFirstLetterAndLowercase(routingProfileValue);
                    LOG.error("Error trying to get routing resource for " + routingProfileValue + "\n" + e);
                }
            }
            if (Algorithms.isEmpty(routingProfile)) {
                itemHolder.subTitle.setVisibility(View.GONE);
            } else {
                itemHolder.subTitle.setText(String.format(app.getString(R.string.ltr_or_rtl_combine_via_colon), app.getString(R.string.nav_type_hint), routingProfile));
                itemHolder.subTitle.setVisibility(View.VISIBLE);
            }
            int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName);
            ProfileIconColors iconColor = modeBean.iconColor;
            Integer customIconColor = modeBean.customIconColor;
            int actualIconColor = customIconColor != null ? customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode));
            itemHolder.icon.setImageDrawable(uiUtilities.getPaintedIcon(profileIconRes, actualIconColor));
        } else if (currentItem instanceof QuickAction) {
            QuickAction action = (QuickAction) currentItem;
            itemHolder.title.setText(action.getName(app));
            itemHolder.icon.setImageDrawable(uiUtilities.getIcon(action.getIconRes(), activeColorRes));
        } else if (currentItem instanceof PoiUIFilter) {
            PoiUIFilter filter = (PoiUIFilter) currentItem;
            itemHolder.title.setText(filter.getName());
            int iconRes = RenderingIcons.getBigIconResourceId(filter.getIconId());
            itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_action_user, activeColorRes));
        } else if (currentItem instanceof ITileSource) {
            itemHolder.title.setText(((ITileSource) currentItem).getName());
            itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_map, activeColorRes));
        } else if (currentItem instanceof File) {
            File file = (File) currentItem;
            FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
            itemHolder.title.setText(file.getName());
            if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) {
                itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_map_style, activeColorRes));
            } else if (file.getAbsolutePath().contains(IndexConstants.ROUTING_PROFILES_DIR)) {
                itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
            } else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) {
                itemHolder.title.setText(GpxUiHelper.getGpxTitle(file.getName()));
                itemHolder.icon.setImageDrawable(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes));
            } else if (file.getAbsolutePath().contains(IndexConstants.AV_INDEX_DIR)) {
                int iconId = AudioVideoNotesPlugin.getIconIdForRecordingFile(file);
                if (iconId == -1) {
                    iconId = R.drawable.ic_action_photo_dark;
                }
                itemHolder.title.setText(new Recording(file).getName(app, true));
                itemHolder.icon.setImageDrawable(uiUtilities.getIcon(iconId, activeColorRes));
            } else if (fileSubtype.isMap() || fileSubtype == FileSubtype.TTS_VOICE || fileSubtype == FileSubtype.VOICE) {
                itemHolder.title.setText(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName()));
                itemHolder.icon.setImageDrawable(uiUtilities.getIcon(fileSubtype.getIconId(), activeColorRes));
            }
        } else if (currentItem instanceof AvoidRoadInfo) {
            itemHolder.title.setText(((AvoidRoadInfo) currentItem).name);
            itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_alert, activeColorRes));
        } else if (currentItem instanceof FavoriteGroup) {
            itemHolder.title.setText(((FavoriteGroup) currentItem).getDisplayName(app));
            itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_favorite, activeColorRes));
        } else if (currentItem instanceof MapMarker) {
            MapMarker mapMarker = (MapMarker) currentItem;
            itemHolder.title.setText(mapMarker.getName(app));
            itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_flag, activeColorRes));
        } else if (currentItem instanceof HistoryEntry) {
            itemHolder.title.setText(((HistoryEntry) currentItem).getName().getName());
        } else if (currentItem instanceof OnlineRoutingEngine) {
            itemHolder.title.setText(((OnlineRoutingEngine) currentItem).getName(app));
            itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_world_globe_dark, activeColorRes));
        } else if (currentItem instanceof MapMarkersGroup) {
            MapMarkersGroup markersGroup = (MapMarkersGroup) currentItem;
            String groupName = markersGroup.getName();
            if (Algorithms.isEmpty(groupName)) {
                if (markersGroup.getType() == ItineraryType.FAVOURITES) {
                    groupName = app.getString(R.string.shared_string_favorites);
                } else if (markersGroup.getType() == ItineraryType.MARKERS) {
                    groupName = app.getString(R.string.map_markers);
                }
            }
            itemHolder.title.setText(groupName);
            itemHolder.icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_flag, activeColorRes));
        }
        itemHolder.divider.setVisibility(shouldShowDivider(position) ? View.VISIBLE : View.GONE);
    }
}
Also used : QuickAction(net.osmand.plus.quickaction.QuickAction) ProfileIconColors(net.osmand.plus.profiles.ProfileIconColors) ApplicationModeBean(net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean) MapMarker(net.osmand.plus.mapmarkers.MapMarker) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) AvoidRoadInfo(net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) 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) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) FileSubtype(net.osmand.plus.settings.backend.backup.items.FileSettingsItem.FileSubtype) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) File(java.io.File)

Aggregations

ProfileIconColors (net.osmand.plus.profiles.ProfileIconColors)3 File (java.io.File)2 ITileSource (net.osmand.map.ITileSource)2 AvoidRoadInfo (net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)2 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)2 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)2 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)2 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)2 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)2 QuickAction (net.osmand.plus.quickaction.QuickAction)2 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)2 ApplicationModeBean (net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean)2 SuppressLint (android.annotation.SuppressLint)1 ArrayList (java.util.ArrayList)1 TileSourceTemplate (net.osmand.map.TileSourceManager.TileSourceTemplate)1 MapActivity (net.osmand.plus.activities.MapActivity)1 MapMarker (net.osmand.plus.mapmarkers.MapMarker)1 Recording (net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording)1 OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)1 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)1