mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +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 android.widget.Toast;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
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.DatabaseComponent;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
@@ -29,6 +30,9 @@ public class DistributedBackupActivity extends BriarActivity implements
|
|||||||
@Inject
|
@Inject
|
||||||
public SocialBackupManager socialBackupManager;
|
public SocialBackupManager socialBackupManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public ContactManager contactManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DatabaseComponent db;
|
public DatabaseComponent db;
|
||||||
|
|
||||||
@@ -52,6 +56,20 @@ public class DistributedBackupActivity extends BriarActivity implements
|
|||||||
showInitialFragment(fragment);
|
showInitialFragment(fragment);
|
||||||
});
|
});
|
||||||
} catch (DbException e) {
|
} 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 fragment =
|
||||||
CustodianSelectorFragment.newInstance();
|
CustodianSelectorFragment.newInstance();
|
||||||
showInitialFragment(fragment);
|
showInitialFragment(fragment);
|
||||||
|
|||||||
@@ -729,4 +729,7 @@
|
|||||||
<string name="activity_name_recovery">Recover Account</string>
|
<string name="activity_name_recovery">Recover Account</string>
|
||||||
<string name="activity_name_custodian_help_recovery">Help 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="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>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user