Commit 31a80d82 authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud

options: do not show clear history on swarm

Change-Id: I40323c4f7d91dab270f56c11dd726f0cdaf4ab42
GitLab: #859
parent 6568c6a8
......@@ -367,17 +367,19 @@ public class ContactDetailsActivity extends AppCompatActivity {
goToCallActivity(conversation, contact.getUri(), true)));
adapter.actions.add(new ContactAction(R.drawable.baseline_videocam_24, getText(R.string.ab_action_video_call), () ->
goToCallActivity(conversation, contact.getUri(), false)));
adapter.actions.add(new ContactAction(R.drawable.baseline_clear_all_24, getText(R.string.conversation_action_history_clear), () ->
new MaterialAlertDialogBuilder(ContactDetailsActivity.this)
.setTitle(R.string.clear_history_dialog_title)
.setMessage(R.string.clear_history_dialog_message)
.setPositiveButton(R.string.conversation_action_history_clear, (b, i) -> {
mConversationFacade.clearHistory(conversation.getAccountId(), contact.getUri()).subscribe();
Snackbar.make(binding.getRoot(), R.string.clear_history_completed, Snackbar.LENGTH_LONG).show();
})
.setNegativeButton(android.R.string.cancel, null)
.create()
.show()));
if (!conversation.isSwarm()) {
adapter.actions.add(new ContactAction(R.drawable.baseline_clear_all_24, getText(R.string.conversation_action_history_clear), () ->
new MaterialAlertDialogBuilder(ContactDetailsActivity.this)
.setTitle(R.string.clear_history_dialog_title)
.setMessage(R.string.clear_history_dialog_message)
.setPositiveButton(R.string.conversation_action_history_clear, (b, i) -> {
mConversationFacade.clearHistory(conversation.getAccountId(), contact.getUri()).subscribe();
Snackbar.make(binding.getRoot(), R.string.clear_history_completed, Snackbar.LENGTH_LONG).show();
})
.setNegativeButton(android.R.string.cancel, null)
.create()
.show()));
}
adapter.actions.add(new ContactAction(R.drawable.baseline_block_24, getText(R.string.conversation_action_block_this), () ->
new MaterialAlertDialogBuilder(ContactDetailsActivity.this)
.setTitle(getString(R.string.block_contact_dialog_title, conversationUri))
......
......@@ -344,24 +344,42 @@ public class SmartListFragment extends BaseSupportFragment<SmartListPresenter> i
@Override
public void displayConversationDialog(final SmartListViewModel smartListViewModel) {
new MaterialAlertDialogBuilder(requireContext())
.setItems(R.array.conversation_actions, (dialog, which) -> {
switch (which) {
case ActionHelper.ACTION_COPY:
presenter.copyNumber(smartListViewModel);
break;
case ActionHelper.ACTION_CLEAR:
presenter.clearConversation(smartListViewModel);
break;
case ActionHelper.ACTION_DELETE:
presenter.removeConversation(smartListViewModel);
break;
case ActionHelper.ACTION_BLOCK:
presenter.banContact(smartListViewModel);
break;
}
})
.show();
if (smartListViewModel.isSwarm()) {
new MaterialAlertDialogBuilder(requireContext())
.setItems(R.array.swarm_actions, (dialog, which) -> {
switch (which) {
case 0:
presenter.copyNumber(smartListViewModel);
break;
case 1:
presenter.removeConversation(smartListViewModel);
break;
case 2:
presenter.banContact(smartListViewModel);
break;
}
})
.show();
} else {
new MaterialAlertDialogBuilder(requireContext())
.setItems(R.array.conversation_actions, (dialog, which) -> {
switch (which) {
case ActionHelper.ACTION_COPY:
presenter.copyNumber(smartListViewModel);
break;
case ActionHelper.ACTION_CLEAR:
presenter.clearConversation(smartListViewModel);
break;
case ActionHelper.ACTION_DELETE:
presenter.removeConversation(smartListViewModel);
break;
case ActionHelper.ACTION_BLOCK:
presenter.banContact(smartListViewModel);
break;
}
})
.show();
}
}
@Override
......
......@@ -47,8 +47,8 @@ public class ActionHelper {
}
public static void launchClearAction(final Context context,
final Uri uri,
final Conversation.ConversationActionCallback callback) {
final Uri uri,
final Conversation.ConversationActionCallback callback) {
if (context == null) {
Log.d(TAG, "launchClearAction: activity is null");
return;
......
......@@ -25,6 +25,11 @@ along with this program; if not, write to the Free Software
<item>@string/conversation_action_remove_this</item>
<item>@string/conversation_action_block_this</item>
</string-array>
<string-array name="swarm_actions">
<item>@string/conversation_action_copy_peer_number</item>
<item>@string/conversation_action_remove_this</item>
<item>@string/conversation_action_block_this</item>
</string-array>
<string-array name="video_bitrates">
<item>0</item>
......
......@@ -52,6 +52,7 @@ public class SmartListViewModel
private boolean isChecked = false;
private Observable<Boolean> isSelected = null;
private final Interaction lastEvent;
private boolean isSwarm = false;
public enum Title {
None,
......@@ -97,6 +98,7 @@ public class SmartListViewModel
this.hasOngoingCall = false;
this.lastEvent = lastEvent;
isSelected = conversation.getVisible();
isSwarm = conversation.isSwarm();
for (Contact contact : contacts) {
if (contact.isUser())
continue;
......@@ -128,6 +130,10 @@ public class SmartListViewModel
return uri;
}
public boolean isSwarm() {
return isSwarm;
}
public List<Contact> getContacts() {
return contact;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment