use of net.osmand.plus.backup.ExportBackupTask 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);
}
use of net.osmand.plus.backup.ExportBackupTask 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.ExportBackupTask 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