Exemplo n.º 1
0
 private void SaveCarDetailsToDb(HashMap carMap)
 {
     if (AppDataHelper.GetCurrentUser() != null)
     {
         var vehicleRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}/MyCars");
         vehicleRef.SetValue(carMap)
         .AddOnSuccessListener(new OnSuccessListener(result =>
         {
             var driverRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}/{StringConstants.StageofRegistration}");
             driverRef.SetValue($"{RegistrationStage.Agreement}")
             .AddOnSuccessListener(new OnSuccessListener(result2 =>
             {
                 CarRegComplete.Invoke(this, new EventArgs());
                 OnboardingActivity.CloseProgressDialog();
             })).AddOnFailureListener(new OnFailureListener(e2 =>
             {
                 OnboardingActivity.CloseProgressDialog();
                 Toast.MakeText(Activity, e2.Message, ToastLength.Short).Show();
             }));
         }))
         .AddOnFailureListener(new OnFailureListener(e1 =>
         {
             OnboardingActivity.CloseProgressDialog();
             Toast.MakeText(Activity, e1.Message, ToastLength.Short).Show();
         }));
     }
     else
     {
         return;
     }
 }
Exemplo n.º 2
0
 private void CheckUserAvailability()
 {
     try
     {
         var userRef = SessionManager.UserRef.Child(SessionManager.UserId);
         userRef.AddValueEventListener(new SingleValueListener(
                                           onDataChange: (s) =>
         {
             if (!s.Exists())
             {
                 GotoProfile();
             }
             else
             {
                 var firstname = s.Child("profile").Child("fname") == null ? "" : s.Child("profile").Child("fname").Value.ToString();
                 GotoMain(firstname);
             }
         },
                                           onCancelled: (e) =>
         {
         }));
     }
     catch (Exception e)
     {
         OnboardingActivity.ShowError(e.Source, e.Message);
     }
 }
Exemplo n.º 3
0
 private void GotoProfile()
 {
     SetStatus("create_profile");
     OnboardingActivity.DismissLoader();
     ParentFragmentManager.BeginTransaction()
     .Replace(Resource.Id.frag_container, new CreateProfileFragment())
     .CommitAllowingStateLoss();
 }
        private void SaveImage()
        {
            picDisplayFragment.DismissAllowingStateLoss();
            var storeRef = FirebaseStorage.Instance.GetReferenceFromUrl("gs://taxiproject-185a4.appspot.com");

            if (AppDataHelper.GetCurrentUser() != null)
            {
                var stream = new MemoryStream();
                bitmap.Compress(Bitmap.CompressFormat.Webp, 80, stream);
                byte[] bitmapArray = stream.ToArray();

                imageRef = storeRef.Child("driverProfilePics/" + AppDataHelper.GetCurrentUser().Uid);
                imageRef.PutBytes(bitmapArray).ContinueWithTask(new ContinuationTask(t =>
                {
                    if (!t.IsSuccessful)
                    {
                        OnboardingActivity.CloseProgressDialog();
                        Toast.MakeText(Activity, t.Exception.Message, ToastLength.Long).Show();
                    }
                })).AddOnCompleteListener(new OnCompleteListener(t =>
                {
                    if (t.IsSuccessful)
                    {
                        var driverRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}");
                        driverRef.Child("profile_img_url").SetValue(t.Result.ToString()).AddOnCompleteListener(new OnCompleteListener(t3 =>
                        {
                            if (!t3.IsSuccessful)
                            {
                                Toast.MakeText(Activity, t3.Exception.Message, ToastLength.Long).Show();
                            }
                            OnboardingActivity.CloseProgressDialog();

                            driverRef.Child(StringConstants.StageofRegistration).SetValue($"{RegistrationStage.CarRegistering}")
                            .AddOnSuccessListener(new OnSuccessListener(r2 =>
                            {
                                ProfileCaptured.Invoke(this, new EventArgs());
                                UpdateUiOnCpture(CaptureType.ProfilePic);
                                OnboardingActivity.CloseProgressDialog();
                            })).AddOnFailureListener(new OnFailureListener(e2 =>
                            {
                                OnboardingActivity.CloseProgressDialog();
                                OnboardingActivity.ShowErrorDialog("Something went wrong, please retry");
                            }));
                        }));
                    }
                    else
                    {
                        OnboardingActivity.CloseProgressDialog();
                        OnboardingActivity.ShowErrorDialog("Something went wrong, please retry");
                    }
                }));
            }
            else
            {
                return;
            }
        }
Exemplo n.º 5
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();
                }
            };
        }
Exemplo n.º 6
0
        private void GotoMain(string name)
        {
            SetStatus("done");
            var intent = new Intent(Activity, typeof(MainActivity));

            intent.PutExtra("firstName", name);
            intent.AddFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask);
            StartActivity(intent);
            OnboardingActivity.DismissLoader();
        }
Exemplo n.º 7
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);
        }
        private void SaveDriverToDb()
        {
            var DriverRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{ AppDataHelper.GetCurrentUser().Uid}");

            HashMap compliments = new HashMap();

            compliments.Put("cool_car", "0");
            compliments.Put("neat_and_tidy", "0");
            compliments.Put("expert_navigation", "0");
            compliments.Put("awesome_music", "0");
            compliments.Put("made_me_laugh", "0");

            HashMap driverMap = new HashMap();

            driverMap.Put("fname", fname);
            driverMap.Put("lname", lname);
            driverMap.Put("email", email);
            driverMap.Put("phone", phone);
            driverMap.Put("city", city);
            driverMap.Put("invitecode", code);
            driverMap.Put("ratings", "0");
            driverMap.Put("compliments", compliments);
            driverMap.Put("created_at", DateTime.UtcNow.ToString());



            DriverRef.SetValue(driverMap)
            .AddOnSuccessListener(new OnSuccessListener(r =>
            {
                DriverRef.Child(StringConstants.StageofRegistration).SetValue(RegistrationStage.Partnering.ToString())
                .AddOnSuccessListener(new OnSuccessListener(r2 =>
                {
                    OnboardingActivity.CloseProgressDialog();
                    SignUpSuccess.Invoke(this, new SignUpSuccessArgs {
                        IsCompleted = true
                    });
                }))
                .AddOnFailureListener(new OnFailureListener(e1 =>
                {
                    OnboardingActivity.CloseProgressDialog();
                    Toast.MakeText(Activity, e1.Message, ToastLength.Short).Show();
                }));
            }))
            .AddOnFailureListener(new OnFailureListener(e =>
            {
                OnboardingActivity.ShowErrorDialog("Something went wrong, please retry");
            }));
        }
Exemplo n.º 9
0
        private void SendVerificationCode()
        {
            auth = SessionManager.GetFirebaseAuth();
            PhoneAuthProvider.GetInstance(auth)
            .VerifyPhoneNumber(phone, 30, TimeUnit.Seconds, Activity, new PhoneVerificationCallbacks(
                                   onVerificationCompleted: (cred) =>
            {
                var code = cred.SmsCode;
                if (string.IsNullOrEmpty(code))
                {
                    return;
                }

                otpView.Value = code;
                VerifyCode(code);
            }, onVerificationFailed: (e) =>
            {
                try
                {
                    resendBtn.Enabled = false;
                    cdTimer.Cancel();
                    throw e;
                }
                catch (FirebaseNetworkException)
                {
                    OnboardingActivity.ShowNoNetDialog(false);
                }
                catch (FirebaseTooManyRequestsException ftmre)
                {
                    OnboardingActivity.ShowError(ftmre.Source, ftmre.Message);
                }
                catch (FirebaseAuthInvalidCredentialsException faice)
                {
                    OnboardingActivity.ShowError(faice.Source, faice.Message);
                }
                catch (FirebaseAuthInvalidUserException fiue)
                {
                    OnboardingActivity.ShowError(fiue.Source, fiue.Message);
                }
                catch (Exception ex)
                {
                    OnboardingActivity.ShowError(ex.Source, ex.Message);
                }
            }, onCodeSent: (code, token) =>
            {
                verificationId = code;
            }));
        }
Exemplo n.º 10
0
        private void VerifyCode(string code)
        {
            OnboardingActivity.ShowLoader();
            PhoneAuthCredential cred = PhoneAuthProvider.GetCredential(verificationId, code);

            auth.SignInWithCredential(cred)
            .AddOnCompleteListener(new OncompleteListener(
                                       onComplete: (t) =>
            {
                try
                {
                    switch (t.IsSuccessful)
                    {
                    case false:
                        throw t.Exception;

                    default:
                        CheckUserAvailability();
                        break;
                    }
                }
                catch (FirebaseAuthInvalidCredentialsException fiace)
                {
                    OnboardingActivity.DismissLoader();
                    OnboardingActivity.ShowError(fiace.Source, fiace.Message);
                }
                catch (FirebaseTooManyRequestsException ftmre)
                {
                    OnboardingActivity.DismissLoader();
                    OnboardingActivity.ShowError(ftmre.Source, ftmre.Message);
                }
                catch (FirebaseAuthInvalidUserException fiue)
                {
                    OnboardingActivity.DismissLoader();
                    OnboardingActivity.ShowError(fiue.Source, fiue.Message);
                }
                catch (FirebaseNetworkException)
                {
                    OnboardingActivity.DismissLoader();
                    OnboardingActivity.ShowNoNetDialog(false);
                }
                catch (Exception e)
                {
                    OnboardingActivity.DismissLoader();
                    OnboardingActivity.ShowError(e.Source, e.Message);
                }
            }));
        }
Exemplo n.º 11
0
        public void OnSuccess(Java.Lang.Object result)
        {
            loginResult = result as LoginResult;

            var credentials = FacebookAuthProvider.GetCredential(loginResult.AccessToken.Token);

            SessionManager.GetFirebaseAuth().SignInWithCredential(credentials)
            .AddOnCompleteListener(new OncompleteListener((t) =>
            {
                if (!t.IsSuccessful)
                {
                    return;
                }
                OnboardingActivity.ShowSuccess();
            }));
        }
 private void DetectedResponse(Bitmap bitmap, SparseArray faces)
 {
     if (faces.Size() < 1)
     {
         OnboardingActivity.CloseProgressDialog();
         OnboardingActivity.ShowErrorDialog("No face in photo");
     }
     else if (faces.Size() == 1)
     {
         SaveImage();
     }
     else if (faces.Size() > 1)
     {
         OnboardingActivity.CloseProgressDialog();
         OnboardingActivity.ShowErrorDialog("More than one face detected");
     }
 }
Exemplo n.º 13
0
 public override void OnReceive(Context context, Intent intent)
 {
     try
     {
         if (IsOnline(context))
         {
             OnboardingActivity.ShowNoNetDialog(true);
         }
         else
         {
             OnboardingActivity.ShowNoNetDialog(false);
         }
     }
     catch (NullPointerException e)
     {
         Log.Error("labs", e.Message);
     }
 }
Exemplo n.º 14
0
        public override void OnReceive(Context context, Intent intent)
        {
            if (intent == null || intent.Extras == null)
            {
                return;
            }

            var connManager = context.GetSystemService(Context.ConnectivityService) as ConnectivityManager;

            connManager.RegisterDefaultNetworkCallback(new DefaultNetCallback(
                                                           (net, capa) =>
            {
                var connected = capa.HasCapability(NetCapability.Internet);
                OnboardingActivity.ShowNoNetDialog(connected);
            }, (net) =>
            {
                OnboardingActivity.ShowNoNetDialog(false);
            }));
        }
Exemplo n.º 15
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 UpdateUiOnCpture(CaptureType captureType)
        {
            switch (captureType)
            {
            case CaptureType.ProfilePic:
                Card1.CardBackgroundColor = ColorStateList.ValueOf(Color.LightSkyBlue);
                NxtImg1.ImageTintList     = ColorStateList.ValueOf(Color.Blue);
                break;

            case CaptureType.FrontOfLicense:
                Card2.CardBackgroundColor = ColorStateList.ValueOf(Color.LightSkyBlue);
                NxtImg2.ImageTintList     = ColorStateList.ValueOf(Color.Blue);
                break;

            case CaptureType.BackOfLicense:
                Card3.CardBackgroundColor = ColorStateList.ValueOf(Color.LightSkyBlue);
                NxtImg3.ImageTintList     = ColorStateList.ValueOf(Color.Blue);
                break;
            }

            OnboardingActivity.CloseProgressDialog();
        }
        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 UpdateUiOnError(CaptureType captureType)
        {
            switch (captureType)
            {
            case CaptureType.ProfilePic:
                Card1.CardBackgroundColor = ColorStateList.ValueOf(Color.PapayaWhip);
                NxtImg1.SetImageResource(Resource.Drawable.ic_error);
                HeaderTxt1.SetText(Resource.String.string_attention_seekr);
                break;

            case CaptureType.FrontOfLicense:
                Card2.CardBackgroundColor = ColorStateList.ValueOf(Color.PapayaWhip);
                NxtImg2.SetImageResource(Resource.Drawable.ic_error);
                HeaderTxt2.SetText(Resource.String.string_attention_seekr);
                break;

            case CaptureType.BackOfLicense:
                Card3.CardBackgroundColor = ColorStateList.ValueOf(Color.PapayaWhip);
                NxtImg3.SetImageResource(Resource.Drawable.ic_error);
                HeaderTxt3.SetText(Resource.String.string_attention_seekr);
                break;
            }
            OnboardingActivity.CloseProgressDialog();
        }
        private async void SaveToDb()
        {
            try
            {
                var profileRef = SessionManager.GetFireDB().GetReference($"users/{SessionManager.UserId}/profile");
                var userMap    = new HashMap();
                var stream     = new System.IO.MemoryStream();
                var bitmap     = MediaStore.Images.Media.GetBitmap(Context.ContentResolver, img_uri);
                await bitmap.CompressAsync(Bitmap.CompressFormat.Webp, 90, stream);

                var imgArray = stream.ToArray();

                var imageRef = FirebaseStorage.Instance.GetReference($"profileImages/{SessionManager.UserId}");
                imageRef.PutBytes(imgArray).ContinueWithTask(new ContinuationTask(
                                                                 then: t =>
                {
                    if (!t.IsSuccessful)
                    {
                        throw t.Exception;
                    }
                })).AddOnCompleteListener(new OncompleteListener(
                                              onComplete: t =>
                {
                    if (!t.IsSuccessful)
                    {
                        throw t.Exception;
                    }

                    userMap.Put(Constants.SNAPSHOT_FNAME, fullnameEt.EditText.Text);
                    userMap.Put(Constants.SNAPSHOT_EMAIL, emailEt.EditText.Text);
                    userMap.Put(Constants.SNAPSHOT_GENDER, (int)userGender);
                    userMap.Put(Constants.SNAPSHOT_PHONE, SessionManager.GetFirebaseAuth().CurrentUser.PhoneNumber);
                    userMap.Put(Constants.SNAPSHOT_PHOTO_URL, t.Result.ToString());
                    profileRef.SetValue(userMap).AddOnCompleteListener(new OncompleteListener(
                                                                           onComplete: task =>
                    {
                        try
                        {
                            if (!task.IsSuccessful)
                            {
                                throw task.Exception;
                            }

                            GetSmsFragment.SetStatus("set_partner");
                            ParentFragmentManager.BeginTransaction()
                            .Replace(Resource.Id.frag_container, new PartnerFragment())
                            .CommitAllowingStateLoss();
                        }
                        catch (DatabaseException de)
                        {
                            OnboardingActivity.ShowError("Database Exception", de.Message);
                        }
                    }));
                    profileRef.KeepSynced(true);
                }));
            }
            catch (DatabaseException fde)
            {
                OnboardingActivity.ShowError("Database Exception", fde.Message);
            }
            catch (FirebaseNetworkException)
            {
                OnboardingActivity.ShowNoNetDialog(false);
            }
            catch (StorageException se)
            {
                OnboardingActivity.ShowError("Storage Exception", se.Message);
            }
            catch (Exception ex)
            {
                OnboardingActivity.ShowError("Exception", ex.Message);
            }
        }
        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;
                }
                }
            };
        }
        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();
                    }
                }));
            };
        }
 private void CameraIntroDialog_StartCameraAsync(object sender, EventArgs args)
 {
     OnboardingActivity.ShowProgressDialog();
     CheckAndStartCamera();
 }
 private void CameraActivity_onImageCaptured(object sender, CameraActivity.ImageCapturedEventArgs e)
 {
     OnboardingActivity.CloseProgressDialog();
     bitmap = e.ProfilePic;
     DisplayPic(e.RotationDegrees);
 }
Exemplo n.º 24
0
 public void OnError(FacebookException error)
 {
     OnboardingActivity.ShowError(error.Source, error.Message);
 }
Exemplo n.º 25
0
 public void OnCancel()
 {
     OnboardingActivity.ShowError("Login canceled", "You canceled the login operation");
 }