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