Search in sources :

Example 11 with BaseScalaActivity

use of com.waz.zclient.BaseScalaActivity in project wire-android by wireapp.

the class EmailSignInFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_signin__with_email, viewGroup, false);
    guidedEditTextEmail = ViewUtils.getView(view, R.id.get__sign_in__email);
    guidedEditTextPassword = ViewUtils.getView(view, R.id.get__sign_in__password);
    resetPasswordTextView = ViewUtils.getView(view, R.id.ttv_signin_forgot_password);
    tabIndicatorLayout = ViewUtils.getView(view, R.id.til__app_entry);
    textViewGoToPhoneSignIn = ViewUtils.getView(view, R.id.ttv__new_reg__sign_in__go_to__phone);
    signInButton = ViewUtils.getView(view, R.id.pcb__signin__email);
    buttonBack = ViewUtils.getView(view, R.id.ll__activation_button__back);
    // as there is supposed to be another version of the signup screen in 12.2015
    // I am keeping the basic structure of the layouts and I am switching the elements
    // that are not visible so far
    buttonBack.setVisibility(View.GONE);
    guidedEditTextEmail.setResource(R.layout.guided_edit_text_sign_in__email);
    guidedEditTextEmail.setValidator(EmailValidator.newInstanceAcceptingEverything());
    guidedEditTextEmail.getEditText().addTextChangedListener(this);
    guidedEditTextPassword.setResource(R.layout.guided_edit_text_sign_in__password);
    guidedEditTextPassword.setValidator(PasswordValidator.instanceLegacy(getActivity()));
    guidedEditTextPassword.getEditText().addTextChangedListener(this);
    guidedEditTextPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                signIn();
                return true;
            } else {
                return false;
            }
        }
    });
    // reset password
    resetPasswordTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getContainer().onOpenUrl(getResources().getString(R.string.url_password_reset));
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new ResetPassword(ResetPassword.Location.FROM_SIGN_IN));
        }
    });
    return view;
}
Also used : KeyEvent(android.view.KeyEvent) ResetPassword(com.waz.zclient.controllers.tracking.events.profile.ResetPassword) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView)

Example 12 with BaseScalaActivity

use of com.waz.zclient.BaseScalaActivity in project wire-android by wireapp.

the class ConversationListManagerFragment method onKeepUsernameChosen.

@Override
public void onKeepUsernameChosen(String username) {
    getControllerFactory().getUsernameController().closeFirstAssignUsernameScreen();
    hideFirstAssignUsernameScreen();
    getStoreFactory().getZMessagingApiStore().getApi().getSelf().setUsername(username, new CredentialsUpdateListener() {

        @Override
        public void onUpdated() {
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new KeptGeneratedUsernameEvent(true));
        }

        @Override
        public void onUpdateFailed(int code, String message, String label) {
            Toast.makeText(getActivity(), getString(R.string.username__set__toast_error), Toast.LENGTH_SHORT).show();
            getControllerFactory().getUsernameController().logout();
            getControllerFactory().getUsernameController().setUser(getStoreFactory().getZMessagingApiStore().getApi().getSelf());
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new KeptGeneratedUsernameEvent(false));
        }
    });
}
Also used : CredentialsUpdateListener(com.waz.api.CredentialsUpdateListener) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) KeptGeneratedUsernameEvent(com.waz.zclient.core.controllers.tracking.events.onboarding.KeptGeneratedUsernameEvent)

Example 13 with BaseScalaActivity

use of com.waz.zclient.BaseScalaActivity 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 14 with BaseScalaActivity

use of com.waz.zclient.BaseScalaActivity 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)

Example 15 with BaseScalaActivity

use of com.waz.zclient.BaseScalaActivity in project wire-android by wireapp.

the class ParticipantFragment method toggleArchiveConversation.

public void toggleArchiveConversation(final IConversation conversation, final boolean archive) {
    if (getStoreFactory().getConversationStore() != null) {
        getControllerFactory().getNavigationController().setVisiblePage(Page.CONVERSATION_LIST, TAG);
        getControllerFactory().getConversationScreenController().hideParticipants(false, true);
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                if (getContainer() == null) {
                    return;
                }
                getStoreFactory().getConversationStore().archive(conversation, archive);
                if (getControllerFactory() == null || getControllerFactory().isTornDown()) {
                    return;
                }
                if (archive) {
                    ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new ArchivedConversationEvent(conversation.getType().toString()));
                } else {
                    ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new UnarchivedConversationEvent(conversation.getType().toString()));
                }
            }
        }, getResources().getInteger(R.integer.framework_animation_duration_medium));
    }
}
Also used : BaseScalaActivity(com.waz.zclient.BaseScalaActivity) Handler(android.os.Handler) UnarchivedConversationEvent(com.waz.zclient.controllers.tracking.events.conversation.UnarchivedConversationEvent) ArchivedConversationEvent(com.waz.zclient.controllers.tracking.events.conversation.ArchivedConversationEvent)

Aggregations

BaseScalaActivity (com.waz.zclient.BaseScalaActivity)16 View (android.view.View)7 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)5 TextView (android.widget.TextView)4 IConversation (com.waz.api.IConversation)4 Handler (android.os.Handler)3 NetworkMode (com.waz.api.NetworkMode)3 AddedMemberToGroupEvent (com.waz.zclient.controllers.tracking.events.group.AddedMemberToGroupEvent)3 CreatedGroupConversationEvent (com.waz.zclient.controllers.tracking.events.group.CreatedGroupConversationEvent)3 TypefaceTextView (com.waz.zclient.ui.text.TypefaceTextView)3 Nullable (android.support.annotation.Nullable)2 AbsListView (android.widget.AbsListView)2 AdapterView (android.widget.AdapterView)2 OpenedGroupActionEvent (com.waz.zclient.controllers.tracking.events.group.OpenedGroupActionEvent)2 ViewTOS (com.waz.zclient.core.controllers.tracking.events.registration.ViewTOS)2 NetworkAction (com.waz.zclient.core.stores.network.NetworkAction)2 ListActionsView (com.waz.zclient.pages.main.conversationlist.views.ListActionsView)2 SwipeListView (com.waz.zclient.pages.main.conversationlist.views.listview.SwipeListView)2 RightIndicatorView (com.waz.zclient.pages.main.conversationlist.views.row.RightIndicatorView)2 FooterMenuCallback (com.waz.zclient.views.menus.FooterMenuCallback)2