mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Configurable calendar backup.
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
a77ab9eb66
commit
16c957c834
6 changed files with 29 additions and 5 deletions
|
@ -29,6 +29,7 @@ import androidx.work.Worker
|
|||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import third_parties.sufficientlysecure.AndroidCalendar
|
||||
import third_parties.sufficientlysecure.SaveCalendar
|
||||
|
@ -50,6 +51,12 @@ class CalendarBackupWork(
|
|||
}
|
||||
|
||||
override fun doWork(): Result {
|
||||
val showCalendarBackup = applicationContext.resources.getBoolean(R.bool.show_calendar_backup)
|
||||
if (!showCalendarBackup) {
|
||||
Log_OC.d(TAG, "Calendar backup is disabled.")
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
val accountName = inputData.getString(ACCOUNT) ?: ""
|
||||
val optionalUser = accountManager.getUser(accountName)
|
||||
if (!optionalUser.isPresent || TextUtils.isEmpty(accountName)) { // no account provided
|
||||
|
|
|
@ -561,6 +561,13 @@ public class SettingsActivity extends PreferenceActivity
|
|||
private void setupBackupPreference() {
|
||||
Preference pContactsBackup = findPreference("backup");
|
||||
if (pContactsBackup != null) {
|
||||
boolean showCalendarBackup = getResources().getBoolean(R.bool.show_calendar_backup);
|
||||
pContactsBackup.setTitle(showCalendarBackup
|
||||
? getString(R.string.backup_title)
|
||||
: getString(R.string.contact_backup_title));
|
||||
pContactsBackup.setSummary(showCalendarBackup
|
||||
? getString(R.string.prefs_daily_backup_summary)
|
||||
: getString(R.string.prefs_daily_contact_backup_summary));
|
||||
pContactsBackup.setOnPreferenceClickListener(preference -> {
|
||||
ContactsPreferenceActivity.startActivityWithoutSidebar(this);
|
||||
return true;
|
||||
|
|
|
@ -102,7 +102,8 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
|
|||
private CompoundButton.OnCheckedChangeListener calendarCheckedListener;
|
||||
private User user;
|
||||
private boolean showSidebar = true;
|
||||
|
||||
//flag to check if calendar backup should be shown and backup should be done or not
|
||||
private boolean showCalendarBackup = true;
|
||||
public static BackupFragment create(boolean showSidebar) {
|
||||
BackupFragment fragment = new BackupFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
|
@ -144,6 +145,8 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
|
|||
showSidebar = getArguments().getBoolean(ARG_SHOW_SIDEBAR);
|
||||
}
|
||||
|
||||
showCalendarBackup = requireContext().getResources().getBoolean(R.bool.show_calendar_backup);
|
||||
|
||||
final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity();
|
||||
user = contactsPreferenceActivity.getUser().orElseThrow(RuntimeException::new);
|
||||
|
||||
|
@ -151,7 +154,8 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
|
|||
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
viewThemeUtils.files.themeActionBar(requireContext(), actionBar, R.string.backup_title);
|
||||
viewThemeUtils.files.themeActionBar(requireContext(), actionBar,
|
||||
showCalendarBackup ? R.string.backup_title : R.string.contact_backup_title);
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,6 +168,7 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
|
|||
binding.contacts.setChecked(isContactsBackupEnabled() && checkContactBackupPermission());
|
||||
binding.calendar.setChecked(isCalendarBackupEnabled() && checkCalendarBackupPermission(getContext()));
|
||||
|
||||
binding.calendar.setVisibility(showCalendarBackup ? View.VISIBLE : View.GONE);
|
||||
|
||||
setupCheckListeners();
|
||||
|
||||
|
@ -395,7 +400,7 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
|
|||
startContactsBackupJob();
|
||||
}
|
||||
|
||||
if (isCalendarBackupEnabled() && checkCalendarBackupPermission(requireContext())) {
|
||||
if (showCalendarBackup && isCalendarBackupEnabled() && checkCalendarBackupPermission(requireContext())) {
|
||||
startCalendarBackupJob();
|
||||
}
|
||||
|
||||
|
@ -651,7 +656,7 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
|
|||
}
|
||||
|
||||
// calendars
|
||||
if (MimeTypeUtil.isCalendar(file)) {
|
||||
if (showCalendarBackup && MimeTypeUtil.isCalendar(file)) {
|
||||
calendarBackupsToRestore.add(file);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
<string name="away">Abwesend</string>
|
||||
<string name="backup_settings">Sicherungseinstellungen</string>
|
||||
<string name="backup_title">Kontakte & Kalender-Sicherung</string>
|
||||
<string name="contact_backup_title">Kontakte-Sicherung</string>
|
||||
<string name="battery_optimization_close">Schliessen</string>
|
||||
<string name="battery_optimization_disable">Deaktivieren</string>
|
||||
<string name="battery_optimization_message">Ihr Gerät hat möglicherweise Batterieoptimierung aktiv. AutoUpload funktioniert nur dann richtig, wenn Sie diese App davon ausschließen.</string>
|
||||
|
@ -561,6 +562,7 @@
|
|||
<string name="prefs_category_general">Allgemein</string>
|
||||
<string name="prefs_category_more">Mehr</string>
|
||||
<string name="prefs_daily_backup_summary">Tägliche Sicherung Ihrer Kalender & Kontakte</string>
|
||||
<string name="prefs_daily_contact_backup_summary">Tägliche Sicherung Ihrer Kontakte</string>
|
||||
<string name="prefs_davx5_setup_error">Unerwarteter Fehler beim Einrichten von DAVx5 (früher bekannt als DAVdroid)</string>
|
||||
<string name="prefs_e2e_active">Ende-zu-Ende-Verschlüsselung ist eingerichtet!</string>
|
||||
<string name="prefs_e2e_mnemonic">E2E-Gedächtnisstütze</string>
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
<string name="contacts_backup_folder">/.Contacts-Backup</string>
|
||||
<integer name="contacts_backup_expire">-1</integer>
|
||||
<string name="calendar_backup_folder">/.Calendar-Backup</string>
|
||||
<!-- flag to enable/disable contact backup -->
|
||||
<bool name="show_calendar_backup">true</bool>
|
||||
|
||||
<!-- What's new -->
|
||||
<bool name="show_whats_new">true</bool>
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<string name="prefs_calendar_contacts_no_store_error">Neither F-Droid nor Google Play is installed</string>
|
||||
<string name="prefs_calendar_contacts_sync_setup_successful">Calendar & contacts sync set up</string>
|
||||
<string name="prefs_daily_backup_summary">Daily backup of your calendar & contacts</string>
|
||||
<string name="prefs_daily_contact_backup_summary">Daily backup of your contacts</string>
|
||||
<string name="prefs_sycned_folders_summary">Manage folders for auto upload</string>
|
||||
<string name="prefs_help">Help</string>
|
||||
<string name="prefs_recommend">Recommend to a friend</string>
|
||||
|
@ -605,7 +606,7 @@
|
|||
<string name="contacts_preferences_backup_scheduled">Backup scheduled and will start shortly</string>
|
||||
<string name="contacts_preferences_import_scheduled">Import scheduled and will start shortly</string>
|
||||
<string name="backup_title">Contacts & calendar backup</string>
|
||||
|
||||
<string name="contact_backup_title">Contacts backup</string>
|
||||
<string name="drawer_logout">Log out</string>
|
||||
<string name="picture_set_as_no_app">No app found to set a picture with</string>
|
||||
<string name="privacy">Privacy</string>
|
||||
|
|
Loading…
Reference in a new issue