Search in sources :

Example 6 with FooterMenuCallback

use of com.waz.zclient.views.menus.FooterMenuCallback in project wire-android by wireapp.

the class SendConnectRequestFragment method onConnectUserUpdated.

//////////////////////////////////////////////////////////////////////////////////////////
//
//  IConnectStoreObserver
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onConnectUserUpdated(final User user, final IConnectStore.UserRequester userRequester) {
    if (this.userRequester != userRequester) {
        return;
    }
    imageAssetImageViewProfile.connectImageAsset(user.getPicture());
    displayNameTextView.setText(user.getName());
    userDetailsView.setUser(user);
    connectButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (user == null || getStoreFactory() == null || getStoreFactory().isTornDown()) {
                return;
            }
            User me = getStoreFactory().getProfileStore().getSelfUser();
            String myName = me != null ? me.getName() : "";
            String otherName = user.getName();
            String message = getString(R.string.connect__message, otherName, myName);
            IConversation conversation = getStoreFactory().getConnectStore().connectToNewUser(user, message);
            trackSendConnectRequest(user);
            if (conversation != null) {
                KeyboardUtils.hideKeyboard(getActivity());
                getContainer().onConnectRequestWasSentToUser();
            }
        }
    });
    if (userRequester == IConnectStore.UserRequester.PARTICIPANTS) {
        footerMenu.setRightActionText(getString(R.string.glyph__minus));
    }
    footerMenu.setCallback(new FooterMenuCallback() {

        @Override
        public void onLeftActionClicked() {
            showConnectButtonInsteadOfFooterMenu();
        }

        @Override
        public void onRightActionClicked() {
            if (userRequester == IConnectStore.UserRequester.PARTICIPANTS) {
                getContainer().showRemoveConfirmation(user);
            }
        }
    });
    if (userRequester == IConnectStore.UserRequester.PARTICIPANTS) {
        footerMenu.setVisibility(View.VISIBLE);
        connectButton.setVisibility(View.GONE);
    } else {
        footerMenu.setVisibility(View.GONE);
        connectButton.setVisibility(View.VISIBLE);
    }
}
Also used : User(com.waz.api.User) IConversation(com.waz.api.IConversation) FooterMenuCallback(com.waz.zclient.views.menus.FooterMenuCallback) ImageAssetImageView(com.waz.zclient.views.images.ImageAssetImageView) View(android.view.View) UserDetailsView(com.waz.zclient.ui.views.UserDetailsView) TextView(android.widget.TextView)

Example 7 with FooterMenuCallback

use of com.waz.zclient.views.menus.FooterMenuCallback in project wire-android by wireapp.

the class ParticipantBodyFragment method onConnectUserUpdated.

@Override
public void onConnectUserUpdated(final User user, IConnectStore.UserRequester usertype) {
    if (usertype != userRequester || user == null) {
        return;
    }
    imageAssetImageView.setVisibility(View.VISIBLE);
    imageAssetImageView.connectImageAsset(user.getPicture());
    footerMenu.setVisibility(View.VISIBLE);
    topBorder.setVisibility(View.INVISIBLE);
    final IConversation conversation = getStoreFactory().getConversationStore().getCurrentConversation();
    if (conversation.getType() == IConversation.Type.ONE_TO_ONE) {
        if (user.isMe()) {
            footerMenu.setLeftActionText(getString(R.string.glyph__profile));
            footerMenu.setLeftActionLabelText(getString(R.string.popover__action__profile));
            footerMenu.setRightActionText("");
            footerMenu.setRightActionLabelText("");
        } else {
            footerMenu.setLeftActionText(getString(R.string.glyph__add_people));
            footerMenu.setLeftActionLabelText(getString(R.string.conversation__action__create_group));
            footerMenu.setRightActionText(getString(R.string.glyph__block));
            footerMenu.setRightActionLabelText(getString(R.string.popover__action__block));
        }
    } else {
        if (user.isMe()) {
            footerMenu.setLeftActionText(getString(R.string.glyph__profile));
            footerMenu.setLeftActionLabelText(getString(R.string.popover__action__profile));
            footerMenu.setRightActionText(getString(R.string.glyph__minus));
            footerMenu.setRightActionLabelText("");
        } else {
            footerMenu.setLeftActionText(getString(R.string.glyph__conversation));
            footerMenu.setLeftActionLabelText(getString(R.string.popover__action__open));
            footerMenu.setRightActionText(getString(R.string.glyph__minus));
            footerMenu.setRightActionLabelText(getString(R.string.popover__action__remove));
        }
    }
    footerMenu.setCallback(new FooterMenuCallback() {

        @Override
        public void onLeftActionClicked() {
            if (user.isMe() || conversation.getType() != IConversation.Type.ONE_TO_ONE) {
                getControllerFactory().getConversationScreenController().hideParticipants(true, false);
                // Go to conversation with this user
                getControllerFactory().getPickUserController().hidePickUserWithoutAnimations(getContainer().getCurrentPickerDestination());
                getStoreFactory().getConversationStore().setCurrentConversation(user.getConversation(), ConversationChangeRequester.START_CONVERSATION);
            } else {
                ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGroupActionEvent());
                getControllerFactory().getConversationScreenController().addPeopleToConversation();
            }
        }

        @Override
        public void onRightActionClicked() {
            if (conversation.getType() == IConversation.Type.ONE_TO_ONE) {
                if (!user.isMe()) {
                    getContainer().toggleBlockUser(user, user.getConnectionStatus() != User.ConnectionStatus.BLOCKED);
                }
            } else {
                getStoreFactory().getNetworkStore().doIfHasInternetOrNotifyUser(new NetworkAction() {

                    @Override
                    public void execute(NetworkMode networkMode) {
                        if (user.isMe()) {
                            showLeaveConfirmation(getStoreFactory().getConversationStore().getCurrentConversation());
                        } else {
                            getContainer().showRemoveConfirmation(user);
                        }
                    }

                    @Override
                    public void onNoNetwork() {
                        if (user.isMe()) {
                            ViewUtils.showAlertDialog(getActivity(), R.string.alert_dialog__no_network__header, R.string.leave_conversation_failed__message, R.string.alert_dialog__confirmation, null, true);
                        } else {
                            ViewUtils.showAlertDialog(getActivity(), R.string.alert_dialog__no_network__header, R.string.remove_from_conversation__no_network__message, R.string.alert_dialog__confirmation, null, true);
                        }
                    }
                });
            }
        }
    });
}
Also used : BaseScalaActivity(com.waz.zclient.BaseScalaActivity) OpenedGroupActionEvent(com.waz.zclient.controllers.tracking.events.group.OpenedGroupActionEvent) IConversation(com.waz.api.IConversation) FooterMenuCallback(com.waz.zclient.views.menus.FooterMenuCallback) NetworkMode(com.waz.api.NetworkMode) NetworkAction(com.waz.zclient.core.stores.network.NetworkAction)

Example 8 with FooterMenuCallback

use of com.waz.zclient.views.menus.FooterMenuCallback in project wire-android by wireapp.

the class ParticipantBodyFragment method conversationUpdated.

@Override
public void conversationUpdated(final IConversation conversation) {
    footerMenu.setVisibility(View.VISIBLE);
    if (conversation.getType() == IConversation.Type.ONE_TO_ONE) {
        footerMenu.setLeftActionText(getString(R.string.glyph__plus));
        topBorder.setVisibility(View.INVISIBLE);
        footerMenu.setRightActionText(getString(R.string.glyph__more));
        getStoreFactory().getSingleParticipantStore().setUser(conversation.getOtherParticipant());
    } else {
        imageAssetImageView.setVisibility(View.GONE);
        // Check if self user is member for group conversation
        if (conversation.isMemberOfConversation()) {
            footerMenu.setLeftActionText(getString(R.string.glyph__add_people));
            footerMenu.setRightActionText(getString(R.string.glyph__more));
            footerMenu.setLeftActionLabelText(getString(R.string.conversation__action__add_people));
        } else {
            footerMenu.setLeftActionText("");
            footerMenu.setRightActionText("");
            footerMenu.setLeftActionLabelText("");
        }
        if (lastParticipantAboveFooter()) {
            topBorder.setVisibility(View.INVISIBLE);
        } else {
            topBorder.setVisibility(View.VISIBLE);
        }
    }
    footerMenu.setCallback(new FooterMenuCallback() {

        @Override
        public void onLeftActionClicked() {
            if (userRequester == IConnectStore.UserRequester.POPOVER) {
                final User user = getStoreFactory().getSingleParticipantStore().getUser();
                if (user.isMe()) {
                    getControllerFactory().getConversationScreenController().hideParticipants(true, false);
                    // Go to conversation with this user
                    getControllerFactory().getPickUserController().hidePickUserWithoutAnimations(getContainer().getCurrentPickerDestination());
                    getStoreFactory().getConversationStore().setCurrentConversation(user.getConversation(), ConversationChangeRequester.START_CONVERSATION);
                    return;
                }
            }
            if (!conversation.isMemberOfConversation()) {
                return;
            }
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGroupActionEvent());
            getControllerFactory().getConversationScreenController().addPeopleToConversation();
        }

        @Override
        public void onRightActionClicked() {
            getStoreFactory().getNetworkStore().doIfHasInternetOrNotifyUser(new NetworkAction() {

                @Override
                public void execute(NetworkMode networkMode) {
                    if (!conversation.isMemberOfConversation()) {
                        return;
                    }
                    if (userRequester == IConnectStore.UserRequester.POPOVER) {
                        User otherUser = conversation.getOtherParticipant();
                        getContainer().toggleBlockUser(otherUser, otherUser.getConnectionStatus() != User.ConnectionStatus.BLOCKED);
                    } else {
                        getControllerFactory().getConversationScreenController().showConversationMenu(IConversationScreenController.CONVERSATION_DETAILS, conversation, null);
                    }
                }

                @Override
                public void onNoNetwork() {
                    ViewUtils.showAlertDialog(getActivity(), R.string.alert_dialog__no_network__header, R.string.leave_conversation_failed__message, R.string.alert_dialog__confirmation, null, true);
                }
            });
        }
    });
}
Also used : User(com.waz.api.User) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) OpenedGroupActionEvent(com.waz.zclient.controllers.tracking.events.group.OpenedGroupActionEvent) FooterMenuCallback(com.waz.zclient.views.menus.FooterMenuCallback) NetworkMode(com.waz.api.NetworkMode) NetworkAction(com.waz.zclient.core.stores.network.NetworkAction)

Aggregations

FooterMenuCallback (com.waz.zclient.views.menus.FooterMenuCallback)8 IConversation (com.waz.api.IConversation)4 NetworkMode (com.waz.api.NetworkMode)3 NetworkAction (com.waz.zclient.core.stores.network.NetworkAction)3 View (android.view.View)2 TextView (android.widget.TextView)2 User (com.waz.api.User)2 BaseScalaActivity (com.waz.zclient.BaseScalaActivity)2 OpenedGroupActionEvent (com.waz.zclient.controllers.tracking.events.group.OpenedGroupActionEvent)2 UserDetailsView (com.waz.zclient.ui.views.UserDetailsView)2 ImageAssetImageView (com.waz.zclient.views.images.ImageAssetImageView)2