Disable help recover account option by default

This commit is contained in:
ameba23
2021-08-27 12:08:36 +02:00
parent 5e530c25b6
commit c49c1f78d2
3 changed files with 25 additions and 1 deletions

View File

@@ -371,6 +371,13 @@ public class ConversationActivity extends BriarActivity
observeOnce(viewModel.getContactItem(), this, contact ->
menu.findItem(R.id.action_set_alias).setEnabled(true));
// enable help recover account action if available
observeOnce(viewModel.amCustodian(), this, enable -> {
if (enable) {
menu.findItem(R.id.action_help_recover_account).setEnabled(true);
}
});
return super.onCreateOptionsMenu(menu);
}

View File

@@ -40,6 +40,8 @@ import org.briarproject.briar.api.messaging.PrivateMessage;
import org.briarproject.briar.api.messaging.PrivateMessageFactory;
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
import org.briarproject.briar.api.messaging.event.AttachmentReceivedEvent;
import org.briarproject.briar.api.socialbackup.SocialBackup;
import org.briarproject.briar.api.socialbackup.SocialBackupManager;
import java.util.Collection;
import java.util.List;
@@ -84,6 +86,7 @@ public class ConversationViewModel extends DbViewModel
private final PrivateMessageFactory privateMessageFactory;
private final AttachmentRetriever attachmentRetriever;
private final AttachmentCreator attachmentCreator;
private final SocialBackupManager socialBackupManager;
@Nullable
private ContactId contactId = null;
@@ -104,6 +107,7 @@ public class ConversationViewModel extends DbViewModel
new MutableLiveData<>();
private final MutableLiveEvent<PrivateMessageHeader> addedHeader =
new MutableLiveEvent<>();
private final MutableLiveData<Boolean> amCustodian = new MutableLiveData<>();
@Inject
ConversationViewModel(Application application,
@@ -118,7 +122,8 @@ public class ConversationViewModel extends DbViewModel
SettingsManager settingsManager,
PrivateMessageFactory privateMessageFactory,
AttachmentRetriever attachmentRetriever,
AttachmentCreator attachmentCreator) {
AttachmentCreator attachmentCreator,
SocialBackupManager socialBackupManager) {
super(application, dbExecutor, lifecycleManager, db, androidExecutor);
this.db = db;
this.eventBus = eventBus;
@@ -129,6 +134,7 @@ public class ConversationViewModel extends DbViewModel
this.privateMessageFactory = privateMessageFactory;
this.attachmentRetriever = attachmentRetriever;
this.attachmentCreator = attachmentCreator;
this.socialBackupManager = socialBackupManager;
messagingGroupId = map(contactItem, c ->
messagingManager.getContactGroup(c.getContact()).getId());
contactDeleted.setValue(false);
@@ -296,6 +302,12 @@ public class ConversationViewModel extends DbViewModel
onOnboardingShown(SHOW_ONBOARDING_INTRODUCTION);
showIntroductionOnboarding.postEvent(true);
}
// Check if we are a social backup custodian for this contact
boolean amCustodianBool = db.transactionWithResult(true,
txn -> socialBackupManager.amCustodian(txn, c));
amCustodian.postValue(amCustodianBool);
}
@DatabaseExecutor
@@ -381,6 +393,10 @@ public class ConversationViewModel extends DbViewModel
return addedHeader;
}
LiveData<Boolean> amCustodian() {
return amCustodian;
}
@UiThread
void recheckFeaturesAndOnboarding(ContactId contactId) {
runOnDbThread(() -> {

View File

@@ -31,5 +31,6 @@
android:id="@+id/action_help_recover_account"
android:icon="@drawable/introduction_white"
android:title="@string/help_recover_account"
android:enabled="false"
app:showAsAction="never"/>
</menu>