use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.
the class ContactsBackupFragment method openDate.
public void openDate(@Nullable Date savedDate) {
final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
String backupFolderString = getResources().getString(R.string.contacts_backup_folder) + OCFile.PATH_SEPARATOR;
OCFile backupFolder = contactsPreferenceActivity.getStorageManager().getFileByPath(backupFolderString);
List<OCFile> backupFiles = contactsPreferenceActivity.getStorageManager().getFolderContent(backupFolder, false);
Collections.sort(backupFiles, new Comparator<OCFile>() {
@Override
public int compare(OCFile o1, OCFile o2) {
if (o1.getModificationTimestamp() == o2.getModificationTimestamp()) {
return 0;
}
if (o1.getModificationTimestamp() > o2.getModificationTimestamp()) {
return 1;
} else {
return -1;
}
}
});
Calendar cal = Calendar.getInstance();
int year;
int month;
int day;
if (savedDate == null) {
year = cal.get(Calendar.YEAR);
month = cal.get(Calendar.MONTH) + 1;
day = cal.get(Calendar.DAY_OF_MONTH);
} else {
year = savedDate.getYear();
month = savedDate.getMonth();
day = savedDate.getDay();
}
if (backupFiles.size() > 0 && backupFiles.get(backupFiles.size() - 1) != null) {
datePickerDialog = new DatePickerDialog(contactsPreferenceActivity, this, year, month, day);
datePickerDialog.getDatePicker().setMaxDate(backupFiles.get(backupFiles.size() - 1).getModificationTimestamp());
datePickerDialog.getDatePicker().setMinDate(backupFiles.get(0).getModificationTimestamp());
datePickerDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
selectedDate = null;
}
});
datePickerDialog.show();
} else {
Toast.makeText(contactsPreferenceActivity, R.string.contacts_preferences_something_strange_happened, Toast.LENGTH_SHORT).show();
}
}
use of com.owncloud.android.ui.activity.ContactsPreferenceActivity in project android by nextcloud.
the class ContactsBackupFragment method startContactsBackupJob.
private void startContactsBackupJob() {
final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
PersistableBundleCompat bundle = new PersistableBundleCompat();
bundle.putString(ContactsBackupJob.ACCOUNT, contactsPreferenceActivity.getAccount().name);
bundle.putBoolean(ContactsBackupJob.FORCE, true);
new JobRequest.Builder(ContactsBackupJob.TAG).setExtras(bundle).startNow().setUpdateCurrent(false).build().schedule();
Snackbar.make(getView().findViewById(R.id.contacts_linear_layout), R.string.contacts_preferences_backup_scheduled, Snackbar.LENGTH_LONG).show();
}
Aggregations