Search in sources :

Example 1 with AdminQR

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;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) LayoutInflater(android.view.LayoutInflater) Fragment(android.support.v4.app.Fragment) AppCompatImageButton(android.support.v7.widget.AppCompatImageButton) Transitions(co.krypt.krypton.uiutils.Transitions) TeamService(co.krypt.krypton.team.TeamService) AdminQR(co.krypt.krypton.team.invite.inperson.admin.AdminQR) AppCompatTextView(android.support.v7.widget.AppCompatTextView) ViewGroup(android.view.ViewGroup) Sigchain(co.krypt.krypton.team.Sigchain) AlertDialog(android.support.v7.app.AlertDialog) EventBus(org.greenrobot.eventbus.EventBus) View(android.view.View) R(co.krypt.krypton.R) Sigchain(co.krypt.krypton.team.Sigchain) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatImageButton(android.support.v7.widget.AppCompatImageButton) AppCompatTextView(android.support.v7.widget.AppCompatTextView) View(android.view.View) TeamService(co.krypt.krypton.team.TeamService) AdminQR(co.krypt.krypton.team.invite.inperson.admin.AdminQR)

Aggregations

Context (android.content.Context)1 Bundle (android.os.Bundle)1 Fragment (android.support.v4.app.Fragment)1 AlertDialog (android.support.v7.app.AlertDialog)1 AppCompatImageButton (android.support.v7.widget.AppCompatImageButton)1 AppCompatTextView (android.support.v7.widget.AppCompatTextView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 R (co.krypt.krypton.R)1 Sigchain (co.krypt.krypton.team.Sigchain)1 TeamService (co.krypt.krypton.team.TeamService)1 AdminQR (co.krypt.krypton.team.invite.inperson.admin.AdminQR)1 Transitions (co.krypt.krypton.uiutils.Transitions)1 EventBus (org.greenrobot.eventbus.EventBus)1