use of co.krypt.krypton.team.onboarding.create.CreateTeamProgress 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;
}
use of co.krypt.krypton.team.onboarding.create.CreateTeamProgress 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;
}
use of co.krypt.krypton.team.onboarding.create.CreateTeamProgress 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();
}
use of co.krypt.krypton.team.onboarding.create.CreateTeamProgress in project krypton-android by kryptco.
the class TeamOnboardingActivity method onNewIntent.
@Override
protected void onNewIntent(Intent intent) {
try {
if (TeamDataProvider.getTeamHomeData(this).success != null) {
Toast.makeText(getApplicationContext(), "You must leave your current team before joining another.", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
}
} catch (Native.NotLinked notLinked) {
notLinked.printStackTrace();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
return;
}
if (intent.getAction() != null && intent.getAction().equals("android.intent.action.VIEW") && intent.getData() != null) {
Uri data = intent.getData();
if ((data.getScheme().equals("krypton") && data.getHost().equals("verify_email")) || (data.getScheme().equals("https") && data.getHost().equals("krypt.co") && data.getPath().equals("/app/verify_email.html"))) {
final String nonce;
// Handle https:// link
String queryParam = data.getQueryParameter("nonce");
if (queryParam != null) {
nonce = queryParam;
} else {
// Handle krypton:// link
nonce = data.getLastPathSegment();
}
Log.i(TAG, "received VERIFY_EMAIL intent");
CreateTeamProgress createTeamProgress = new CreateTeamProgress(this);
JoinTeamProgress joinTeamProgress = new JoinTeamProgress(this);
if (createTeamProgress.inProgress()) {
createTeamProgress.updateTeamData((s, d) -> {
d.emailChallengeNonce = nonce;
return CreateStage.LOAD_TEAM;
});
getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_right, R.anim.exit_to_left).replace(R.id.fragment_teams, new OnboardingLoadTeamFragment()).commitAllowingStateLoss();
} else if (joinTeamProgress.inProgress()) {
joinTeamProgress.updateTeamData((s, d) -> {
d.emailChallengeNonce = nonce;
if (s.equals(JoinStage.CHALLENGE_EMAIL_SENT)) {
return s;
} else if (s.equals(JoinStage.INPERSON_CHALLENGE_EMAIL_SENT)) {
return s;
} else if (s.equals(JoinStage.VERIFY_EMAIL)) {
// Allows clicking on an old verification link before sending a new challenge in case email is rate limited
return JoinStage.CHALLENGE_EMAIL_SENT;
}
return JoinStage.NONE;
});
getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_right, R.anim.exit_to_left).replace(R.id.fragment_teams, joinTeamProgress.currentStage().getFragment()).commitAllowingStateLoss();
} else {
Toast.makeText(getApplicationContext(), "Begin joining a team before verifying your email.", Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
return;
}
} else if (data.getScheme().equals("krypton") && data.getHost().equals("join_team")) {
Log.i(TAG, "received JOIN_TEAM intent");
new CreateTeamProgress(this).reset();
JoinTeamProgress progress = new JoinTeamProgress(getApplicationContext());
progress.updateTeamData((s, d) -> {
try {
Sigchain.NativeResult<Sigchain.TeamHomeData> teamData = TeamDataProvider.getTeamHomeData(getApplicationContext());
if (s.equals(JoinStage.NONE)) {
s = JoinStage.DECRYPT_INVITE;
d.inviteLink = data.toString();
} else {
// continue current onboarding
}
} catch (Native.NotLinked notLinked) {
notLinked.printStackTrace();
return s;
}
Profile me = Silo.shared(getBaseContext()).meStorage().load();
if (me == null) {
Toast.makeText(getApplicationContext(), "Welcome to Krypton! Let's generate your key pair before joining the team.", Toast.LENGTH_LONG).show();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
return s;
}
getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_right, R.anim.exit_to_left).replace(R.id.fragment_teams, s.getFragment()).commitAllowingStateLoss();
return s;
});
}
}
}
Aggregations