Search in sources :

Example 6 with Recording

use of net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording in project Osmand by osmandapp.

the class ExportItemsBottomSheet method setupBottomSheetItemForFile.

private void setupBottomSheetItemForFile(BottomSheetItemWithCompoundButton item, File file) {
    FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath());
    item.setTitle(file.getName());
    if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) {
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_map_style, getItemIconColor(item.getTag())));
    } else if (file.getAbsolutePath().contains(IndexConstants.ROUTING_PROFILES_DIR)) {
        item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, getItemIconColor(item.getTag())));
    } else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) {
        setupBottomSheetItemForGpx(item, file, null);
    } else if (file.getAbsolutePath().contains(IndexConstants.AV_INDEX_DIR)) {
        int iconId = AudioVideoNotesPlugin.getIconIdForRecordingFile(file);
        if (iconId == -1) {
            iconId = R.drawable.ic_action_photo_dark;
        }
        if (item.getTag() instanceof FileSettingsItem) {
            FileSettingsItem settingsItem = (FileSettingsItem) item.getTag();
            item.setTitle(Recording.getNameForMultimediaFile(app, file.getName(), settingsItem.getLastModifiedTime()));
        } else {
            item.setTitle(new Recording(file).getName(app, true));
        }
        item.setIcon(uiUtilities.getIcon(iconId, getItemIconColor(item.getTag())));
        item.setDescription(AndroidUtils.formatSize(app, file.length()));
    } else if (fileSubtype.isMap() || fileSubtype == FileSettingsItem.FileSubtype.TTS_VOICE || fileSubtype == FileSettingsItem.FileSubtype.VOICE) {
        item.setTitle(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName()));
        item.setIcon(uiUtilities.getIcon(fileSubtype.getIconId(), getItemIconColor(item.getTag())));
        if (fileSubtype.isMap()) {
            String mapDescription = getMapDescription(file);
            String formattedSize = AndroidUtils.formatSize(app, file.length());
            if (mapDescription != null) {
                item.setDescription(getString(R.string.ltr_or_rtl_combine_via_bold_point, mapDescription, formattedSize));
            } else {
                item.setDescription(formattedSize);
            }
        }
    }
}
Also used : FileSettingsItem(net.osmand.plus.settings.backend.backup.items.FileSettingsItem) FileSubtype(net.osmand.plus.settings.backend.backup.items.FileSettingsItem.FileSubtype) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording)

Example 7 with Recording

use of net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording 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)

Example 8 with Recording

use of net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording in project Osmand by osmandapp.

the class NotesFragment method generateGPXForRecordings.

private File generateGPXForRecordings(Set<Recording> selected) {
    File tmpFile = new File(getActivity().getCacheDir(), "share/noteLocations.gpx");
    tmpFile.getParentFile().mkdirs();
    GPXFile file = new GPXFile(Version.getFullVersion(getMyApplication()));
    for (Recording r : getRecordingsForGpx(selected)) {
        if (r != SHARE_LOCATION_FILE) {
            String desc = r.getDescriptionName(r.getFileName());
            if (desc == null) {
                desc = r.getFileName();
            }
            WptPt wpt = new WptPt();
            wpt.lat = r.getLatitude();
            wpt.lon = r.getLongitude();
            wpt.name = desc;
            wpt.link = r.getFileName();
            wpt.time = r.getFile().lastModified();
            wpt.category = r.getSearchHistoryType();
            wpt.desc = r.getTypeWithDuration(getContext());
            getMyApplication().getSelectedGpxHelper().addPoint(wpt, file);
        }
    }
    GPXUtilities.writeGpxFile(tmpFile, file);
    return tmpFile;
}
Also used : WptPt(net.osmand.GPXUtilities.WptPt) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) GPXFile(net.osmand.GPXUtilities.GPXFile) GPXFile(net.osmand.GPXUtilities.GPXFile) File(java.io.File)

Example 9 with Recording

use of net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording in project Osmand by osmandapp.

the class NotesFragment method shareItems.

private void shareItems(Set<Recording> selected) {
    FragmentActivity activity = getActivity();
    if (activity != null) {
        ArrayList<Uri> uris = new ArrayList<>();
        for (Recording rec : selected) {
            File file = rec == SHARE_LOCATION_FILE ? generateGPXForRecordings(selected) : rec.getFile();
            if (file != null) {
                uris.add(AndroidUtils.getUriForFile(activity, file));
            }
        }
        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        intent.setType("*/*");
        intent.putExtra(Intent.EXTRA_STREAM, uris);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        if (Build.VERSION.SDK_INT > 18) {
            intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
        }
        Intent chooserIntent = Intent.createChooser(intent, getString(R.string.share_note));
        AndroidUtils.startActivityIfSafe(activity, intent, chooserIntent);
    }
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) Uri(android.net.Uri) GPXFile(net.osmand.GPXUtilities.GPXFile) File(java.io.File)

Example 10 with Recording

use of net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording in project Osmand by osmandapp.

the class NotesFragment method getRecordingsByType.

private List<Recording> getRecordingsByType(int type) {
    List<Recording> allRecs = new LinkedList<>(plugin.getAllRecordings());
    List<Recording> res = new LinkedList<>();
    for (Recording rec : allRecs) {
        if (isAppropriate(rec, type)) {
            res.add(rec);
        }
    }
    return res;
}
Also used : Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) LinkedList(java.util.LinkedList)

Aggregations

Recording (net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording)11 File (java.io.File)4 ArrayList (java.util.ArrayList)3 MapMarker (net.osmand.plus.mapmarkers.MapMarker)3 GPXFile (net.osmand.GPXUtilities.GPXFile)2 WptPt (net.osmand.GPXUtilities.WptPt)2 LatLon (net.osmand.data.LatLon)2 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)2 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)2 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)2 FileSubtype (net.osmand.plus.settings.backend.backup.items.FileSettingsItem.FileSubtype)2 Context (android.content.Context)1 Intent (android.content.Intent)1 PointF (android.graphics.PointF)1 Uri (android.net.Uri)1 Pair (android.util.Pair)1 LayoutInflater (android.view.LayoutInflater)1 FrameLayout (android.widget.FrameLayout)1 LinearLayout (android.widget.LinearLayout)1 NonNull (androidx.annotation.NonNull)1