do not show installed accounts in restore view
This commit is contained in:
parent
18982174ce
commit
2e0db4dcda
|
@ -103,6 +103,7 @@ public class ImportBackupService extends Service {
|
||||||
|
|
||||||
public void loadBackupFiles(OnBackupFilesLoaded onBackupFilesLoaded) {
|
public void loadBackupFiles(OnBackupFilesLoaded onBackupFilesLoaded) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
|
List<Jid> accounts = mDatabaseBackend.getAccountJids(false);
|
||||||
final ArrayList<BackupFile> backupFiles = new ArrayList<>();
|
final ArrayList<BackupFile> backupFiles = new ArrayList<>();
|
||||||
final Set<String> apps = new HashSet<>(Arrays.asList("Conversations", "Quicksy", getString(R.string.app_name)));
|
final Set<String> apps = new HashSet<>(Arrays.asList("Conversations", "Quicksy", getString(R.string.app_name)));
|
||||||
for (String app : apps) {
|
for (String app : apps) {
|
||||||
|
@ -114,7 +115,12 @@ public class ImportBackupService extends Service {
|
||||||
for (File file : directory.listFiles()) {
|
for (File file : directory.listFiles()) {
|
||||||
if (file.isFile() && file.getName().endsWith(".ceb")) {
|
if (file.isFile() && file.getName().endsWith(".ceb")) {
|
||||||
try {
|
try {
|
||||||
backupFiles.add(BackupFile.read(file));
|
final BackupFile backupFile = BackupFile.read(file);
|
||||||
|
if (accounts.contains(backupFile.getHeader().getJid())) {
|
||||||
|
Log.d(Config.LOGTAG,"skipping backup for "+backupFile.getHeader().getJid());
|
||||||
|
} else {
|
||||||
|
backupFiles.add(backupFile);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.d(Config.LOGTAG, "unable to read backup file ", e);
|
Log.d(Config.LOGTAG, "unable to read backup file ", e);
|
||||||
}
|
}
|
||||||
|
@ -153,7 +159,6 @@ public class ImportBackupService extends Service {
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(gzipInputStream, "UTF-8"));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(gzipInputStream, "UTF-8"));
|
||||||
String line;
|
String line;
|
||||||
StringBuilder multiLineQuery = null;
|
StringBuilder multiLineQuery = null;
|
||||||
int error = 0;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
int count = count(line, '\'');
|
int count = count(line, '\'');
|
||||||
if (multiLineQuery != null) {
|
if (multiLineQuery != null) {
|
||||||
|
@ -171,7 +176,6 @@ public class ImportBackupService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "done reading file");
|
|
||||||
final Jid jid = backupFileHeader.getJid();
|
final Jid jid = backupFileHeader.getJid();
|
||||||
Cursor countCursor = db.rawQuery("select count(messages.uuid) from messages join conversations on conversations.uuid=messages.conversationUuid join accounts on conversations.accountUuid=accounts.uuid where accounts.username=? and accounts.server=?", new String[]{jid.getEscapedLocal(), jid.getDomain()});
|
Cursor countCursor = db.rawQuery("select count(messages.uuid) from messages join conversations on conversations.uuid=messages.conversationUuid join accounts on conversations.accountUuid=accounts.uuid where accounts.username=? and accounts.server=?", new String[]{jid.getEscapedLocal(), jid.getDomain()});
|
||||||
countCursor.moveToFirst();
|
countCursor.moveToFirst();
|
||||||
|
|
|
@ -917,11 +917,11 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
return getAccounts(db);
|
return getAccounts(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Jid> getAccountJids() {
|
public List<Jid> getAccountJids(final boolean enabledOnly) {
|
||||||
SQLiteDatabase db = this.getReadableDatabase();
|
SQLiteDatabase db = this.getReadableDatabase();
|
||||||
final List<Jid> jids = new ArrayList<>();
|
final List<Jid> jids = new ArrayList<>();
|
||||||
final String[] columns = new String[]{Account.USERNAME, Account.SERVER};
|
final String[] columns = new String[]{Account.USERNAME, Account.SERVER};
|
||||||
String where = "not options & (1 <<1)";
|
String where = enabledOnly ? "not options & (1 <<1)" : null;
|
||||||
Cursor cursor = db.query(Account.TABLENAME, columns, where, null, null, null, null);
|
Cursor cursor = db.query(Account.TABLENAME, columns, where, null, null, null, null);
|
||||||
try {
|
try {
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class UriHandlerActivity extends AppCompatActivity {
|
||||||
private void handleUri(Uri uri, final boolean scanned) {
|
private void handleUri(Uri uri, final boolean scanned) {
|
||||||
final Intent intent;
|
final Intent intent;
|
||||||
final XmppUri xmppUri = new XmppUri(uri);
|
final XmppUri xmppUri = new XmppUri(uri);
|
||||||
final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids(); //TODO only look at enabled accounts
|
final List<Jid> accounts = DatabaseBackend.getInstance(this).getAccountJids(true);
|
||||||
|
|
||||||
if (accounts.size() == 0) {
|
if (accounts.size() == 0) {
|
||||||
if (xmppUri.isJidValid()) {
|
if (xmppUri.isJidValid()) {
|
||||||
|
|
Loading…
Reference in a new issue