Ejemplo n.º 1
0
        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            LayoutInflater inflater = context.LayoutInflater;
            View           v        = inflater.Inflate(Resource.Layout.Common_LeftDrawer, null, true);

            ImageView OptionIconIView = v.FindViewById <ImageView> (Resource.Id.imageView2);
            TextView  OptionTView     = v.FindViewById <TextView> (Resource.Id.textView2);

            OptionTView.Text = Optiuni [position];
            SetTypeface.Normal.SetTypeFace(context, OptionTView);

            OptionIconIView.SetImageDrawable(OptiuniIcon[position]);

            OptionTView.Click += (object sender, EventArgs e) => {
                switch (((TextView)sender).Text)
                {
                case "Logout": {
                    SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(context);

                    Save.Clear(SaveUsingSharedPreferences.Tags.Login.Username);

                    Intent StartSignUp = new Intent(context, typeof(Login));

                    StartSignUp.PutExtra("BackgroundLoginByteArray", DrawableConverter.DrawableToByteArray(Background));
                    context.StartActivity(StartSignUp);
                } break;
                }
            };

            return(v);
        }
Ejemplo n.º 2
0
        private void CheckIfFirstLogin()
        {
            SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(this);

            ////   if (Save.LoadString(SaveUsingSharedPreferences.Tags.Trip.TipId).Equals(string.Empty))
            // {
            if (!IsServiceStarted(Class.FromType(typeof(StartUpService))))
            {
                Intent StartServices = new Intent(this, typeof(StartUpService));
                StartService(StartServices);
            }
            // }
        }
Ejemplo n.º 3
0
        private void Initiate()
        {
            SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(this);
            string DistanceString           = Save.LoadString(SaveUsingSharedPreferences.Tags.Organizator.Distanta);

            if (DistanceString != "")
            {
                Distanta = int.Parse(Save.LoadString(SaveUsingSharedPreferences.Tags.Organizator.Distanta));
            }
            else
            {
                Save.Save(SaveUsingSharedPreferences.Tags.Organizator.Distanta, "50");
                Distanta = 50;
            }
        }
Ejemplo n.º 4
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(this)
                                                  .SetSmallIcon(Resource.Drawable.NotificationIcon)
                                                  .SetContentTitle("Safe Traveling")
                                                  .SetSound(Settings.System.DefaultNotificationUri)
                                                  .SetContentText("Application service has successfully started!");

            NotificationManager nManager = (NotificationManager)this.GetSystemService(Context.NotificationService);

            nManager.Notify(0, nBuilder.Build());

            string NumarTelefon = new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Login.Username);
            string TripId       = new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Trip.TipId);

            Handler mHandler = new Handler(Looper.MainLooper);

            new Thread(new ThreadStart(() =>
            {
                TcpClient Client = new TcpClient(_Details.ServerIP, _Details.LocationServicePort);
                NetworkStream ns = Client.GetStream();

                _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { TripId, NumarTelefon }));

                LocationManager lm            = (LocationManager)GetSystemService(LocationService);
                ILocationListener gpsListener = new LocationListener(Client, ns);

                mHandler.Post(() =>
                              lm.RequestLocationUpdates(LocationManager.NetworkProvider, 5000, 1, gpsListener)
                              );
            })).Start();

            new Thread(new ThreadStart(() =>
            {
                TcpClient Client = new TcpClient(_Details.ServerIP, _Details.NotificationServicePort);
                NetworkStream ns = Client.GetStream();


                _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { TripId, NumarTelefon }));

                new SafeTraveling.Scripts.StartUpService.NotificationService(this, new Client(Client, ns), NumarTelefon);
            })).Start();

            return(StartCommandResult.Sticky);
        }
Ejemplo n.º 5
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.Organizator_Trip_NewQuestionPool_SetareDurata, null, false);

            NumberPicker   PickDurata = v.FindViewById <NumberPicker>(Resource.Id.numberPicker1);
            TextView       IntroducetiDurata_TView = v.FindViewById <TextView>(Resource.Id.textView1);
            TextView       MinuteHint = v.FindViewById <TextView>(Resource.Id.textView2);
            TextView       TrimitereIntrebare_TView = v.FindViewById <TextView>(Resource.Id.textView3);
            RelativeLayout TrimitereIntrebare       = v.FindViewById <RelativeLayout>(Resource.Id.relativeLayout2);

            SetTypeface.Normal.SetTypeFace(Activity, TrimitereIntrebare_TView);
            SetTypeface.Normal.SetTypeFace(Activity, IntroducetiDurata_TView);
            SetTypeface.Normal.SetTypeFace(Activity, MinuteHint);

            PickDurata.MaxValue          = 60;
            PickDurata.MinValue          = 10;
            PickDurata.WrapSelectorWheel = false;

            TrimitereIntrebare.Click += ((object sender, EventArgs e) => {
                TcpClient Client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
                NetworkStream ns = Client.GetStream();

                string TripId = new SaveUsingSharedPreferences(Activity).LoadString(SaveUsingSharedPreferences.Tags.Trip.TipId);
                string NrTel = new SaveUsingSharedPreferences(Activity).LoadString(SaveUsingSharedPreferences.Tags.Login.Username);
                string Intrebare = IntroducereIntrebare.IntroducetiIntrebarea_EText.Text;
                string Variante = string.Join(",", ((Organizator_Trip_NewQuestionPool_SetareVariante_VarianteAdapter)SetareVariante.VarianteListView.Adapter).Variante);
                string Durata = PickDurata.Value.ToString();
                string Id = Guid.NewGuid().ToString();

                _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { _Details.NewQuestionPool, NrTel, TripId, Intrebare, Variante, Durata, Id }));

                Activity.Finish();
            });

            return(v);
        }
Ejemplo n.º 6
0
        void LoginBtn_Click(object sender, EventArgs e)
        {
            string Nume   = LoginText.Text;
            string Parola = ParolaText.Text;

            TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LoginSignUpNewTripPort);
            NetworkStream ns     = Client.GetStream();

            _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { "LOGIN", Nume, Parola }));
            string[] Response = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns));

            switch (Response[0])
            {
            case "Utilizator":
            {
                if (RememberMe.Checked)
                {
                    SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(this);

                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Username, Nume);
                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Password, Parola);

                    Intent StartSignUp = new Intent(this, typeof(Utilizator_Main));

                    StartSignUp.PutExtra("BackgroundUtilizatorMainByteArray", BackID);
                    StartActivity(StartSignUp);
                }
                else
                {
                    Intent StartSignUp = new Intent(this, typeof(Utilizator_Main));

                    StartSignUp.PutExtra("BackgroundUtilizatorMainByteArray", BackID);
                    StartActivity(StartSignUp);
                }
            }
            break;

            case "Organizator":
            {
                if (Response[1] == "1")
                {
                    SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(this);

                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Username, Nume);
                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Password, Parola);

                    Intent StartOrganizatorTrip = new Intent(this, typeof(Organizator_Trip));
                    StartOrganizatorTrip.PutExtra("BackgroundByteArray", DrawableConverter.DrawableToByteArray(Backgroud.Background));
                    StartActivity(StartOrganizatorTrip);
                }
                else
                {
                    SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(this);

                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Username, Nume);
                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Password, Parola);

                    Intent StartOrganizatorMain = new Intent(this, typeof(Organizator_Main));

                    StartOrganizatorMain.PutExtra("BackgroundUtilizatorMainByteArray", DrawableConverter.DrawableToByteArray(Backgroud.Background));
                    StartActivity(StartOrganizatorMain);
                }
            }
            break;

            default:
            {
                Toast.MakeText(this, "Ne pare rau,numele utilizatorului sau parola au fost introduse gresit!", ToastLength.Long).Show();
            }
            break;
            }
        }
        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            LayoutInflater inflater = context.LayoutInflater;
            View           v        = inflater.Inflate(Resource.Layout.Organizator_Trip_GridViewAdapter, null, true);

            ImageView Icon_iView = v.FindViewById <ImageView> (Resource.Id.imageView1);

            Icon_iView.SetImageDrawable(Icons[position]);

            Icon_iView.Click += (object sender, EventArgs e) => {
                switch (position)
                {
                case 1: {
                    context.StartActivity(typeof(Organizator_Trip_VizualizareExcursionisti));
                } break;

                case 3:
                {
                    Dialog diag = new Dialog(context);
                    diag.Window.RequestFeature(WindowFeatures.NoTitle);

                    View      CostumView = inflater.Inflate(Resource.Layout.Utilizator_Trip_TripInfo_AlertDialogAdapter, null);
                    TextView  NumeCamp   = CostumView.FindViewById <TextView>(Resource.Id.textView1);
                    ImageView EditInfo   = CostumView.FindViewById <ImageView>(Resource.Id.imageView1);
                    EditText  NewValue   = CostumView.FindViewById <EditText>(Resource.Id.editText1);

                    SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(context);
                    string Distanta = Save.LoadString(SaveUsingSharedPreferences.Tags.Organizator.Distanta);

                    NumeCamp.Text   = "Valoarea actuala este:" + Distanta;
                    EditInfo.Click += (object sender1, EventArgs e1) =>
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.Organizator.Distanta, NewValue.Text);

                        diag.Cancel();
                    };

                    diag.SetContentView(CostumView);

                    diag.SetCanceledOnTouchOutside(true);
                    diag.Show();
                    diag.Window.SetBackgroundDrawable(context.Resources.GetDrawable(Resource.Drawable.background_MarginiOvaleAlb));
                } break;

                case 4: {
                    PopupMenu popup = new PopupMenu(context, v);
                    popup.MenuItemClick += (object s, PopupMenu.MenuItemClickEventArgs e1) =>
                    {
                        switch (e1.Item.ToString())
                        {
                        case "Adauga intrebare noua":
                        {
                            context.StartActivity(typeof(Organizator_Trip_NewQuestionPool));
                        } break;

                        case "Vezi progresul intrebarilor actuale":
                        {
                            TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
                            NetworkStream ns     = Client.GetStream();

                            string TripId = new SaveUsingSharedPreferences(context).LoadString(SaveUsingSharedPreferences.Tags.Trip.TipId);
                            _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { _Details.RequestVotesQuestionPool, TripId }));

                            string[] Response = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns));

                            string[] Intrebari = Response[0].Split(',');
                            string[] Ids       = Response[1].Split(',');

                            var Test = new Organizator_Trip_ViewQuestionPool_Adapters.IntrebarVariante[Intrebari.Length];

                            for (int i = 0; i < Intrebari.Length; i++)
                            {
                                Response = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns));

                                List <string> Variante = new List <string>();
                                List <string> Procente = new List <string>();

                                for (int j = 0; j < Response.Length; j++)
                                {
                                    if (Response[j] != "")
                                    {
                                        Variante.Add(Response[j].Split(',')[0]);
                                        Procente.Add(Response[j].Split(',')[1]);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }

                                var temp = new Organizator_Trip_ViewQuestionPool_Adapters.IntrebarVariante();
                                temp.Intrebare = Intrebari[i];
                                temp.Variante  = Variante.ToArray();
                                temp.Procente  = Procente.ToArray();

                                Test[i] = temp;
                            }

                            Organizator_Trip_ViewQuestionPool_DialogFragment diag = new Organizator_Trip_ViewQuestionPool_DialogFragment(Test);
                            diag.Show(context.FragmentManager, "ViewQuestionPool");
                        } break;
                        }
                    };
                    MenuInflater menuInflater = popup.MenuInflater;
                    menuInflater.Inflate(Resource.Menu.OptiuniQuestionPool, popup.Menu);
                    popup.Show();
                } break;
                }
            };

            return(v);
        }
Ejemplo n.º 8
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Layouturi[position], container, false);
            SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(context);

            switch (position)
            {
            case 0:
            {
                TextView    Nume_TView    = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView    Prenume_TView = v.FindViewById <TextView> (Resource.Id.textView2);
                TextView    Varsta_TView  = v.FindViewById <TextView> (Resource.Id.textView3);
                TextView    Sex_TView     = v.FindViewById <TextView> (Resource.Id.textView4);
                RadioButton Masculin      = v.FindViewById <RadioButton> (Resource.Id.radioButton1);
                RadioButton Feminin       = v.FindViewById <RadioButton> (Resource.Id.radioButton3);
                EditText    Nume_EText    = v.FindViewById <EditText> (Resource.Id.editText1);
                EditText    Prenume_EText = v.FindViewById <EditText> (Resource.Id.editText2);
                EditText    Varsta_EText  = v.FindViewById <EditText> (Resource.Id.editText3);

                Nume_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Nume, Nume_EText.Text);
                };

                Prenume_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Prenume, Prenume_EText.Text);
                };

                Varsta_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Varsta, Varsta_EText.Text);
                };

                Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Masculin");
                Masculin.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                    if (e.IsChecked)
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Masculin");
                    }
                    else
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Feminin");
                    }
                };

                SetTypeface.Normal.SetTypeFace(context, Nume_TView);
                SetTypeface.Normal.SetTypeFace(context, Prenume_TView);
                SetTypeface.Normal.SetTypeFace(context, Varsta_TView);
                SetTypeface.Normal.SetTypeFace(context, Sex_TView);
                SetTypeface.Normal.SetTypeFace(context, Masculin);
                SetTypeface.Normal.SetTypeFace(context, Feminin);
            }
            break;

            case 1:
            {
                TextView    Email_TView        = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView    NumarTelefon_TView = v.FindViewById <TextView> (Resource.Id.textView2);
                TextView    Mark               = v.FindViewById <TextView> (Resource.Id.textView3);
                TextView    TipCont_TView      = v.FindViewById <TextView> (Resource.Id.textView4);
                RadioButton Utilizator         = v.FindViewById <RadioButton> (Resource.Id.radioButton1);
                RadioButton Organizator        = v.FindViewById <RadioButton> (Resource.Id.radioButton3);
                EditText    Email_EText        = v.FindViewById <EditText> (Resource.Id.editText1);
                EditText    NumarTelefon_EText = v.FindViewById <EditText> (Resource.Id.editText2);

                SetTypeface.Normal.SetTypeFace(context, Email_TView);
                SetTypeface.Normal.SetTypeFace(context, NumarTelefon_TView);
                SetTypeface.Normal.SetTypeFace(context, Mark);
                SetTypeface.Normal.SetTypeFace(context, TipCont_TView);
                SetTypeface.Normal.SetTypeFace(context, Utilizator);
                SetTypeface.Normal.SetTypeFace(context, Organizator);

                Save.Save(SaveUsingSharedPreferences.Tags.SetUp.TipCont, "Utilizator");
                Utilizator.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                    if (e.IsChecked)
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.TipCont, "Utilizator");
                    }
                    else
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.TipCont, "Organizator");
                    }
                };

                Email_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Email, Email_EText.Text);
                };

                NumarTelefon_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.NumarTelefon, NumarTelefon_EText.Text);
                };
            }
            break;

            case 2:
            {
                ImageView ChaptaView        = v.FindViewById <ImageView> (Resource.Id.imageView1);
                TextView  VIntroducetiCodul = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView  VParola           = v.FindViewById <TextView> (Resource.Id.textView2);
                TextView  VConfParola       = v.FindViewById <TextView> (Resource.Id.textView3);
                Button    Gata             = v.FindViewById <Button> (Resource.Id.button1);
                EditText  Chapta           = v.FindViewById <EditText> (Resource.Id.editText1);
                EditText  Parola_EText     = v.FindViewById <EditText> (Resource.Id.editText2);
                EditText  ConfParola_Etext = v.FindViewById <EditText> (Resource.Id.editText3);

                SetTypeface.Normal.SetTypeFace(context, VIntroducetiCodul);
                SetTypeface.Normal.SetTypeFace(context, Gata);
                SetTypeface.Normal.SetTypeFace(context, VParola);
                SetTypeface.Normal.SetTypeFace(context, VConfParola);

                DisplayChapta displayChapta = new DisplayChapta(5);
                displayChapta.Create();
                string ChaptaText = displayChapta.GetText();
                Bitmap b          = displayChapta.GetBitmap();
                ChaptaView.SetImageBitmap(b);

                Gata.Click += (object sender, EventArgs e) => {
                    string Nume         = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Nume);
                    string Prenume      = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Prenume);
                    string Varsta       = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Varsta);
                    string Sex          = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Sex);
                    string Email        = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Email);
                    string TipCont      = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.TipCont);
                    string NumarTelefon = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.NumarTelefon);
                    string Parola       = Parola_EText.Text;
                    string ConfParola   = ConfParola_Etext.Text;

                    //if (VerificareDate (
                    //	Nume,Prenume,Varsta,Email,NumarTelefon,Parola,ConfParola,Chapta.Text, ChaptaText)) {

                    TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LoginSignUpNewTripPort);
                    NetworkStream ns     = Client.GetStream();

                    _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { "SIGNUP", Nume, Prenume, Varsta, Sex, Email, NumarTelefon, TipCont, Parola }));

                    if (CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns))[0] == "ok")
                    {
                        Toast.MakeText(context, "Ala-i bosssss!", ToastLength.Long).Show();

                        Intent StartLogin = new Intent(context, typeof(Login));
                        StartLogin.PutExtra("BackgroundLoginByteArray", DrawableConverter.DrawableToByteArray(context.Background.Background));
                        context.StartActivity(StartLogin);
                    }
                    else
                    {
                        Toast.MakeText(context, "Fail!", ToastLength.Long).Show();
                        Intent StartLogin = new Intent(context, typeof(Login));
                        StartLogin.PutExtra("BackgroundLoginByteArray", DrawableConverter.DrawableToByteArray(context.Background.Background));
                        context.StartActivity(StartLogin);
                    }

                    //}
                };
            }
            break;
            }

            return(v);
        }
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Layouturi[position], null, true);
            SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(context);

            switch (position)
            {
            case 0:
            {
                TextView    TViewDestinatiePrincipala = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView    TViewTipulParticipantilor = v.FindViewById <TextView> (Resource.Id.textView4);
                EditText    DestinatiePrincipala      = v.FindViewById <EditText> (Resource.Id.editText1);
                RadioButton Elevi           = v.FindViewById <RadioButton> (Resource.Id.radioButton1);
                RadioButton PersoanePrivate = v.FindViewById <RadioButton> (Resource.Id.radioButton3);

                SetTypeface.Normal.SetTypeFace(context, TViewDestinatiePrincipala);
                SetTypeface.Normal.SetTypeFace(context, TViewTipulParticipantilor);
                SetTypeface.Normal.SetTypeFace(context, DestinatiePrincipala);
                SetTypeface.Normal.SetTypeFace(context, Elevi);
                SetTypeface.Normal.SetTypeFace(context, PersoanePrivate);

                DestinatiePrincipala.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DestinatiePrincipala, DestinatiePrincipala.Text);
                };

                Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.TipulParticipantilor, "Elevi");
                Elevi.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                    if (e.IsChecked)
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Elevi");
                    }
                    else
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Persoane private");
                    }
                };
            }
            break;

            case 1:
            {
                TextView   PerioadaExcursieiTView = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView   DataPlecareTView       = v.FindViewById <TextView> (Resource.Id.textView2);
                TextView   DataIntoarcereTView    = v.FindViewById <TextView> (Resource.Id.textView3);
                DatePicker DataPlecare            = v.FindViewById <DatePicker> (Resource.Id.datePicker1);
                DatePicker DataIntoarcere         = v.FindViewById <DatePicker> (Resource.Id.datePicker2);

                SetTypeface.Normal.SetTypeFace(context, PerioadaExcursieiTView);
                SetTypeface.Normal.SetTypeFace(context, DataPlecareTView);
                SetTypeface.Normal.SetTypeFace(context, DataIntoarcereTView);

                Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DataPlecare, System.DateTime.Now.Day.ToString() + "." + System.DateTime.Now.Month.ToString() + "." + System.DateTime.Now.Year.ToString());
                DataPlecare.CalendarView.DateChange += (object sender, CalendarView.DateChangeEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DataPlecare, e.DayOfMonth.ToString() + "." + e.Month.ToString() + "." + e.Year.ToString());
                };

                Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DataIntoarcere, System.DateTime.Now.Day.ToString() + "." + System.DateTime.Now.Month.ToString() + "." + System.DateTime.Now.Year.ToString());
                DataIntoarcere.CalendarView.DateChange += (object sender, CalendarView.DateChangeEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DataIntoarcere, e.DayOfMonth.ToString() + "." + e.Month.ToString() + "." + e.Year.ToString());
                };
            }
            break;

            case 2:
            {
                TextView   LocatiePlecareTView = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView   OraPlecareTview     = v.FindViewById <TextView> (Resource.Id.textView2);
                EditText   LocatiePlecare      = v.FindViewById <EditText> (Resource.Id.editText1);
                TimePicker OraPlecare          = v.FindViewById <TimePicker> (Resource.Id.timePicker1);

                OraPlecare.SetIs24HourView(Java.Lang.Boolean.True);

                SetTypeface.Normal.SetTypeFace(context, LocatiePlecareTView);
                SetTypeface.Normal.SetTypeFace(context, OraPlecareTview);
                SetTypeface.Normal.SetTypeFace(context, LocatiePlecare);

                LocatiePlecare.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.LocatiePlecare, LocatiePlecare.Text);
                };

                Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.OraPlecare, System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Hour.ToString());
                OraPlecare.TimeChanged += (object sender, TimePicker.TimeChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.OraPlecare, e.Minute.ToString() + ":" + e.HourOfDay.ToString());
                };
            }
            break;

            case 3:
            {
                Button   Finalizare      = v.FindViewById <Button> (Resource.Id.button1);
                TextView ObservatiiTView = v.FindViewById <TextView> (Resource.Id.textView1);
                EditText ObservatiiEText = v.FindViewById <EditText> (Resource.Id.editText1);

                SetTypeface.Normal.SetTypeFace(context, Finalizare);
                SetTypeface.Normal.SetTypeFace(context, ObservatiiTView);
                SetTypeface.Normal.SetTypeFace(context, ObservatiiEText);

                Finalizare.Click += (object sender, EventArgs e) => {
                    string DestinatiePrincipala = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.DestinatiePrincipala);
                    string TipulParticipantilor = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.TipulParticipantilor);
                    string DataPlecare          = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.DataPlecare);
                    string DataIntoarcere       = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.DataIntoarcere);
                    string LocatiePlecare       = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.LocatiePlecare);
                    string OraPlecare           = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.OraPlecare);
                    string Observatii           = ObservatiiEText.Text;
                    string NumeOrganizator      = "numeOrganizator";
                    string NumarTelefon         = new SaveUsingSharedPreferences(context).LoadString(SaveUsingSharedPreferences.Tags.Login.Username);

                    if (VerificareDate(DestinatiePrincipala, LocatiePlecare))
                    {
                        TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.TripPort_INPUT);
                        NetworkStream ns     = Client.GetStream();

                        _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] {
                                "NEWTRIP",
                                DestinatiePrincipala,
                                TipulParticipantilor,
                                DataPlecare,
                                DataIntoarcere,
                                LocatiePlecare,
                                OraPlecare,
                                Observatii,
                                NumeOrganizator,
                                NumarTelefon
                            }));

                        if (CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns)) [0] == "1")
                        {
                            Toast.MakeText(context, "Ala-i bosssss!", ToastLength.Long).Show();

                            TcpClient     client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
                            NetworkStream Ns     = client.GetStream();

                            _TcpDataExchange.WriteStreamString(Ns, CryptDecryptData.CryptData(new string[] { _Details.GetTripId, new SaveUsingSharedPreferences(context).LoadString(SaveUsingSharedPreferences.Tags.Login.Username) }));
                            string TripId = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(Ns))[0];
                            new SaveUsingSharedPreferences(context).Save(SaveUsingSharedPreferences.Tags.Trip.TipId, TripId);

                            ns.Dispose();
                            client.Close();

                            Intent StartOrganizatorTrip = new Intent(context, typeof(Organizator_Trip));
                            StartOrganizatorTrip.PutExtra("BackgroundByteArray", DrawableConverter.DrawableToByteArray(Background));
                            context.StartActivity(StartOrganizatorTrip);
                        }
                        else
                        {
                            Toast.MakeText(context, "Fail!", ToastLength.Long).Show();
                            context.Finish();
                        }
                    }
                };
            }
            break;
            }

            return(v);
        }
Ejemplo n.º 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            Bundle Extras = Intent.Extras;
            int    BackgroundByteArray = Extras.GetInt("BackgroundUtilizatorMainByteArray");

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Utilizator_Main);

            Background       = FindViewById <RelativeLayout> (Resource.Id.relativeLayout1);
            LeftDrawer       = FindViewById <ListView> (Resource.Id.left_drawer_listview);
            Next             = FindViewById <Button> (Resource.Id.button1);
            Container        = FindViewById <RelativeLayout> (Resource.Id.relativeLayout3);
            Cod              = FindViewById <EditText> (Resource.Id.editText1);
            IntroducetiCodul = FindViewById <TextView> (Resource.Id.textView2);
            UserProfilePic   = FindViewById <ImageView> (Resource.Id.imageView1);
            UserNume         = FindViewById <TextView> (Resource.Id.textView1);

            List <Drawable> DrawableList = new List <Drawable>();

            for (int i = 1; i < 5; i++)
            {
                DrawableList.Add(DrawableConverter.GetDrawableFromAssets("LB/img" + i.ToString() + ".jpg", this));
            }
            for (int i = 1; i < 8; i++)
            {
                DrawableList.Add(DrawableConverter.GetDrawableFromAssets("LoadingBackgrounds/img" + i.ToString() + ".jpg", this));
            }
            Background.Background = DrawableList[BackgroundByteArray];

            Cod.Text = new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Trip.TipId);
            //Cod.Text = "c41z1zb6xc";

            SetTypeface.Normal.SetTypeFace(this, IntroducetiCodul);
            SetTypeface.Normal.SetTypeFace(this, Next);
            SetTypeface.Normal.SetTypeFace(this, Cod);

            TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
            NetworkStream ns     = Client.GetStream();

            _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { _Details.GetProfilePic, new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Login.Username) }));

            int ReadedBytes;

            byte[]       Buffer = new byte[1000];
            MemoryStream ms     = new MemoryStream();

            while ((ReadedBytes = ns.Read(Buffer, 0, Buffer.Length)) > 0)
            {
                ms.Write(Buffer, 0, ReadedBytes);
            }

            Client.Close();
            ns.Dispose();

            Bitmap bitMap = ((BitmapDrawable)DrawableConverter.ByteArrayToDrawable(ms.ToArray(), this)).Bitmap;

            UserProfilePic.SetImageDrawable(new BitmapDrawable(Resources, RoundedBitmap.MakeRound(bitMap, bitMap.Height / 2)));

            TcpClient     client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
            NetworkStream Ns     = client.GetStream();

            _TcpDataExchange.WriteStreamString(Ns, CryptDecryptData.CryptData(new string[] { _Details.GetUserName, new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Login.Username) }));
            string NumeUtilizator = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(Ns))[0];

            UserNume.Text = NumeUtilizator;

            client.Close();
            Ns.Dispose();

            SetTypeface.Normal.SetTypeFace(this, UserNume);
            LeftDrawer.Adapter = new Utilizator_Main_LeftDrawerAdapter(this, new string[] { "Logout" }, Background.Background);

            Next.Click += (object sender, EventArgs e) => {
                TcpClient     OUTPUT_Client = new TcpClient(_Details.ServerIP, _Details.TripPort_INPUT);
                NetworkStream OUTPUT_ns     = OUTPUT_Client.GetStream();
                OUTPUT = new Client(OUTPUT_Client, OUTPUT_ns);

                string NumePrenume  = "nume Prenume";
                string NumarTelefon = new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Login.Username);
                string TripId       = Cod.Text;

                _TcpDataExchange.WriteStreamString(OUTPUT_ns, CryptDecryptData.CryptData(new String [] { "TRIPENTER", NumePrenume, NumarTelefon, TripId }));

                List <string> Messages = new List <string>();
                Messages.AddRange(CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(OUTPUT_ns)));
                Messages.Add(TripId);

                TcpClient     INPUT_Client = new TcpClient(_Details.ServerIP, _Details.TripPort_OUTPUT);
                NetworkStream INPUT_ns     = INPUT_Client.GetStream();
                INPUT = new Client(INPUT_Client, INPUT_ns);

                _TcpDataExchange.WriteStreamString(INPUT_ns, CryptDecryptData.CryptData(new String [] { NumePrenume, NumarTelefon, TripId }));

                new SaveUsingSharedPreferences(this).Save(SaveUsingSharedPreferences.Tags.Trip.TipId, TripId);
                Intent StartUtilizatorTrip = new Intent(this, typeof(Utilizator_Trip));
                StartUtilizatorTrip.PutExtra("BackgroundByteArray", DrawableConverter.DrawableToByteArray(Background.Background));
                StartUtilizatorTrip.PutStringArrayListExtra("TripData", Messages);
                StartActivity(StartUtilizatorTrip);
            };
        }