Search in sources :

Example 1 with ImportBackupTask

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

the class RestoreDuplicatesFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    settingsHelper = app.getNetworkSettingsHelper();
    ImportBackupTask importTask = settingsHelper.getImportTask(RESTORE_ITEMS_KEY);
    if (importTask != null) {
        if (settingsItems == null) {
            settingsItems = importTask.getSelectedItems();
        }
        if (duplicatesList == null) {
            duplicatesList = importTask.getDuplicates();
        }
        Fragment target = getTargetFragment();
        if (target instanceof RestoreSettingsFragment) {
            ImportListener importListener = ((RestoreSettingsFragment) target).getImportListener();
            importTask.setImportListener(importListener);
        }
    }
}
Also used : ImportBackupTask(net.osmand.plus.backup.ImportBackupTask) FileImportDuplicatesFragment(net.osmand.plus.settings.fragments.FileImportDuplicatesFragment) ImportDuplicatesFragment(net.osmand.plus.settings.fragments.ImportDuplicatesFragment) ImportSettingsFragment(net.osmand.plus.settings.fragments.ImportSettingsFragment) Fragment(androidx.fragment.app.Fragment) ImportListener(net.osmand.plus.settings.backend.backup.SettingsHelper.ImportListener)

Example 2 with ImportBackupTask

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

the class ItemViewHolder method setupItemView.

protected void setupItemView(@NonNull String exportKey, @NonNull SettingsItem item, boolean deleteItem) {
    OsmandApplication app = getApplication();
    String publicName = item.getPublicName(app);
    if (item instanceof FileSettingsItem) {
        FileSettingsItem settingsItem = (FileSettingsItem) item;
        if (settingsItem.getSubtype() == FileSubtype.VOICE) {
            publicName += " (" + app.getString(R.string.shared_string_recorded) + ")";
        } else if (settingsItem.getSubtype() == FileSubtype.TTS_VOICE) {
            publicName += " (" + app.getString(R.string.tts_title) + ")";
        }
    }
    title.setText(publicName);
    String fileName = BackupHelper.getItemFileName(item);
    String summary = app.getString(R.string.last_backup);
    UploadedFileInfo info = app.getBackupHelper().getDbHelper().getUploadedFileInfo(item.getType().name(), fileName);
    if (info != null) {
        String time = OsmAndFormatter.getFormattedPassedTime(app, info.getUploadTime(), app.getString(R.string.shared_string_never));
        description.setText(app.getString(R.string.ltr_or_rtl_combine_via_colon, summary, time));
    } else {
        description.setText(app.getString(R.string.ltr_or_rtl_combine_via_colon, summary, app.getString(R.string.shared_string_never)));
    }
    icon.setImageDrawable(getItemIcon(item));
    NetworkSettingsHelper settingsHelper = app.getNetworkSettingsHelper();
    ImportBackupTask importTask = settingsHelper.getImportTask(exportKey);
    ExportBackupTask exportTask = settingsHelper.getExportTask(exportKey);
    if (exportTask == null && importTask == null) {
        AndroidUiHelper.updateVisibility(secondIcon, deleteItem);
        AndroidUiHelper.updateVisibility(progressBar, false);
        secondIcon.setImageDrawable(getContentIcon(deleteItem ? R.drawable.ic_action_delete_dark : R.drawable.ic_action_cloud_done));
    } else {
        ItemProgressInfo progressInfo = null;
        if (exportTask != null) {
            progressInfo = exportTask.getItemProgressInfo(item.getType().name(), fileName);
        }
        if (importTask != null) {
            progressInfo = importTask.getItemProgressInfo(item.getType().name(), fileName);
        }
        setupProgress(progressInfo);
    }
    itemView.setTag(item);
}
Also used : NetworkSettingsHelper(net.osmand.plus.backup.NetworkSettingsHelper) ImportBackupTask(net.osmand.plus.backup.ImportBackupTask) OsmandApplication(net.osmand.plus.OsmandApplication) ItemProgressInfo(net.osmand.plus.backup.ExportBackupTask.ItemProgressInfo) FileSettingsItem(net.osmand.plus.settings.backend.backup.items.FileSettingsItem) UploadedFileInfo(net.osmand.plus.backup.BackupDbHelper.UploadedFileInfo) ExportBackupTask(net.osmand.plus.backup.ExportBackupTask)

Example 3 with ImportBackupTask

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

the class RestoreSettingsFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    exportMode = false;
    settingsHelper = app.getNetworkSettingsHelper();
    ImportBackupTask importTask = settingsHelper.getImportTask(RESTORE_ITEMS_KEY);
    if (importTask != null) {
        if (settingsItems == null) {
            settingsItems = importTask.getItems();
        }
        List<Object> duplicates = importTask.getDuplicates();
        List<SettingsItem> selectedItems = importTask.getSelectedItems();
        if (duplicates == null) {
            importTask.setDuplicatesListener(getDuplicatesListener());
        } else if (duplicates.isEmpty() && selectedItems != null) {
            try {
                settingsHelper.importSettings(RESTORE_ITEMS_KEY, selectedItems, false, getImportListener());
            } catch (IllegalStateException e) {
                LOG.error(e.getMessage(), e);
            }
        }
    }
}
Also used : ImportBackupTask(net.osmand.plus.backup.ImportBackupTask) SettingsItem(net.osmand.plus.settings.backend.backup.items.SettingsItem)

Example 4 with ImportBackupTask

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

the class ConflictViewHolder method updateButtonsState.

private void updateButtonsState(@NonNull NetworkSettingsHelper helper, @NonNull String fileName) {
    ImportBackupTask importTask = helper.getImportTask(fileName);
    ExportBackupTask exportTask = helper.getExportTask(fileName);
    boolean enabled = exportTask == null && importTask == null;
    serverButton.setEnabled(enabled);
    localVersionButton.setEnabled(enabled);
}
Also used : ImportBackupTask(net.osmand.plus.backup.ImportBackupTask) ExportBackupTask(net.osmand.plus.backup.ExportBackupTask)

Aggregations

ImportBackupTask (net.osmand.plus.backup.ImportBackupTask)4 ExportBackupTask (net.osmand.plus.backup.ExportBackupTask)2 Fragment (androidx.fragment.app.Fragment)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 UploadedFileInfo (net.osmand.plus.backup.BackupDbHelper.UploadedFileInfo)1 ItemProgressInfo (net.osmand.plus.backup.ExportBackupTask.ItemProgressInfo)1 NetworkSettingsHelper (net.osmand.plus.backup.NetworkSettingsHelper)1 ImportListener (net.osmand.plus.settings.backend.backup.SettingsHelper.ImportListener)1 FileSettingsItem (net.osmand.plus.settings.backend.backup.items.FileSettingsItem)1 SettingsItem (net.osmand.plus.settings.backend.backup.items.SettingsItem)1 FileImportDuplicatesFragment (net.osmand.plus.settings.fragments.FileImportDuplicatesFragment)1 ImportDuplicatesFragment (net.osmand.plus.settings.fragments.ImportDuplicatesFragment)1 ImportSettingsFragment (net.osmand.plus.settings.fragments.ImportSettingsFragment)1