private void NavigateToReader(ReaderFragment readerFragment) { var readerTransaction = Activity.SupportFragmentManager.BeginTransaction(); readerTransaction.SetCustomAnimations(Resource.Animation.abc_slide_in_top, Resource.Animation.abc_fade_out); readerTransaction.Replace(Resource.Id.fragment_container, readerFragment, "Reader"); readerTransaction.Commit(); }
private async void LoginOK_Click(object sender, EventArgs e) { var passwordBytes = Sodium.GenericHash.Hash(userPassword.Text, deviceId, 32); var keyPair = Sodium.PublicKeyBox.GenerateKeyPair(passwordBytes); if (string.IsNullOrWhiteSpace(publicKey)) { // No Public Key Present - Store await encryptionService.SetPublicKey(Convert.ToBase64String(keyPair.PublicKey)); await encryptionService.SetPassword(userPassword.Text); Toast.MakeText(Activity, "Encryption Keys Generated", ToastLength.Long).Show(); NavigateToWelcome(); } else { // Public Key Present - Generate and Check var generatedPublicKeyBase64 = Convert.ToBase64String(keyPair.PublicKey); if (publicKey.Equals(generatedPublicKeyBase64)) { await encryptionService.SetPassword(userPassword.Text); Toast.MakeText(Activity, "Login Successful", ToastLength.Long).Show(); if (string.IsNullOrEmpty(incomingSMSContent)) { NavigateToWelcome(); } else { var readerFragment = new ReaderFragment(incomingSMSContent); NavigateToReader(readerFragment); } } else { // TODO: Display Failure Alert var builder = new AlertDialog.Builder(Activity); builder.SetTitle("Login Failure"); builder.SetMessage("Incorrect password/passphrase - please try again."); builder.SetPositiveButton("OK", (s, e) => { builder.Dispose(); }); var dialog = builder.Create(); dialog.Show(); } } }