Search in sources :

Example 6 with BaseScalaActivity

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

the class PickUserFragment method onContactListContactClicked.

@Override
public void onContactListContactClicked(final ContactDetails contactDetails) {
    getStoreFactory().getNetworkStore().doIfHasInternetOrNotifyUser(new DefaultNetworkAction() {

        @Override
        public void execute(NetworkMode networkMode) {
            final int contactMethodsCount = contactDetails.getContactMethods().size();
            final ContactMethod[] contactMethods = contactDetails.getContactMethods().toArray(new ContactMethod[contactMethodsCount]);
            if (contactMethodsCount == 1 && contactMethods[0].getKind() == ContactMethod.Kind.SMS) {
                // Launch SMS app directly if contact only has phone numner
                final String number = contactMethods[0].getStringRepresentation();
                sendSMSInvite(number);
                ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGenericInviteMenuEvent(OpenedGenericInviteMenuEvent.EventContext.ADDRESSBOOK));
                return;
            }
            final CharSequence[] itemNames = new CharSequence[contactMethodsCount];
            for (int i = 0; i < contactMethodsCount; i++) {
                ContactMethod contactMethod = contactMethods[i];
                itemNames[i] = contactMethod.getStringRepresentation();
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(getResources().getString(R.string.people_picker__contact_list__invite_dialog__title)).setPositiveButton(getResources().getText(R.string.confirmation_menu__confirm_done), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    ListView lv = dialog.getListView();
                    int selected = lv.getCheckedItemPosition();
                    ContactMethod selectedContactMethod = null;
                    if (selected >= 0) {
                        selectedContactMethod = contactMethods[selected];
                    }
                    if (selectedContactMethod == null) {
                        return;
                    }
                    if (selectedContactMethod.getKind() == ContactMethod.Kind.SMS) {
                        final String number = String.valueOf(itemNames[selected]);
                        sendSMSInvite(number);
                        ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGenericInviteMenuEvent(OpenedGenericInviteMenuEvent.EventContext.ADDRESSBOOK));
                    } else {
                        selectedContactMethod.invite(" ", null);
                        Toast.makeText(getActivity(), getResources().getString(R.string.people_picker__invite__sent_feedback), Toast.LENGTH_LONG).show();
                        boolean fromSearch = TextUtils.isEmpty(getControllerFactory().getPickUserController().getSearchFilter());
                        TrackingUtils.tagSentInviteToContactEvent(((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class), selectedContactMethod.getKind(), contactDetails.hasBeenInvited(), fromSearch);
                    }
                }
            }).setNegativeButton(getResources().getText(R.string.confirmation_menu__cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            }).setSingleChoiceItems(itemNames, DEFAULT_SELECTED_INVITE_METHOD, null);
            dialog = builder.create();
            dialog.show();
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).onApplicationScreen(ApplicationScreen.SEND_PERSONAL_INVITE_MENU);
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) DialogInterface(android.content.DialogInterface) NetworkMode(com.waz.api.NetworkMode) ListView(android.widget.ListView) OpenedGenericInviteMenuEvent(com.waz.zclient.controllers.tracking.events.connect.OpenedGenericInviteMenuEvent) DefaultNetworkAction(com.waz.zclient.core.stores.network.DefaultNetworkAction) ContactMethod(com.waz.api.ContactMethod)

Example 7 with BaseScalaActivity

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

the class ParticipantFragment method showRemoveConfirmation.

//////////////////////////////////////////////////////////////////////////////////////////
//
//  UserProfileContainer
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void showRemoveConfirmation(final User user) {
    // Show confirmation dialog before removing user
    ConfirmationCallback callback = new TwoButtonConfirmationCallback() {

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
            dismissUserProfile();
            new Handler().post(new Runnable() {

                @Override
                public void run() {
                    getStoreFactory().getConversationStore().getCurrentConversation().removeMember(user);
                    ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new RemoveContactEvent(true, getParticipantsCount()));
                }
            });
        }

        @Override
        public void negativeButtonClicked() {
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new RemoveContactEvent(false, getParticipantsCount()));
        }

        @Override
        public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
        }
    };
    String header = getString(R.string.confirmation_menu__header);
    String text = getString(R.string.confirmation_menu_text_with_name, user.getDisplayName());
    String confirm = getString(R.string.confirmation_menu__confirm_remove);
    String cancel = getString(R.string.confirmation_menu__cancel);
    ConfirmationRequest request = new ConfirmationRequest.Builder().withHeader(header).withMessage(text).withPositiveButton(confirm).withNegativeButton(cancel).withConfirmationCallback(callback).withWireTheme(getControllerFactory().getThemeController().getThemeDependentOptionsTheme()).build();
    getControllerFactory().getConfirmationController().requestConfirmation(request, 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) BaseScalaActivity(com.waz.zclient.BaseScalaActivity) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) Handler(android.os.Handler) RemoveContactEvent(com.waz.zclient.controllers.tracking.events.group.RemoveContactEvent) ConfirmationRequest(com.waz.zclient.controllers.confirmation.ConfirmationRequest)

Example 8 with BaseScalaActivity

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

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

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

the class EmailInvitationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_invite__email, viewGroup, false);
    int buttonColor = getResources().getColor(R.color.text__primary_dark);
    TextView termsOfServicesTextView = ViewUtils.getView(view, R.id.tv__email_invite__terms_of_service);
    TextViewUtils.linkifyText(termsOfServicesTextView, buttonColor, false, new Runnable() {

        @Override
        public void run() {
            if (getContainer() == null || getControllerFactory() == null || getControllerFactory().isTornDown()) {
                return;
            }
            getContainer().onOpenUrlInApp(getString(R.string.url_terms_of_service), true);
            ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new ViewTOS(ViewTOS.Source.FROM_JOIN_PAGE));
        }
    });
    signUpAlternativeButton = ViewUtils.getView(view, R.id.zb__email_invite__signup_alternative);
    signUpAlternativeButton.setIsFilled(false);
    signUpAlternativeButton.setAccentColor(getResources().getColor(R.color.text__secondary_dark__40));
    if (LayoutSpec.isPhone(getActivity())) {
        signUpAlternativeButton.setText(getString(R.string.invitation_email__normal_phone_signup_button));
    } else {
        signUpAlternativeButton.setText(getString(R.string.invitation_email__normal_email_signup_button));
    }
    headerTextView = ViewUtils.getView(view, R.id.ttv_email_invite__header);
    headerTextView.setText(getResources().getString(R.string.invitation_email__welcome_header, name));
    messageTextView = ViewUtils.getView(view, R.id.ttv_email_invite__message);
    registerButton = ViewUtils.getView(view, R.id.zb__email_invite__register);
    registerButton.setIsFilled(true);
    registerButton.setAccentColor(buttonColor);
    registerButton.setEnabled(false);
    passwordEditText = ViewUtils.getView(view, R.id.tet__email_invite__password);
    passwordEditText.setHint(getResources().getString(R.string.invitation_email__password_placeholder, getResources().getInteger(R.integer.password_validator__min_password_length)));
    emailTextView = ViewUtils.getView(view, R.id.tet__email_invite__email);
    emailTextView.setText(email);
    view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            int[] buttonLocation = new int[2];
            signUpAlternativeButton.getLocationOnScreen(buttonLocation);
            int[] headerLocation = new int[2];
            headerTextView.getLocationOnScreen(headerLocation);
            if (buttonLocation[1] + signUpAlternativeButton.getHeight() > headerLocation[1]) {
                headerTextView.setVisibility(View.INVISIBLE);
                messageTextView.setVisibility(View.INVISIBLE);
            } else {
                headerTextView.setVisibility(View.VISIBLE);
                messageTextView.setVisibility(View.VISIBLE);
            }
        }
    });
    return view;
}
Also used : BaseScalaActivity(com.waz.zclient.BaseScalaActivity) ViewTOS(com.waz.zclient.core.controllers.tracking.events.registration.ViewTOS) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView)

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