Search in sources :

Example 1 with OpenedGenericInviteMenuEvent

use of com.waz.zclient.controllers.tracking.events.connect.OpenedGenericInviteMenuEvent 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 2 with OpenedGenericInviteMenuEvent

use of com.waz.zclient.controllers.tracking.events.connect.OpenedGenericInviteMenuEvent in project wire-android by wireapp.

the class PickUserFragment method sendGenericInvite.

private void sendGenericInvite(final boolean fromSearch) {
    if (getControllerFactory() == null || getControllerFactory().isTornDown() || getStoreFactory() == null || getStoreFactory().isTornDown()) {
        return;
    }
    User self = getStoreFactory().getProfileStore().getSelfUser();
    String name = self != null && self.getDisplayName() != null ? self.getDisplayName() : "";
    String username = self != null && self.getUsername() != null ? self.getUsername() : "";
    Intent sharingIntent = IntentUtils.getInviteIntent(getString(R.string.people_picker__invite__share_text__header, name), getString(R.string.people_picker__invite__share_text__body, StringUtils.formatHandle(username)));
    startActivity(Intent.createChooser(sharingIntent, getString(R.string.people_picker__invite__share_details_dialog)));
    OpenedGenericInviteMenuEvent.EventContext eventContext = fromSearch ? OpenedGenericInviteMenuEvent.EventContext.NO_RESULTS : OpenedGenericInviteMenuEvent.EventContext.BANNER;
    ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGenericInviteMenuEvent(eventContext));
    ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).onApplicationScreen(ApplicationScreen.SEND_GENERIC_INVITE_MENU);
}
Also used : SelectedTopUser(com.waz.zclient.controllers.tracking.events.connect.SelectedTopUser) User(com.waz.api.User) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) OpenedGenericInviteMenuEvent(com.waz.zclient.controllers.tracking.events.connect.OpenedGenericInviteMenuEvent) Intent(android.content.Intent)

Example 3 with OpenedGenericInviteMenuEvent

use of com.waz.zclient.controllers.tracking.events.connect.OpenedGenericInviteMenuEvent in project wire-android by wireapp.

the class RootPreferences method sendGenericInvite.

private void sendGenericInvite() {
    if (getControllerFactory() == null || getControllerFactory().isTornDown() || getStoreFactory() == null || getStoreFactory().isTornDown()) {
        return;
    }
    User self = getStoreFactory().getProfileStore().getSelfUser();
    String name = self != null && self.getDisplayName() != null ? self.getDisplayName() : "";
    String username = self != null && self.getUsername() != null ? self.getUsername() : "";
    Intent sharingIntent = IntentUtils.getInviteIntent(getString(R.string.people_picker__invite__share_text__header, name), getString(R.string.people_picker__invite__share_text__body, StringUtils.formatHandle(username)));
    startActivity(Intent.createChooser(sharingIntent, getString(R.string.people_picker__invite__share_details_dialog)));
    ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGenericInviteMenuEvent(OpenedGenericInviteMenuEvent.EventContext.SETTINGS));
    ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).onApplicationScreen(ApplicationScreen.SEND_GENERIC_INVITE_MENU);
}
Also used : User(com.waz.api.User) GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) OpenedGenericInviteMenuEvent(com.waz.zclient.controllers.tracking.events.connect.OpenedGenericInviteMenuEvent) Intent(android.content.Intent)

Aggregations

OpenedGenericInviteMenuEvent (com.waz.zclient.controllers.tracking.events.connect.OpenedGenericInviteMenuEvent)3 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)3 Intent (android.content.Intent)2 User (com.waz.api.User)2 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 ListView (android.widget.ListView)1 ContactMethod (com.waz.api.ContactMethod)1 NetworkMode (com.waz.api.NetworkMode)1 BaseScalaActivity (com.waz.zclient.BaseScalaActivity)1 SelectedTopUser (com.waz.zclient.controllers.tracking.events.connect.SelectedTopUser)1 DefaultNetworkAction (com.waz.zclient.core.stores.network.DefaultNetworkAction)1