mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +01:00
Disable help recover account option by default
This commit is contained in:
@@ -371,6 +371,13 @@ public class ConversationActivity extends BriarActivity
|
|||||||
observeOnce(viewModel.getContactItem(), this, contact ->
|
observeOnce(viewModel.getContactItem(), this, contact ->
|
||||||
menu.findItem(R.id.action_set_alias).setEnabled(true));
|
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);
|
return super.onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ import org.briarproject.briar.api.messaging.PrivateMessage;
|
|||||||
import org.briarproject.briar.api.messaging.PrivateMessageFactory;
|
import org.briarproject.briar.api.messaging.PrivateMessageFactory;
|
||||||
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
import org.briarproject.briar.api.messaging.PrivateMessageHeader;
|
||||||
import org.briarproject.briar.api.messaging.event.AttachmentReceivedEvent;
|
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.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -84,6 +86,7 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
private final PrivateMessageFactory privateMessageFactory;
|
private final PrivateMessageFactory privateMessageFactory;
|
||||||
private final AttachmentRetriever attachmentRetriever;
|
private final AttachmentRetriever attachmentRetriever;
|
||||||
private final AttachmentCreator attachmentCreator;
|
private final AttachmentCreator attachmentCreator;
|
||||||
|
private final SocialBackupManager socialBackupManager;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ContactId contactId = null;
|
private ContactId contactId = null;
|
||||||
@@ -104,6 +107,7 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
new MutableLiveData<>();
|
new MutableLiveData<>();
|
||||||
private final MutableLiveEvent<PrivateMessageHeader> addedHeader =
|
private final MutableLiveEvent<PrivateMessageHeader> addedHeader =
|
||||||
new MutableLiveEvent<>();
|
new MutableLiveEvent<>();
|
||||||
|
private final MutableLiveData<Boolean> amCustodian = new MutableLiveData<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ConversationViewModel(Application application,
|
ConversationViewModel(Application application,
|
||||||
@@ -118,7 +122,8 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
SettingsManager settingsManager,
|
SettingsManager settingsManager,
|
||||||
PrivateMessageFactory privateMessageFactory,
|
PrivateMessageFactory privateMessageFactory,
|
||||||
AttachmentRetriever attachmentRetriever,
|
AttachmentRetriever attachmentRetriever,
|
||||||
AttachmentCreator attachmentCreator) {
|
AttachmentCreator attachmentCreator,
|
||||||
|
SocialBackupManager socialBackupManager) {
|
||||||
super(application, dbExecutor, lifecycleManager, db, androidExecutor);
|
super(application, dbExecutor, lifecycleManager, db, androidExecutor);
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
@@ -129,6 +134,7 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
this.privateMessageFactory = privateMessageFactory;
|
this.privateMessageFactory = privateMessageFactory;
|
||||||
this.attachmentRetriever = attachmentRetriever;
|
this.attachmentRetriever = attachmentRetriever;
|
||||||
this.attachmentCreator = attachmentCreator;
|
this.attachmentCreator = attachmentCreator;
|
||||||
|
this.socialBackupManager = socialBackupManager;
|
||||||
messagingGroupId = map(contactItem, c ->
|
messagingGroupId = map(contactItem, c ->
|
||||||
messagingManager.getContactGroup(c.getContact()).getId());
|
messagingManager.getContactGroup(c.getContact()).getId());
|
||||||
contactDeleted.setValue(false);
|
contactDeleted.setValue(false);
|
||||||
@@ -296,6 +302,12 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
onOnboardingShown(SHOW_ONBOARDING_INTRODUCTION);
|
onOnboardingShown(SHOW_ONBOARDING_INTRODUCTION);
|
||||||
showIntroductionOnboarding.postEvent(true);
|
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
|
@DatabaseExecutor
|
||||||
@@ -381,6 +393,10 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
return addedHeader;
|
return addedHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LiveData<Boolean> amCustodian() {
|
||||||
|
return amCustodian;
|
||||||
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
void recheckFeaturesAndOnboarding(ContactId contactId) {
|
void recheckFeaturesAndOnboarding(ContactId contactId) {
|
||||||
runOnDbThread(() -> {
|
runOnDbThread(() -> {
|
||||||
|
|||||||
@@ -31,5 +31,6 @@
|
|||||||
android:id="@+id/action_help_recover_account"
|
android:id="@+id/action_help_recover_account"
|
||||||
android:icon="@drawable/introduction_white"
|
android:icon="@drawable/introduction_white"
|
||||||
android:title="@string/help_recover_account"
|
android:title="@string/help_recover_account"
|
||||||
|
android:enabled="false"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
</menu>
|
</menu>
|
||||||
Reference in New Issue
Block a user