public static CommunicationManger GetInstance()
        {
            if (instance == null)
            {
                instance = new CommunicationManger();
            }

            return(instance);
        }
        private void GetPassword(int id)
        {
            Response res = CommunicationManger.GetInstance().RequestGetPassword(id);

            if (res.Success)
            {
                FragmentTransaction     transaction     = FragmentManager.BeginTransaction();
                PasswordDisplayFragment displayFragment = new PasswordDisplayFragment(res.Name, res.Password);

                displayFragment.Show(transaction, "password display");
            }
            else
            {
                this.RunOnUiThread(
                    () => { Toast.MakeText(this, "Could not get password\n" + res.ErrorMsg, ToastLength.Long).Show(); });
            }
        }
        private void DeletePassword(object sender, ConfirmDeleteEventArgs confirmDeleteEventArgs)
        {
            new Thread(() =>
            {
                Response res = CommunicationManger.GetInstance().RequestDeletePassword(confirmDeleteEventArgs.passID);

                if (res.Success)
                {
                    items.Remove(items.Find(x => x.ID == confirmDeleteEventArgs.passID));
                }
                else
                {
                    this.RunOnUiThread(
                        () => { Toast.MakeText(this, "Could not delete password\n" + res.ErrorMsg, ToastLength.Long).Show(); });
                }
            }).Start();
        }
Beispiel #4
0
        private void OkBtnOnClick(object sender, EventArgs eventArgs)
        {
            var commManager = CommunicationManger.GetInstance();

            if (commManager.Connected)
            {
                if (commManager.StartAuthorize(passwordBox.Text))
                {
                    Intent intent = new Intent(this, typeof(ItemsSelectionActivity));
                    this.StartActivity(intent);
                }
                else
                {
                    Toast.MakeText(this, "Connection refused", ToastLength.Long).Show();
                    Finish();
                }
            }
        }
        private void UpdatePassword(object sender, EntryDataPasswordEventArgs updatePasswordEventArgs)
        {
            new Thread(() =>
            {
                Response res = CommunicationManger.GetInstance()
                               .RequestUpdatePassword(updatePasswordEventArgs.ID, updatePasswordEventArgs.Name,
                                                      updatePasswordEventArgs.Pass);

                if (res.Success)
                {
                    int i    = items.FindIndex(x => x.ID == res.ID);
                    items[i] = new PasswordEntry(res.ID, updatePasswordEventArgs.Name);
                }
                else
                {
                    this.RunOnUiThread(
                        () => { Toast.MakeText(this, "Could not update password\n" + res.ErrorMsg, ToastLength.Long).Show(); });
                }
            }).Start();
        }
        private void AddPassword(object sender, EntryDataPasswordEventArgs addPasswordEventArgs)
        {
            new Thread(() =>
            {
                Response res = CommunicationManger.GetInstance()
                               .RequestAddPassword(addPasswordEventArgs.Name, addPasswordEventArgs.Pass);

                if (res.Success)
                {
                    items.Add(new PasswordEntry(res.ID, addPasswordEventArgs.Name));
                }
                else
                {
                    this.RunOnUiThread(
                        () =>
                    {
                        Toast.MakeText(this, "Could not add password\n" + res.ErrorMsg, ToastLength.Long).Show();
                    });
                }
            }).Start();
        }
Beispiel #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            ClipboardInterface.GetInstance().SetClipboardManager((ClipboardManager)GetSystemService(Context.ClipboardService));

            commManager = CommunicationManger.GetInstance();

            txtState    = FindViewById <TextView>(Resource.Id.txtState);
            progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar1);
            var searchBtn = FindViewById <Button>(Resource.Id.searchBtn);

            txtState.Text          = "Searching for server";
            txtState.Visibility    = ViewStates.Gone;
            progressBar.Visibility = ViewStates.Gone;

            searchBtn.Click += (sender, args) => SearchServer(30);
            onSearchEnd     += SearchEnded;

            if (!commManager.IsBluetoothExists())
            {
                Console.WriteLine("finished");
                Toast.MakeText(this, "No bluetooth adapter found", ToastLength.Long);
                Finish();
                return;
            }

            if (!commManager.IsBluetoothOn())
            {
                Intent enableIntent = new Intent(BluetoothAdapter.ActionRequestEnable);
                StartActivityForResult(enableIntent, 2);
            }

            Console.WriteLine("finished setup");
        }