mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
When creating social backup, only allow selecting contacts when there are at least 2 contacts in contact list
This commit is contained in:
@@ -4,6 +4,7 @@ import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.contact.ContactManager;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.briar.R;
|
||||
@@ -29,6 +30,9 @@ public class DistributedBackupActivity extends BriarActivity implements
|
||||
@Inject
|
||||
public SocialBackupManager socialBackupManager;
|
||||
|
||||
@Inject
|
||||
public ContactManager contactManager;
|
||||
|
||||
@Inject
|
||||
public DatabaseComponent db;
|
||||
|
||||
@@ -52,6 +56,20 @@ public class DistributedBackupActivity extends BriarActivity implements
|
||||
showInitialFragment(fragment);
|
||||
});
|
||||
} catch (DbException e) {
|
||||
// Check the number of contacts in the contacts list > 1
|
||||
try {
|
||||
if (contactManager.getContacts().size() < 2) {
|
||||
Toast.makeText(this,
|
||||
R.string.social_backup_not_enough_contacts,
|
||||
Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
} catch (DbException dbException) {
|
||||
Toast.makeText(this,
|
||||
R.string.reading_contacts_error,
|
||||
Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
CustodianSelectorFragment fragment =
|
||||
CustodianSelectorFragment.newInstance();
|
||||
showInitialFragment(fragment);
|
||||
|
||||
@@ -729,4 +729,7 @@
|
||||
<string name="activity_name_recovery">Recover Account</string>
|
||||
<string name="activity_name_custodian_help_recovery">Help recover account</string>
|
||||
<string name="existing_backup_explain">%d of the following contacts are needed to restore your account:</string>
|
||||
|
||||
<string name="social_backup_not_enough_contacts">To make a social backup, you need at least 2 contacts in your contacts list</string>
|
||||
<string name="reading_contacts_error">There was an error reading your contacts list</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user