Пример #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.sheetRenameAuthenticator, null);

            SetupToolbar(view, Resource.String.rename);

            _issuerLayout   = view.FindViewById <TextInputLayout>(Resource.Id.editIssuerLayout);
            _issuerText     = view.FindViewById <TextInputEditText>(Resource.Id.editIssuer);
            _usernameLayout = view.FindViewById <TextInputLayout>(Resource.Id.editUsernameLayout);
            _usernameText   = view.FindViewById <TextInputEditText>(Resource.Id.editUsername);

            _issuerText.Append(_issuer);

            if (_username != null)
            {
                _usernameText.Append(_username);
            }

            _issuerLayout.CounterMaxLength = Authenticator.IssuerMaxLength;
            _issuerText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(Authenticator.IssuerMaxLength) });
            _usernameLayout.CounterMaxLength = Authenticator.UsernameMaxLength;
            _usernameText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(Authenticator.UsernameMaxLength) });

            TextInputUtil.EnableAutoErrorClear(_issuerLayout);

            var cancelButton = view.FindViewById <MaterialButton>(Resource.Id.buttonCancel);

            cancelButton.Click += delegate
            {
                Dismiss();
            };

            var renameButton = view.FindViewById <MaterialButton>(Resource.Id.buttonRename);

            renameButton.Click += delegate
            {
                var issuer = _issuerText.Text.Trim();
                if (issuer == "")
                {
                    _issuerLayout.Error = GetString(Resource.String.noIssuer);
                    return;
                }

                var args = new RenameEventArgs(_position, issuer, _usernameText.Text);
                Rename?.Invoke(this, args);
                Dismiss();
            };

            _usernameText.EditorAction += (_, args) =>
            {
                if (args.ActionId == ImeAction.Done)
                {
                    renameButton.PerformClick();
                }
            };

            return(view);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.sheetRenameAuthenticator, null);

            _issuerLayout = view.FindViewById <TextInputLayout>(Resource.Id.editIssuerLayout);
            _issuerText   = view.FindViewById <TextInputEditText>(Resource.Id.editIssuer);
            _usernameText = view.FindViewById <TextInputEditText>(Resource.Id.editUsername);

            _issuerText.Text   = _issuer;
            _usernameText.Text = _username;

            var cancelButton = view.FindViewById <MaterialButton>(Resource.Id.buttonCancel);

            cancelButton.Click += (s, e) =>
            {
                Dismiss();
            };

            var renameButton = view.FindViewById <MaterialButton>(Resource.Id.buttonRename);

            renameButton.Click += (s, e) =>
            {
                var issuer = _issuerText.Text.Trim();
                if (issuer == "")
                {
                    _issuerLayout.Error = GetString(Resource.String.noIssuer);
                    return;
                }

                var args = new RenameEventArgs(_itemPosition, issuer, _usernameText.Text);
                Rename?.Invoke(this, args);
                Dismiss();
            };

            _usernameText.EditorAction += (sender, args) =>
            {
                if (args.ActionId == ImeAction.Done)
                {
                    renameButton.PerformClick();
                }
            };

            return(view);
        }