protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.SetupOne);

            DAO = new DataAccessObject();

            var saveDetails = FindViewById <Button>(Resource.Id.saveDetailsButton);

            saveDetails.Click += (sender, e) => {
                Log.Debug("SetUp", FindViewById <TextView>(Resource.Id.nameEditText).Text + " text");

                //VALIDATION ON THE FIELDS
                if (FindViewById <TextView>(Resource.Id.nameEditText).Text != null && FindViewById <TextView>(Resource.Id.nameEditText).Text.Count <Char>() > 1)
                {
                    if (FindViewById <TextView>(Resource.Id.emailEditText).Text != null && FindViewById <TextView>(Resource.Id.emailEditText).Text.Count <Char>() > 7)
                    {
                        if (FindViewById <TextView>(Resource.Id.emailEditText).Text.Contains("@") && FindViewById <TextView>(Resource.Id.emailEditText).Text.Contains("."))
                        {
                            if (FindViewById <TextView>(Resource.Id.remailEditText).Text == FindViewById <TextView>(Resource.Id.emailEditText).Text)
                            {
                                if (FindViewById <TextView>(Resource.Id.passwordEditText).Text != null)
                                {
                                    if (FindViewById <TextView>(Resource.Id.rpasswordEditText).Text == FindViewById <TextView>(Resource.Id.passwordEditText).Text)
                                    {
                                        DAO.insertUserDetails(FindViewById <TextView>(Resource.Id.nameEditText).Text, FindViewById <TextView>(Resource.Id.remailEditText).Text, FindViewById <TextView>(Resource.Id.passwordEditText).Text);
                                        StartActivity(typeof(MainActivity));
                                    }
                                    else
                                    {
                                        Toast.MakeText(this, "Passwords do not match!!", ToastLength.Short).Show();
                                    }
                                }
                                else
                                {
                                    Toast.MakeText(this, "Please complete Password!!", ToastLength.Short).Show();
                                }
                            }
                            else
                            {
                                Toast.MakeText(this, "Emails do not match!!", ToastLength.Short).Show();
                            }
                        }
                        else
                        {
                            Toast.MakeText(this, "Wrong Email Format!!", ToastLength.Short).Show();
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, "Please complete Email!!", ToastLength.Short).Show();
                    }
                }
                else
                {
                    Toast.MakeText(this, "Please complete name field!!", ToastLength.Short).Show();
                }
            };
        }
        public override void OnStart(Android.Content.Intent intent, int startId)
        {
            base.OnStart(intent, startId);

            Log.Debug("SimpleService", "SimpleService started");

            flag = false;
            DAO  = new DataAccessObject();

            sv = new SurfaceView(this.BaseContext);

            position = new Position();

            getLatLong();

            //Get a surface
            sHolder = sv.Holder;

            //add the callback interface methods defined below as the Surface View callbacks
            sHolder.AddCallback(this);

            //cslls the camera
            SurfaceCreated(sHolder);

            //set up the camera and take picture
            SurfaceChanged(sHolder, Android.Graphics.Format.Jpeg, 0, 0);

            emailThread = new Thread(StartProtection);
            emailThread.Start();

            Log.Debug("", DAO.getDetails(1));
        }
        public void OnPictureTaken(byte[] data, Android.Hardware.Camera camera)
        {
            // Creates a data access object to record the intrusion in the history
            DAO = new DataAccessObject();
            DAO.insertHistoryItems(DateTime.Now.ToString(), "Intrusion Detected", data);

            Bitmap bmp;

            BitmapFactory.Options bmpOptions = new BitmapFactory.Options {
                InJustDecodeBounds = true
            };
            bmpOptions.InSampleSize = 4;

            bmpOptions.InJustDecodeBounds = false;

            //decode the data obtained by the camera into a Bitmap
            bmp = BitmapFactory.DecodeByteArray(data, 0, data.Length, bmpOptions);

            int    width  = bmp.Width;
            int    height = bmp.Height;
            Matrix matrix = new Matrix();

            matrix.PostRotate(270);

            Bitmap resized = Bitmap.CreateBitmap(bmp, 0, 0, width, height, matrix, false);

            afile       = new Java.IO.File(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "picture.jpeg");
            fileWritter = new FileOutputStream(afile);
            fileWritter.Write(data, 0, data.Length);

            attach = new Attachment(afile.Path);

            picturePath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "picture.jpeg");
        }
 public SettingsLayoutAdapter(Activity context, List <SettingsItems> items) : base()
 {
     this.items   = items;
     this.context = context;
     DAO          = new DataAccessObject();
     myPosition   = new int[4];
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.StartupActivity);
            DAO = new DataAccessObject();

            if (DAO.getDetails(0) == null)
            {
                StartActivity(typeof(SetupActivityOne));
            }
            else
            {
                StartActivity(typeof(MainActivity));
            }
            // Create your application here
        }
Exemple #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.LockScreen);
            SetPersistent(true);

            DAO = new DataAccessObject();

            var unlock = FindViewById <ImageView>(Resource.Id.UnnlockImageView);

            unlock.Click += (sender, e) => {
                if (FindViewById <TextView>(Resource.Id.unlockTextView).Text != DAO.getDetails(2))
                {
                    count++;
                    count2++;
                    if (count == 3)
                    {
                        StartService(new Intent(this, typeof(ProtectionService)));
                        count = 0;
                    }

                    if (count2 == 4)
                    {
                        if (new DataAccessObject().getSettingStatus(1))
                        {
                            StartService(new Intent(this, typeof(SoundService)));
                        }
                        count2 = 0;
                    }
                }
                else
                {
                    if (timer != null)
                    {
                        timer.Dispose();
                    }
                    StopService(new Intent(this, typeof(ProtectionService)));
                    StopService(new Intent(this, typeof(SoundService)));
                    StartActivity(typeof(MainActivity));
                }
            };
        }
Exemple #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.PictureScreen);

            Bundle extra = this.Intent.Extras;

            id = extra.GetInt("id") + 1;

            DAO = new DataAccessObject();
            Bitmap bmp;

            BitmapFactory.Options bmpOptions = new BitmapFactory.Options {
                InJustDecodeBounds = true
            };
            bmpOptions.InSampleSize = 4;

            bmpOptions.InJustDecodeBounds = false;

            //decode the data obtained by the camera into a Bitmap
            bmp = BitmapFactory.DecodeByteArray(DAO.getHistoryPicture(id).image, 0, DAO.getHistoryPicture(id).image.Length, bmpOptions);

            int    width  = bmp.Width;
            int    height = bmp.Height;
            Matrix matrix = new Matrix();

            matrix.PostRotate(270);

            Bitmap resized = Bitmap.CreateBitmap(bmp, 0, 0, width, height, matrix, false);

            FindViewById <ImageView> (Resource.Id.IntruderPictureView).SetImageBitmap(resized);

            FindViewById <TextView> (Resource.Id.PictureScreenTextView).Text = "The person in the above picture tried to access your device without your permission" +
                                                                               " on the " + DAO.getHistoryPicture(id).date + ".";

            // Create your application here
        }