Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Localise.SetLayoutDirectionByCulture(this);

            Application.RegisterActivityLifecycleCallbacks(this);

            CheckAuth();
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            firebaseAnalytics = FirebaseAnalytics.GetInstance(this);
            base.OnCreate(savedInstanceState);
            Localise.SetLayoutDirectionByCulture(this);
            SetContentView(Resource.Layout.register);

            SupportActionBar.Title = StringResources.register_ui_title;
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            FindViewById <TextView>(Resource.Id.loadingMessage).Text = StringResources.common_comms_loading;

            languageSpinner = FindViewById <Spinner>(Resource.Id.chooseLanguageSpinner);
            languageSpinner.ItemSelected += LanguageSpinner_ItemSelected;

            AppCompatButton submit = FindViewById <AppCompatButton>(Resource.Id.submit);

            submit.Text = StringResources.register_ui_submit_button;

            TextInputLayout nameInput = FindViewById <TextInputLayout>(Resource.Id.nameLayout);

            nameInput.Hint = StringResources.register_ui_fullname_label;

            TextInputLayout emailInput = FindViewById <TextInputLayout>(Resource.Id.emailLayout);

            emailInput.Hint = StringResources.common_ui_forms_email_label;

            TextInputLayout passwordInput = FindViewById <TextInputLayout>(Resource.Id.passwordLayout);

            passwordInput.Hint = StringResources.common_ui_forms_password_label;

            TextInputLayout confirmPassInput = FindViewById <TextInputLayout>(Resource.Id.passwordConfirmLayout);

            confirmPassInput.Hint = StringResources.common_ui_forms_password_confirm_label;

            var terms        = FindViewById <TextView>(Resource.Id.Terms);
            var termsContent = string.Format(StringResources.register_ui_terms_label, Config.WEB_URL);

            terms.TextFormatted  = Android.Text.Html.FromHtml(termsContent);
            terms.MovementMethod = Android.Text.Method.LinkMovementMethod.Instance;

            FindViewById <TextInputEditText>(Resource.Id.password).EditorAction += (_, e) =>
            {
                e.Handled = false;
                if (e.ActionId == Android.Views.InputMethods.ImeAction.Done)
                {
                    FindViewById <AppCompatButton>(Resource.Id.submit).PerformClick();
                    e.Handled = true;
                }
            };

            submit.Click += Submit_Click;

            LoadLanguages();
        }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            firebaseAnalytics = FirebaseAnalytics.GetInstance(this);
            base.OnCreate(savedInstanceState);
            Localise.SetLayoutDirectionByCulture(this);
            SetContentView(Resource.Layout.onboarding);

            pager = FindViewById <ViewPager>(Resource.Id.pager);

            var pages = new List <OnboardingPageContent> {
                new OnboardingPageContent {
                    Image   = Resource.Drawable.AppLogo,
                    Title   = StringResources.onboarding_ui_page_zero_title,
                    Content = StringResources.onboarding_ui_page_zero_content
                },
                new OnboardingPageContent {
                    Image   = Resource.Drawable.onboarding_02,
                    Title   = StringResources.onboarding_ui_page_first_title,
                    Content = StringResources.onboarding_ui_page_first_content
                },
                new OnboardingPageContent {
                    Image   = Resource.Drawable.onboarding_03,
                    Title   = StringResources.onboarding_ui_page_second_title,
                    Content = StringResources.onboarding_ui_page_second_content
                },
                new OnboardingPageContent {
                    Image   = Resource.Drawable.onboarding_04,
                    Title   = StringResources.onboarding_ui_page_third_title,
                    Content = StringResources.onboarding_ui_page_third_content
                },
                new OnboardingPageContent {
                    Image   = Resource.Drawable.onboarding_05,
                    Title   = StringResources.onboarding_ui_page_fourth_title,
                    Content = string.Format(StringResources.onboarding_ui_page_fourth_content, GabberPCL.Config.PRINT_URL)
                }
            };

            pager.Adapter = new Adapters.SharedPager(this, pages);
            pager.AddOnPageChangeListener(this);

            var tabs = FindViewById <TabLayout>(Resource.Id.tabs);

            tabs.SetupWithViewPager(pager, true);
            tabs.SetSelectedTabIndicatorHeight(0);

            var login = FindViewById <AppCompatButton>(Resource.Id.login);

            login.Text   = StringResources.login_ui_submit_button;
            login.Click += (sender, e) => StartActivity(typeof(LoginActivity));

            var register = FindViewById <AppCompatButton>(Resource.Id.register);

            register.Text   = StringResources.register_ui_submit_button;
            register.Click += (sender, e) => StartActivity(typeof(RegisterActivity));
        }
Beispiel #4
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            firebaseAnalytics = FirebaseAnalytics.GetInstance(this);

            base.OnCreate(savedInstanceState);
            Localise.SetLayoutDirectionByCulture(this);
            SetContentView(Resource.Layout.register_verification_res);

            var prefs = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);

            // The user has already been logged in -- not sure how they got here.
            if (!string.IsNullOrWhiteSpace(prefs.GetString("username", "")))
            {
                StartActivity(typeof(MainActivity));
                Finish();
            }

            var _title = FindViewById <TextView>(Resource.Id.registerVerifyTitle);

            _title.Text = StringResources.register_verifying_ui_page_title;
            var _content = FindViewById <TextView>(Resource.Id.registerVerifyContent);

            _content.Text = StringResources.register_verifying_ui_page_content;

            // Shown if an error occurs, such as account already been verified.
            var loginButton = FindViewById <AppCompatButton>(Resource.Id.registerVerifyLogin);

            loginButton.Text = StringResources.register_verifying_ui_button_login;

            // The URI click in the email
            var dataURI = base.Intent.Data;

            if (!string.IsNullOrEmpty(dataURI.ToString()))
            {
                FindViewById <ProgressBar>(Resource.Id.registerVerifyProgressBar).Visibility = ViewStates.Visible;
                var response = await RestClient.RegisterVerify(dataURI.LastPathSegment);

                FindViewById <ProgressBar>(Resource.Id.registerVerifyProgressBar).Visibility = ViewStates.Gone;

                if (response.Meta.Success)
                {
                    LOG_EVENT_WITH_ACTION("EMAIL_VERIFICATION", "SUCCESS");
                    prefs.Edit().PutString("username", response.Data.User.Email).Commit();
                    prefs.Edit().PutString("tokens", JsonConvert.SerializeObject(response.Data.Tokens)).Commit();
                    Queries.SetActiveUser(response.Data);

                    var intent = new Intent(this, typeof(MainActivity));
                    intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.ClearTask | ActivityFlags.NewTask);
                    StartActivity(intent);
                    Finish();
                }
                else
                {
                    LOG_EVENT_WITH_ACTION("EMAIL_VERIFICATION", "ERROR");
                    loginButton.Visibility = ViewStates.Visible;
                    FindViewById <TextView>(Resource.Id.registerVerifyContent).Text = StringResources.register_verifying_ui_page_content_error;
                    response.Meta.Messages.ForEach(MakeError);
                }
            }

            loginButton.Click += delegate {
                LOG_EVENT_WITH_ACTION("EMAIL_VERIFICATION", "LOGIN_CLICKED");
                var intent = new Intent(this, typeof(LoginActivity));
                intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.ClearTask | ActivityFlags.NewTask);
                StartActivity(intent);
                Finish();
            };
        }
Beispiel #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            firebaseAnalytics = FirebaseAnalytics.GetInstance(this);
            base.OnCreate(savedInstanceState);
            Localise.SetLayoutDirectionByCulture(this);
            SetContentView(Resource.Layout.login);

            SupportActionBar.Title = StringResources.login_ui_title;
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            var submit = FindViewById <AppCompatButton>(Resource.Id.submit);

            submit.Text = StringResources.login_ui_submit_button;

            // Have to manually change hints on input layout.
            var _email = FindViewById <TextInputLayout>(Resource.Id.emailTextInput);

            _email.Hint = StringResources.common_ui_forms_email_label;
            var _password = FindViewById <TextInputLayout>(Resource.Id.passwordTextInput);

            _password.Hint = StringResources.common_ui_forms_password_label;

            FindViewById <TextInputEditText>(Resource.Id.password).EditorAction += (_, e) =>
            {
                e.Handled = false;
                if (e.ActionId == Android.Views.InputMethods.ImeAction.Done)
                {
                    FindViewById <AppCompatButton>(Resource.Id.submit).PerformClick();
                    e.Handled = true;
                }
            };

            submit.Click += async delegate
            {
                var imm = (Android.Views.InputMethods.InputMethodManager)GetSystemService(InputMethodService);
                imm.HideSoftInputFromWindow(FindViewById <TextInputEditText>(Resource.Id.password).WindowToken, 0);

                var email = FindViewById <AppCompatEditText>(Resource.Id.email);
                var passw = FindViewById <AppCompatEditText>(Resource.Id.password);

                if (string.IsNullOrWhiteSpace(email.Text))
                {
                    email.Error = StringResources.common_ui_forms_email_validate_empty;
                    email.RequestFocus();
                }
                else if (string.IsNullOrWhiteSpace(passw.Text))
                {
                    passw.Error = StringResources.common_ui_forms_password_validate_empty;
                    passw.RequestFocus();
                }
                else if (!Android.Util.Patterns.EmailAddress.Matcher(email.Text).Matches())
                {
                    email.Error = StringResources.common_ui_forms_email_validate_invalid;
                    email.RequestFocus();
                }
                else
                {
                    FindViewById <ProgressBar>(Resource.Id.progressBar).Visibility = ViewStates.Visible;
                    FindViewById <AppCompatButton>(Resource.Id.submit).Enabled     = false;

                    LOG_EVENT_WITH_ACTION("LOGIN", "ATTEMPT");
                    var response = await RestClient.Login(email.Text.ToLower(), passw.Text);

                    if (response.Meta.Messages.Count > 0)
                    {
                        LOG_EVENT_WITH_ACTION("LOGIN", "ERROR");
                        RunOnUiThread(() =>
                        {
                            response.Meta.Messages.ForEach(MakeError);
                            FindViewById <AppCompatButton>(Resource.Id.submit).Enabled     = true;
                            FindViewById <ProgressBar>(Resource.Id.progressBar).Visibility = ViewStates.Gone;
                        });
                    }
                    // If there are no errors, then tokens exist as the request was a great success.
                    else if (!string.IsNullOrEmpty(response.Data?.Tokens.Access))
                    {
                        LOG_EVENT_WITH_ACTION("LOGIN", "SUCCESS");
                        // When the application is closed, the ActiveUser is reset. The username and tokens
                        // are used to build a new active user.
                        var prefs = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
                        // Used in MainActivity to determine if a user has logged in.
                        prefs.Edit().PutString("username", email.Text).Commit();
                        prefs.Edit().PutString("tokens", JsonConvert.SerializeObject(response.Data.Tokens)).Commit();

                        // Set active user on login/register as the user object is in the response.
                        // This prevents us from storing a user object in local storage.
                        Queries.SetActiveUser(response.Data);
                        FirebaseAnalytics.GetInstance(this).SetUserId(Session.ActiveUser.Id.ToString());

                        // We do not want the user to return to ANY gabber recording pages once captured.
                        var intent = new Intent(this, typeof(MainActivity));
                        intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.ClearTask | ActivityFlags.NewTask);
                        StartActivity(intent);
                        // Prevent returning to login once authenticated.
                        Finish();
                    }
                }
            };

            _email.RequestFocus();
            Window.SetSoftInputMode(SoftInput.StateAlwaysVisible);
        }