use of com.waz.zclient.controllers.tracking.events.conversation.DeleteConversationEvent in project wire-android by wireapp.
the class ParticipantFragment method deleteConversation.
public void deleteConversation(final IConversation conversation) {
ConfirmationCallback callback = new TwoButtonConfirmationCallback() {
@Override
public void positiveButtonClicked(boolean checkboxIsSelected) {
}
@Override
public void negativeButtonClicked() {
}
@Override
public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
if (getStoreFactory() == null || getStoreFactory().isTornDown() || getControllerFactory() == null || getControllerFactory().isTornDown()) {
return;
}
if (!confirmed) {
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new DeleteConversationEvent(ConversationType.getValue(conversation), DeleteConversationEvent.Context.LIST, DeleteConversationEvent.Response.CANCEL));
return;
}
IConversation currentConversation = getStoreFactory().getConversationStore().getCurrentConversation();
boolean deleteCurrentConversation = conversation != null && currentConversation != null && conversation.getId().equals(currentConversation.getId());
getStoreFactory().getConversationStore().deleteConversation(conversation, checkboxIsSelected);
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new DeleteConversationEvent(ConversationType.getValue(conversation), DeleteConversationEvent.Context.PARTICIPANTS, DeleteConversationEvent.Response.DELETE));
if (deleteCurrentConversation) {
getStoreFactory().getConversationStore().setCurrentConversationToNext(ConversationChangeRequester.DELETE_CONVERSATION);
}
if (LayoutSpec.isTablet(getActivity())) {
getControllerFactory().getConversationScreenController().hideParticipants(false, true);
}
}
};
String header = getString(R.string.confirmation_menu__meta_delete);
String text = getString(R.string.confirmation_menu__meta_delete_text);
String confirm = getString(R.string.confirmation_menu__confirm_delete);
String cancel = getString(R.string.confirmation_menu__cancel);
ConfirmationRequest.Builder builder = new ConfirmationRequest.Builder().withHeader(header).withMessage(text).withPositiveButton(confirm).withNegativeButton(cancel).withConfirmationCallback(callback).withWireTheme(getControllerFactory().getThemeController().getThemeDependentOptionsTheme());
if (conversation.getType() == IConversation.Type.GROUP) {
builder = builder.withCheckboxLabel(getString(R.string.confirmation_menu__delete_conversation__checkbox__label)).withCheckboxSelectedByDefault();
}
getControllerFactory().getConfirmationController().requestConfirmation(builder.build(), IConfirmationController.PARTICIPANTS);
SoundController ctrl = inject(SoundController.class);
if (ctrl != null) {
ctrl.playAlert();
}
}
use of com.waz.zclient.controllers.tracking.events.conversation.DeleteConversationEvent in project wire-android by wireapp.
the class ConversationListManagerFragment method deleteConversation.
public void deleteConversation(final IConversation conversation) {
closeMenu();
ConfirmationCallback callback = new TwoButtonConfirmationCallback() {
@Override
public void positiveButtonClicked(boolean checkboxIsSelected) {
}
@Override
public void negativeButtonClicked() {
}
@Override
public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
if (getStoreFactory() == null || getStoreFactory().isTornDown() || getControllerFactory() == null || getControllerFactory().isTornDown()) {
return;
}
if (!confirmed) {
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new DeleteConversationEvent(ConversationType.getValue(conversation), DeleteConversationEvent.Context.LIST, DeleteConversationEvent.Response.CANCEL));
return;
}
boolean deleteCurrentConversation = conversation.getId().equals(getStoreFactory().getConversationStore().getCurrentConversation().getId());
getStoreFactory().getConversationStore().deleteConversation(conversation, checkboxIsSelected);
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new DeleteConversationEvent(ConversationType.getValue(conversation), DeleteConversationEvent.Context.LIST, DeleteConversationEvent.Response.DELETE));
if (deleteCurrentConversation) {
getStoreFactory().getConversationStore().setCurrentConversationToNext(ConversationChangeRequester.DELETE_CONVERSATION);
}
}
};
String header = getString(R.string.confirmation_menu__meta_delete);
String text = getString(R.string.confirmation_menu__meta_delete_text);
String confirm = getString(R.string.confirmation_menu__confirm_delete);
String cancel = getString(R.string.confirmation_menu__cancel);
String checkboxLabel = "";
if (conversation.getType() == IConversation.Type.GROUP) {
checkboxLabel = getString(R.string.confirmation_menu__delete_conversation__checkbox__label);
}
ConfirmationRequest request = new ConfirmationRequest.Builder().withHeader(header).withMessage(text).withPositiveButton(confirm).withNegativeButton(cancel).withConfirmationCallback(callback).withCheckboxLabel(checkboxLabel).withWireTheme(getControllerFactory().getThemeController().getOptionsDarkTheme()).build();
getControllerFactory().getConfirmationController().requestConfirmation(request, IConfirmationController.CONVERSATION_LIST);
SoundController ctrl = inject(SoundController.class);
if (ctrl != null) {
ctrl.playAlert();
}
}
Aggregations