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);
}
});
}
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();
}
}
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();
}
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()));
}
}
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;
}
Aggregations