private bool Delete()
        {
            bool local    = DataController.Instance().DeleteFromLocalDatabase();
            bool notlocal = DataController.Instance().DeleteFromDatabase();

            return(local && notlocal);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.RegisterCamera);

            //ImageButton menu = FindViewById<ImageButton>(Resource.Id.Menu);
            imageview    = FindViewById <ImageView>(Resource.Id.ImageView);
            layout       = FindViewById <RelativeLayout>(Resource.Id.layout);
            changeCamera = FindViewById <ImageButton>(Resource.Id.ChangeCamera);
            takePhoto    = FindViewById <ImageButton>(Resource.Id.TakePhoto);
            declinePhoto = FindViewById <ImageButton>(Resource.Id.DeclinePhoto);
            confirmPhoto = FindViewById <ImageButton>(Resource.Id.ConfirmPhoto);
            person       = DataController.Instance().currentPerson;
            //menu.Click += OpenMenu; <--- for now, let's stay without menu for Register Camera
            changeCamera.Click += ChangeCameraFacing;
            takePhoto.Click    += TakePhoto;
            declinePhoto.Click += DeclinePhoto;
            confirmPhoto.Click += ConfirmPhoto;


            // vvv hide the unwanted buttons
            declinePhoto.Visibility = ViewStates.Gone;
            confirmPhoto.Visibility = ViewStates.Gone;


            preview        = FindViewById <CameraSourcePreview>(Resource.Id.preview);
            graphicOverlay = FindViewById <GraphicOverlay>(Resource.Id.faceOverlay);

            CreateCameraSource(CameraFacing.Back);
        }
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     if ((requestCode == PickImageId) && (resultCode == Result.Ok) && (data != null))
     {
         Android.Net.Uri uri = data.Data;
         profileImage.SetImageURI(uri);
         byte[] picture = convertImageToByte(uri);
         DataController.Instance().UpdateLocalDatabase(picture);
         DataController.Instance().UpdateDatabase(picture);
     }
 }
Exemple #4
0
        public void checkIfTouching()
        {
            touching = DataController.Instance().getTouching();
            if (touching == true)
            {
                x = DataController.Instance().getX();
                y = DataController.Instance().getY();

                if (x > left && x < right && y > top && y < bottom)
                {
                    DataController.Instance().openProfile = true;
                }

                touching = false;
            }
        }
Exemple #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Camera);

            ImageButton menu         = FindViewById <ImageButton>(Resource.Id.Menu);
            ImageButton changeCamera = FindViewById <ImageButton>(Resource.Id.ChangeCamera);

            imageview      = FindViewById <ImageView>(Resource.Id.ImageViewCamera);
            layout         = FindViewById <RelativeLayout>(Resource.Id.layoutcamera);
            preview        = FindViewById <CameraSourcePreview>(Resource.Id.preview);
            graphicOverlay = FindViewById <GraphicOverlay>(Resource.Id.faceOverlay);
            loadingView    = FindViewById <TextView>(Resource.Id.Loading);
            person         = DataController.Instance().currentPerson;

            loadingView.Visibility = ViewStates.Gone;

            imageview.Visibility = ViewStates.Invisible;

            menu.Click += delegate(object sender, EventArgs e)
            {
                Intent i = new Intent(this, typeof(MenuActivity));
                StartActivity(i);
            };

            changeCamera.Click += delegate(object sender, EventArgs e)
            {
                if (cameraSource != null)
                {
                    cameraSource.Release();
                    if (cameraSource.CameraFacing == CameraFacing.Back)
                    {
                        CreateCameraSource(CameraFacing.Front);
                    }
                    else
                    {
                        CreateCameraSource(CameraFacing.Back);
                    }
                    StartCameraSource();
                }
            };

            CreateCameraSource(CameraFacing.Back);

            DataController.Instance().openProfile = false;
            graphicOverlay.SetOnTouchListener(this);
        }
Exemple #6
0
        public void OnPictureTaken(byte[] data)
        {
            DataController.Instance().openProfile = false;

            Android.Graphics.Bitmap bm = ImageController.ByteArrayToBitmap(data);
            imageview.SetImageBitmap(bm);
            bm = ImageController.LoadBitmapFromView(imageview);
            bm = ImageController.ResizeBitmap(bm);
            byteArrayPicture = ImageController.BitmapToByteArray(bm);


            Recognition.RecognitionController.RecognisePic(byteArrayPicture);

            DataController.Instance().isShowingRecognition = true;

            Intent i = new Intent(this, typeof(ProfileActivity));

            StartActivity(i);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Profile);

            Button changePicture = FindViewById <Button>(Resource.Id.ChangeProfilePicture);

            changePicture.Click += delegate(object sender, EventArgs e)
            {
                Intent = new Intent();
                Intent.SetType("image/*");
                Intent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId);
            };

            Button deleteAccount = FindViewById <Button>(Resource.Id.DeleteAccount);

            deleteAccount.Click += delegate(object sender, EventArgs e)
            {
                bool answer = Delete();
                if (answer)
                {
                    Intent i = new Intent(this, typeof(MainActivity));
                    StartActivity(i);
                }
            };

            profileName   = FindViewById <TextView>(Resource.Id.ProfileName);
            profileImage  = FindViewById <ImageView>(Resource.Id.ProfileImage);
            currentPerson = DataController.Instance().currentPerson;

            if (DataController.Instance().isShowingRecognition)
            {
                currentPerson = DataController.Instance().recognizedPerson;
                DataController.Instance().isShowingRecognition = false;
                changePicture.Visibility = ViewStates.Gone;
                deleteAccount.Visibility = ViewStates.Gone;
            }
            AddPerson();
        }
Exemple #8
0
        public bool OnTouch(View v, MotionEvent e)
        {
            float x = e.GetX();
            float y = e.GetY();

            if (e.Action == MotionEventActions.Down)
            {
                DataController.Instance().TouchEventDown(x, y);
            }
            else if (e.Action == MotionEventActions.Up)
            {
                DataController.Instance().TouchEventUp();
                if (DataController.Instance().openProfile == true)
                {
                    loadingView.Visibility = ViewStates.Visible;

                    cameraSource.TakePicture(null, this);
                }
            }

            return(true);
        }
        private void ConfirmPhoto(object sender, EventArgs e)
        {
            if (DataController.Instance().SavePicture(byteArrayPicture))
            {
                Recognition.RecognitionController.TrainAlbum(byteArrayPicture, person.Email);

                Intent i = new Intent(this, typeof(CameraActivity));

                if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.Camera) == Permission.Denied)
                {
                    ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.Camera }, 10);
                }
                else
                {
                    StartActivity(i);
                }
            }
            else
            {
                DeclinePhoto(null, null);
                Toast.MakeText(ApplicationContext, Resource.String.CANNOT_REGISTER, ToastLength.Long).Show();
            }
        }
Exemple #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Login);

            Button loggedIn = FindViewById <Button>(Resource.Id.FinalLogin);

            email           = FindViewById <EditText>(Resource.Id.LoginEmail);
            password        = FindViewById <EditText>(Resource.Id.LoginPassword);
            loggedIn.Click += delegate(object sender, EventArgs e)
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    if (DataController.Instance().Login(email.Text, password.Text))
                    {
                        Intent i = new Intent(this, typeof(CameraActivity));

                        if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.Camera) == Permission.Denied)
                        {
                            ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.Camera }, 10);
                        }
                        else
                        {
                            StartActivity(i);
                        }
                    }
                    else
                    {
                        Toast.MakeText(ApplicationContext, Resource.String.WRONG_EMAIL_OR_PASSWORD, ToastLength.Long).Show();
                    }
                }
                else
                {
                    Toast.MakeText(ApplicationContext, Resource.String.NO_INTERNET_CONNECTION, ToastLength.Long).Show();
                }
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Register);

            name           = FindViewById <EditText>(Resource.Id.RegisterName);
            surname        = FindViewById <EditText>(Resource.Id.RegisterSurname);
            email          = FindViewById <EditText>(Resource.Id.RegisterEmail);
            password       = FindViewById <EditText>(Resource.Id.RegisterPassword);
            repeatPassword = FindViewById <EditText>(Resource.Id.RegisterPassword2);

            Button registered = FindViewById <Button>(Resource.Id.FinalRegister);

            registered.Click += delegate(object sender, EventArgs e)
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    DataController.RegistrationCallbacks callback = DataController.Instance().Register(name.Text, surname.Text, email.Text, password.Text, repeatPassword.Text);

                    if (callback == DataController.RegistrationCallbacks.PASSED)
                    {
                        Intent i = new Intent(this, typeof(RegisterCamera));

                        if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.Camera) == Permission.Denied)
                        {
                            ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.Camera }, 10);
                        }
                        else
                        {
                            StartActivity(i);
                        }
                    }
                    else
                    {
                        switch (callback)
                        {
                        case DataController.RegistrationCallbacks.EMAIL_EXISTS:
                            Toast.MakeText(ApplicationContext, Resource.String.EMAIL_ALREADY_EXISTS, ToastLength.Long).Show();
                            break;

                        case DataController.RegistrationCallbacks.INVALID_NAME:
                            Toast.MakeText(ApplicationContext, Resource.String.INVALID_NAME, ToastLength.Long).Show();
                            break;

                        case DataController.RegistrationCallbacks.INVALID_SURNAME:
                            Toast.MakeText(ApplicationContext, Resource.String.INVALID_SURNAME, ToastLength.Long).Show();
                            break;

                        case DataController.RegistrationCallbacks.INVALID_EMAIL:
                            Toast.MakeText(ApplicationContext, Resource.String.INVALID_EMAIL, ToastLength.Long).Show();
                            break;

                        case DataController.RegistrationCallbacks.INVALID_PASSWORD:
                            Toast.MakeText(ApplicationContext, Resource.String.INVALID_PASSWORD, ToastLength.Long).Show();
                            break;

                        case DataController.RegistrationCallbacks.USER_EXISTS:
                            Toast.MakeText(ApplicationContext, Resource.String.INVALID_EMAIL, ToastLength.Long).Show();
                            break;

                        default:
                            Toast.MakeText(ApplicationContext, Resource.String.SOMETHING_WENT_WRONG, ToastLength.Long).Show();
                            break;
                        }
                    }
                }
                else
                {
                    Toast.MakeText(ApplicationContext, Resource.String.NO_INTERNET_CONNECTION, ToastLength.Long).Show();
                }
            };
        }
 public void AddPerson()
 {
     profileName.Text = currentPerson.Name + " " + currentPerson.Surname;
     profileImage.SetImageBitmap(DataController.Instance().ByteArrayToBitmap(DataController.Instance().Base64StringToByteArray(currentPerson.Picture)));
 }