Search in sources :

Example 6 with AudioVideoNotesPlugin

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

the class SettingsImportTask method handlePluginImport.

private void handlePluginImport(final PluginSettingsItem pluginItem, final File file) {
    FragmentActivity activity = activityRef.get();
    final ProgressDialog progress;
    if (AndroidUtils.isActivityNotDestroyed(activity)) {
        progress = new ProgressDialog(activity);
        progress.setTitle(app.getString(R.string.loading_smth, ""));
        progress.setMessage(app.getString(R.string.importing_from, pluginItem.getPublicName(app)));
        progress.setIndeterminate(true);
        progress.setCancelable(false);
        progress.show();
    } else {
        progress = null;
    }
    final ImportListener importListener = new ImportListener() {

        @Override
        public void onImportItemStarted(@NonNull String type, @NonNull String fileName, int work) {
        }

        @Override
        public void onImportItemProgress(@NonNull String type, @NonNull String fileName, int value) {
        }

        @Override
        public void onImportItemFinished(@NonNull String type, @NonNull String fileName) {
        }

        @Override
        public void onImportFinished(boolean succeed, boolean needRestart, @NonNull List<SettingsItem> items) {
            FragmentActivity activity = activityRef.get();
            if (progress != null && AndroidUtils.isActivityNotDestroyed(activity)) {
                progress.dismiss();
            }
            AudioVideoNotesPlugin pluginAudioVideo = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
            if (pluginAudioVideo != null) {
                pluginAudioVideo.indexingFiles(true, true);
            }
            CustomOsmandPlugin plugin = pluginItem.getPlugin();
            plugin.loadResources();
            if (!Algorithms.isEmpty(plugin.getDownloadMaps())) {
                app.getDownloadThread().runReloadIndexFilesSilent();
            }
            if (!Algorithms.isEmpty(plugin.getRendererNames())) {
                app.getRendererRegistry().updateExternalRenderers();
            }
            if (!Algorithms.isEmpty(plugin.getRouterNames())) {
                loadRoutingFiles(app, null);
            }
            if (!silentImport && activity != null) {
                plugin.onInstall(app, activity);
            }
            String pluginId = pluginItem.getPluginId();
            File pluginDir = app.getAppPath(IndexConstants.PLUGINS_DIR + pluginId);
            if (!pluginDir.exists()) {
                pluginDir.mkdirs();
            }
            app.getFileSettingsHelper().exportSettings(pluginDir, "items", null, items, false);
        }
    };
    List<SettingsItem> pluginItems = new ArrayList<>(pluginItem.getPluginDependentItems());
    pluginItems.add(0, pluginItem);
    app.getFileSettingsHelper().checkDuplicates(file, pluginItems, pluginItems, new CheckDuplicatesListener() {

        @Override
        public void onDuplicatesChecked(@NonNull List<Object> duplicates, List<SettingsItem> items) {
            for (SettingsItem item : items) {
                item.setShouldReplace(true);
            }
            app.getFileSettingsHelper().importSettings(file, items, "", 1, importListener);
        }
    });
}
Also used : AudioVideoNotesPlugin(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin) CustomOsmandPlugin(net.osmand.plus.plugins.CustomOsmandPlugin) ArrayList(java.util.ArrayList) ProgressDialog(android.app.ProgressDialog) ImportListener(net.osmand.plus.settings.backend.backup.SettingsHelper.ImportListener) FragmentActivity(androidx.fragment.app.FragmentActivity) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) PluginSettingsItem(net.osmand.plus.settings.backend.backup.items.PluginSettingsItem) NonNull(androidx.annotation.NonNull) ArrayList(java.util.ArrayList) List(java.util.List) CallbackWithObject(net.osmand.CallbackWithObject) File(java.io.File) CheckDuplicatesListener(net.osmand.plus.settings.backend.backup.SettingsHelper.CheckDuplicatesListener)

Example 7 with AudioVideoNotesPlugin

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

the class OsmandPlugin method initPlugins.

public static void initPlugins(@NonNull OsmandApplication app) {
    Set<String> enabledPlugins = app.getSettings().getEnabledPlugins();
    allPlugins.clear();
    allPlugins.add(new WikipediaPlugin(app));
    allPlugins.add(new OsmandRasterMapsPlugin(app));
    allPlugins.add(new OsmandMonitoringPlugin(app));
    checkMarketPlugin(app, new SRTMPlugin(app));
    checkMarketPlugin(app, new NauticalMapsPlugin(app));
    checkMarketPlugin(app, new SkiMapsPlugin(app));
    allPlugins.add(new AudioVideoNotesPlugin(app));
    checkMarketPlugin(app, new ParkingPositionPlugin(app));
    allPlugins.add(new OsmEditingPlugin(app));
    allPlugins.add(new OpenPlaceReviewsPlugin(app));
    allPlugins.add(new MapillaryPlugin(app));
    allPlugins.add(new AccessibilityPlugin(app));
    allPlugins.add(new OsmandDevelopmentPlugin(app));
    loadCustomPlugins(app);
    registerAppInitializingDependedProperties(app);
    enablePluginsByDefault(app, enabledPlugins);
    activatePlugins(app, enabledPlugins);
}
Also used : SRTMPlugin(net.osmand.plus.plugins.srtm.SRTMPlugin) AudioVideoNotesPlugin(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin) OpenPlaceReviewsPlugin(net.osmand.plus.plugins.openplacereviews.OpenPlaceReviewsPlugin) OsmandMonitoringPlugin(net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) MapillaryPlugin(net.osmand.plus.plugins.mapillary.MapillaryPlugin) SkiMapsPlugin(net.osmand.plus.plugins.skimaps.SkiMapsPlugin) ParkingPositionPlugin(net.osmand.plus.plugins.parking.ParkingPositionPlugin) OsmandDevelopmentPlugin(net.osmand.plus.plugins.development.OsmandDevelopmentPlugin) NauticalMapsPlugin(net.osmand.plus.plugins.openseamaps.NauticalMapsPlugin) WikipediaPlugin(net.osmand.plus.wikipedia.WikipediaPlugin) AccessibilityPlugin(net.osmand.plus.plugins.accessibility.AccessibilityPlugin) OsmandRasterMapsPlugin(net.osmand.plus.plugins.rastermaps.OsmandRasterMapsPlugin)

Example 8 with AudioVideoNotesPlugin

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

the class OsmandAidlApi method registerStopRecordingReceiver.

private void registerStopRecordingReceiver(@NonNull MapActivity mapActivity) {
    final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
    BroadcastReceiver stopRecordingReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            MapActivity mapActivity = mapActivityRef.get();
            final AudioVideoNotesPlugin plugin = OsmandPlugin.getActivePlugin(AudioVideoNotesPlugin.class);
            if (mapActivity != null && plugin != null) {
                plugin.stopRecording(mapActivity, false);
            }
        }
    };
    registerReceiver(stopRecordingReceiver, mapActivity, AIDL_STOP_RECORDING);
}
Also used : Context(android.content.Context) AudioVideoNotesPlugin(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin) WeakReference(java.lang.ref.WeakReference) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) MapActivity(net.osmand.plus.activities.MapActivity)

Example 9 with AudioVideoNotesPlugin

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

the class SettingsImportTask method handlePluginImport.

private void handlePluginImport(final PluginSettingsItem pluginItem, final File file) {
    FragmentActivity activity = activityRef.get();
    final ProgressDialog progress;
    if (AndroidUtils.isActivityNotDestroyed(activity)) {
        progress = new ProgressDialog(activity);
        progress.setTitle(app.getString(R.string.loading_smth, ""));
        progress.setMessage(app.getString(R.string.importing_from, pluginItem.getPublicName(app)));
        progress.setIndeterminate(true);
        progress.setCancelable(false);
        progress.show();
    } else {
        progress = null;
    }
    final ImportListener importListener = new ImportListener() {

        @Override
        public void onImportItemStarted(@NonNull String type, @NonNull String fileName, int work) {
        }

        @Override
        public void onImportItemProgress(@NonNull String type, @NonNull String fileName, int value) {
        }

        @Override
        public void onImportItemFinished(@NonNull String type, @NonNull String fileName) {
        }

        @Override
        public void onImportFinished(boolean succeed, boolean needRestart, @NonNull List<SettingsItem> items) {
            FragmentActivity activity = activityRef.get();
            if (progress != null && AndroidUtils.isActivityNotDestroyed(activity)) {
                progress.dismiss();
            }
            AudioVideoNotesPlugin pluginAudioVideo = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
            if (pluginAudioVideo != null) {
                pluginAudioVideo.indexingFiles(true, true);
            }
            CustomOsmandPlugin plugin = pluginItem.getPlugin();
            plugin.loadResources();
            if (!Algorithms.isEmpty(plugin.getDownloadMaps())) {
                app.getDownloadThread().runReloadIndexFilesSilent();
            }
            if (!Algorithms.isEmpty(plugin.getRendererNames())) {
                app.getRendererRegistry().updateExternalRenderers();
            }
            if (!Algorithms.isEmpty(plugin.getRouterNames())) {
                loadRoutingFiles(app, null);
            }
            if (!silentImport && activity != null) {
                plugin.onInstall(app, activity);
            }
            String pluginId = pluginItem.getPluginId();
            File pluginDir = app.getAppPath(IndexConstants.PLUGINS_DIR + pluginId);
            if (!pluginDir.exists()) {
                pluginDir.mkdirs();
            }
            app.getFileSettingsHelper().exportSettings(pluginDir, "items", null, items, false);
        }
    };
    List<SettingsItem> pluginItems = new ArrayList<>(pluginItem.getPluginDependentItems());
    pluginItems.add(0, pluginItem);
    app.getFileSettingsHelper().checkDuplicates(file, pluginItems, pluginItems, new CheckDuplicatesListener() {

        @Override
        public void onDuplicatesChecked(@NonNull List<Object> duplicates, List<SettingsItem> items) {
            for (SettingsItem item : items) {
                item.setShouldReplace(true);
            }
            app.getFileSettingsHelper().importSettings(file, items, "", 1, importListener);
        }
    });
}
Also used : AudioVideoNotesPlugin(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin) CustomOsmandPlugin(net.osmand.plus.plugins.CustomOsmandPlugin) ArrayList(java.util.ArrayList) ProgressDialog(android.app.ProgressDialog) ImportListener(net.osmand.plus.settings.backend.backup.SettingsHelper.ImportListener) FragmentActivity(androidx.fragment.app.FragmentActivity) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) PluginSettingsItem(net.osmand.plus.settings.backend.backup.items.PluginSettingsItem) NonNull(androidx.annotation.NonNull) ArrayList(java.util.ArrayList) List(java.util.List) CallbackWithObject(net.osmand.CallbackWithObject) File(java.io.File) CheckDuplicatesListener(net.osmand.plus.settings.backend.backup.SettingsHelper.CheckDuplicatesListener)

Example 10 with AudioVideoNotesPlugin

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

the class SettingsHelper method getMyPlacesItems.

private Map<ExportSettingsType, List<?>> getMyPlacesItems(@Nullable List<ExportSettingsType> settingsTypes, boolean addEmptyItems) {
    Map<ExportSettingsType, List<?>> myPlacesItems = new LinkedHashMap<>();
    List<FavoriteGroup> favoriteGroups = settingsTypes == null || settingsTypes.contains(ExportSettingsType.FAVORITES) ? app.getFavoritesHelper().getFavoriteGroups() : Collections.emptyList();
    if (!favoriteGroups.isEmpty() || addEmptyItems) {
        myPlacesItems.put(ExportSettingsType.FAVORITES, favoriteGroups);
    }
    List<GpxDataItem> gpxItems = settingsTypes == null || settingsTypes.contains(ExportSettingsType.TRACKS) ? app.getGpxDbHelper().getItems() : Collections.emptyList();
    if (!gpxItems.isEmpty() || addEmptyItems) {
        List<File> files = new ArrayList<>();
        for (GpxDataItem gpxItem : gpxItems) {
            File file = gpxItem.getFile();
            if (file.exists() && !file.isDirectory()) {
                files.add(file);
            }
        }
        if (!files.isEmpty() || addEmptyItems) {
            myPlacesItems.put(ExportSettingsType.TRACKS, files);
        }
    }
    OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getActivePlugin(OsmEditingPlugin.class);
    if (osmEditingPlugin != null) {
        List<OsmNotesPoint> notesPointList = settingsTypes == null || settingsTypes.contains(ExportSettingsType.OSM_NOTES) ? osmEditingPlugin.getDBBug().getOsmbugsPoints() : Collections.emptyList();
        if (!notesPointList.isEmpty() || addEmptyItems) {
            myPlacesItems.put(ExportSettingsType.OSM_NOTES, notesPointList);
        }
        List<OpenstreetmapPoint> editsPointList = settingsTypes == null || settingsTypes.contains(ExportSettingsType.OSM_EDITS) ? osmEditingPlugin.getDBPOI().getOpenstreetmapPoints() : Collections.emptyList();
        if (!editsPointList.isEmpty() || addEmptyItems) {
            myPlacesItems.put(ExportSettingsType.OSM_EDITS, editsPointList);
        }
    }
    AudioVideoNotesPlugin avNotesPlugin = OsmandPlugin.getActivePlugin(AudioVideoNotesPlugin.class);
    if (avNotesPlugin != null) {
        List<File> files = new ArrayList<>();
        if (settingsTypes == null || settingsTypes.contains(ExportSettingsType.MULTIMEDIA_NOTES)) {
            for (Recording rec : avNotesPlugin.getAllRecordings()) {
                File file = rec.getFile();
                if (file != null && file.exists()) {
                    files.add(file);
                }
            }
        }
        if (!files.isEmpty() || addEmptyItems) {
            myPlacesItems.put(ExportSettingsType.MULTIMEDIA_NOTES, files);
        }
    }
    List<MapMarker> mapMarkers = settingsTypes == null || settingsTypes.contains(ExportSettingsType.ACTIVE_MARKERS) ? app.getMapMarkersHelper().getMapMarkers() : Collections.emptyList();
    if (!mapMarkers.isEmpty() || addEmptyItems) {
        String name = app.getString(R.string.map_markers);
        String groupId = ExportSettingsType.ACTIVE_MARKERS.name();
        MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, ItineraryType.MARKERS);
        markersGroup.setMarkers(mapMarkers);
        myPlacesItems.put(ExportSettingsType.ACTIVE_MARKERS, Collections.singletonList(markersGroup));
    }
    List<MapMarker> markersHistory = settingsTypes == null || settingsTypes.contains(ExportSettingsType.HISTORY_MARKERS) ? app.getMapMarkersHelper().getMapMarkersHistory() : Collections.emptyList();
    if (!markersHistory.isEmpty() || addEmptyItems) {
        String name = app.getString(R.string.shared_string_history);
        String groupId = ExportSettingsType.HISTORY_MARKERS.name();
        MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, ItineraryType.MARKERS);
        markersGroup.setMarkers(markersHistory);
        myPlacesItems.put(ExportSettingsType.HISTORY_MARKERS, Collections.singletonList(markersGroup));
    }
    List<HistoryEntry> historyEntries = settingsTypes == null || settingsTypes.contains(ExportSettingsType.SEARCH_HISTORY) ? SearchHistoryHelper.getInstance(app).getHistoryEntries(false) : Collections.emptyList();
    if (!historyEntries.isEmpty() || addEmptyItems) {
        myPlacesItems.put(ExportSettingsType.SEARCH_HISTORY, historyEntries);
    }
    List<MapMarkersGroup> markersGroups = settingsTypes == null || settingsTypes.contains(ExportSettingsType.ITINERARY_GROUPS) ? app.getMapMarkersHelper().getVisibleMapMarkersGroups() : Collections.emptyList();
    if (!markersGroups.isEmpty() || addEmptyItems) {
        myPlacesItems.put(ExportSettingsType.ITINERARY_GROUPS, markersGroups);
    }
    return myPlacesItems;
}
Also used : AudioVideoNotesPlugin(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin) MapMarker(net.osmand.plus.mapmarkers.MapMarker) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) GpxDataItem(net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem) List(java.util.List) ArrayList(java.util.ArrayList) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) File(java.io.File)

Aggregations

AudioVideoNotesPlugin (net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin)20 Intent (android.content.Intent)10 List (java.util.List)10 MapActivity (net.osmand.plus.activities.MapActivity)10 BroadcastReceiver (android.content.BroadcastReceiver)8 Context (android.content.Context)8 WeakReference (java.lang.ref.WeakReference)8 ArrayList (java.util.ArrayList)8 NonNull (androidx.annotation.NonNull)6 File (java.io.File)6 ImportListener (net.osmand.plus.settings.backend.backup.SettingsHelper.ImportListener)6 FragmentActivity (androidx.fragment.app.FragmentActivity)4 MapMarker (net.osmand.plus.mapmarkers.MapMarker)4 OsmandMonitoringPlugin (net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin)4 OsmEditingPlugin (net.osmand.plus.plugins.osmedit.OsmEditingPlugin)4 ProgressDialog (android.app.ProgressDialog)2 DialogInterface (android.content.DialogInterface)2 Uri (android.net.Uri)2 ParcelFileDescriptor (android.os.ParcelFileDescriptor)2 FragmentManager (androidx.fragment.app.FragmentManager)2