Ejemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            try
            {
                SetContentView(Resource.Layout.AuthAfter);
                AuthorizationMethods authorizationMethods = new AuthorizationMethods();

                profileLL        = FindViewById <LinearLayout>(Resource.Id.profileLL);
                dialogsLL        = FindViewById <LinearLayout>(Resource.Id.dialogsLL);
                specialistsLL    = FindViewById <LinearLayout>(Resource.Id.specialistsLL);
                dialogsLL.Click += (s, e) =>
                {
                    edit_dialog = dialog_data.Edit();
                    edit_dialog.PutString("come_from", "Came directly from bottom");
                    edit_dialog.Apply();
                    StartActivity(typeof(ChatListActivity));
                };
                specialistsLL.Click += (s, e) =>
                {
                    StartActivity(typeof(SpecialistsCategoryActivity));
                };
                Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");
                emailTV           = FindViewById <TextView>(Resource.Id.emailTV);
                emailTV.Text      = pref.GetString("email", String.Empty);
                resendBn          = FindViewById <Button>(Resource.Id.resendBn);
                completeLoginBn   = FindViewById <Button>(Resource.Id.completeLoginBn);
                textviewwe        = FindViewById <TextView>(Resource.Id.textviewwe);
                textView1         = FindViewById <TextView>(Resource.Id.textView1);
                activityIndicator = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
                activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);

                resendBn.SetTypeface(tf, TypefaceStyle.Normal);
                completeLoginBn.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.specialistsTV).SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.dialogsTV).SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.profileTV).SetTypeface(tf, TypefaceStyle.Normal);
                textviewwe.SetTypeface(tf, TypefaceStyle.Normal);
                textView1.SetTypeface(tf, TypefaceStyle.Normal);
                emailTV.SetTypeface(tf, TypefaceStyle.Normal);


                completeLoginBn.Click += async(s, e) =>
                {
                    completeLoginBn.Visibility   = ViewStates.Gone;
                    resendBn.Visibility          = ViewStates.Gone;
                    activityIndicator.Visibility = ViewStates.Visible;
                    var activate = await authorizationMethods.AuthActivate(pref.GetString("email", String.Empty), true);

                    completeLoginBn.Visibility   = ViewStates.Visible;
                    resendBn.Visibility          = ViewStates.Visible;
                    activityIndicator.Visibility = ViewStates.Gone;
                    if (activate.Contains("authToken"))
                    {
                        if (activate != "null" && activate != null && activate != "false")
                        {
                            var deserialized_value = JsonConvert.DeserializeObject <RegAfter>(activate.ToString());
                            if (deserialized_value.confirmed != false)
                            {
                                userMethods.InsertUser(deserialized_value.authToken, pref.GetString("email", String.Empty));
                                StartActivity(typeof(UserProfileActivity));
                            }
                            else
                            {
                                Toast.MakeText(this, GetString(Resource.String.no_confirmation_by_mail), ToastLength.Short).Show();
                            }
                        }
                    }
                };

                resendBn.Click += async(s, e) =>
                {
                    resendBn.Visibility          = ViewStates.Gone;
                    completeLoginBn.Visibility   = ViewStates.Gone;
                    activityIndicator.Visibility = ViewStates.Visible;
                    var reg_result = await authorizationMethods.Authorize(pref.GetString("email", String.Empty));

                    resendBn.Visibility          = ViewStates.Visible;
                    completeLoginBn.Visibility   = ViewStates.Visible;
                    activityIndicator.Visibility = ViewStates.Gone;
                    StartActivity(typeof(AuthAfterActivity));
                };
            }
            catch
            {
                StartActivity(typeof(MainActivity));
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            try {
                SetContentView(Resource.Layout.RegEmail);
                InputMethodManager   imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                AuthorizationMethods authorizationMethods = new AuthorizationMethods();
                headerTV           = FindViewById <TextView>(Resource.Id.headerTV);
                infoTV             = FindViewById <TextView>(Resource.Id.infoTV);
                mainImageIV        = FindViewById <ImageView>(Resource.Id.mainImageIV);
                backRelativeLayout = FindViewById <RelativeLayout>(Resource.Id.backRelativeLayout);
                back_button        = FindViewById <ImageButton>(Resource.Id.back_button);
                activityIndicator  = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
                activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                ISharedPreferences       pref = Application.Context.GetSharedPreferences("auth_data", FileCreationMode.Private);
                ISharedPreferencesEditor edit = pref.Edit();
                sendBn  = FindViewById <Button>(Resource.Id.sendBn);
                emailET = FindViewById <EditText>(Resource.Id.emailET);
                mainImageIV.SetBackgroundResource(Resource.Drawable.mail_small2);
                infoTV.Text   = GetString(Resource.String.link_for_enter);
                sendBn.Text   = GetString(Resource.String.send_link);
                headerTV.Text = GetString(Resource.String.login);
                Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");
                headerTV.SetTypeface(tf, TypefaceStyle.Bold);
                sendBn.SetTypeface(tf, TypefaceStyle.Normal);
                infoTV.SetTypeface(tf, TypefaceStyle.Normal);
                emailET.SetTypeface(tf, TypefaceStyle.Normal);

                Intent intent = new Intent(this, typeof(AuthAfterActivity));
                intent.PutExtra("bottom_value", "profile");
                backRelativeLayout.Click += (s, e) =>
                {
                    OnBackPressed();
                };
                back_button.Click += (s, e) =>
                {
                    OnBackPressed();
                };
                sendBn.Click += async(s, e) =>
                {
                    edit.PutString("email", emailET.Text);
                    edit.Apply();
                    sendBn.Visibility            = ViewStates.Gone;
                    activityIndicator.Visibility = ViewStates.Visible;
                    var auth_result = await authorizationMethods.Authorize(emailET.Text);

                    if (auth_result.Contains("с таким email нет в нашей базе"))
                    {
                        infoTV.Text = GetString(Resource.String.email_not_exists);
                    }
                    else
                    {
                        StartActivity(intent);
                    }
                    sendBn.Visibility            = ViewStates.Visible;
                    activityIndicator.Visibility = ViewStates.Gone;
                };
                emailET.EditorAction += (object sender, EditText.EditorActionEventArgs e) =>
                {
                    imm.HideSoftInputFromWindow(emailET.WindowToken, 0);
                };
            }
            catch
            {
                StartActivity(typeof(MainActivity));
            }
        }