Search in sources :

Example 31 with IConversation

use of com.waz.api.IConversation in project wire-android by wireapp.

the class ParticipantsDialogFragment method onSelectedUsers.

@Override
public void onSelectedUsers(List<User> users, ConversationChangeRequester requester) {
    // TODO https://wearezeta.atlassian.net/browse/AN-3730
    getControllerFactory().getPickUserController().hidePickUser(getCurrentPickerDestination(), false);
    IConversation currentConversation = getStoreFactory().getConversationStore().getCurrentConversation();
    if (currentConversation.getType() == IConversation.Type.ONE_TO_ONE) {
        getStoreFactory().getConversationStore().createGroupConversation(users, requester);
        if (!getStoreFactory().getNetworkStore().hasInternetConnection()) {
            ViewUtils.showAlertDialog(getActivity(), R.string.conversation__create_group_conversation__no_network__title, R.string.conversation__create_group_conversation__no_network__message, R.string.conversation__create_group_conversation__no_network__button, null, true);
        }
        ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new CreatedGroupConversationEvent(true, (users.size() + 1)));
    } else if (currentConversation.getType() == IConversation.Type.GROUP) {
        currentConversation.addMembers(users);
        if (!getStoreFactory().getNetworkStore().hasInternetConnection()) {
            ViewUtils.showAlertDialog(getActivity(), R.string.conversation__add_user__no_network__title, R.string.conversation__add_user__no_network__message, R.string.conversation__add_user__no_network__button, null, true);
        }
        ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new AddedMemberToGroupEvent(getParticipantsCount(), users.size()));
    }
    hide();
}
Also used : CreatedGroupConversationEvent(com.waz.zclient.controllers.tracking.events.group.CreatedGroupConversationEvent) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) IConversation(com.waz.api.IConversation) AddedMemberToGroupEvent(com.waz.zclient.controllers.tracking.events.group.AddedMemberToGroupEvent)

Example 32 with IConversation

use of com.waz.api.IConversation in project wire-android by wireapp.

the class ParticipantFragment method onSelectedUsers.

//////////////////////////////////////////////////////////////////////////////////////////
//
//  PickUserFragment.Container
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onSelectedUsers(List<User> users, ConversationChangeRequester requester) {
    IConversation currentConversation = getStoreFactory().getConversationStore().getCurrentConversation();
    if (currentConversation.getType() == IConversation.Type.ONE_TO_ONE) {
        getControllerFactory().getPickUserController().hidePickUser(getCurrentPickerDestination(), false);
        dismissDialog();
        getStoreFactory().getConversationStore().createGroupConversation(users, requester);
        if (!getStoreFactory().getNetworkStore().hasInternetConnection()) {
            ViewUtils.showAlertDialog(getActivity(), R.string.conversation__create_group_conversation__no_network__title, R.string.conversation__create_group_conversation__no_network__message, R.string.conversation__create_group_conversation__no_network__button, null, true);
        }
        ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new CreatedGroupConversationEvent(true, (users.size() + 1)));
    } else if (currentConversation.getType() == IConversation.Type.GROUP) {
        currentConversation.addMembers(users);
        getControllerFactory().getPickUserController().hidePickUser(getCurrentPickerDestination(), false);
        if (!getStoreFactory().getNetworkStore().hasInternetConnection()) {
            ViewUtils.showAlertDialog(getActivity(), R.string.conversation__add_user__no_network__title, R.string.conversation__add_user__no_network__message, R.string.conversation__add_user__no_network__button, null, true);
        }
        ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new AddedMemberToGroupEvent(getParticipantsCount(), users.size()));
    }
}
Also used : CreatedGroupConversationEvent(com.waz.zclient.controllers.tracking.events.group.CreatedGroupConversationEvent) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) IConversation(com.waz.api.IConversation) AddedMemberToGroupEvent(com.waz.zclient.controllers.tracking.events.group.AddedMemberToGroupEvent)

Example 33 with IConversation

use of com.waz.api.IConversation 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 34 with IConversation

use of com.waz.api.IConversation in project wire-android by wireapp.

the class ImageSharingPreviewFragment method confirmShareImages.

private void confirmShareImages() {
    SharedContentType sharedContentType = getControllerFactory().getSharingController().getSharedContentType();
    if (sharedContentType == null) {
        return;
    }
    IConversation destination = getControllerFactory().getSharingController().getDestination();
    List<Uri> sharedImageUris = getControllerFactory().getSharingController().getSharedFileUris();
    switch(sharedContentType) {
        case IMAGE:
            getStoreFactory().getConversationStore().sendMessage(destination, ImageAssetFactory.getImageAsset(sharedImageUris.get(0)));
            TrackingUtils.onSentPhotoMessageFromSharing(((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class), destination);
            break;
    }
    getControllerFactory().getSharingController().onContentShared(getActivity(), destination);
    getActivity().finish();
}
Also used : GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) SharedContentType(com.waz.zclient.controllers.sharing.SharedContentType) IConversation(com.waz.api.IConversation) Uri(android.net.Uri)

Example 35 with IConversation

use of com.waz.api.IConversation in project wire-android by wireapp.

the class ScalaConversationStore method loadConversation.

@Override
public void loadConversation(String conversationId, OnConversationLoadedListener onConversationLoadedListener) {
    IConversation conversation = conversationsList.getConversation(conversationId);
    onConversationLoadedListener.onConversationLoaded(conversation);
}
Also used : IConversation(com.waz.api.IConversation)

Aggregations

IConversation (com.waz.api.IConversation)69 FragmentTest (com.waz.zclient.testutils.FragmentTest)25 Test (org.junit.Test)25 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)14 View (android.view.View)10 User (com.waz.api.User)9 ArrayList (java.util.ArrayList)6 SuppressLint (android.annotation.SuppressLint)5 Intent (android.content.Intent)4 Handler (android.os.Handler)4 AbsListView (android.widget.AbsListView)4 CreatedGroupConversationEvent (com.waz.zclient.controllers.tracking.events.group.CreatedGroupConversationEvent)4 FooterMenuCallback (com.waz.zclient.views.menus.FooterMenuCallback)4 Instrumentation (android.app.Instrumentation)3 TextView (android.widget.TextView)3 BaseScalaActivity (com.waz.zclient.BaseScalaActivity)3 AddedMemberToGroupEvent (com.waz.zclient.controllers.tracking.events.group.AddedMemberToGroupEvent)3 ExceptionHandler (net.hockeyapp.android.ExceptionHandler)3 Animator (android.animation.Animator)2 AnimatorSet (android.animation.AnimatorSet)2