forked from mirror/monocles_chat
continue revert backup changes
This commit is contained in:
parent
27b1e28d34
commit
60e8f742ac
7 changed files with 14 additions and 49 deletions
|
@ -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));
|
||||
|
|
|
@ -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<File> 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<File> 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<File> export(StorageHelper.BackupCompatTypes compatType) throws Exception {
|
||||
private List<File> 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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -1341,8 +1341,4 @@
|
|||
<string name="no_i2p_calls">Anrufe können nicht über I2P gemacht werden</string>
|
||||
<string name="confirm_delete_attachment_summary">Soll das Löschen von lokalen Dateien in Chats immer bestätigt werden?</string>
|
||||
<string name="pref_confirm_delete_attachment">Löschen von lokalen Dateien in Chats</string>
|
||||
<string name="create_monocles_backup">Zwei Sicherungsdateien werden angelegt. Sicherung #1 ist nur mit Monocles kompatibel, Sicherung #2 kann auch von Conversations o.ä benutzt werden.</string>
|
||||
<string name="backup_started">Das Backup wurde gestartet. Du wirst informiert sobald der Prozess abgeschlossen ist.</string>
|
||||
<string name="pref_keep_num_backups">Wie viele Backups sollen behalten werden. Standard ist 3</string>
|
||||
<string name="pref_keep_num_backups_title">Anzahl zu speichernder Backups</string>
|
||||
</resources>
|
|
@ -106,7 +106,6 @@
|
|||
<string name="default_push_account">none</string>
|
||||
<bool name="dialler_integration_incoming">true</bool>
|
||||
<bool name="follow_thread_in_channel">false</bool>
|
||||
<integer name="keep_num_backups">3</integer>
|
||||
|
||||
<string-array name="domains">
|
||||
<item>conversations.im</item>
|
||||
|
|
|
@ -550,6 +550,7 @@
|
|||
<string name="inviteUser_Subject">has invited you via</string>
|
||||
<string name="InviteText">Hello,\n\nthe user %s has invited you to monocles. Just click the following link…</string>
|
||||
<string name="pref_broadcast_last_activity">Broadcast Last User Interaction</string>
|
||||
<string name="pref_broadcast_last_activity_summary">Let all your contacts know when use monocles chat</string>
|
||||
<string name="request_permissions_message">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.</string>
|
||||
<string name="request_permissions_message_again">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.</string>
|
||||
<string name="unable_to_connect_to_keychain">Unable to connect to OpenKeychain</string>
|
||||
|
@ -865,7 +866,6 @@
|
|||
<string name="restore">Restore</string>
|
||||
<string name="enter_password_to_restore">Enter your password for the account %s to restore the backup.</string>
|
||||
<string name="restore_warning">Don\'t use the restore feature under any circumstances except in the case of migrating or losing your device.</string>
|
||||
<string name="restore_warning_continued">Do not attempt to restore backups that you have not created yourself!</string>
|
||||
<string name="unable_to_restore_backup">Unable to restore backup.</string>
|
||||
<string name="unable_to_decrypt_backup">Unable to decrypt backup. Is the password correct?</string>
|
||||
<string name="pref_prefer_xmpp_avatar_summary">Prefer the user\'s XMPP avatar instead of the one from your address book</string>
|
||||
|
@ -1305,7 +1305,4 @@
|
|||
<string name="pref_confirm_delete_attachment">Confirm local file removal</string>
|
||||
<string name="pref_keep_num_backups">How many backups should be kept?. Defaults to 3</string>
|
||||
<string name="pref_keep_num_backups_title">Number of backups to keep</string>
|
||||
<string name="pref_broadcast_last_activity_summary">Allow contacts to see when you were last active in the app</string>
|
||||
<string name="settings_restore_message_success">Settings successfully restored</string>
|
||||
<string name="settings_restore_message_failure">Failed to restore settings: %s</string>
|
||||
</resources>
|
||||
|
|
|
@ -495,11 +495,6 @@
|
|||
android:key="create_backup"
|
||||
android:summary="@string/pref_create_backup_summary"
|
||||
android:title="@string/pref_create_backup" />
|
||||
<Preference
|
||||
android:key="keep_num_backups"
|
||||
android:summary="@string/pref_keep_num_backups"
|
||||
android:title="@string/pref_keep_num_backups_title"
|
||||
android:defaultValue="@integer/keep_num_backups"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="@bool/plain_text_logs"
|
||||
android:key="export_plain_text_logs"
|
||||
|
|
Loading…
Reference in a new issue