AImageButton CreateImageButton(Context context, BindableObject bindable, BindableProperty property, int defaultImage, int leftMargin, int rightMargin, string tag) { var result = new AImageButton(context); result.Tag = tag; result.SetPadding(0, 0, 0, 0); result.Focusable = false; result.SetScaleType(ImageView.ScaleType.FitCenter); if (bindable.GetValue(property) is ImageSource image) { AutomationPropertiesProvider.SetContentDescription(result, image, null, null); } ((ImageSource)bindable.GetValue(property)).LoadImage(MauiContext, (r) => { result.SetImageDrawable(r?.Value); }); var lp = new LinearLayout.LayoutParams((int)Context.ToPixels(22), LP.MatchParent) { LeftMargin = leftMargin, RightMargin = rightMargin }; result.LayoutParameters = lp; lp.Dispose(); result.SetBackground(null); return(result); }
public ItemsViewRenderer(Context context) : base(context) { CollectionView.VerifyCollectionViewFlagEnabled(nameof(ItemsViewRenderer)); _automationPropertiesProvider = new AutomationPropertiesProvider(this); _effectControlProvider = new EffectControlProvider(this); }
AImageButton CreateImageButton(Context context, ImageSource image, int defaultImage, int leftMargin, int rightMargin) { var result = new AImageButton(context); result.SetPadding(0, 0, 0, 0); result.Focusable = false; string defaultHint = null; string defaultDescription = null; AutomationPropertiesProvider.SetContentDescription(result, image, ref defaultDescription, ref defaultHint); SetImage(result, image, defaultImage); var lp = new LinearLayout.LayoutParams((int)Context.ToPixels(22), LP.MatchParent) { LeftMargin = leftMargin, RightMargin = rightMargin }; result.LayoutParameters = lp; lp.Dispose(); result.SetBackground(null); return(result); }
void SetupAutomationDefaults() { if (!_defaultAutomationSet) { _defaultAutomationSet = true; AutomationPropertiesProvider.SetupDefaults(this, ref _defaultContentDescription, ref _defaultHint); } }
public override void OnInitializeAccessibilityNodeInfo(global::Android.Views.View host, AccessibilityNodeInfo info) { base.OnInitializeAccessibilityNodeInfo(host, info); info.ClassName = ClassName; if (_element != null) { var value = string.IsNullOrWhiteSpace(ValueText) ? string.Empty : $"{ValueText}. "; host.ContentDescription = $"{value}{AutomationPropertiesProvider.ConcatenateNameAndHelpText(_element)}"; } }
public ItemsViewRenderer(Context context) : base(new ContextThemeWrapper(context, Resource.Style.collectionViewStyle)) { CollectionView.VerifyCollectionViewFlagEnabled(nameof(ItemsViewRenderer)); _automationPropertiesProvider = new AutomationPropertiesProvider(this); _effectControlProvider = new EffectControlProvider(this); VerticalScrollBarEnabled = false; HorizontalScrollBarEnabled = false; }
void Initialize() { _automationPropertiesProvider = new AutomationPropertiesProvider(this); _backgroundTracker = new BorderBackgroundManager(this); SoundEffectsEnabled = false; OnFocusChangeListener = this; SetOnCheckedChangeListener(this); Tag = this; }
public ItemsViewRenderer(Context context) : base(new ContextThemeWrapper(context, Resource.Style.collectionViewStyle)) { _automationPropertiesProvider = new AutomationPropertiesProvider(this); _effectControlProvider = new EffectControlProvider(this); _emptyCollectionObserver = new DataChangeObserver(UpdateEmptyViewVisibility); _itemsUpdateScrollObserver = new DataChangeObserver(AdjustScrollForItemUpdate); VerticalScrollBarEnabled = false; HorizontalScrollBarEnabled = false; }
public MaterialButtonRenderer(Context context) : base(new ContextThemeWrapper(context, Resource.Style.XamarinFormsMaterialTheme)) { VisualElement.VerifyVisualFlagEnabled(); _automationPropertiesProvider = new AutomationPropertiesProvider(this); SoundEffectsEnabled = false; SetOnClickListener(this); SetOnTouchListener(this); AddOnAttachStateChangeListener(this); OnFocusChangeListener = this; Tag = this; }
public MaterialButtonRenderer(Context context, BindableObject element) : base(MaterialContextThemeWrapper.Create(context)) { _automationPropertiesProvider = new AutomationPropertiesProvider(this); _buttonLayoutManager = new ButtonLayoutManager(this, alignIconWithText: true, preserveInitialPadding: true, borderAdjustsPadding: false, maintainLegacyMeasurements: false); SoundEffectsEnabled = false; SetOnClickListener(this); SetOnTouchListener(this); AddOnAttachStateChangeListener(this); OnFocusChangeListener = this; Tag = this; }
AImageButton CreateImageButton(Context context, BindableObject bindable, BindableProperty property, int defaultImage, int leftMargin, int rightMargin, string tag) { var result = new AImageButton(context); result.Tag = tag; result.SetPadding(0, 0, 0, 0); result.Focusable = false; result.SetScaleType(ImageView.ScaleType.FitCenter); string defaultHint = null; string defaultDescription = null; if (bindable.GetValue(property) is ImageSource image) { AutomationPropertiesProvider.SetContentDescription(result, image, ref defaultDescription, ref defaultHint); } _shellContext.ApplyDrawableAsync(bindable, property, drawable => { if (drawable != null) { result.SetImageDrawable(drawable); } else if (defaultImage > 0) { result.SetImageResource(defaultImage); } else { result.SetImageDrawable(null); } }); var lp = new LinearLayout.LayoutParams((int)Context.ToPixels(22), LP.MatchParent) { LeftMargin = leftMargin, RightMargin = rightMargin }; result.LayoutParameters = lp; lp.Dispose(); result.SetBackground(null); return(result); }
public MediaElementRenderer(Context context) : base(context) { System.Maui.MediaElement.VerifyMediaElementFlagEnabled(nameof(MediaElementRenderer)); _automationPropertiesProvider = new AutomationPropertiesProvider(this); _effectControlProvider = new EffectControlProvider(this); _view = new FormsVideoView(Context); _view.SetZOrderMediaOverlay(true); _view.SetOnCompletionListener(this); _view.SetOnInfoListener(this); _view.SetOnPreparedListener(this); _view.SetOnErrorListener(this); _view.MetadataRetrieved += MetadataRetrieved; AddView(_view, -1, -1); _controller = new MediaController(Context); _controller.SetAnchorView(this); _view.SetMediaController(_controller); }
public MaterialButtonRenderer(Context context) : base(new ContextThemeWrapper(context, Resource.Style.XamarinFormsMaterialTheme)) { VisualElement.VerifyVisualFlagEnabled(); _automationPropertiesProvider = new AutomationPropertiesProvider(this); _buttonLayoutManager = new ButtonLayoutManager(this, alignIconWithText: true, preserveInitialPadding: true, borderAdjustsPadding: false, maintainLegacyMeasurements: false); SoundEffectsEnabled = false; SetOnClickListener(this); SetOnTouchListener(this); AddOnAttachStateChangeListener(this); OnFocusChangeListener = this; Tag = this; }
void UpdateTitleIcon() { Page currentPage = Element.CurrentPage; if (currentPage == null) { return; } ImageSource source = NavigationPage.GetTitleIconImageSource(currentPage); if (source == null || source.IsEmpty) { _toolbar.RemoveView(_titleIconView); _titleIconView?.Dispose(); _titleIconView = null; _imageSource = null; return; } if (_titleIconView == null) { _titleIconView = new ImageView(Context); _toolbar.AddView(_titleIconView, 0); } if (_imageSource != source) { _imageSource = source; _titleIconView.SetImageResource(global::Android.Resource.Color.Transparent); _ = this.ApplyDrawableAsync(currentPage, NavigationPage.TitleIconImageSourceProperty, Context, drawable => { _titleIconView.SetImageDrawable(drawable); AutomationPropertiesProvider.AccessibilitySettingsChanged(_titleIconView, source); }); } }
void OnTabLayoutChange(object sender, AView.LayoutChangeEventArgs e) { if (_disposed) { return; } var items = SectionController.GetItems(); for (int i = 0; i < _tablayout.TabCount; i++) { if (items.Count <= i) { break; } var tab = _tablayout.GetTabAt(i); if (tab.View != null) { AutomationPropertiesProvider.AccessibilitySettingsChanged(tab.View, items[i]); } } }
public void OnLongPress(MotionEvent e) { if (!HasAnyDragGestures()) { return; } SendEventArgs <DragGestureRecognizer>(rec => { if (!rec.CanDrag) { return; } var element = GetView(); var renderer = Platform.GetRenderer(element); var v = renderer.View; if (v.Handle == IntPtr.Zero) { return; } var args = rec.SendDragStarting(element); if (args.Cancel) { return; } CustomLocalStateData customLocalStateData = new CustomLocalStateData(); customLocalStateData.DataPackage = args.Data; //_dragSource[element] = args.Data; string clipDescription = AutomationPropertiesProvider.ConcatenateNameAndHelpText(element) ?? String.Empty; ClipData.Item item = null; List <string> mimeTypes = new List <string>(); if (!args.Handled) { if (args.Data.Image != null) { mimeTypes.Add("image/jpeg"); item = ConvertToClipDataItem(args.Data.Image, mimeTypes); } else { string text = clipDescription ?? args.Data.Text; if (Uri.TryCreate(text, UriKind.Absolute, out _)) { item = new ClipData.Item(AUri.Parse(text)); mimeTypes.Add(ClipDescription.MimetypeTextUrilist); } else { item = new ClipData.Item(text); mimeTypes.Add(ClipDescription.MimetypeTextPlain); } } } var dataPackage = args.Data; ClipData.Item userItem = null; if (dataPackage.Image != null) { userItem = ConvertToClipDataItem(dataPackage.Image, mimeTypes); } if (dataPackage.Text != null) { userItem = new ClipData.Item(dataPackage.Text); } if (item == null) { item = userItem; userItem = null; } ClipData data = new ClipData(clipDescription, mimeTypes.ToArray(), item); if (userItem != null) { data.AddItem(userItem); } var dragShadowBuilder = new AView.DragShadowBuilder(v); customLocalStateData.SourceNativeView = v; customLocalStateData.SourceElement = renderer?.Element; if (Forms.IsNougatOrNewer) { v.StartDragAndDrop(data, dragShadowBuilder, customLocalStateData, (int)ADragFlags.Global | (int)ADragFlags.GlobalUriRead); } else #pragma warning disable CS0618 // Type or member is obsolete { v.StartDrag(data, dragShadowBuilder, customLocalStateData, (int)ADragFlags.Global | (int)ADragFlags.GlobalUriRead); } #pragma warning restore CS0618 // Type or member is obsolete }); }
public MaterialEntryRenderer(Context context) : base(new ContextThemeWrapper(context, Resource.Style.XamarinFormsMaterialTheme)) { VisualElement.VerifyVisualFlagEnabled(); _automationPropertiesProvider = new AutomationPropertiesProvider(this); _effectControlProvider = new EffectControlProvider(this); }
protected virtual void SetFocusable() => AutomationPropertiesProvider.SetFocusable(this, Element, ref _defaultFocusable);
void UpdateAutomationId() { AutomationPropertiesProvider .SetAutomationId(_editText, _searchHandler?.AutomationId); }
protected virtual void SetFocusable() => AutomationPropertiesProvider.SetFocusable(this, Element, ref _defaultFocusable, ref _defaultImportantForAccessibility);
protected virtual void SetAutomationId(string id) { SetupAutomationDefaults(); AutomationPropertiesProvider.SetAutomationId(this, Element, id); }
protected virtual void SetContentDescription() { SetupAutomationDefaults(); AutomationPropertiesProvider.SetContentDescription(this, Element, _defaultContentDescription, _defaultHint); }
protected virtual void SetAutomationId(string id) => AutomationPropertiesProvider.SetAutomationId(this, Element, id);
protected override void SetContentDescription() => AutomationPropertiesProvider.SetBasicContentDescription(this, Element, ref _defaultContentDescription);
protected virtual void SetContentDescription() => AutomationPropertiesProvider.SetContentDescription(this, Element, ref _defaultContentDescription, ref _defaultHint);