From 60e8f742ac400ff3e02c9a8e0968931dbb9c0f3c Mon Sep 17 00:00:00 2001 From: Arne Date: Sat, 26 Aug 2023 21:23:59 +0200 Subject: [PATCH] continue revert backup changes --- .../conversations/utils/StorageHelper.java | 7 ----- .../services/ExportBackupService.java | 29 ++++--------------- .../conversations/ui/SettingsActivity.java | 12 +++++--- src/main/res/values-de-rDE/strings.xml | 4 --- src/main/res/values/defaults.xml | 1 - src/main/res/values/strings.xml | 5 +--- src/main/res/xml/preferences.xml | 5 ---- 7 files changed, 14 insertions(+), 49 deletions(-) diff --git a/src/git/java/eu/siacs/conversations/utils/StorageHelper.java b/src/git/java/eu/siacs/conversations/utils/StorageHelper.java index 8dc167e74..a29e1348d 100644 --- a/src/git/java/eu/siacs/conversations/utils/StorageHelper.java +++ b/src/git/java/eu/siacs/conversations/utils/StorageHelper.java @@ -10,15 +10,8 @@ import androidx.annotation.Nullable; import java.io.File; -import eu.siacs.conversations.services.ExportBackupService; - public class StorageHelper { - public static enum BackupCompatTypes { - MonoclesOnly, - Compatible - } - public static File getConversationsDirectory(final Context context, final String type) { if (type.equalsIgnoreCase("null")) { return new File(getStorage(context, STORAGE_INDEX.get(), APP_DIRECTORY, type)); diff --git a/src/main/java/eu/siacs/conversations/services/ExportBackupService.java b/src/main/java/eu/siacs/conversations/services/ExportBackupService.java index 0f22331c7..c5c994e5b 100644 --- a/src/main/java/eu/siacs/conversations/services/ExportBackupService.java +++ b/src/main/java/eu/siacs/conversations/services/ExportBackupService.java @@ -68,7 +68,6 @@ import eu.siacs.conversations.persistance.DatabaseBackend; import eu.siacs.conversations.persistance.FileBackend; import eu.siacs.conversations.utils.BackupFileHeader; import eu.siacs.conversations.utils.Compatibility; -import eu.siacs.conversations.utils.StorageHelper; import eu.siacs.conversations.utils.WakeLockHelper; import eu.siacs.conversations.xmpp.Jid; import static eu.siacs.conversations.utils.Compatibility.s; @@ -266,25 +265,8 @@ public class ExportBackupService extends Service { boolean success; List files; try { - files = export(StorageHelper.BackupCompatTypes.Compatible); - if(files == null) { - Log.d(Config.LOGTAG, "Failed to create a Conversations compatible backup. Giving up!"); - success = false; - } - else { - List f = export(StorageHelper.BackupCompatTypes.MonoclesOnly); - if(f == null) { - Log.d(Config.LOGTAG, "Failed to create a Monocles-Only compatible backup. Giving up!"); - success = false; - } else { - files.addAll(f); - success = files != null; - - if(success) { - Log.d(Config.LOGTAG, "Backup successfully created two backup versions"); - } - } - } + files = export(intent.getBooleanExtra("monocles_db", true)); + success = files != null; } catch (final Exception e) { Log.d(Config.LOGTAG, "unable to create backup", e); success = false; @@ -411,7 +393,7 @@ public class ExportBackupService extends Service { } } - private List export(StorageHelper.BackupCompatTypes compatType) throws Exception { + private List export(boolean withmonoclesDb) throws Exception { wakeLock.acquire(15 * 60 * 1000L /*15 minutes*/); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext(), NotificationService.BACKUP_CHANNEL_ID); mBuilder.setContentTitle(getString(R.string.notification_create_backup_title)) @@ -438,8 +420,7 @@ public class ExportBackupService extends Service { secureRandom.nextBytes(salt); final BackupFileHeader backupFileHeader = new BackupFileHeader(getString(R.string.app_name), account.getJid(), System.currentTimeMillis(), IV, salt); final Progress progress = new Progress(mBuilder, max, count); - final String compatTag = StorageHelper.BackupCompatTypes.Compatible == compatType ? "compat" : "monocles"; - final File file = new File(getBackupDirectory(null), account.getJid().asBareJid().toEscapedString() + "_" + compatTag + "_" + ((new SimpleDateFormat("yyyy-MM-dd_mm-HH-ss")).format(new Date())) + ".ceb"); + final File file = new File(getBackupDirectory(null), account.getJid().asBareJid().toEscapedString() + "_" + ((new SimpleDateFormat("yyyy-MM-dd")).format(new Date())) + ".ceb"); files.add(file); final File directory = file.getParentFile(); if (directory != null && directory.mkdirs()) { @@ -464,7 +445,7 @@ public class ExportBackupService extends Service { accountExport(db, uuid, writer); simpleExport(db, Conversation.TABLENAME, Conversation.ACCOUNT, uuid, writer); messageExport(db, uuid, writer, progress); - if (compatType == StorageHelper.BackupCompatTypes.MonoclesOnly) messageExportmonocles(db, uuid, writer, progress); + if (withmonoclesDb) messageExportmonocles(db, uuid, writer, progress); for (String table : Arrays.asList(SQLiteAxolotlStore.PREKEY_TABLENAME, SQLiteAxolotlStore.SIGNED_PREKEY_TABLENAME, SQLiteAxolotlStore.SESSION_TABLENAME, SQLiteAxolotlStore.IDENTITIES_TABLENAME)) { simpleExport(db, table, SQLiteAxolotlStore.ACCOUNT, uuid, writer); } diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index a61b47071..f44b98775 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -824,18 +824,22 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference private void createBackup() { new AlertDialog.Builder(this) .setTitle(getString(R.string.pref_create_backup)) - .setMessage(getString(R.string.create_monocles_backup)) + .setMessage(getString(R.string.create_monocles_only_backup)) .setPositiveButton(R.string.yes, (dialog, whichButton) -> { - createBackup(true); + createBackup(true, true); + }) + .setNegativeButton(R.string.no, (dialog, whichButton) -> { + createBackup(false, false); }).show(); } - private void createBackup(boolean notify) { + private void createBackup(boolean notify, boolean withmonoclesDb) { Intent intent = new Intent(this, ExportBackupService.class); + intent.putExtra("monocles_db", withmonoclesDb); intent.putExtra("NOTIFY_ON_BACKUP_COMPLETE", notify); ContextCompat.startForegroundService(this, intent); final AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(R.string.backup_started); + builder.setMessage(R.string.backup_started_message); builder.setPositiveButton(R.string.ok, null); builder.create().show(); } diff --git a/src/main/res/values-de-rDE/strings.xml b/src/main/res/values-de-rDE/strings.xml index cfceb0fca..2de8589e7 100644 --- a/src/main/res/values-de-rDE/strings.xml +++ b/src/main/res/values-de-rDE/strings.xml @@ -1341,8 +1341,4 @@ Anrufe können nicht über I2P gemacht werden Soll das Löschen von lokalen Dateien in Chats immer bestätigt werden? Löschen von lokalen Dateien in Chats - Zwei Sicherungsdateien werden angelegt. Sicherung #1 ist nur mit Monocles kompatibel, Sicherung #2 kann auch von Conversations o.ä benutzt werden. - Das Backup wurde gestartet. Du wirst informiert sobald der Prozess abgeschlossen ist. - Wie viele Backups sollen behalten werden. Standard ist 3 - Anzahl zu speichernder Backups \ No newline at end of file diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index df89162e3..f0cd85e5d 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -106,7 +106,6 @@ none true false - 3 conversations.im diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 1fcfaf95f..fd17ff777 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -550,6 +550,7 @@ has invited you via Hello,\n\nthe user %s has invited you to monocles. Just click the following link… Broadcast Last User Interaction + Let all your contacts know when use monocles chat monocles chat will ask you to allow a few permissions. It is important that you allow all these permissions to use all features of this messenger. If you deny any of these permissions the app will close itself. You have denied some or all permissions needed for monocles chat. Would you like to jump to the settings and allow these permissions? If you denie any of these permissions, the app will close itself. Unable to connect to OpenKeychain @@ -865,7 +866,6 @@ Restore Enter your password for the account %s to restore the backup. Don\'t use the restore feature under any circumstances except in the case of migrating or losing your device. - Do not attempt to restore backups that you have not created yourself! Unable to restore backup. Unable to decrypt backup. Is the password correct? Prefer the user\'s XMPP avatar instead of the one from your address book @@ -1305,7 +1305,4 @@ Confirm local file removal How many backups should be kept?. Defaults to 3 Number of backups to keep - Allow contacts to see when you were last active in the app - Settings successfully restored - Failed to restore settings: %s diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index edc748c7f..58e593126 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -495,11 +495,6 @@ android:key="create_backup" android:summary="@string/pref_create_backup_summary" android:title="@string/pref_create_backup" /> -