Пример #1
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            var AccountTypeTGroup = view.FindViewById <MaterialButtonToggleGroup>(Resource.Id.drv_part_tggl_grp);
            var InfoImgSwitcher   = view.FindViewById <ImageSwitcher>(Resource.Id.drv_part_img_swtchr1);
            var InfoTSwitcher     = view.FindViewById <TextSwitcher>(Resource.Id.drv_part_txt_swtchr1);
            var ContinueBtn       = view.FindViewById <MaterialButton>(Resource.Id.drv_part_cnt_btn);

            InitSwitchers(InfoImgSwitcher, InfoTSwitcher);

            AccountTypeTGroup.AddOnButtonCheckedListener(new OnButtonChecked(id =>
            {
                switch (id)
                {
                case Resource.Id.drv_tggl_partner_btn:
                    partner = true;
                    InfoTSwitcher.SetText(GetString(Resource.String.partner_desc_txt));
                    InfoImgSwitcher.SetImageResource(Resource.Drawable.driver_pablo);
                    break;

                case Resource.Id.drv_tggl_driver_btn:
                    partner = false;
                    InfoTSwitcher.SetText(GetString(Resource.String.driving_desc_txt));
                    InfoImgSwitcher.SetImageResource(Resource.Drawable.driver_pablo);
                    break;
                }
            }));


            ContinueBtn.Click += (s1, e1) =>
            {
                if (AppDataHelper.GetCurrentUser() != null)
                {
                    OnboardingActivity.ShowProgressDialog();
                    var driverRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}");
                    driverRef.Child("isPartner").SetValue(partner.ToString())
                    .AddOnSuccessListener(new OnSuccessListener(r1 =>
                    {
                        driverRef.Child(StringConstants.StageofRegistration).SetValue(RegistrationStage.Capturing.ToString())
                        .AddOnSuccessListener(new OnSuccessListener(r2 =>
                        {
                            PartnerTypeComplete.Invoke(this, new PartnerEventArgs {
                                IsPartnerComplete = true
                            });
                            OnboardingActivity.CloseProgressDialog();
                        }))
                        .AddOnFailureListener(new OnFailureListener(e1 => { OnboardingActivity.CloseProgressDialog(); }));
                    }))
                    .AddOnFailureListener(new OnFailureListener(e1 => { OnboardingActivity.CloseProgressDialog(); }));
                }
                else
                {
                    Toast.MakeText(Activity, "Something aint right", ToastLength.Short).Show();
                }
            };
        }
Пример #2
0
        private void ContinueBtn_Click(object sender, EventArgs e)
        {
            OnboardingActivity.ShowProgressDialog();
            HashMap carMap = new HashMap();

            carMap.Put("car_model", CarModelEt.Text);
            carMap.Put("car_brand", CarBrandEt.Text);
            carMap.Put("car_year", CarYearEt.Text);
            carMap.Put("car_color", CarColorEt.Text);
            carMap.Put("car_condition", ConditionEt.Text);
            carMap.Put("licence_no", DriverLicenceEt.EditText.Text);
            carMap.Put("reg_no", RegNoEt.EditText.Text);

            SaveCarDetailsToDb(carMap);
        }
Пример #3
0
        private void InitControls(View view)
        {
            var visit_btn = view.FindViewById <MaterialButton>(Resource.Id.visit_site_btn);
            var skip_btn  = view.FindViewById <MaterialButton>(Resource.Id.skip_btn);

            skip_btn.Click += (s1, e1) =>
            {
                if (AppDataHelper.GetCurrentUser().Uid == null)
                {
                    return;
                }
                else
                {
                    OnboardingActivity.ShowProgressDialog();
                    var dataRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}/{StringConstants.StageofRegistration}");
                    dataRef.SetValue(RegistrationStage.RegistrationDone.ToString())
                    .AddOnSuccessListener(new OnSuccessListener(r =>
                    {
                        editor = preferences.Edit();
                        editor.PutString("firstRun", "regd");
                        editor.Commit();

                        OnboardingActivity.CloseProgressDialog();
                        var intent = new Intent(Context, typeof(MainActivity));
                        intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask);
                        StartActivity(intent);
                    })).AddOnFailureListener(new OnFailureListener(e =>
                    {
                        OnboardingActivity.CloseProgressDialog();
                        OnboardingActivity.ShowErrorDialog(e.Message);
                    }));
                }
            };

            visit_btn.Click += (s2, e2) =>
            {
                string url = "https://www.google.com";
                Intent i   = new Intent(Intent.ActionView);
                i.SetData(Android.Net.Uri.Parse(url));
                StartActivity(i);
            };
        }
        private void DetectFace()
        {
            OnboardingActivity.ShowProgressDialog();
            try
            {
                FaceDetector detector = new FaceDetector.Builder(Context)
                                        .SetMode(FaceDetectionMode.Accurate)
                                        .SetClassificationType(ClassificationType.All)
                                        .SetLandmarkType(LandmarkDetectionType.All)
                                        .SetProminentFaceOnly(true)
                                        .SetTrackingEnabled(false)
                                        .Build();

                if (!detector.IsOperational)
                {
                    //Handle contingency
                }
                else
                {
                    Frame frame = new Frame.Builder()
                                  .SetBitmap(bitmap)
                                  .Build();

                    var faces = detector.Detect(frame);
                    detector.Release();
                    DetectedResponse(bitmap, faces);
                }


                SaveImage();
            }
            catch (Exception e)
            {
                OnboardingActivity.CloseProgressDialog();
                OnboardingActivity.ShowErrorDialog(e.Message);
            }
        }
 private void CameraIntroDialog_StartCameraAsync(object sender, EventArgs args)
 {
     OnboardingActivity.ShowProgressDialog();
     CheckAndStartCamera();
 }
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            SubmitBtn = view.FindViewById <MaterialButton>(Resource.Id.drv_signup_sbmtbtn);
            FnameText = view.FindViewById <TextInputLayout>(Resource.Id.drv_signup_fname_et);
            LnameText = view.FindViewById <TextInputLayout>(Resource.Id.drv_signup_lname_et);
            EmailText = view.FindViewById <TextInputLayout>(Resource.Id.drv_signup_email_et);
            PhoneText = view.FindViewById <TextInputLayout>(Resource.Id.drv_signup_phone_et);
            CodeText  = view.FindViewById <TextInputLayout>(Resource.Id.drv_signup_code_et);
            PassText  = view.FindViewById <TextInputLayout>(Resource.Id.drv_signup_pass_et);
            CityText  = view.FindViewById <AppCompatAutoCompleteTextView>(Resource.Id.autocity_et);
            var regAppBar = view.FindViewById <AppBarLayout>(Resource.Id.signup_appbar);

            var toolbar = regAppBar.FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.main_toolbar);

            toolbar.Title = "Register";
            toolbar.InflateMenu(Resource.Menu.help_menu);
            toolbar.MenuItemClick += Toolbar_MenuItemClick;

            FnameText.EditText.AfterTextChanged += EditText_AfterTextChanged;
            LnameText.EditText.AfterTextChanged += EditText_AfterTextChanged;
            PassText.EditText.AfterTextChanged  += EditText_AfterTextChanged;
            EmailText.EditText.AfterTextChanged += EditText_AfterTextChanged;
            PhoneText.EditText.AfterTextChanged += EditText_AfterTextChanged;

            var adapter = ArrayAdapterClass.CreateArrayAdapter(Activity, names);

            CityText.Adapter           = adapter;
            CityText.AfterTextChanged += EditText_AfterTextChanged;

            SubmitBtn.Click += (s1, e1) =>
            {
                //open progress
                OnboardingActivity.ShowProgressDialog();
                fname = FnameText.EditText.Text;
                lname = LnameText.EditText.Text;
                email = EmailText.EditText.Text;
                phone = PhoneText.EditText.Text;
                city  = CityText.Text;
                code  = CodeText.EditText.Text;

                AppDataHelper.GetFirebaseAuth().CreateUserWithEmailAndPassword(email, PassText.EditText.Text)
                .AddOnCompleteListener(new OnCompleteListener(t =>
                {
                    if (!t.IsSuccessful)
                    {
                        try
                        {
                            OnboardingActivity.CloseProgressDialog();
                            throw t.Exception;
                        }
                        catch (FirebaseAuthInvalidCredentialsException)
                        {
                            OnboardingActivity.ShowErrorDialog("The email or password is not correct");
                        }
                        catch (FirebaseAuthUserCollisionException)
                        {
                            ShowEmailExistsDialog();
                        }
                        catch (FirebaseAuthInvalidUserException)
                        {
                            OnboardingActivity.ShowErrorDialog("User invalid");
                        }
                        catch (FirebaseNetworkException)
                        {
                            OnboardingActivity.ShowNoNetDialog(false);
                        }
                        catch (Exception)
                        {
                            OnboardingActivity.ShowErrorDialog("Your request could not be completed at this time");
                        }
                    }
                    else
                    {
                        SaveDriverToDb();
                    }
                }));
            };
        }
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            var emailText     = view.FindViewById <TextInputLayout>(Resource.Id.drv_signin_email_et);
            var passText      = view.FindViewById <TextInputLayout>(Resource.Id.drv_signin_pass_et);
            var forgotPassBtn = view.FindViewById <MaterialButton>(Resource.Id.btn_forgot_pass);

            forgotPassBtn.Click += (s1, e1) =>
            {
                ForgotPassFragment passFragment = new ForgotPassFragment();
                AndroidX.Fragment.App.FragmentTransaction ft = ChildFragmentManager.BeginTransaction();
                ft.Add(passFragment, "forgot_pass_fragment");
                ft.CommitAllowingStateLoss();
            };

            var continueFab = view.FindViewById <FloatingActionButton>(Resource.Id.fab1);

            continueFab.Click += (s2, e2) =>
            {
                bool enabled = !(!Patterns.EmailAddress.Matcher(emailText.EditText.Text).Matches() || passText.EditText.Text.Length < 8);
                switch (enabled)
                {
                case false:
                    Toast.MakeText(Activity, "A valid email and password is required", ToastLength.Short).Show();
                    break;

                default:
                {
                    //showProgress
                    OnboardingActivity.ShowProgressDialog();
                    AppDataHelper.GetFirebaseAuth().SignInWithEmailAndPassword(emailText.EditText.Text, passText.EditText.Text)
                    .AddOnCompleteListener(new OnCompleteListener(t =>
                        {
                            if (t.IsSuccessful)
                            {
                                var dataRef = AppDataHelper.GetDatabase().GetReference("Drivers/" + AppDataHelper.GetCurrentUser().Uid);
                                dataRef.AddValueEventListener(new SingleValueListener(d =>
                                {
                                    if (!d.Exists())
                                    {
                                        return;
                                    }

                                    var stage = (d.Child(StringConstants.StageofRegistration) != null) ? d.Child(StringConstants.StageofRegistration).Value.ToString() : "";
                                    if (stage != $"{RegistrationStage.RegistrationDone}")
                                    {
                                        editor = preferences.Edit();
                                        editor.PutString("firstRun", "reg");
                                        editor.Commit();
                                        OnboardingActivity.CloseProgressDialog();
                                        onRegUncompleteListener?.Invoke(this, new RegUncompleteArgs {
                                            StageReached = stage
                                        });
                                    }
                                    else
                                    {
                                        editor = preferences.Edit();
                                        editor.PutString("firstRun", "regd");
                                        editor.Commit();

                                        var intent = new Intent(Context, typeof(MainActivity));
                                        intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask);
                                        StartActivity(intent);
                                    }
                                }, e =>
                                {
                                    try
                                    {
                                        OnboardingActivity.CloseProgressDialog();
                                        throw t.Exception;
                                    }
                                    catch (DatabaseException)
                                    {
                                        OnboardingActivity.ShowErrorDialog("Database exeption");
                                    }
                                    catch (FirebaseNetworkException)
                                    {
                                        OnboardingActivity.ShowNoNetDialog(false);
                                    }
                                    catch (Exception)
                                    {
                                        OnboardingActivity.ShowErrorDialog("Something went wrong, please retry");
                                    }
                                }));
                            }
                            else
                            {
                                try
                                {
                                    OnboardingActivity.CloseProgressDialog();
                                    throw t.Exception;
                                }
                                catch (FirebaseAuthInvalidCredentialsException)
                                {
                                    OnboardingActivity.ShowErrorDialog("Your email or password is incorrect. Please try again.");
                                }
                                catch (FirebaseAuthInvalidUserException)
                                {
                                    OnboardingActivity.ShowErrorDialog("We can't find an account with this email address. Please try again or create a new account.");
                                }
                                catch (FirebaseNetworkException)
                                {
                                    OnboardingActivity.ShowNoNetDialog(false);
                                }
                                catch (Exception)
                                {
                                    OnboardingActivity.ShowErrorDialog("We couldn't sign you in at this time. Please retry");
                                }
                            }
                        }));

                    break;
                }
                }
            };
        }