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();
}
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());
}
}
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;
}
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);
}
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;
}
Aggregations