Search in sources :

Example 11 with Analytics

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

the class KnownHostsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_known_hosts, container, false);
    adapter = new KnownHostsRecyclerViewAdapter(getActivity(), new ArrayList<KnownHost>());
    RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.knownHostsList);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapter);
    Button doneButton = (Button) root.findViewById(R.id.doneButton);
    doneButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
            SettingsFragment settingsFragment = new SettingsFragment();
            transaction.setCustomAnimations(R.anim.instant, R.anim.exit_to_bottom).replace(R.id.fragmentOverlay, settingsFragment).commit();
            new Analytics(getContext()).postPageView("About");
        }
    });
    populateHosts();
    root.setTranslationZ(1);
    return root;
}
Also used : SettingsFragment(co.krypt.krypton.settings.SettingsFragment) FragmentTransaction(android.support.v4.app.FragmentTransaction) Button(android.widget.Button) ArrayList(java.util.ArrayList) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Analytics(co.krypt.krypton.analytics.Analytics)

Example 12 with Analytics

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

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    CrashReporting.startANRReporting();
    Notifications.setupNotificationChannels(getApplicationContext());
    silo = Silo.shared(getApplicationContext());
    startService(new Intent(this, BluetoothService.class));
    OnboardingProgress progress = new OnboardingProgress(getApplicationContext());
    if (new MeStorage(getApplicationContext()).load() == null || progress.inProgress()) {
        startActivity(new Intent(this, OnboardingActivity.class));
        finish();
        return;
    }
    if (ConnectionResult.SUCCESS != GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(getApplicationContext())) {
    // TODO: warn about no push notifications, prompt to install google play services
    }
    setContentView(R.layout.activity_main);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setOffscreenPageLimit(4);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    ImageButton settingsButton = (ImageButton) findViewById(R.id.settingsButton);
    settingsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            SettingsFragment settingsFragment = new SettingsFragment();
            transaction.setCustomAnimations(R.anim.enter_from_bottom, R.anim.exit_to_bottom, R.anim.enter_from_bottom, R.anim.exit_to_bottom).addToBackStack(null).replace(R.id.fragmentOverlay, settingsFragment).commit();
            new Analytics(getApplicationContext()).postPageView("About");
        }
    });
    ImageButton infoButton = (ImageButton) findViewById(R.id.infoButton);
    infoButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            HelpFragment helpFragment = new HelpFragment();
            transaction.setCustomAnimations(R.anim.enter_from_bottom, R.anim.exit_to_bottom, R.anim.enter_from_bottom, R.anim.exit_to_bottom).addToBackStack(null).replace(R.id.fragmentOverlay, helpFragment).commit();
            new Analytics(getApplicationContext()).postPageView("Help");
        }
    });
    if (getIntent() != null) {
        onNewIntent(getIntent());
    }
}
Also used : OnboardingActivity(co.krypt.krypton.onboarding.OnboardingActivity) TeamOnboardingActivity(co.krypt.krypton.team.onboarding.TeamOnboardingActivity) Intent(android.content.Intent) HelpFragment(co.krypt.krypton.help.HelpFragment) View(android.view.View) Analytics(co.krypt.krypton.analytics.Analytics) SettingsFragment(co.krypt.krypton.settings.SettingsFragment) ImageButton(android.widget.ImageButton) BluetoothService(co.krypt.krypton.transport.BluetoothService) FragmentTransaction(android.support.v4.app.FragmentTransaction) TabLayout(android.support.design.widget.TabLayout) MeStorage(co.krypt.krypton.me.MeStorage) OnboardingProgress(co.krypt.krypton.onboarding.OnboardingProgress)

Example 13 with Analytics

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

the class MeFragment method onEmailChanged.

private void onEmailChanged(String email) {
    Profile me = Silo.shared(getContext()).meStorage().load();
    if (me == null) {
        me = new Profile(email, null, null, null);
    }
    me.email = email;
    Silo.shared(getContext()).meStorage().set(me);
    new Analytics(getContext()).publishEmailToTeamsIfNeeded(email);
}
Also used : Profile(co.krypt.krypton.protocol.Profile) Analytics(co.krypt.krypton.analytics.Analytics)

Example 14 with Analytics

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

the class FirstPairFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getChildFragmentManager().beginTransaction().add(R.id.pairLayout, pairFragment).commit();
    View root = inflater.inflate(R.layout.fragment_first_pair, container, false);
    Button nextButton = (Button) root.findViewById(R.id.nextButton);
    nextButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            skip();
        }
    });
    curlButton = root.findViewById(R.id.curlButton);
    brewButton = root.findViewById(R.id.brewButton);
    npmButton = root.findViewById(R.id.npmButton);
    moreButton = root.findViewById(R.id.moreButton);
    installCommand = root.findViewById(R.id.installCommand);
    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("onboard_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("onboard_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("onboard_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("onboard_install", "more", null, null, false);
        }
    });
    return root;
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) View(android.view.View) Analytics(co.krypt.krypton.analytics.Analytics)

Example 15 with Analytics

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

the class GenerateFragment method next.

private void next() {
    KeyType keyType = null;
    if (keyTypeButton.getText().equals(getString(R.string.ed25519_key_type))) {
        keyType = KeyType.Ed25519;
    } else if (keyTypeButton.getText().equals(getString(R.string.rsa_key_type))) {
        keyType = KeyType.RSA;
    } else {
        keyType = KeyType.RSA;
    }
    final KeyType finalKeyType = keyType;
    final FragmentActivity context = getActivity();
    final OnboardingProgress progress = new OnboardingProgress(getContext());
    progress.setStage(OnboardingStage.GENERATING);
    new Analytics(context).postEvent("onboard", "generate tapped", null, null, false);
    final long startMillis = System.currentTimeMillis();
    final GeneratingFragment generatingFragment = new GeneratingFragment();
    getActivity().getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left).replace(R.id.activity_onboarding, generatingFragment).commit();
    final Fragment self = this;
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                final long start = System.currentTimeMillis();
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                SSHKeyPairI pair = KeyManager.loadOrGenerateKeyPair(context, finalKeyType, KeyManager.ME_TAG);
                new MeStorage(context).set(new Profile("", pair.publicKeySSHWireFormat(), null, null));
                final long genTime = System.currentTimeMillis() - start;
                new Analytics(context).postEvent("keypair", "generate", null, (int) (genTime / 1000), false);
                if (genTime < 5000) {
                    try {
                        Thread.sleep(5000 - genTime);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                generatingFragment.onGenerate();
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                progress.setStage(OnboardingStage.ENTER_EMAIL);
                EnterEmailFragment enterEmailFragment = new EnterEmailFragment();
                final FragmentActivity activity = context;
                if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
                    activity.getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left).hide(generatingFragment).add(R.id.activity_onboarding, enterEmailFragment).show(enterEmailFragment).commitAllowingStateLoss();
                }
            } catch (InvalidKeyException | IOException | CryptoException | UnsupportedOperationException | IllegalArgumentException e) {
                e.printStackTrace();
                progress.reset();
                final FragmentActivity activity = context;
                if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) {
                    GenerateFragment generateFragment = new GenerateFragment();
                    if (finalKeyType == KeyType.RSA) {
                        Bundle args = new Bundle();
                        args.putString(DEFAULT_KEY_TYPE_KEY, activity.getString(R.string.ed25519_key_type));
                        generateFragment.setArguments(args);
                        activity.runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                Toast.makeText(activity, "Error generating rsa key, try again to generate an ed25519 key.", Toast.LENGTH_LONG).show();
                            }
                        });
                    }
                    activity.getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left).replace(R.id.activity_onboarding, generateFragment).commitAllowingStateLoss();
                }
            }
        }
    }).start();
}
Also used : KeyType(co.krypt.krypton.crypto.KeyType) Bundle(android.os.Bundle) SSHKeyPairI(co.krypt.krypton.crypto.SSHKeyPairI) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException) Fragment(android.support.v4.app.Fragment) Analytics(co.krypt.krypton.analytics.Analytics) Profile(co.krypt.krypton.protocol.Profile) FragmentActivity(android.support.v4.app.FragmentActivity) MeStorage(co.krypt.krypton.me.MeStorage) CryptoException(co.krypt.krypton.exception.CryptoException)

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