Search in sources :

Example 1 with DeleteConversationEvent

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();
    }
}
Also used : SoundController(com.waz.zclient.media.SoundController) ConfirmationCallback(com.waz.zclient.controllers.confirmation.ConfirmationCallback) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) IConversation(com.waz.api.IConversation) DeleteConversationEvent(com.waz.zclient.controllers.tracking.events.conversation.DeleteConversationEvent) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Example 2 with DeleteConversationEvent

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();
    }
}
Also used : SoundController(com.waz.zclient.media.SoundController) ConfirmationCallback(com.waz.zclient.controllers.confirmation.ConfirmationCallback) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) DeleteConversationEvent(com.waz.zclient.controllers.tracking.events.conversation.DeleteConversationEvent) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Aggregations

ConfirmationCallback (com.waz.zclient.controllers.confirmation.ConfirmationCallback)2 ConfirmationRequest (com.waz.zclient.controllers.confirmation.ConfirmationRequest)2 TwoButtonConfirmationCallback (com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback)2 DeleteConversationEvent (com.waz.zclient.controllers.tracking.events.conversation.DeleteConversationEvent)2 SoundController (com.waz.zclient.media.SoundController)2 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)2 IConversation (com.waz.api.IConversation)1