use of co.krypt.krypton.team.invite.inperson.admin.AdminQR in project krypton-android by kryptco.
the class CreateInviteDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_teams_invite_modal, container, false);
String myEmail = getArguments().getString("myEmail");
// TODO: filter on common email endings and hide team link in that case
String[] emailToks = myEmail.split("@");
AppCompatImageButton teamLinkButton = rootView.findViewById(R.id.teamLinkButton);
if (emailToks.length == 2) {
String domain = emailToks[1];
AppCompatTextView teamLinkDetail = rootView.findViewById(R.id.teamEmailLinkDetail);
teamLinkDetail.setText("Anyone with an @" + domain + " email address");
teamLinkButton.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("Create a team-only invite link?").setMessage("This will create a secret invite link that can only be used by people with an @" + domain + " email address.").setPositiveButton("Yes", (dialog, which) -> {
Sigchain.RequestableTeamOperation request = new Sigchain.RequestableTeamOperation(new Sigchain.IndirectInvitationRestriction(domain));
EventBus.getDefault().post(new TeamService.RequestTeamOperation(request, TeamService.C.withStatusCallback(getActivity(), this::onCreateInvite)));
getFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
}).setNegativeButton("No", (dialog, which) -> {
getFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
}).show();
});
} else {
// TODO: hide teamLinkButton if no domain on email or user has a common domain like gmail
}
AppCompatImageButton individualLinkButton = rootView.findViewById(R.id.individualsLinkButton);
individualLinkButton.setOnClickListener(v -> {
getFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right).replace(R.id.fragmentOverlay, SelectIndividualsFragment.newInstance()).addToBackStack(null).commitAllowingStateLoss();
});
AppCompatImageButton inpersonButton = rootView.findViewById(R.id.inPersonButton);
inpersonButton.setOnClickListener(v -> {
Transitions.beginFade(this).replace(R.id.fragmentOverlay, new AdminQR()).addToBackStack(null).commitAllowingStateLoss();
});
return rootView;
}
Aggregations