public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == Constants.Scan_Public_Key_Request_Code)
            {
                // Ensure Dialog is removed from backstack etc
                var prev = ParentFragmentManager.FindFragmentByTag("scanContactDialog");
                if (prev != null)
                {
                    var fragmentTransaction = ParentFragmentManager.BeginTransaction();
                    fragmentTransaction.Remove(prev);
                    fragmentTransaction.Commit();
                }

                if (resultCode == Constants.Successful_Public_Key_Scan)
                {
                    // Pull Data elements and pass to Add Contact Dialog
                    var contactId = data.GetStringExtra("contactId");
                    var publicKey = data.GetStringExtra("publicKey");

                    OpenAddContactDialog(contactId, publicKey);
                }
                else if (resultCode == Constants.Unsuccessful_Public_Key_Scan)
                {
                    Activity.RunOnUiThread(() => Toast.MakeText(Activity, "Invalid Barcode - Please try again!", ToastLength.Long).Show());
                }
                else
                {
                    Activity.RunOnUiThread(() => Toast.MakeText(Activity, "Hmmm - something weird just happened, please try again!", ToastLength.Long).Show());
                }
            }
        }
Beispiel #2
0
 private void GsPhoneEt_Click(object sender, EventArgs e)
 {
     ParentFragmentManager.BeginTransaction()
     .AddSharedElement(phoneEt, "phone_et")
     .AddToBackStack(TAG)
     .Replace(Resource.Id.frag_container, new EnterPhoneFragment())
     .CommitAllowingStateLoss();
 }
 private void GotoProfile()
 {
     SetStatus("create_profile");
     OnboardingActivity.DismissLoader();
     ParentFragmentManager.BeginTransaction()
     .Replace(Resource.Id.frag_container, new CreateProfileFragment())
     .CommitAllowingStateLoss();
 }
Beispiel #4
0
 private void InputClicked()
 {
     using (var transaction = ParentFragmentManager.BeginTransaction())
     {
         transaction.SetStatusBarTitle("Send input");
         transaction.ReplaceContentAnimated(new SendInputFragment().WithAgent(this));
         transaction.Commit();
     }
 }
Beispiel #5
0
 private void CursorControlClicked()
 {
     using (var transaction = ParentFragmentManager.BeginTransaction())
     {
         transaction.SetStatusBarTitle("Mouse control");
         transaction.ReplaceContentAnimated(new MouseInputFragment().WithAgent(this));
         transaction.Commit();
     }
 }
Beispiel #6
0
 private void KillProcessOnClick(object sender, EventArgs e)
 {
     using (var fragmentTransaction = ParentFragmentManager.BeginTransaction())
     {
         fragmentTransaction.ReplaceContentAnimated(new KillProcessFragment().WithAgent(this));
         fragmentTransaction.SetStatusBarTitle("Processes");
         fragmentTransaction.Commit();
     }
 }
Beispiel #7
0
 private void BrowserVideoPlayerClicked()
 {
     using (var transaction = ParentFragmentManager.BeginTransaction())
     {
         transaction.SetStatusBarTitle("Video player");
         transaction.ReplaceContentAnimated(new BrowserVideoPlayerFragment().WithAgent(this));
         transaction.Commit();
     }
 }
Beispiel #8
0
 private void ClipboardClicked()
 {
     using (var transaction = ParentFragmentManager.BeginTransaction())
     {
         transaction.SetStatusBarTitle("Clipboard");
         transaction.ReplaceContentAnimated(new ClipboardFragment().WithAgent(this));
         transaction.Commit();
     }
 }
Beispiel #9
0
 private void StartProgramOnClick(object sender, EventArgs e)
 {
     using (var fragmentTransaction = ParentFragmentManager.BeginTransaction())
     {
         fragmentTransaction.ReplaceContentAnimated(new LaunchProgramFragment().WithAgent(this));
         fragmentTransaction.SetStatusBarTitle("Launch program");
         fragmentTransaction.Commit();
     }
 }
        private void DobEditText_Click(object sender, EventArgs e)
        {
            var datePicker = new DatePickerDialog();

            datePicker.OnDatePicked += DatePicker_OnDatePicked;
            var ft = ParentFragmentManager.BeginTransaction();

            ft.Add(datePicker, "date_picker");
            ft.CommitAllowingStateLoss();
        }
Beispiel #11
0
        private async void AudioClicked()
        {
            if (!await IsAuthorizedAsync())
            {
                return;
            }

            using (var transaction = ParentFragmentManager.BeginTransaction())
            {
                transaction.SetStatusBarTitle("Audio");
                transaction.ReplaceContentAnimated(new AudioFragment().WithAgent(this));
                transaction.Commit();
            }
        }
Beispiel #12
0
        private void NextBtn_Click(object sender, System.EventArgs e)
        {
            nextBtn.Post(() =>
            {
                var extras = new Bundle();
                var phone  = dialcodeTv.Text + phoneEt.EditText.Text;
                extras.PutString(phoneKey, phone);
                smsFragment.Arguments = extras;

                ParentFragmentManager.BeginTransaction()
                .AddToBackStack(null)
                .Replace(Resource.Id.frag_container, smsFragment)
                .CommitAllowingStateLoss();
            });
        }
Beispiel #13
0
        private async void SharePublicKey_Click(object sender, EventArgs e)
        {
            var fragmentTransaction = ParentFragmentManager.BeginTransaction();

            // Remove fragment else it will crash as it is already added to backstack
            var prev = ParentFragmentManager.FindFragmentByTag("publicKeyDialog");

            if (prev != null)
            {
                fragmentTransaction.Remove(prev);
            }

            fragmentTransaction.AddToBackStack(null);

            // Create and show the dialog
            var newFragment = new SharePublicKeyDialogFragment(await encryptionService.GetQRCodeContent());

            //Add fragment
            newFragment.Show(fragmentTransaction, "publicKeyDialog");
        }
Beispiel #14
0
        private void AddElements(List <ButtonElement> list, IEnumerable <ProcessListResponseItem> filtered)
        {
            foreach (var item in filtered.OrderBy(d => d.ProcessName))
            {
                var buttonElement = new ButtonElement();
                buttonElement.Clickable    = true;
                buttonElement.ButtonText   = item.ProcessName;
                buttonElement.ButtonAction = () =>
                {
                    using (var transaction = ParentFragmentManager.BeginTransaction())
                    {
                        transaction.ReplaceContentAnimated(new KillProcessByIdFragment(item.ProcessName).WithAgent(this));
                        transaction.SetStatusBarTitle($"Process: {item.ProcessName}");
                        transaction.Commit();
                    }
                };

                list.Add(buttonElement);
            }
        }
        private void OpenScanner()
        {
            // TODO: If scan is valid, open 'Add New Contact' Fragment
            var fragmentTransaction = ParentFragmentManager.BeginTransaction();

            // Remove fragment else it will crash as it is already added to backstack
            var prev = ParentFragmentManager.FindFragmentByTag("scanContactDialog");

            if (prev != null)
            {
                fragmentTransaction.Remove(prev);
            }

            // Create and show the dialog
            var newFragment = new ScanPublicKeyDialogFragment();

            newFragment.SetTargetFragment(this, Constants.Scan_Public_Key_Request_Code);

            //Add fragment
            newFragment.Show(fragmentTransaction, "scanContactDialog");
        }
        private void OpenAddContactDialog(string contactId, string publicKey)
        {
            var fragmentTransaction = ParentFragmentManager.BeginTransaction();

            // Remove fragment else it will crash as it is already added to backstack
            var prev = ParentFragmentManager.FindFragmentByTag("addContactDialog");

            if (prev != null)
            {
                fragmentTransaction.Remove(prev);
            }

            // Create and show the dialog
            var newFragment = new AddContactDialogFragment();
            var dataBundle  = new Bundle();

            dataBundle.PutString("contactId", contactId);
            dataBundle.PutString("publicKey", publicKey);

            newFragment.Arguments = dataBundle;

            // Add fragment
            newFragment.Show(fragmentTransaction, "addContactDialog");
        }
        private async void SaveToDb()
        {
            try
            {
                var profileRef = SessionManager.GetFireDB().GetReference($"users/{SessionManager.UserId}/profile");
                var userMap    = new HashMap();
                var stream     = new System.IO.MemoryStream();
                var bitmap     = MediaStore.Images.Media.GetBitmap(Context.ContentResolver, img_uri);
                await bitmap.CompressAsync(Bitmap.CompressFormat.Webp, 90, stream);

                var imgArray = stream.ToArray();

                var imageRef = FirebaseStorage.Instance.GetReference($"profileImages/{SessionManager.UserId}");
                imageRef.PutBytes(imgArray).ContinueWithTask(new ContinuationTask(
                                                                 then: t =>
                {
                    if (!t.IsSuccessful)
                    {
                        throw t.Exception;
                    }
                })).AddOnCompleteListener(new OncompleteListener(
                                              onComplete: t =>
                {
                    if (!t.IsSuccessful)
                    {
                        throw t.Exception;
                    }

                    userMap.Put(Constants.SNAPSHOT_FNAME, fullnameEt.EditText.Text);
                    userMap.Put(Constants.SNAPSHOT_EMAIL, emailEt.EditText.Text);
                    userMap.Put(Constants.SNAPSHOT_GENDER, (int)userGender);
                    userMap.Put(Constants.SNAPSHOT_PHONE, SessionManager.GetFirebaseAuth().CurrentUser.PhoneNumber);
                    userMap.Put(Constants.SNAPSHOT_PHOTO_URL, t.Result.ToString());
                    profileRef.SetValue(userMap).AddOnCompleteListener(new OncompleteListener(
                                                                           onComplete: task =>
                    {
                        try
                        {
                            if (!task.IsSuccessful)
                            {
                                throw task.Exception;
                            }

                            GetSmsFragment.SetStatus("set_partner");
                            ParentFragmentManager.BeginTransaction()
                            .Replace(Resource.Id.frag_container, new PartnerFragment())
                            .CommitAllowingStateLoss();
                        }
                        catch (DatabaseException de)
                        {
                            OnboardingActivity.ShowError("Database Exception", de.Message);
                        }
                    }));
                    profileRef.KeepSynced(true);
                }));
            }
            catch (DatabaseException fde)
            {
                OnboardingActivity.ShowError("Database Exception", fde.Message);
            }
            catch (FirebaseNetworkException)
            {
                OnboardingActivity.ShowNoNetDialog(false);
            }
            catch (StorageException se)
            {
                OnboardingActivity.ShowError("Storage Exception", se.Message);
            }
            catch (Exception ex)
            {
                OnboardingActivity.ShowError("Exception", ex.Message);
            }
        }