mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Only show remote wipe menu item if we are a remote wiper for that contact
This commit is contained in:
@@ -372,6 +372,13 @@ public class ConversationActivity extends BriarActivity
|
||||
observeOnce(viewModel.getContactItem(), this, contact ->
|
||||
menu.findItem(R.id.action_set_alias).setEnabled(true));
|
||||
|
||||
// enable remote wipe action if available
|
||||
observeOnce(viewModel.amRemoteWiper(), this, amWiper -> {
|
||||
if (amWiper != null && amWiper) {
|
||||
menu.findItem(R.id.action_remote_wipe).setEnabled(true);
|
||||
}
|
||||
});
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ 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.remotewipe.RemoteWipeManager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -84,6 +85,7 @@ public class ConversationViewModel extends DbViewModel
|
||||
private final PrivateMessageFactory privateMessageFactory;
|
||||
private final AttachmentRetriever attachmentRetriever;
|
||||
private final AttachmentCreator attachmentCreator;
|
||||
private final RemoteWipeManager remoteWipeManager;
|
||||
|
||||
@Nullable
|
||||
private ContactId contactId = null;
|
||||
@@ -104,6 +106,7 @@ public class ConversationViewModel extends DbViewModel
|
||||
new MutableLiveData<>();
|
||||
private final MutableLiveEvent<PrivateMessageHeader> addedHeader =
|
||||
new MutableLiveEvent<>();
|
||||
private final MutableLiveData<Boolean> amRemoteWiper = new MutableLiveData<>();
|
||||
|
||||
@Inject
|
||||
ConversationViewModel(Application application,
|
||||
@@ -118,6 +121,7 @@ public class ConversationViewModel extends DbViewModel
|
||||
SettingsManager settingsManager,
|
||||
PrivateMessageFactory privateMessageFactory,
|
||||
AttachmentRetriever attachmentRetriever,
|
||||
RemoteWipeManager remoteWipeManager,
|
||||
AttachmentCreator attachmentCreator) {
|
||||
super(application, dbExecutor, lifecycleManager, db, androidExecutor);
|
||||
this.db = db;
|
||||
@@ -129,6 +133,7 @@ public class ConversationViewModel extends DbViewModel
|
||||
this.privateMessageFactory = privateMessageFactory;
|
||||
this.attachmentRetriever = attachmentRetriever;
|
||||
this.attachmentCreator = attachmentCreator;
|
||||
this.remoteWipeManager = remoteWipeManager;
|
||||
messagingGroupId = map(contactItem, c ->
|
||||
messagingManager.getContactGroup(c.getContact()).getId());
|
||||
contactDeleted.setValue(false);
|
||||
@@ -296,6 +301,11 @@ public class ConversationViewModel extends DbViewModel
|
||||
onOnboardingShown(SHOW_ONBOARDING_INTRODUCTION);
|
||||
showIntroductionOnboarding.postEvent(true);
|
||||
}
|
||||
|
||||
// Check if we are a remote wiper for this contact
|
||||
boolean amWiper = db.transactionWithResult(true,
|
||||
txn -> remoteWipeManager.amWiper(txn, c));
|
||||
amRemoteWiper.postValue(amWiper);
|
||||
}
|
||||
|
||||
@DatabaseExecutor
|
||||
@@ -381,6 +391,10 @@ public class ConversationViewModel extends DbViewModel
|
||||
return addedHeader;
|
||||
}
|
||||
|
||||
LiveData<Boolean> amRemoteWiper() {
|
||||
return amRemoteWiper;
|
||||
}
|
||||
|
||||
@UiThread
|
||||
void recheckFeaturesAndOnboarding(ContactId contactId) {
|
||||
runOnDbThread(() -> {
|
||||
|
||||
@@ -37,5 +37,6 @@
|
||||
android:id="@+id/action_remote_wipe"
|
||||
android:icon="@drawable/action_delete_white"
|
||||
android:title="@string/activate_remote_wipe"
|
||||
android:enabled="false"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
Reference in New Issue
Block a user