Esempio n. 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.SetupTwo);
            FindViewById <TextView> (Resource.Id.PasswordText).Enabled = false;
            FindViewById <TextView>(Resource.Id.NameText).Text         = DAO.getDetails(0);
            FindViewById <TextView>(Resource.Id.EmailText).Text        = DAO.getDetails(1);
            FindViewById <TextView>(Resource.Id.PasswordText).Text     = DAO.getDetails(2);

            var updateDetails = FindViewById <Button>(Resource.Id.updateAccountDetails);

            updateDetails.Click += (sender, e) => {
                if (FindViewById <TextView>(Resource.Id.NameText).Text.Count <Char>() > 1)
                {
                    if (FindViewById <TextView>(Resource.Id.EmailText).Text.Count <Char>() > 7)
                    {
                        if (FindViewById <TextView>(Resource.Id.EmailText).Text.Contains("@") && FindViewById <TextView>(Resource.Id.EmailText).Text.Contains("."))
                        {
                            if (FindViewById <TextView>(Resource.Id.NameText).Text == DAO.getDetails(0) && FindViewById <TextView>(Resource.Id.EmailText).Text == DAO.getDetails(1))
                            {
                                Toast.MakeText(this, "No Change Made!!", ToastLength.Short).Show();
                            }
                            else
                            {
                                DAO.updateUserDetails(FindViewById <TextView>(Resource.Id.NameText).Text,
                                                      FindViewById <TextView>(Resource.Id.EmailText).Text,
                                                      FindViewById <TextView>(Resource.Id.PasswordText).Text);

                                Toast.MakeText(this, "Account Details Saved!!", ToastLength.Short).Show();
                            }
                        }
                        else
                        {
                            Toast.MakeText(this, "Wrong Email Format!!", ToastLength.Short).Show();
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, "Enter Email please!!", ToastLength.Short).Show();
                    }
                }
                else
                {
                    Toast.MakeText(this, "Enter Your Name Please!!", 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));
        }
Esempio n. 3
0
        protected override void OnDestroy()
        {
            if (FindViewById <TextView> (Resource.Id.unlockTextView).Text == DAO.getDetails(2))
            {
                StopService(new Intent(this, typeof(ProtectionService)));
                StopService(new Intent(this, typeof(SoundService)));
                timer.Dispose();
            }
            else
            {
                if (timer == null)
                {
                    timer = new System.Threading.Timer((o) => {
                        Log.Debug("SimpleService", "hello from simple service");
                        StartService(new Intent(this, typeof(ProtectionService)));
                    }
                                                       , null, 0, 3600000);
                }
            }

            base.OnDestroy();
        }
        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
        }
Esempio n. 5
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));
                }
            };
        }
        public void StartProtection()
        {
            try
            {
                //Attachment attach = new Attachment("picture.png");

                mail = new MailMessage();
                //mail.Attachments.Add(attach);

                string address = DAO.getDetails(1);
                Log.Debug("", address);

                // set up email info
                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(new MailAddress(address));
                mail.IsBodyHtml = true;
                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Never;
                //mail.Body = "<!DOCTYPE html><html>  <head><H1>Just Trying</H1></head>  <body><img src =\"http://maps.googleapis.com/maps/api/staticmap?zoom=13&size=600x300&maptype=roadmap&markers=color:red%7Ccolor:red%7Clabel:C%7C"+position.Latitude+","+position.Longitude+"&sensor=false\" height = \"420\" width = \"620\"></body></html>";

                //create a client account for sendind the email
                client = new SmtpClient();
                client.UseDefaultCredentials = false;
                client.Credentials           = new NetworkCredential("ericwatat", "ripapyrus23");
                client.Port      = 587;
                client.EnableSsl = true;
                client.Host      = "smtp.gmail.com";
                client.Timeout   = 60000;

                //authenticate credentials
                ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors Sslpolicy) { return(true); };

                while (!flag)                 // performs until location is available
                {
                    if (position.Latitude != 0 && position.Longitude != 0 && picturePath != null)
                    {
                        // Adds map to the email if Location
                        // is activated in the settings
                        if (new DataAccessObject().getSettingStatus(4))
                        {
                            mail.Body = "<!DOCTYPE html><html>  <head><H1>Intrusion Detected</H1></head>  <body><p>Dear " + DAO.getDetails(0) + ",</p><p align = \"justify\"> You received that email because the person in the attached picture\n" +
                                        "has attempted to access your device without your permission.</p>\n" +
                                        " <p align = \"justify\">The map below pinpoints the location of the unauthorised access\n\n\n." +
                                        "</p><p>If you trigger that email and forgot your details, your password is: " + DAO.getDetails(2) + "</p>\n<img src = \"" + picturePath + "\"><img src =\"http://maps.googleapis.com/maps/api/staticmap?zoom=13&size=600x300&maptype=roadmap&markers=color:red%7Ccolor:red%7Clabel:C%7C" + position.Latitude + "," + position.Longitude + "&sensor=false\" height = \"420\" width = \"620\"><br><p align = \"justify\">If you received this email by error please accept our appology and ignore it.</p></body></html>";
                        }


                        else
                        {
                            mail.Body = "<!DOCTYPE html><html>  <head><H1>Intrusion Detected</H1></head>  <body><p>Dear " + DAO.getDetails(0) + ",</p><p align = \"justify\"> You received that email because the person in the attached picture\n" +
                                        "has attempted to access your device without your permission.</p><br>" +
                                        "<p>If you trigger that email and forgot your details, your password is: " + DAO.getDetails(2) + "</p><br><p align = \"justify\">If you received this email by error please accept our appology and ignore it.</p></body></html>";
                        }

                        if (new DataAccessObject().getSettingStatus(3))
                        {
                            mail.Attachments.Add(attach);
                        }
                        //Sends the email if email notification is
                        //Activated in the settings
                        if (new DataAccessObject().getSettingStatus(2))
                        {
                            client.Send(mail);
                        }
                        flag = true;
                        afile.Delete();
                        emailThread.Abort();
                    }
                }

                Log.Debug("SimpleService", "sending successfull!!");
                SurfaceDestroyed(sv.Holder);
                StopSelf();
            } catch (Exception smtpE) {
                Log.Debug("SimpleService", "sending failed!!");
                SurfaceDestroyed(sv.Holder);
            }
        }