Search in sources :

Example 1 with JoinTeamProgress

use of co.krypt.krypton.team.onboarding.join.JoinTeamProgress in project krypton-android by kryptco.

the class SettingsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_settings, container, false);
    Button doneButton = (Button) root.findViewById(R.id.doneButton);
    final Fragment self = this;
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            MainActivity activity = (MainActivity) getActivity();
            activity.postCurrentActivePageView();
            getActivity().getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_bottom, R.anim.exit_to_bottom).hide(self).commit();
        }
    });
    TextView versionText = (TextView) root.findViewById(R.id.versionText);
    try {
        PackageInfo packageInfo = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0);
        versionText.setText(packageInfo.versionName);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    ImageButton deleteButton = (ImageButton) root.findViewById(R.id.deleteButton);
    deleteButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            LocalAuthentication.requestAuthentication(getActivity(), "Destroy key pair permanently?", "You will have to generate a new key pair and re-add it to services like GitHub.", () -> new Thread(() -> {
                try {
                    new Analytics(getContext()).postEvent("keypair", "destroy", null, null, false);
                    EventBus.getDefault().post(new TeamService.RequestTeamOperation(Sigchain.RequestableTeamOperation.leave(), C.background(getContext())));
                    Silo.shared(getContext()).unpairAll();
                    KeyManager.deleteAllMeKeyPairs(getContext());
                    new MeStorage(getContext()).delete();
                    new JoinTeamProgress(getContext()).resetAndDeleteTeam(getContext());
                    new CreateTeamProgress(getContext()).reset();
                    startActivity(new Intent(getContext(), OnboardingActivity.class));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }).start());
        }
    });
    Button contactButton = (Button) root.findViewById(R.id.contactUsButton);
    contactButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            Uri data = Uri.parse("mailto:hello@krypt.co?subject=Krypton%20Feedback&body=");
            intent.setData(data);
            startActivity(intent);
        }
    });
    Button softwareButton = (Button) root.findViewById(R.id.softwareButton);
    softwareButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://krypt.co/app/open-source-libraries/"));
            startActivity(browserIntent);
        }
    });
    Button privacyButton = (Button) root.findViewById(R.id.privacyButton);
    privacyButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://krypt.co/app/privacy/"));
            startActivity(browserIntent);
        }
    });
    SwitchCompat disableAnalyticsSwitch = (SwitchCompat) root.findViewById(R.id.disableAnalyticsSwitch);
    disableAnalyticsSwitch.setChecked(new Analytics(getContext()).isDisabled());
    disableAnalyticsSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            new Analytics(getContext()).setAnalyticsDisabled(isChecked);
        }
    });
    SwitchCompat enableApprovedNotifications = (SwitchCompat) root.findViewById(R.id.enableAutoApproveNotificationsSwitch);
    enableApprovedNotifications.setChecked(new Settings(getContext()).approvedNotificationsEnabled());
    enableApprovedNotifications.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            new Settings(getContext()).setApprovedNotificationsEnabled(isChecked);
        }
    });
    SwitchCompat silenceNotifications = (SwitchCompat) root.findViewById(R.id.silenceNotificationsSwitch);
    silenceNotifications.setChecked(new Settings(getContext()).silenceNotifications());
    silenceNotifications.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            new Settings(getContext()).setSilenceNotifications(isChecked);
        }
    });
    ImageButton exportLogsButton = (ImageButton) root.findViewById(R.id.exportLogsButton);
    exportLogsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                String token = AuditLogContentProvider.setToken(v.getContext());
                Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.ACTION_SEND);
                sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Krypton Audit Log");
                sendIntent.setType("application/x-sqlite3");
                Uri auditLogUriWithToken = AuditLogContentProvider.getAuditLogURIWithToken();
                if (auditLogUriWithToken == null) {
                    return;
                }
                sendIntent.putExtra(Intent.EXTRA_STREAM, auditLogUriWithToken);
                startActivity(sendIntent);
            } catch (IOException e) {
                e.printStackTrace();
                Toast.makeText(v.getContext(), "Error exporting audit log: " + e.getMessage(), Toast.LENGTH_LONG).show();
            }
        }
    });
    Button editKnownHostsButton = (Button) root.findViewById(R.id.editKnownHostsButton);
    editKnownHostsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getView().setTranslationZ(0);
            FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
            KnownHostsFragment knownHostsFragment = new KnownHostsFragment();
            transaction.setCustomAnimations(R.anim.enter_from_bottom, R.anim.delayed).replace(R.id.fragmentOverlay, knownHostsFragment).commit();
            new Analytics(getActivity().getApplicationContext()).postPageView("KnownHostsEdit");
        }
    });
    return root;
}
Also used : MainActivity(co.krypt.kryptonite.MainActivity) Fragment(android.support.v4.app.Fragment) KnownHostsFragment(co.krypt.krypton.knownhosts.KnownHostsFragment) Uri(android.net.Uri) ImageButton(android.widget.ImageButton) FragmentTransaction(android.support.v4.app.FragmentTransaction) PackageManager(android.content.pm.PackageManager) ImageButton(android.widget.ImageButton) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) TextView(android.widget.TextView) PackageInfo(android.content.pm.PackageInfo) JoinTeamProgress(co.krypt.krypton.team.onboarding.join.JoinTeamProgress) Intent(android.content.Intent) IOException(java.io.IOException) View(android.view.View) TextView(android.widget.TextView) Analytics(co.krypt.krypton.analytics.Analytics) IOException(java.io.IOException) MeStorage(co.krypt.krypton.me.MeStorage) CreateTeamProgress(co.krypt.krypton.team.onboarding.create.CreateTeamProgress) KnownHostsFragment(co.krypt.krypton.knownhosts.KnownHostsFragment) CompoundButton(android.widget.CompoundButton) SwitchCompat(android.support.v7.widget.SwitchCompat)

Example 2 with JoinTeamProgress

use of co.krypt.krypton.team.onboarding.join.JoinTeamProgress in project krypton-android by kryptco.

the class IntroFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_teams_intro, container, false);
    Button createTeamButton = rootView.findViewById(R.id.createTeamOBButton);
    createTeamButton.setOnClickListener(v -> {
        new CreateTeamProgress(getContext()).reset();
        new JoinTeamProgress(getContext()).reset();
        startActivity(new Intent(v.getContext(), TeamOnboardingActivity.class));
    });
    Button joinTeamButton = rootView.findViewById(R.id.joinTeamButton);
    joinTeamButton.setOnClickListener(b -> {
        new JoinTeamProgress(getContext()).reset();
        new CreateTeamProgress(getContext()).reset();
        Transitions.beginSlide(this).replace(R.id.fragmentOverlay, new MemberScan()).addToBackStack(null).commitAllowingStateLoss();
    });
    return rootView;
}
Also used : TeamOnboardingActivity(co.krypt.krypton.team.onboarding.TeamOnboardingActivity) Button(android.widget.Button) MemberScan(co.krypt.krypton.team.invite.inperson.member.MemberScan) CreateTeamProgress(co.krypt.krypton.team.onboarding.create.CreateTeamProgress) JoinTeamProgress(co.krypt.krypton.team.onboarding.join.JoinTeamProgress) Intent(android.content.Intent) View(android.view.View)

Example 3 with JoinTeamProgress

use of co.krypt.krypton.team.onboarding.join.JoinTeamProgress in project krypton-android by kryptco.

the class MemberQR method onCreateClient.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onCreateClient(TeamService.GenerateClientResult r) {
    if (r.c.error != null) {
        Error.shortToast(getContext(), r.c.error);
        Transitions.beginFade(this).remove(this).commitAllowingStateLoss();
        return;
    }
    Sigchain.Identity identity = r.c.success;
    Sigchain.MemberQRPayload memberQRPayload = new Sigchain.MemberQRPayload(identity.email, identity.publicKey);
    Sigchain.QRPayload qrPayload = new Sigchain.QRPayload(memberQRPayload);
    try {
        BitMatrix qrData = new QRCodeWriter().encode(JSON.toJson(qrPayload), BarcodeFormat.DATA_MATRIX.QR_CODE, 500, 500);
        qr.setImageBitmap(new BarcodeEncoder().createBitmap(qrData));
        qrPayloads.set(new QRPayloads(memberQRPayload, MemberScan.lastScannedPayload.get()));
        loadQRProgress.setAlpha(0);
        joinProgress.animate().setDuration(1000).alpha(1).start();
        new JoinTeamProgress(getContext()).updateTeamData((s, d) -> {
            d.identity = identity;
            d.teamName = qrPayloads.get().admin.teamName;
            return s;
        });
    } catch (WriterException e) {
        e.printStackTrace();
        Error.shortToast(getContext(), "Error creating QRCode");
        Transitions.beginFade(this).remove(this).commitAllowingStateLoss();
        return;
    }
    EventBus.getDefault().post(new PollRead());
}
Also used : Sigchain(co.krypt.krypton.team.Sigchain) BarcodeEncoder(com.journeyapps.barcodescanner.BarcodeEncoder) JoinTeamProgress(co.krypt.krypton.team.onboarding.join.JoinTeamProgress) BitMatrix(com.google.zxing.common.BitMatrix) QRCodeWriter(com.google.zxing.qrcode.QRCodeWriter) WriterException(com.google.zxing.WriterException) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 4 with JoinTeamProgress

use of co.krypt.krypton.team.onboarding.join.JoinTeamProgress in project krypton-android by kryptco.

the class MemberVerifyEmail method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_teams_invite_inperson_member_verify_email, container, false);
    MemberQR.QRPayloads qrPayloads = MemberQR.qrPayloads.get();
    if (qrPayloads == null) {
        Error.shortToast(getContext(), "No QRcode payloads found.");
        getFragmentManager().popBackStack();
        return rootView;
    }
    Button cancelButton = rootView.findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(v -> {
        getActivity().finish();
    });
    ProgressBar progressBar = rootView.findViewById(R.id.progressBar);
    progressBar.setAlpha(0);
    Button resendButton = rootView.findViewById(R.id.resendButton);
    AppCompatTextView checkYourEmailText = rootView.findViewById(R.id.checkYourEmailText);
    AppCompatTextView checkYourEmailSubtext = rootView.findViewById(R.id.checkYourEmailSubtext);
    Runnable onSubmitUI = () -> {
        progressBar.animate().alpha(1).setDuration(1000).start();
        checkYourEmailSubtext.animate().alpha(0).setDuration(500).start();
        checkYourEmailText.animate().alpha(0).setDuration(500).start();
    };
    Runnable onSuccessUI = () -> {
        progressBar.animate().alpha(0).setDuration(500).start();
        resendButton.animate().alpha(1).setDuration(1000).start();
        resendButton.setEnabled(true);
        checkYourEmailSubtext.animate().alpha(1).setDuration(500).start();
        checkYourEmailText.animate().alpha(1).setDuration(500).start();
    };
    Runnable onErrorUI = () -> {
        Toast.makeText(getContext(), "Error sending email verification.", Toast.LENGTH_SHORT).show();
        progressBar.animate().alpha(0).setDuration(500).start();
    };
    resendButton.setAlpha(0);
    checkYourEmailSubtext.setAlpha(0);
    checkYourEmailText.setAlpha(0);
    resendButton.setEnabled(false);
    AppCompatTextView teamName = rootView.findViewById(R.id.teamName);
    teamName.setText(qrPayloads.admin.teamName);
    AppCompatTextView emailText = rootView.findViewById(R.id.profileEmail);
    emailText.setText(qrPayloads.member.email);
    Runnable requestEmailChallenge = () -> {
        onSubmitUI.run();
        new Thread(() -> {
            Log.i(TAG, "requesting email challenge...");
            try {
                final Sigchain.NativeResult<JsonObject> result = TeamDataProvider.requestEmailChallenge(getContext(), qrPayloads.member.email);
                emailText.post(() -> {
                    if (result.success != null) {
                        Log.i(TAG, "request email challenge success");
                        onSuccessUI.run();
                        new JoinTeamProgress(getContext()).updateTeamData((s, d) -> JoinStage.INPERSON_CHALLENGE_EMAIL_SENT);
                    } else {
                        Log.i(TAG, "request email challenge failure");
                        onErrorUI.run();
                        resendButton.animate().alpha(1).setDuration(1000).start();
                        resendButton.setEnabled(true);
                    }
                });
            } catch (Native.NotLinked notLinked) {
                notLinked.printStackTrace();
            }
        }).start();
    };
    resendButton.setOnClickListener(v -> {
        requestEmailChallenge.run();
    });
    requestEmailChallenge.run();
    return rootView;
}
Also used : Sigchain(co.krypt.krypton.team.Sigchain) AppCompatTextView(android.support.v7.widget.AppCompatTextView) JoinTeamProgress(co.krypt.krypton.team.onboarding.join.JoinTeamProgress) JsonObject(com.google.gson.JsonObject) AppCompatTextView(android.support.v7.widget.AppCompatTextView) View(android.view.View) Native(co.krypt.krypton.team.Native) Button(android.widget.Button) ProgressBar(android.widget.ProgressBar)

Example 5 with JoinTeamProgress

use of co.krypt.krypton.team.onboarding.join.JoinTeamProgress in project krypton-android by kryptco.

the class TeamOnboardingActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    CrashReporting.startANRReporting();
    setContentView(R.layout.fragment_teams);
    if (getIntent() != null && getIntent().getAction() != null) {
        onNewIntent(getIntent());
        return;
    }
    Fragment initialFragment = null;
    CreateTeamProgress createTeamProgress = new CreateTeamProgress(getApplicationContext());
    JoinTeamProgress joinTeamProgress = new JoinTeamProgress(getApplicationContext());
    if (createTeamProgress.inProgress()) {
        initialFragment = createTeamProgress.currentStage().getFragment();
    } else if (joinTeamProgress.inProgress()) {
        initialFragment = joinTeamProgress.currentStage().getFragment();
    } else {
        // default to create team
        initialFragment = new OnboardingCreateFragment();
    }
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_teams, initialFragment).commitAllowingStateLoss();
}
Also used : OnboardingCreateFragment(co.krypt.krypton.team.onboarding.create.OnboardingCreateFragment) CreateTeamProgress(co.krypt.krypton.team.onboarding.create.CreateTeamProgress) JoinTeamProgress(co.krypt.krypton.team.onboarding.join.JoinTeamProgress) Fragment(android.support.v4.app.Fragment) OnboardingCreateFragment(co.krypt.krypton.team.onboarding.create.OnboardingCreateFragment) OnboardingLoadTeamFragment(co.krypt.krypton.team.onboarding.create.OnboardingLoadTeamFragment)

Aggregations

JoinTeamProgress (co.krypt.krypton.team.onboarding.join.JoinTeamProgress)6 View (android.view.View)4 CreateTeamProgress (co.krypt.krypton.team.onboarding.create.CreateTeamProgress)4 Intent (android.content.Intent)3 Fragment (android.support.v4.app.Fragment)3 Button (android.widget.Button)3 Sigchain (co.krypt.krypton.team.Sigchain)3 Uri (android.net.Uri)2 Native (co.krypt.krypton.team.Native)2 OnboardingCreateFragment (co.krypt.krypton.team.onboarding.create.OnboardingCreateFragment)2 OnboardingLoadTeamFragment (co.krypt.krypton.team.onboarding.create.OnboardingLoadTeamFragment)2 MainActivity (co.krypt.kryptonite.MainActivity)2 Context (android.content.Context)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 Rect (android.graphics.Rect)1 Bundle (android.os.Bundle)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 AppCompatTextView (android.support.v7.widget.AppCompatTextView)1