Exemplo n.º 1
0
        public static void Focus(this AView platformView, FocusRequest request)
        {
            request.IsFocused = true;

            // Android does the actual focus/unfocus work on the main looper
            // So in case we're setting the focus in response to another control's un-focusing,
            // we need to post the handling of it to the main looper so that it happens _after_ all the other focus
            // work is done; otherwise, a call to ClearFocus on another control will kill the focus we set

            var q = Looper.MyLooper();

            if (q != null)
            {
                new Handler(q).Post(RequestFocus);
            }
            else
            {
                MainThread.InvokeOnMainThreadAsync(RequestFocus);
            }

            void RequestFocus()
            {
                if (platformView == null || platformView.IsDisposed())
                {
                    return;
                }

                platformView?.RequestFocus();
            }
        }
Exemplo n.º 2
0
 public static void ShowKeyboard(Context context, View pView)
 {
     pView.RequestFocus();
     InputMethodManager inputMethodManager = (InputMethodManager)context.GetSystemService (Context.InputMethodService);
     inputMethodManager.ShowSoftInput(pView, ShowFlags.Forced);
     inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
 }
		public void OnChildLaidOut(ViewGroup parent, View view, int position, long id)
		{
			if (view != null && position == 0)
			{
				view.RequestFocus();
			}
		}
Exemplo n.º 4
0
        public static void ShowKeyboard(View pView)
        {
            pView.RequestFocus();

            InputMethodManager inputMethodManager = Current.GetSystemService(Context.InputMethodService) as InputMethodManager;

            inputMethodManager.ShowSoftInput(pView, ShowFlags.Forced);
            inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
        }
Exemplo n.º 5
0
        private void ShowKeyboard(Android.Views.View view)
        {
            view.RequestFocus();

            InputMethodManager inputMethodManager = MainActivity.Context.GetSystemService(Context.InputMethodService) as InputMethodManager;

            inputMethodManager.ShowSoftInput(view, ShowFlags.Forced);
            inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
        }
Exemplo n.º 6
0
 public override void OnResume()
 {
     base.OnResume();
     if (View == null)
     {
         return;
     }
     if (PopoverFragment.Instance == null)
     {
         View.LayoutParameters = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent);
         ((RichText)View).Browser.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
     }
     View.RequestFocus();
 }
Exemplo n.º 7
0
        protected virtual void SearchHandlerFocusChangeRequested(object sender, VisualElement.FocusRequestArgs e)
        {
            e.Result = true;

            if (e.Focus)
            {
                _control?.RequestFocus();
                _control?.PostShowKeyboard();
            }
            else
            {
                _control.ClearFocus();
                _control.HideKeyboard();
            }
        }
Exemplo n.º 8
0
        public static void Focus(this AView platformView, FocusRequest request)
        {
            // Android does the actual focus/unfocus work on the main looper
            // So in case we're setting the focus in response to another control's un-focusing,
            // we need to post the handling of it to the main looper so that it happens _after_ all the other focus
            // work is done; otherwise, a call to ClearFocus on another control will kill the focus we set here
            MainThread.BeginInvokeOnMainThread(() =>
            {
                if (platformView == null || platformView.IsDisposed())
                {
                    return;
                }

                platformView?.RequestFocus();
            });
        }
Exemplo n.º 9
0
 public static void OpenSoftKeyboard(Android.Views.View view)
 {
     view.RequestFocus();
     ThreadPool.QueueUserWorkItem(s =>
     {
         try
         {
             Thread.Sleep(100);
             InputMethodManager inputMethodManager = view.Context.GetSystemService(Context.InputMethodService) as InputMethodManager;
             inputMethodManager.ShowSoftInput(view, ShowFlags.Forced);
             inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly);
         }
         catch (Exception e)
         {
         }
     });
 }
Exemplo n.º 10
0
 public static void ShowKeyboard(View responder)
 {
     if (responder == null || responder.Visibility != ViewStates.Visible || !responder.Enabled)
     {
         return;
     }
     responder.RequestFocus();
     if (MainActivity.Resources.Configuration.Keyboard != Android.Content.Res.KeyboardType.Nokeys)
     {
         return;
     }
     responder.Post(() =>
     {
         if (responder != TextBase.CurrentFocus)
         {
             return;
         }
         var imm = (InputMethodManager)MainActivity.GetSystemService(Context.InputMethodService);
         imm.ShowSoftInput(responder, ShowFlags.Implicit);
     });
 }
Exemplo n.º 11
0
        public override AView GetView(int position, AView convertView, ViewGroup parent)
        {
            bool isHeader, nextIsHeader;
            Cell item = GetCellForPosition(position, out isHeader, out nextIsHeader);

            if (item == null)
            {
                return(new AView(Context));
            }

            var makeBline = true;
            var layout    = convertView as ConditionalFocusLayout;

            if (layout != null)
            {
                makeBline   = false;
                convertView = layout.GetChildAt(0);
            }
            else
            {
                layout = new ConditionalFocusLayout(Context)
                {
                    Orientation = Orientation.Vertical
                }
            };

            AView aview = CellFactory.GetCell(item, convertView, parent, Context, _view);

            if (!makeBline)
            {
                if (convertView != aview)
                {
                    layout.RemoveViewAt(0);
                    layout.AddView(aview, 0);
                }
            }
            else
            {
                layout.AddView(aview, 0);
            }

            AView bline;

            if (makeBline)
            {
                bline = new AView(Context)
                {
                    LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 1)
                };

                layout.AddView(bline);
            }
            else
            {
                bline = layout.GetChildAt(1);
            }

            if (isHeader)
            {
                bline.SetBackgroundColor(Color.Accent.ToAndroid());
            }
            else if (nextIsHeader)
            {
                bline.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
            }
            else
            {
                using (var value = new TypedValue())
                {
                    int id = global::Android.Resource.Drawable.DividerHorizontalDark;
                    if (Context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ListDivider, value, true))
                    {
                        id = value.ResourceId;
                    }
                    else if (Context.Theme.ResolveAttribute(global::Android.Resource.Attribute.Divider, value, true))
                    {
                        id = value.ResourceId;
                    }

                    bline.SetBackgroundResource(id);
                }
            }

            layout.ApplyTouchListenersToSpecialCells(item);

            if (_restoreFocus == item)
            {
                if (!aview.HasFocus)
                {
                    aview.RequestFocus();
                }

                _restoreFocus = null;
            }
            else if (aview.HasFocus)
            {
                aview.ClearFocus();
            }

            return(layout);
        }
Exemplo n.º 12
0
        private void animateAlphaTranslate(View view, float alphaFrom, float alphaTo, float xFrom, float xTo,
            bool requestFocus)
        {
            AnimationSet animationSet = new AnimationSet(true);

            AlphaAnimation fade = new AlphaAnimation(alphaFrom, alphaTo);
            fade.Duration = 350;

            TranslateAnimation slide = new TranslateAnimation(Dimension.RelativeToSelf, xFrom,
                                                              Dimension.RelativeToSelf, xTo,
                                                              Dimension.RelativeToSelf, 0,
                                                              Dimension.RelativeToSelf, 0);

            slide.Duration = 350;

            animationSet.AddAnimation(fade);
            animationSet.AddAnimation(slide);
            view.StartAnimation(animationSet);

            if (requestFocus)
            {
                animationSet.AnimationEnd += (obj, args) => view.RequestFocus();
            }
        }
Exemplo n.º 13
0
		public void showSoftKeyboard(View view) {
			if (view.RequestFocus()) {
				
				InputMethodManager imm = (InputMethodManager)
					GetSystemService (Context.InputMethodService);
					//getSystemService(Context.INPUT_METHOD_SERVICE);
				//imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
				imm.ShowSoftInput (view, InputMethodManager.ShowImplicit);
			}
		}
Exemplo n.º 14
0
        public override void OnClick(View v)
        {
            v.Focusable = true;
            v.FocusableInTouchMode = true;
            v.RequestFocus ();
            if (v == EditButton || v == BackButton) {
                Warning.Visibility = ViewStates.Gone;

                SwitchVisibility (DropDownButton);
                SwitchVisibility (BackButton);

                SwitchVisibility (EditButton);
                SwitchVisibility (RemoveButton);

                SwitchVisibility (Product);
                SwitchVisibility (EditProduct);

                SwitchVisibility (Price);
                SwitchVisibility (EditPrice);

                if (v == BackButton) {
                    Product.Text = EditProduct.Text;
                    Price.Text = EditPrice.Text;
                }
                _onClick (new ListItemEventArgs (LayoutPosition, -3));

            } else if (v == Product || v == DropDownButton) {
                if (DropDown.Visibility == ViewStates.Gone) {
                    DropDown.Visibility = ViewStates.Visible;
                } else {
                    DropDown.Visibility = ViewStates.Gone;
                }
                _onClick (new ListItemEventArgs (LayoutPosition, -2));
            } else if (v == RemoveButton){
                _onClick (new ListItemEventArgs (LayoutPosition, -1));
            } else {
                int i = 0;
                foreach (TextView tv in Initials) {
                    if (v == tv) {
                        _onClick(new ListItemEventArgs(LayoutPosition, i));
                        break;
                    }
                    i++;
                }
            }
            v.Focusable = false;
        }