Search in sources :

Example 1 with NetworkSettingsHelper

use of net.osmand.plus.backup.NetworkSettingsHelper in project Osmand by osmandapp.

the class AppInitializer method onCreateApplication.

public void onCreateApplication() {
    // always update application mode to default
    OsmandSettings osmandSettings = app.getSettings();
    if (osmandSettings.FOLLOW_THE_ROUTE.get()) {
        ApplicationMode savedMode = osmandSettings.readApplicationMode();
        if (!osmandSettings.APPLICATION_MODE.get().getStringKey().equals(savedMode.getStringKey())) {
            osmandSettings.setApplicationMode(savedMode);
        }
    } else {
        osmandSettings.setApplicationMode(osmandSettings.DEFAULT_APPLICATION_MODE.get());
    }
    startTime = System.currentTimeMillis();
    getLazyRoutingConfig();
    app.applyTheme(app);
    startupInit(app.reconnectToBRouter(), IBRouterService.class);
    app.backupHelper = startupInit(new BackupHelper(app), BackupHelper.class);
    app.inAppPurchaseHelper = startupInit(new InAppPurchaseHelperImpl(app), InAppPurchaseHelperImpl.class);
    app.poiTypes = startupInit(MapPoiTypes.getDefaultNoInit(), MapPoiTypes.class);
    app.transportRoutingHelper = startupInit(new TransportRoutingHelper(app), TransportRoutingHelper.class);
    app.routingHelper = startupInit(new RoutingHelper(app), RoutingHelper.class);
    app.routingOptionsHelper = startupInit(new RoutingOptionsHelper(app), RoutingOptionsHelper.class);
    app.resourceManager = startupInit(new ResourceManager(app), ResourceManager.class);
    app.daynightHelper = startupInit(new DayNightHelper(app), DayNightHelper.class);
    app.locationProvider = startupInit(new OsmAndLocationProvider(app), OsmAndLocationProvider.class);
    app.avoidSpecificRoads = startupInit(new AvoidSpecificRoads(app), AvoidSpecificRoads.class);
    app.avoidRoadsHelper = startupInit(new AvoidRoadsHelper(app), AvoidRoadsHelper.class);
    app.savingTrackHelper = startupInit(new SavingTrackHelper(app), SavingTrackHelper.class);
    app.analyticsHelper = startupInit(new AnalyticsHelper(app), AnalyticsHelper.class);
    app.notificationHelper = startupInit(new NotificationHelper(app), NotificationHelper.class);
    app.liveMonitoringHelper = startupInit(new LiveMonitoringHelper(app), LiveMonitoringHelper.class);
    app.selectedGpxHelper = startupInit(new GpxSelectionHelper(app, app.savingTrackHelper), GpxSelectionHelper.class);
    app.gpxDbHelper = startupInit(new GpxDbHelper(app), GpxDbHelper.class);
    app.favoritesHelper = startupInit(new FavouritesHelper(app), FavouritesHelper.class);
    app.waypointHelper = startupInit(new WaypointHelper(app), WaypointHelper.class);
    app.aidlApi = startupInit(new OsmandAidlApi(app), OsmandAidlApi.class);
    app.regions = startupInit(new OsmandRegions(), OsmandRegions.class);
    updateRegionVars();
    app.poiFilters = startupInit(new PoiFiltersHelper(app), PoiFiltersHelper.class);
    app.rendererRegistry = startupInit(new RendererRegistry(app), RendererRegistry.class);
    app.geocodingLookupService = startupInit(new GeocodingLookupService(app), GeocodingLookupService.class);
    app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class);
    app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class);
    app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
    app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
    app.mapViewTrackingUtilities = startupInit(new MapViewTrackingUtilities(app), MapViewTrackingUtilities.class);
    app.osmandMap = startupInit(new OsmandMap(app), OsmandMap.class);
    // TODO TRAVEL_OBF_HELPER check ResourceManager and use TravelObfHelper
    TravelHelper travelHelper = !TravelDbHelper.checkIfDbFileExists(app) ? new TravelObfHelper(app) : new TravelDbHelper(app);
    app.travelHelper = startupInit(travelHelper, TravelHelper.class);
    app.travelRendererHelper = startupInit(new TravelRendererHelper(app), TravelRendererHelper.class);
    app.lockHelper = startupInit(new LockHelper(app), LockHelper.class);
    app.fileSettingsHelper = startupInit(new FileSettingsHelper(app), FileSettingsHelper.class);
    app.networkSettingsHelper = startupInit(new NetworkSettingsHelper(app), NetworkSettingsHelper.class);
    app.quickActionRegistry = startupInit(new QuickActionRegistry(app.getSettings()), QuickActionRegistry.class);
    app.osmOAuthHelper = startupInit(new OsmOAuthHelper(app), OsmOAuthHelper.class);
    app.oprAuthHelper = startupInit(new OprAuthHelper(app), OprAuthHelper.class);
    app.onlineRoutingHelper = startupInit(new OnlineRoutingHelper(app), OnlineRoutingHelper.class);
    app.launcherShortcutsHelper = startupInit(new LauncherShortcutsHelper(app), LauncherShortcutsHelper.class);
    app.gpsFilterHelper = startupInit(new GpsFilterHelper(app), GpsFilterHelper.class);
    app.downloadTilesHelper = startupInit(new DownloadTilesHelper(app), DownloadTilesHelper.class);
    initOpeningHoursParser();
}
Also used : DayNightHelper(net.osmand.plus.helpers.DayNightHelper) OsmOAuthHelper(net.osmand.plus.plugins.osmedit.oauth.OsmOAuthHelper) FavouritesHelper(net.osmand.plus.myplaces.FavouritesHelper) AvoidSpecificRoads(net.osmand.plus.helpers.AvoidSpecificRoads) BackupHelper(net.osmand.plus.backup.BackupHelper) MapViewTrackingUtilities(net.osmand.plus.base.MapViewTrackingUtilities) WaypointHelper(net.osmand.plus.helpers.WaypointHelper) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) SavingTrackHelper(net.osmand.plus.track.helpers.SavingTrackHelper) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) TravelObfHelper(net.osmand.plus.wikivoyage.data.TravelObfHelper) AvoidRoadsHelper(net.osmand.plus.routing.AvoidRoadsHelper) GpxDbHelper(net.osmand.plus.track.helpers.GpxDbHelper) OsmandRegions(net.osmand.map.OsmandRegions) LauncherShortcutsHelper(net.osmand.plus.helpers.LauncherShortcutsHelper) RendererRegistry(net.osmand.plus.render.RendererRegistry) DownloadTilesHelper(net.osmand.plus.plugins.rastermaps.DownloadTilesHelper) TargetPointsHelper(net.osmand.plus.helpers.TargetPointsHelper) QuickActionRegistry(net.osmand.plus.quickaction.QuickActionRegistry) AnalyticsHelper(net.osmand.plus.helpers.AnalyticsHelper) TravelHelper(net.osmand.plus.wikivoyage.data.TravelHelper) OsmandMap(net.osmand.plus.views.OsmandMap) TravelDbHelper(net.osmand.plus.wikivoyage.data.TravelDbHelper) MapMarkersDbHelper(net.osmand.plus.mapmarkers.MapMarkersDbHelper) GpsFilterHelper(net.osmand.plus.track.helpers.GpsFilterHelper) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) ResourceManager(net.osmand.plus.resources.ResourceManager) GpxSelectionHelper(net.osmand.plus.track.helpers.GpxSelectionHelper) TravelRendererHelper(net.osmand.plus.render.TravelRendererHelper) LiveMonitoringHelper(net.osmand.plus.plugins.monitoring.LiveMonitoringHelper) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) MapPoiTypes(net.osmand.osm.MapPoiTypes) QuickSearchHelper(net.osmand.plus.search.QuickSearchHelper) NetworkSettingsHelper(net.osmand.plus.backup.NetworkSettingsHelper) RoutingOptionsHelper(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper) MapMarkersHelper(net.osmand.plus.mapmarkers.MapMarkersHelper) NotificationHelper(net.osmand.plus.notifications.NotificationHelper) InAppPurchaseHelperImpl(net.osmand.plus.inapp.InAppPurchaseHelperImpl) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) FileSettingsHelper(net.osmand.plus.settings.backend.backup.FileSettingsHelper) OprAuthHelper(net.osmand.plus.plugins.openplacereviews.OprAuthHelper) OsmandAidlApi(net.osmand.aidl.OsmandAidlApi) LockHelper(net.osmand.plus.helpers.LockHelper)

Example 2 with NetworkSettingsHelper

use of net.osmand.plus.backup.NetworkSettingsHelper in project Osmand by osmandapp.

the class ActionButtonViewHolder method bindView.

public void bindView(@NonNull MapActivity mapActivity, @NonNull PrepareBackupResult backup, @Nullable BackupExportListener exportListener, boolean uploadItemsVisible, boolean nightMode) {
    OsmandApplication app = (OsmandApplication) itemView.getContext().getApplicationContext();
    BackupStatus status = BackupStatus.getBackupStatus(app, backup);
    NetworkSettingsHelper settingsHelper = app.getNetworkSettingsHelper();
    if (settingsHelper.isBackupExporting()) {
        actionButton.setOnClickListener(v -> {
            settingsHelper.cancelImport();
            settingsHelper.cancelExport();
        });
        UiUtilities.setupDialogButton(nightMode, actionButton, DialogButtonType.SECONDARY_ACTIVE, R.string.shared_string_cancel);
    } else if (status == BackupStatus.MAKE_BACKUP || status == BackupStatus.CONFLICTS) {
        actionButton.setOnClickListener(v -> {
            try {
                BackupInfo info = backup.getBackupInfo();
                List<SettingsItem> items = info.itemsToUpload;
                if (!items.isEmpty() || !Algorithms.isEmpty(info.filteredFilesToDelete)) {
                    settingsHelper.exportSettings(BACKUP_ITEMS_KEY, items, info.itemsToDelete, exportListener);
                }
            } catch (IllegalStateException e) {
                log.error(e.getMessage(), e);
            }
        });
        UiUtilities.setupDialogButton(nightMode, actionButton, DialogButtonType.SECONDARY_ACTIVE, R.string.backup_now);
    } else if (status == BackupStatus.NO_INTERNET_CONNECTION || status == BackupStatus.ERROR) {
        actionButton.setOnClickListener(v -> app.getBackupHelper().prepareBackup());
        UiUtilities.setupDialogButton(nightMode, actionButton, DialogButtonType.SECONDARY_ACTIVE, R.string.retry);
    } else if (status == BackupStatus.SUBSCRIPTION_EXPIRED) {
        actionButton.setOnClickListener(v -> {
            if (Version.isInAppPurchaseSupported()) {
                OsmAndProPlanFragment.showInstance(mapActivity);
            } else {
                PromoCodeBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
            }
        });
        UiUtilities.setupDialogButton(nightMode, actionButton, DialogButtonType.SECONDARY_ACTIVE, R.string.renew_subscription);
    }
    AndroidUiHelper.updateVisibility(divider, uploadItemsVisible);
}
Also used : NetworkSettingsHelper(net.osmand.plus.backup.NetworkSettingsHelper) Version(net.osmand.plus.Version) NonNull(androidx.annotation.NonNull) BACKUP_ITEMS_KEY(net.osmand.plus.backup.NetworkSettingsHelper.BACKUP_ITEMS_KEY) R(net.osmand.plus.R) AndroidUiHelper(net.osmand.plus.helpers.AndroidUiHelper) DialogButtonType(net.osmand.plus.utils.UiUtilities.DialogButtonType) BackupExportListener(net.osmand.plus.backup.NetworkSettingsHelper.BackupExportListener) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem) OsmandApplication(net.osmand.plus.OsmandApplication) BackupInfo(net.osmand.plus.backup.BackupInfo) PrepareBackupResult(net.osmand.plus.backup.PrepareBackupResult) UiUtilities(net.osmand.plus.utils.UiUtilities) List(java.util.List) Nullable(androidx.annotation.Nullable) OsmAndProPlanFragment(net.osmand.plus.chooseplan.OsmAndProPlanFragment) View(android.view.View) Log(org.apache.commons.logging.Log) RecyclerView(androidx.recyclerview.widget.RecyclerView) PlatformUtil(net.osmand.PlatformUtil) Algorithms(net.osmand.util.Algorithms) MapActivity(net.osmand.plus.activities.MapActivity) NetworkSettingsHelper(net.osmand.plus.backup.NetworkSettingsHelper) BackupInfo(net.osmand.plus.backup.BackupInfo) OsmandApplication(net.osmand.plus.OsmandApplication) List(java.util.List)

Example 3 with NetworkSettingsHelper

use of net.osmand.plus.backup.NetworkSettingsHelper in project Osmand by osmandapp.

the class ConflictViewHolder method bindView.

public void bindView(@NonNull Pair<LocalFile, RemoteFile> pair, @Nullable BackupExportListener exportListener, @Nullable ImportListener importListener, boolean nightMode) {
    OsmandApplication app = getApplication();
    NetworkSettingsHelper settingsHelper = app.getNetworkSettingsHelper();
    SettingsItem item = pair.first.item;
    String fileName = BackupHelper.getItemFileName(item);
    setupItemView(fileName, item, false);
    updateButtonsState(settingsHelper, fileName);
    localVersionButton.setOnClickListener(v -> {
        try {
            settingsHelper.exportSettings(fileName, exportListener, item);
        } catch (IllegalStateException e) {
            log.error(e.getMessage(), e);
        }
        updateButtonsState(settingsHelper, fileName);
    });
    serverButton.setOnClickListener(v -> {
        try {
            SettingsItem settingsItem = pair.second.item;
            settingsItem.setShouldReplace(true);
            settingsHelper.importSettings(fileName, Collections.singletonList(settingsItem), true, importListener);
        } catch (IllegalStateException e) {
            log.error(e.getMessage(), e);
        }
        updateButtonsState(settingsHelper, fileName);
    });
    AndroidUiHelper.updateVisibility(serverButton, true);
    AndroidUiHelper.updateVisibility(localVersionButton, true);
    UiUtilities.setupDialogButton(nightMode, localVersionButton, DialogButtonType.SECONDARY_ACTIVE, R.string.upload_local_version);
    UiUtilities.setupDialogButton(nightMode, serverButton, DialogButtonType.SECONDARY_ACTIVE, R.string.download_server_version);
}
Also used : NetworkSettingsHelper(net.osmand.plus.backup.NetworkSettingsHelper) OsmandApplication(net.osmand.plus.OsmandApplication) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem)

Example 4 with NetworkSettingsHelper

use of net.osmand.plus.backup.NetworkSettingsHelper in project Osmand by osmandapp.

the class BackupAndRestoreFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    LayoutInflater themedInflater = UiUtilities.getInflater(getContext(), nightMode);
    View view = themedInflater.inflate(R.layout.backup_and_restore, container, false);
    AndroidUtils.addStatusBarPadding21v(view.getContext(), view);
    setupTabs(view);
    setupToolbar(view);
    OsmandApplication app = requireMyApplication();
    NetworkSettingsHelper settingsHelper = app.getNetworkSettingsHelper();
    if (!settingsHelper.isBackupExporting()) {
        app.getBackupHelper().prepareBackup();
    }
    return view;
}
Also used : NetworkSettingsHelper(net.osmand.plus.backup.NetworkSettingsHelper) OsmandApplication(net.osmand.plus.OsmandApplication) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable)

Example 5 with NetworkSettingsHelper

use of net.osmand.plus.backup.NetworkSettingsHelper in project Osmand by osmandapp.

the class HeaderStatusViewHolder method bindView.

public void bindView(@NonNull BackupStatusAdapter adapter, @NonNull BackupStatus status, boolean nightMode) {
    OsmandApplication app = (OsmandApplication) itemView.getContext().getApplicationContext();
    NetworkSettingsHelper settingsHelper = app.getNetworkSettingsHelper();
    ExportBackupTask exportTask = settingsHelper.getExportTask(BACKUP_ITEMS_KEY);
    if (exportTask != null) {
        title.setText(R.string.uploading);
        icon.setImageDrawable(getContentIcon(R.drawable.ic_action_cloud_upload));
        int progress = exportTask.getGeneralProgress();
        int maxProgress = (int) exportTask.getMaxProgress();
        int percentage = maxProgress != 0 ? BasicProgressAsyncTask.normalizeProgress(progress * 100 / maxProgress) : 0;
        String uploading = app.getString(R.string.local_openstreetmap_uploading);
        title.setText(app.getString(R.string.ltr_or_rtl_combine_via_space, uploading, percentage + "%"));
        progressBar.setMax(maxProgress);
        progressBar.setProgress(progress);
        AndroidUiHelper.updateVisibility(description, false);
        AndroidUiHelper.updateVisibility(progressBar, true);
    } else {
        description.setText(status.statusTitleRes);
        icon.setImageDrawable(getContentIcon(status.statusIconRes));
        String backupTime = MainSettingsFragment.getLastBackupTimeDescription(app);
        if (Algorithms.isEmpty(backupTime)) {
            title.setText(R.string.shared_string_never);
        } else {
            title.setText(backupTime);
        }
        AndroidUiHelper.updateVisibility(description, true);
        AndroidUiHelper.updateVisibility(progressBar, false);
    }
    itemView.setOnClickListener(v -> {
        adapter.toggleUploadItemsVisibility();
        adjustIndicator(app, itemView, adapter.isUploadItemsVisible(), nightMode);
    });
    adjustIndicator(app, itemView, adapter.isUploadItemsVisible(), nightMode);
    setupSelectableBackground(itemView.findViewById(R.id.header_container));
    AndroidUiHelper.updateVisibility(itemView.findViewById(R.id.explicit_indicator), status != BackupStatus.BACKUP_COMPLETE);
}
Also used : NetworkSettingsHelper(net.osmand.plus.backup.NetworkSettingsHelper) OsmandApplication(net.osmand.plus.OsmandApplication) ExportBackupTask(net.osmand.plus.backup.ExportBackupTask)

Aggregations

NetworkSettingsHelper (net.osmand.plus.backup.NetworkSettingsHelper)6 OsmandApplication (net.osmand.plus.OsmandApplication)5 View (android.view.View)2 Nullable (androidx.annotation.Nullable)2 ExportBackupTask (net.osmand.plus.backup.ExportBackupTask)2 SettingsItem (net.osmand.plus.settings.backend.backup.items.SettingsItem)2 LayoutInflater (android.view.LayoutInflater)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 List (java.util.List)1 PlatformUtil (net.osmand.PlatformUtil)1 OsmandAidlApi (net.osmand.aidl.OsmandAidlApi)1 OsmandRegions (net.osmand.map.OsmandRegions)1 MapPoiTypes (net.osmand.osm.MapPoiTypes)1 R (net.osmand.plus.R)1 Version (net.osmand.plus.Version)1 MapActivity (net.osmand.plus.activities.MapActivity)1 UploadedFileInfo (net.osmand.plus.backup.BackupDbHelper.UploadedFileInfo)1