Search in sources :

Example 6 with Analytics

use of co.krypt.krypton.analytics.Analytics in project krypton-android by kryptco.

the class EnterEmailFragment method next.

private void next() {
    Analytics analytics = new Analytics(getContext());
    String email = profileEmail.getText().toString();
    if (email == null || email.trim().equals("")) {
        analytics.postEvent("email", "skipped", null, null, false);
        email = Build.MODEL;
    } else {
        analytics.postEvent("email", "typed", null, null, false);
        email = email.trim();
    }
    analytics.publishEmailToTeamsIfNeeded(email);
    try {
        new MeStorage(getContext()).setEmail(email);
    } catch (CryptoException e) {
        e.printStackTrace();
        Error.shortToast(getContext(), "Failed to set email: " + e.getMessage());
        return;
    }
    final OnboardingProgress progress = new OnboardingProgress(getContext());
    progress.setStage(OnboardingStage.FIRST_PAIR);
    FirstPairFragment firstPairFragment = new FirstPairFragment();
    FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction();
    fragmentTransaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left).add(R.id.activity_onboarding, firstPairFragment).hide(this).show(firstPairFragment).commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) MeStorage(co.krypt.krypton.me.MeStorage) CryptoException(co.krypt.krypton.exception.CryptoException) Analytics(co.krypt.krypton.analytics.Analytics)

Example 7 with Analytics

use of co.krypt.krypton.analytics.Analytics in project krypton-android by kryptco.

the class OnboardingActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_onboarding);
    new Analytics(getApplicationContext()).postEvent("onboard", "start", null, null, false);
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    OnboardingProgress progress = new OnboardingProgress(getApplicationContext());
    GenerateFragment generateFragment;
    EnterEmailFragment enterEmailFragment;
    FirstPairFragment firstPairFragment;
    TestSSHFragment testSSHFragment;
    switch(progress.currentStage()) {
        case NONE:
            generateFragment = new GenerateFragment();
            fragmentTransaction.add(R.id.activity_onboarding, generateFragment).commit();
            break;
        case GENERATE:
            generateFragment = new GenerateFragment();
            fragmentTransaction.add(R.id.activity_onboarding, generateFragment).commit();
            break;
        case GENERATING:
            // generation must have failed, start from beginning
            generateFragment = new GenerateFragment();
            fragmentTransaction.add(R.id.activity_onboarding, generateFragment).commit();
            break;
        case ENTER_EMAIL:
            enterEmailFragment = new EnterEmailFragment();
            fragmentTransaction.add(R.id.activity_onboarding, enterEmailFragment).commit();
            break;
        case FIRST_PAIR:
            firstPairFragment = new FirstPairFragment();
            fragmentTransaction.add(R.id.activity_onboarding, firstPairFragment).commit();
            break;
        case TEST_SSH:
            Iterator<Pairing> pairings = Silo.shared(getApplicationContext()).pairings().loadAll().iterator();
            if (pairings.hasNext()) {
                testSSHFragment = TestSSHFragment.newInstance(pairings.next().workstationName);
                fragmentTransaction.add(R.id.activity_onboarding, testSSHFragment).commit();
            } else {
                // revert to FirstPair stage
                firstPairFragment = new FirstPairFragment();
                fragmentTransaction.add(R.id.activity_onboarding, firstPairFragment).commit();
            }
            break;
    }
    if (getIntent() != null) {
        onNewIntent(getIntent());
    }
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Pairing(co.krypt.krypton.pairing.Pairing) Analytics(co.krypt.krypton.analytics.Analytics)

Example 8 with Analytics

use of co.krypt.krypton.analytics.Analytics in project krypton-android by kryptco.

the class PairDialogFragment method createPairingDialog.

private Dialog createPairingDialog(final PairFragment pairFragment) {
    final Analytics analytics = new Analytics(getActivity());
    final String workstationName = pairFragment.getPendingPairingQR().workstationName;
    AlertDialog.Builder builder = new AlertDialog.Builder(getTargetFragment().getContext());
    builder.setMessage("Pair with " + workstationName + "?").setPositiveButton("Pair", new DialogInterface.OnClickListener() {

        public void onClick(final DialogInterface dialog, int id) {
            if (getTargetFragment() instanceof PairListener) {
                Runnable onPair = new Runnable() {

                    @Override
                    public void run() {
                        HashSet<Pairing> existingPairings = Silo.shared(getContext()).pairings().loadAll();
                        for (Pairing existingPairing : existingPairings) {
                            if (existingPairing.workstationName.equals(workstationName)) {
                                Silo.shared(getContext()).pairings().unpair(existingPairing);
                            }
                        }
                        final PairListener listener = (PairListener) getTargetFragment();
                        analytics.postEvent("device", "pair", "new", null, false);
                        listener.pair();
                    }
                };
                Activity activity = getActivity();
                if (activity instanceof OnboardingActivity) {
                    onPair.run();
                } else {
                    LocalAuthentication.requestAuthentication(getActivity(), "Pair Device Confirmation", "Pair with " + pairFragment.getPendingPairingQR().workstationName + "?\nThis device will be able to request SSH operations.", onPair);
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            if (getTargetFragment() instanceof PairListener) {
                final PairListener listener = (PairListener) getTargetFragment();
                analytics.postEvent("device", "pair", "reject", null, false);
                listener.cancel();
            }
        }
    });
    Dialog dialog = builder.create();
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnboardingActivity(co.krypt.krypton.onboarding.OnboardingActivity) OnboardingActivity(co.krypt.krypton.onboarding.OnboardingActivity) Activity(android.app.Activity) Analytics(co.krypt.krypton.analytics.Analytics) Dialog(android.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog)

Example 9 with Analytics

use of co.krypt.krypton.analytics.Analytics in project krypton-android by kryptco.

the class PairFragment method onPairingFailure.

private void onPairingFailure(final Pairing pairing) {
    Silo silo = Silo.shared(getContext());
    silo.unpair(pairing, false);
    pendingPairingQR.set(null);
    new Analytics(silo.context).postEvent("device", "pair", "failed", null, false);
    pairingStatusText.setText("Failed to pair with\n" + pairing.workstationName);
    pairingStatusView.setVisibility(View.VISIBLE);
    pairingStatusView.postDelayed(new Runnable() {

        @Override
        public void run() {
            pairingStatusView.setVisibility(View.INVISIBLE);
        }
    }, 2000);
}
Also used : Silo(co.krypt.krypton.silo.Silo) Analytics(co.krypt.krypton.analytics.Analytics)

Example 10 with Analytics

use of co.krypt.krypton.analytics.Analytics in project krypton-android by kryptco.

the class HelpFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_help, 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();
        }
    });
    Button pairButton = (Button) root.findViewById(R.id.pairButton);
    pairButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Activity activity = getActivity();
            if (activity != null && activity instanceof MainActivity) {
                MainActivity mainActivity = (MainActivity) activity;
                mainActivity.getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_bottom, R.anim.exit_to_bottom).hide(self).remove(self).commit();
                mainActivity.setActiveTab(MainActivity.PAIR_FRAGMENT_POSITION);
            }
        }
    });
    curlButton = root.findViewById(R.id.curlHelp);
    brewButton = root.findViewById(R.id.brewHelp);
    npmButton = root.findViewById(R.id.npmHelp);
    moreButton = root.findViewById(R.id.moreHelp);
    installCommand = root.findViewById(R.id.installCommandHelp);
    curlButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            installCommand.setText("$ curl https://krypt.co/kr | sh");
            resetButtons();
            curlButton.setTextColor(getResources().getColor(R.color.appGreen));
            new Analytics(getContext()).postEvent("help_install", "curl", null, null, false);
        }
    });
    brewButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            installCommand.setText("$ brew install kryptco/tap/kr");
            resetButtons();
            brewButton.setTextColor(getResources().getColor(R.color.appGreen));
            new Analytics(getContext()).postEvent("help_install", "brew", null, null, false);
        }
    });
    npmButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            installCommand.setText("$ npm install -g krd # mac only");
            resetButtons();
            npmButton.setTextColor(getResources().getColor(R.color.appGreen));
            new Analytics(getContext()).postEvent("help_install", "npm", null, null, false);
        }
    });
    moreButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            installCommand.setText("# go to https://krypt.co/install");
            resetButtons();
            moreButton.setTextColor(getResources().getColor(R.color.appGreen));
            new Analytics(getContext()).postEvent("help_install", "more", null, null, false);
        }
    });
    return root;
}
Also used : Button(android.widget.Button) MainActivity(co.krypt.kryptonite.MainActivity) Activity(android.app.Activity) MainActivity(co.krypt.kryptonite.MainActivity) TextView(android.widget.TextView) View(android.view.View) Fragment(android.support.v4.app.Fragment) Analytics(co.krypt.krypton.analytics.Analytics)

Aggregations

Analytics (co.krypt.krypton.analytics.Analytics)20 View (android.view.View)8 TextView (android.widget.TextView)6 Intent (android.content.Intent)5 FragmentTransaction (android.support.v4.app.FragmentTransaction)5 MeStorage (co.krypt.krypton.me.MeStorage)5 Button (android.widget.Button)4 IOException (java.io.IOException)4 SQLException (java.sql.SQLException)4 DialogInterface (android.content.DialogInterface)3 Fragment (android.support.v4.app.Fragment)3 CryptoException (co.krypt.krypton.exception.CryptoException)3 Pairing (co.krypt.krypton.pairing.Pairing)3 UnpairRequest (co.krypt.krypton.protocol.UnpairRequest)3 Activity (android.app.Activity)2 Dialog (android.app.Dialog)2 Context (android.content.Context)2 AlertDialog (android.support.v7.app.AlertDialog)2 RecyclerView (android.support.v7.widget.RecyclerView)2 ProtocolException (co.krypt.krypton.exception.ProtocolException)2