Beispiel #1
0
 public void ChooseHeight(Java.Lang.ICharSequence?text, int start, int end, int spanstartv, int v, Paint.FontMetricsInt?fm)
 {
     if (fm != null)
     {
         fm.Ascent  = (int)(_ascent * _lineHeight);
         fm.Descent = (int)(_descent * _lineHeight);
     }
 }
Beispiel #2
0
        void ITextWatcher.OnTextChanged(Java.Lang.ICharSequence?s, int start, int before, int count)
        {
            var h = TextChanged;

            if (h != null)
            {
                h(inst, new TextChangedEventArgs(s, start, before, count));
            }
        }
Beispiel #3
0
        void ITextWatcher.BeforeTextChanged(Java.Lang.ICharSequence?s, int start, int before, int after)
        {
            var h = BeforeTextChanged;

            if (h != null)
            {
                h(inst, new TextChangedEventArgs(s, start, before, after));
            }
        }
            public void ChooseHeight(Java.Lang.ICharSequence?text, int start, int end, int spanstartv, int lineHeight, Paint.FontMetricsInt?fm)
            {
                if (fm is null)
                {
                    return;
                }

                fm.Ascent = (int)(fm.Top * _relativeLineHeight);
            }
            void ITextWatcher.OnTextChanged(Java.Lang.ICharSequence?s, int start, int before, int count)
            {
                // We are replacing 0 characters with 0 characters, so skip
                if (before == 0 && count == 0)
                {
                    return;
                }

                Handler?.OnTextChanged(s?.ToString());
            }
        protected override void OnTextChanged(Java.Lang.ICharSequence?text, int start, int lengthBefore, int lengthAfter)
        {
            if (!_isRunningTextChanged && _isInitialized)
            {
                // The Text property cannot be overridden, so we can't prevent this method from being called even if
                // the content really has not changed...

                try
                {
                    _isRunningTextChanged = true;

                    base.OnTextChanged(text, start, lengthBefore, lengthAfter);

                    NotifyTextChanged();
                }
                finally
                {
                    _isRunningTextChanged = false;
                }
            }
        }
 void ITextWatcher.BeforeTextChanged(Java.Lang.ICharSequence?s, int start, int count, int after)
 {
 }
 public static IntPtr ToLocalJniHandle(Java.Lang.ICharSequence?value)
 {
     return(value == null ? IntPtr.Zero : JNIEnv.ToLocalJniHandle(value));
 }
Beispiel #9
0
        static void UpdateMenuItem(AToolbar toolbar,
                                   ToolbarItem item,
                                   int?menuItemIndex,
                                   IMauiContext mauiContext,
                                   Color?tintColor,
                                   PropertyChangedEventHandler toolbarItemChanged,
                                   List <IMenuItem> previousMenuItems,
                                   List <ToolbarItem> previousToolBarItems,
                                   Action <Context, IMenuItem, ToolbarItem>?updateMenuItemIcon = null)
        {
            var context = mauiContext.Context ??
                          throw new ArgumentNullException($"{nameof(mauiContext.Context)}");

            IMenu menu = toolbar.Menu;

            item.PropertyChanged -= toolbarItemChanged;
            item.PropertyChanged += toolbarItemChanged;

            IMenuItem menuitem;

            Java.Lang.ICharSequence?newTitle = null;

            if (!String.IsNullOrWhiteSpace(item.Text))
            {
                if (item.Order != ToolbarItemOrder.Secondary && tintColor != null && tintColor != null)
                {
                    var             color       = item.IsEnabled ? tintColor.ToPlatform() : tintColor.MultiplyAlpha(0.302f).ToPlatform();
                    SpannableString titleTinted = new SpannableString(item.Text);
                    titleTinted.SetSpan(new ForegroundColorSpan(color), 0, titleTinted.Length(), 0);
                    newTitle = titleTinted;
                }
                else
                {
                    newTitle = new Java.Lang.String(item.Text);
                }
            }
            else
            {
                newTitle = new Java.Lang.String();
            }

            if (menuItemIndex == null || menuItemIndex >= previousMenuItems?.Count)
            {
                menuitem = menu.Add(0, AView.GenerateViewId(), 0, newTitle) ??
                           throw new InvalidOperationException($"Failed to create menuitem: {newTitle}");
                previousMenuItems?.Add(menuitem);
            }
            else
            {
                if (previousMenuItems == null || previousMenuItems.Count < menuItemIndex.Value)
                {
                    return;
                }

                menuitem = previousMenuItems[menuItemIndex.Value];

                if (!menuitem.IsAlive())
                {
                    return;
                }

                menuitem.SetTitle(newTitle);
            }

            menuitem.SetEnabled(item.IsEnabled);
            menuitem.SetTitleOrContentDescription(item);

            if (updateMenuItemIcon != null)
            {
                updateMenuItemIcon(context, menuitem, item);
            }
            else
            {
                UpdateMenuItemIcon(mauiContext, menuitem, item, tintColor);
            }

            if (item.Order != ToolbarItemOrder.Secondary)
            {
                menuitem.SetShowAsAction(ShowAsAction.Always);
            }

            menuitem.SetOnMenuItemClickListener(new GenericMenuClickListener(((IMenuItemController)item).Activate));

            if (item.Order != ToolbarItemOrder.Secondary && !PlatformVersion.IsAtLeast(26) && (tintColor != null && tintColor != null))
            {
                var view = toolbar.FindViewById(menuitem.ItemId);
                if (view is ATextView textView)
                {
                    if (item.IsEnabled)
                    {
                        textView.SetTextColor(tintColor.ToPlatform());
                    }
                    else
                    {
                        textView.SetTextColor(tintColor.MultiplyAlpha(0.302f).ToPlatform());
                    }
                }
            }
        }
Beispiel #10
0
 void ITextWatcher.OnTextChanged(Java.Lang.ICharSequence?s, int start, int before, int count)
 {
     Handler?.OnTextChanged(s?.ToString());
 }
Beispiel #11
0
 Java.Lang.IAppendable Java.Lang.IAppendable.Append(Java.Lang.ICharSequence?csq, int start, int end)
 {
     return(Append(csq, start, end) !);
 }
Beispiel #12
0
 Java.Lang.IAppendable Java.Lang.IAppendable.Append(Java.Lang.ICharSequence?csq)
 {
     return(Append(csq) !);
 }