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);
}
}
}
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);
}
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);
}
}
}
}
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);
}
Aggregations