зеркало из https://github.com/DeGsoft/maui-linux.git
Merge branch '3.6.0' into 4.0.0
This commit is contained in:
Коммит
23b61a434b
|
@ -195,7 +195,7 @@ namespace Xamarin.Forms.ControlGallery.Android
|
|||
|
||||
#pragma warning disable 618
|
||||
// Disabled the warning so we have a test that this obsolete stuff still works
|
||||
Control.Adapter = new NativeListViewAdapter(Forms.Context as Activity, e.NewElement);
|
||||
Control.Adapter = new NativeListViewAdapter(Forms.Context.GetActivity(), e.NewElement);
|
||||
#pragma warning restore 618
|
||||
Control.ItemClick += Clicked;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ namespace Xamarin.Forms.ControlGallery.Android
|
|||
|
||||
#pragma warning disable 618
|
||||
// Disabled the warning so we have a test that this obsolete stuff still works
|
||||
Control.Adapter = new NativeListViewAdapter(Forms.Context as Activity, Element);
|
||||
Control.Adapter = new NativeListViewAdapter(Forms.Context.GetActivity(), Element);
|
||||
#pragma warning restore 618
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ namespace Xamarin.Forms.ControlGallery.Android
|
|||
|
||||
if (view == null)
|
||||
{// no view to re-use, create new
|
||||
view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.NativeAndroidCell, null);
|
||||
view = (context.GetActivity()).LayoutInflater.Inflate(Resource.Layout.NativeAndroidCell, null);
|
||||
}
|
||||
else
|
||||
{ // re-use, clear image
|
||||
|
@ -382,7 +382,7 @@ namespace Xamarin.Forms.ControlGallery.Android
|
|||
// subscribe
|
||||
#pragma warning disable 618
|
||||
// Disabled the warning so we have a test that this obsolete stuff still works
|
||||
Control.Adapter = new NativeAndroidListViewAdapter(Forms.Context as Activity, e.NewElement);
|
||||
Control.Adapter = new NativeAndroidListViewAdapter(Forms.Context.GetActivity(), e.NewElement);
|
||||
#pragma warning restore 618
|
||||
Control.ItemClick += Clicked;
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ namespace Xamarin.Forms.ControlGallery.Android
|
|||
|
||||
#pragma warning disable 618
|
||||
// Disabled the warning so we have a test that this obsolete stuff still works
|
||||
Control.Adapter = new NativeAndroidListViewAdapter(Forms.Context as Activity, Element);
|
||||
Control.Adapter = new NativeAndroidListViewAdapter(Forms.Context.GetActivity(), Element);
|
||||
#pragma warning restore 618
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ using Android.Widget;
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.ControlGallery.Android;
|
||||
using Xamarin.Forms.Controls.Issues;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
using AView = Android.Views.View;
|
||||
|
||||
[assembly: ExportRenderer(typeof(Bugzilla38989._38989CustomViewCell), typeof(_38989CustomViewCellRenderer))]
|
||||
|
@ -25,7 +26,7 @@ namespace Xamarin.Forms.ControlGallery.Android
|
|||
var nativeView = convertView;
|
||||
|
||||
if (nativeView == null)
|
||||
nativeView = (context as Activity).LayoutInflater.Inflate(Resource.Layout.Layout38989, null);
|
||||
nativeView = (context.GetActivity()).LayoutInflater.Inflate(Resource.Layout.Layout38989, null);
|
||||
|
||||
return nativeView;
|
||||
}
|
||||
|
|
|
@ -50,15 +50,17 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
|
||||
// Tap the control
|
||||
var y = target.CenterY;
|
||||
var x = target.CenterX;
|
||||
|
||||
// In theory we want to tap the center of the control. But Stepper lays out differently than the other controls,
|
||||
// (it doesn't center vertically within its layout), so we need to adjust for it until someone fixes it
|
||||
if (menuItem == "Stepper")
|
||||
{
|
||||
y = target.Y;
|
||||
x = target.X;
|
||||
}
|
||||
|
||||
RunningApp.TapCoordinates(target.CenterX, y);
|
||||
RunningApp.TapCoordinates(x, y);
|
||||
|
||||
if(menuItem == nameof(DatePicker) || menuItem == nameof(TimePicker))
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
using System.Linq;
|
||||
|
||||
#if UITEST
|
||||
using NUnit.Framework;
|
||||
|
@ -124,7 +125,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
|
||||
Picker GenerateNewPicker()
|
||||
{
|
||||
var picker = new Picker();
|
||||
var picker = new Picker() { ClassId = "PickerEditText" };
|
||||
for (int i = 1; i < 100; i++)
|
||||
picker.Items.Add($"item {i}");
|
||||
return picker;
|
||||
|
@ -140,11 +141,17 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
}
|
||||
|
||||
#if UITEST && __ANDROID__
|
||||
|
||||
UITest.Queries.AppResult[] GetPickerEditText(UITest.IApp RunningApp) =>
|
||||
RunningApp.Query(q => q.TextField()).Where(x => x.Class.Contains("PickerEditText")).ToArray();
|
||||
|
||||
[Test]
|
||||
public void Issue4187Test()
|
||||
{
|
||||
RunningApp.WaitForElement("Text 1");
|
||||
Assert.AreEqual(7, RunningApp.Query(q => q.TextField().Class("PickerEditText")).Length, "picker count");
|
||||
UITest.Queries.AppResult[] fields = RunningApp.Query(q => q.TextField());
|
||||
|
||||
Assert.AreEqual(7, GetPickerEditText(RunningApp).Length, "picker count");
|
||||
TapOnPicker(1);
|
||||
Assert.IsTrue(DialogIsOpened(), "#1");
|
||||
RunningApp.Tap("Text 2");
|
||||
|
@ -175,7 +182,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
|
||||
void TapOnPicker(int index)
|
||||
{
|
||||
var picker = RunningApp.Query(q => q.TextField().Class("PickerEditText"))[index];
|
||||
var picker = GetPickerEditText(RunningApp)[index];
|
||||
var location = picker.Rect;
|
||||
RunningApp.TapCoordinates(location.X + 10, location.Y + location.Height / 2);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
|
||||
#if UITEST
|
||||
using Xamarin.Forms.Core.UITests;
|
||||
using Xamarin.UITest;
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
#if UITEST
|
||||
[Category(UITestCategories.LifeCycle)]
|
||||
#endif
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 5376, "Call unfocus entry crashes app", PlatformAffected.Android)]
|
||||
public class Issue5376 : TestMasterDetailPage
|
||||
{
|
||||
protected async override void Init()
|
||||
{
|
||||
MasterBehavior = MasterBehavior.Popover;
|
||||
IsPresented = false;
|
||||
Master = new ContentPage { Title = "test 5376" };
|
||||
var entryPage = new EntryPage() { Title = $"Test page" };
|
||||
var testPage = new NavigationPage(entryPage);
|
||||
Detail = testPage;
|
||||
while (!entryPage.IsTested)
|
||||
await Task.Delay(100);
|
||||
|
||||
// dispose testPage renderers
|
||||
Detail = new ContentPage();
|
||||
await Task.Delay(100);
|
||||
|
||||
// create testPage renderers
|
||||
entryPage.IsTested = false;
|
||||
Detail = testPage;
|
||||
while (!entryPage.IsTested)
|
||||
await Task.Delay(100);
|
||||
|
||||
Detail = new ContentPage { Content = new Label { Text = "Success" } };
|
||||
}
|
||||
|
||||
[Preserve(AllMembers = true)]
|
||||
class EntryPage : ContentPage
|
||||
{
|
||||
Entry entry;
|
||||
|
||||
public volatile bool IsTested = false;
|
||||
|
||||
public EntryPage()
|
||||
{
|
||||
entry = new Entry { Text = Title };
|
||||
Content = new StackLayout { Children = { entry } };
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
IsTested = false;
|
||||
|
||||
base.OnAppearing();
|
||||
|
||||
entry.Focus();
|
||||
new Thread(() =>
|
||||
{
|
||||
while (!IsTested)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
if (entry.IsFocused)
|
||||
{
|
||||
entry.Unfocus();
|
||||
IsTested = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.Focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
#if UITEST
|
||||
[Test]
|
||||
public void Issue5376Test()
|
||||
{
|
||||
RunningApp.WaitForElement ("Success");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla59172.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue5376.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla60787.xaml.cs">
|
||||
<DependentUpon>Bugzilla60787.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
|
|
|
@ -580,6 +580,7 @@ namespace Xamarin.Forms.Controls
|
|||
|
||||
foreach (var page in Issues.Helpers.ViewHelper.GetAllPages())
|
||||
{
|
||||
page.Visual = VisualMarker.Default;
|
||||
if (!DependencyService.Get<IRegistrarValidationService>().Validate(page, out string message))
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Xamarin.Forms.Core.UITests
|
||||
|
@ -36,10 +37,15 @@ namespace Xamarin.Forms.Core.UITests
|
|||
// renderer, then we *do* need to check the parent control for the property
|
||||
// So we query the control's parent and see if it's a Container (legacy); if so,
|
||||
// we adjust the query to look at the parent of the current control
|
||||
var parent = App.Query(appQuery => appQuery.Raw(ViewQuery + " parent * index:0"));
|
||||
if (parent.Length > 0 && parent[0].Label.EndsWith(ContainerLabel))
|
||||
//var text = Regex.Match(query, "'(?<text>[^']*)'").Groups["text"].Value;
|
||||
//var parent = App.Query(appQuery => appQuery.Raw(ViewQuery + " parent * index:0"));
|
||||
var parent = App.Query(appQuery => appQuery.Raw(ViewQuery).Parent());
|
||||
//parent = App.Query(appQuery => appQuery.Raw(ViewQuery).Parent().Parent());
|
||||
|
||||
var parentElement = parent.FirstOrDefault(x => x.Label?.EndsWith(ContainerLabel) == true);
|
||||
if (parentElement != null)
|
||||
{
|
||||
query = query + " parent * index:0";
|
||||
query = query + $" parent * index:{Array.IndexOf(parent, parentElement)}";
|
||||
}
|
||||
|
||||
return query;
|
||||
|
|
|
@ -30,13 +30,13 @@ namespace Xamarin.Forms.Core.UITests
|
|||
App.WaitForElement (c => c.Marked ("tPicker"));
|
||||
|
||||
var label = App.Query ("lblHello") [0];
|
||||
Assert.AreEqual (label.Text, "Hello Label");
|
||||
Assert.AreEqual ("Hello Label", label.Text);
|
||||
|
||||
var editor = App.Query ("editorHello") [0];
|
||||
Assert.AreEqual (editor.Text, "Hello Editor");
|
||||
Assert.AreEqual ("Hello Editor", editor.Text);
|
||||
|
||||
var entry = App.Query ("entryHello") [0];
|
||||
Assert.AreEqual (entry.Text, "Hello Entry");
|
||||
Assert.AreEqual ("Hello Entry", entry.Text);
|
||||
|
||||
App.Tap (c => c.Marked ("popModal"));
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Xamarin.Forms.Core.UITests
|
|||
[Test]
|
||||
[UiTest(typeof(Entry), "Completed")]
|
||||
[Category(UITestCategories.UwpIgnore)]
|
||||
public void Completed()
|
||||
public virtual void Completed()
|
||||
{
|
||||
var remote = new EventViewContainerRemote(App, Test.Entry.Completed, PlatformViewType);
|
||||
remote.GoTo();
|
||||
|
|
|
@ -22,6 +22,76 @@ namespace Xamarin.Forms.Core.UITests
|
|||
{
|
||||
base._Focus();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "Rotation")]
|
||||
public override void _Rotation()
|
||||
{
|
||||
base._Rotation();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "RotationX")]
|
||||
public override void _RotationX()
|
||||
{
|
||||
base._RotationX();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "RotationY")]
|
||||
public override void _RotationY()
|
||||
{
|
||||
base._RotationY();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "Opacity")]
|
||||
public override void _Opacity()
|
||||
{
|
||||
base._Opacity();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "Scale")]
|
||||
public override void _Scale()
|
||||
{
|
||||
base._Scale();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "IsEnabled")]
|
||||
public override void _IsEnabled()
|
||||
{
|
||||
base._IsEnabled();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "IsVisible")]
|
||||
public override void _IsVisible()
|
||||
{
|
||||
base._IsVisible();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "TranslationX")]
|
||||
public override void _TranslationX()
|
||||
{
|
||||
base._TranslationX();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "TranslationY")]
|
||||
public override void _TranslationY()
|
||||
{
|
||||
base._TranslationY();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[UiTest(typeof(Entry), "Completed")]
|
||||
public override void Completed()
|
||||
{
|
||||
base.Completed();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -180,6 +180,13 @@ namespace Xamarin.Forms.Core.UnitTests
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
VisualElement.SetDefaultVisual(VisualMarker.Default);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestConstructor ()
|
||||
{
|
||||
|
|
|
@ -183,7 +183,9 @@ namespace Xamarin.Forms.Internals
|
|||
// Only go through this process if we have not registered something for this type;
|
||||
// we don't want RenderWith renderers to override ExportRenderers that are already registered.
|
||||
// Plus, there's no need to do this again if we already have a renderer registered.
|
||||
if (!_handlers.TryGetValue(viewType, out Dictionary<Type, Type> visualRenderers) || !visualRenderers.ContainsKey(visualType))
|
||||
if (!_handlers.TryGetValue(viewType, out Dictionary<Type, Type> visualRenderers) ||
|
||||
!(visualRenderers.ContainsKey(visualType) ||
|
||||
visualRenderers.ContainsKey(_defaultVisualType)))
|
||||
{
|
||||
// get RenderWith attribute for just this type, do not inherit attributes from base types
|
||||
var attribute = viewType.GetTypeInfo().GetCustomAttributes<RenderWithAttribute>(false).FirstOrDefault();
|
||||
|
|
|
@ -61,13 +61,20 @@ namespace Xamarin.Forms
|
|||
BindableProperty.Create(nameof(Visual), typeof(IVisual), typeof(VisualElement), Forms.VisualMarker.MatchParent,
|
||||
validateValue: (b, v) => v != null, propertyChanged: OnVisualChanged);
|
||||
|
||||
static IVisual _defaultVisual = Xamarin.Forms.VisualMarker.Default;
|
||||
IVisual _effectiveVisual = _defaultVisual;
|
||||
|
||||
public IVisual Visual
|
||||
{
|
||||
get { return (IVisual)GetValue(VisualProperty); }
|
||||
set { SetValue(VisualProperty, value); }
|
||||
}
|
||||
|
||||
IVisual _effectiveVisual = Xamarin.Forms.VisualMarker.Default;
|
||||
internal static void SetDefaultVisual(IVisual visual)
|
||||
{
|
||||
_defaultVisual = visual;
|
||||
}
|
||||
|
||||
IVisual IVisualController.EffectiveVisual
|
||||
{
|
||||
get { return _effectiveVisual; }
|
||||
|
|
|
@ -5,6 +5,7 @@ using Android.Widget;
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Material.Android;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
using AView = Android.Views.View;
|
||||
|
||||
|
||||
namespace Xamarin.Forms.Material.Android
|
||||
|
@ -18,6 +19,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
{
|
||||
}
|
||||
|
||||
protected override AView ControlUsedForAutomation => EditText;
|
||||
protected override EditText EditText => _textInputEditText;
|
||||
|
||||
protected override MaterialPickerTextInputLayout CreateNativeControl()
|
||||
|
@ -34,6 +36,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
{
|
||||
base.OnElementChanged(e);
|
||||
_textInputLayout.SetHint(string.Empty, Element);
|
||||
UpdateBackgroundColor();
|
||||
}
|
||||
|
||||
protected override void UpdateBackgroundColor()
|
||||
|
|
|
@ -6,6 +6,7 @@ using Android.Widget;
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Material.Android;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
using AView = Android.Views.View;
|
||||
|
||||
namespace Xamarin.Forms.Material.Android
|
||||
{
|
||||
|
@ -57,7 +58,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
protected virtual void ApplyTheme() => _textInputLayout?.ApplyTheme(Element.TextColor, Element.PlaceholderColor);
|
||||
protected override void UpdateTextColor() => ApplyTheme();
|
||||
protected override EditText EditText => _textInputEditText;
|
||||
|
||||
protected override AView ControlUsedForAutomation => EditText;
|
||||
protected override void UpdateFont()
|
||||
{
|
||||
if (_disposed || _textInputLayout == null)
|
||||
|
|
|
@ -6,6 +6,7 @@ using Android.Widget;
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Material.Android;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
using AView = Android.Views.View;
|
||||
|
||||
namespace Xamarin.Forms.Material.Android
|
||||
{
|
||||
|
@ -19,6 +20,8 @@ namespace Xamarin.Forms.Material.Android
|
|||
{
|
||||
}
|
||||
|
||||
protected override AView ControlUsedForAutomation => EditText;
|
||||
|
||||
protected override MaterialFormsTextInputLayout CreateNativeControl()
|
||||
{
|
||||
LayoutInflater inflater = LayoutInflater.FromContext(Context);
|
||||
|
|
|
@ -8,6 +8,8 @@ using Android.Support.V4.View;
|
|||
using Android.Content.Res;
|
||||
using AView = Android.Views.View;
|
||||
using Xamarin.Forms.Platform.Android.AppCompat;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
using Android.Widget;
|
||||
|
||||
namespace Xamarin.Forms.Material.Android
|
||||
{
|
||||
|
@ -98,6 +100,9 @@ namespace Xamarin.Forms.Material.Android
|
|||
* */
|
||||
void OnFocusChange(object sender, FocusChangeEventArgs e)
|
||||
{
|
||||
if (EditText == null)
|
||||
return;
|
||||
|
||||
Device.BeginInvokeOnMainThread(() => ApplyTheme());
|
||||
|
||||
// propagate the focus changed event to the View Renderer base class
|
||||
|
@ -121,6 +126,17 @@ namespace Xamarin.Forms.Material.Android
|
|||
}
|
||||
}
|
||||
|
||||
public override EditText EditText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.IsDisposed())
|
||||
return null;
|
||||
|
||||
return base.EditText;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
|
|
|
@ -5,6 +5,7 @@ using Android.Widget;
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Material.Android;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
using AView = Android.Views.View;
|
||||
|
||||
|
||||
namespace Xamarin.Forms.Material.Android
|
||||
|
@ -19,6 +20,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
}
|
||||
|
||||
protected override EditText EditText => _textInputEditText;
|
||||
protected override AView ControlUsedForAutomation => EditText;
|
||||
|
||||
protected override MaterialPickerTextInputLayout CreateNativeControl()
|
||||
{
|
||||
|
@ -30,6 +32,12 @@ namespace Xamarin.Forms.Material.Android
|
|||
return _textInputLayout;
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
UpdateBackgroundColor();
|
||||
}
|
||||
|
||||
protected override void UpdateBackgroundColor()
|
||||
{
|
||||
if (_textInputLayout == null)
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
MotionEventHelper _motionEventHelper;
|
||||
double _max = 0.0;
|
||||
double _min = 0.0;
|
||||
bool _inputTransparent;
|
||||
|
||||
public MaterialSliderRenderer(Context context)
|
||||
: base(MaterialContextThemeWrapper.Create(context), null, Resource.Attribute.materialSliderStyle)
|
||||
|
@ -44,6 +45,9 @@ namespace Xamarin.Forms.Material.Android
|
|||
|
||||
public override bool OnTouchEvent(MotionEvent e)
|
||||
{
|
||||
if (!Enabled || _inputTransparent)
|
||||
return false;
|
||||
|
||||
if (_visualElementRenderer.OnTouchEvent(e) || base.OnTouchEvent(e))
|
||||
return true;
|
||||
|
||||
|
@ -118,6 +122,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
|
||||
UpdateValue();
|
||||
UpdateColors();
|
||||
UpdateInputTransparent();
|
||||
|
||||
ElevationHelper.SetElevation(this, e.NewElement);
|
||||
}
|
||||
|
@ -131,6 +136,17 @@ namespace Xamarin.Forms.Material.Android
|
|||
UpdateValue();
|
||||
else if (e.IsOneOf(VisualElement.BackgroundColorProperty, Slider.MaximumTrackColorProperty, Slider.MinimumTrackColorProperty, Slider.ThumbColorProperty))
|
||||
UpdateColors();
|
||||
else if (e.PropertyName == VisualElement.InputTransparentProperty.PropertyName)
|
||||
UpdateInputTransparent();
|
||||
}
|
||||
|
||||
|
||||
void UpdateInputTransparent()
|
||||
{
|
||||
if (Element == null)
|
||||
return;
|
||||
|
||||
_inputTransparent = Element.InputTransparent;
|
||||
}
|
||||
|
||||
void UpdateColors()
|
||||
|
@ -201,6 +217,8 @@ namespace Xamarin.Forms.Material.Android
|
|||
|
||||
// ITabStop
|
||||
AView ITabStop.TabStop => this;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
|
||||
MButton _downButton;
|
||||
MButton _upButton;
|
||||
bool _inputTransparent;
|
||||
|
||||
public MaterialStepperRenderer(Context context) : base(context)
|
||||
{
|
||||
|
@ -60,6 +61,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
}
|
||||
|
||||
StepperRendererManager.UpdateButtons(this, _downButton, _upButton);
|
||||
UpdateInputTransparent();
|
||||
}
|
||||
|
||||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
|
@ -67,6 +69,25 @@ namespace Xamarin.Forms.Material.Android
|
|||
base.OnElementPropertyChanged(sender, e);
|
||||
|
||||
StepperRendererManager.UpdateButtons(this, _downButton, _upButton, e);
|
||||
|
||||
if (e.PropertyName == VisualElement.InputTransparentProperty.PropertyName)
|
||||
UpdateInputTransparent();
|
||||
}
|
||||
|
||||
void UpdateInputTransparent()
|
||||
{
|
||||
if (Element == null)
|
||||
return;
|
||||
|
||||
_inputTransparent = Element.InputTransparent;
|
||||
}
|
||||
|
||||
public override bool OnTouchEvent(MotionEvent e)
|
||||
{
|
||||
if (!Enabled || _inputTransparent)
|
||||
return false;
|
||||
|
||||
return base.OnTouchEvent(e);
|
||||
}
|
||||
|
||||
protected override void UpdateBackgroundColor()
|
||||
|
|
|
@ -5,6 +5,7 @@ using Android.Widget;
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Material.Android;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
using AView = Android.Views.View;
|
||||
|
||||
|
||||
namespace Xamarin.Forms.Material.Android
|
||||
|
@ -19,6 +20,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
}
|
||||
|
||||
protected override EditText EditText => _textInputEditText;
|
||||
protected override AView ControlUsedForAutomation => EditText;
|
||||
|
||||
protected override MaterialPickerTextInputLayout CreateNativeControl()
|
||||
{
|
||||
|
@ -35,6 +37,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
{
|
||||
base.OnElementChanged(e);
|
||||
_textInputLayout.SetHint(string.Empty, Element);
|
||||
UpdateBackgroundColor();
|
||||
}
|
||||
|
||||
protected override void UpdateBackgroundColor()
|
||||
|
|
|
@ -76,9 +76,9 @@ namespace Xamarin.Forms.Platform.Android.AppLinks
|
|||
FirebaseAppIndex.Instance.Update(indexable);
|
||||
GMSTask gmsTask = FirebaseUserActions.Instance
|
||||
.Start(indexAction)
|
||||
.AddOnSuccessListener(Context as Activity,
|
||||
.AddOnSuccessListener(Context.GetActivity(),
|
||||
new AndroidActionSuccessListener(appLink as AppLinkEntry, indexAction))
|
||||
.AddOnFailureListener(Context as Activity,
|
||||
.AddOnFailureListener(Context.GetActivity(),
|
||||
new AndroidActionFailureListener(appLink as AppLinkEntry, indexAction));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
using Android.Content;
|
||||
using AActivity = Android.App.Activity;
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android.AppLinks
|
||||
{
|
||||
internal static class ContextExtensions
|
||||
{
|
||||
public static AActivity GetActivity(this Context context)
|
||||
{
|
||||
if (context == null)
|
||||
return null;
|
||||
|
||||
if (context is AActivity activity)
|
||||
return activity;
|
||||
|
||||
if (context is ContextWrapper contextWrapper)
|
||||
return contextWrapper.BaseContext.GetActivity();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@
|
|||
<Reference Include="Mono.Android" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ContextExtensions.cs" />
|
||||
<Compile Include="Resources\Resource.designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="AndroidAppLinks.cs" />
|
||||
|
|
|
@ -469,7 +469,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
if (actionBarHeight <= 0)
|
||||
return Device.Info.CurrentOrientation.IsPortrait() ? (int)Context.ToPixels(56) : (int)Context.ToPixels(48);
|
||||
|
||||
if (((Activity)Context).Window.Attributes.Flags.HasFlag(WindowManagerFlags.TranslucentStatus) || ((Activity)Context).Window.Attributes.Flags.HasFlag(WindowManagerFlags.TranslucentNavigation))
|
||||
if (Context.GetActivity().Window.Attributes.Flags.HasFlag(WindowManagerFlags.TranslucentStatus) || Context.GetActivity().Window.Attributes.Flags.HasFlag(WindowManagerFlags.TranslucentNavigation))
|
||||
{
|
||||
if (_toolbar.PaddingTop == 0)
|
||||
_toolbar.SetPadding(0, GetStatusBarHeight(), 0, 0);
|
||||
|
@ -642,7 +642,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
|
||||
FastRenderers.AutomationPropertiesProvider.GetDrawerAccessibilityResources(context, _masterDetailPage, out int resourceIdOpen, out int resourceIdClose);
|
||||
|
||||
_drawerToggle = new ActionBarDrawerToggle((Activity)context, _drawerLayout, bar,
|
||||
_drawerToggle = new ActionBarDrawerToggle(context.GetActivity(), _drawerLayout, bar,
|
||||
resourceIdOpen == 0 ? global::Android.Resource.String.Ok : resourceIdOpen,
|
||||
resourceIdClose == 0 ? global::Android.Resource.String.Ok : resourceIdClose)
|
||||
{
|
||||
|
|
|
@ -244,7 +244,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
var appCompatActivity = view.Context as AppCompatActivity;
|
||||
if (appCompatActivity == null)
|
||||
_actionMode = ((Activity)view.Context).StartActionMode(this);
|
||||
_actionMode = view.Context.GetActivity().StartActionMode(this);
|
||||
else
|
||||
_supportActionMode = appCompatActivity.StartSupportActionMode(this);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
protected override void OnFocusChanged(bool gainFocus, FocusSearchDirection direction, Rect previouslyFocusedRect)
|
||||
{
|
||||
Window window = ((Activity)Context).Window;
|
||||
Window window = Context.GetActivity().Window;
|
||||
if (gainFocus)
|
||||
{
|
||||
_startingMode = window.Attributes.SoftInputMode;
|
||||
|
|
|
@ -4,6 +4,7 @@ using Android.Content;
|
|||
using Android.Util;
|
||||
using Android.Views.InputMethods;
|
||||
using AApplicationInfoFlags = Android.Content.PM.ApplicationInfoFlags;
|
||||
using AActivity = Android.App.Activity;
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android
|
||||
{
|
||||
|
@ -81,5 +82,19 @@ namespace Xamarin.Forms.Platform.Android
|
|||
using (DisplayMetrics metrics = context.Resources.DisplayMetrics)
|
||||
s_displayDensity = metrics.Density;
|
||||
}
|
||||
|
||||
public static AActivity GetActivity(this Context context)
|
||||
{
|
||||
if (context == null)
|
||||
return null;
|
||||
|
||||
if (context is AActivity activity)
|
||||
return activity;
|
||||
|
||||
if (context is ContextWrapper contextWrapper)
|
||||
return contextWrapper.BaseContext.GetActivity();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,18 +118,18 @@ namespace Xamarin.Forms
|
|||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static void SetTitleBarVisibility(AndroidTitleBarVisibility visibility)
|
||||
{
|
||||
if ((Activity)Context == null)
|
||||
if (Context.GetActivity() == null)
|
||||
throw new NullReferenceException("Must be called after Xamarin.Forms.Forms.Init() method");
|
||||
|
||||
if (visibility == AndroidTitleBarVisibility.Never)
|
||||
{
|
||||
if (!((Activity)Context).Window.Attributes.Flags.HasFlag(WindowManagerFlags.Fullscreen))
|
||||
((Activity)Context).Window.AddFlags(WindowManagerFlags.Fullscreen);
|
||||
if (!Context.GetActivity().Window.Attributes.Flags.HasFlag(WindowManagerFlags.Fullscreen))
|
||||
Context.GetActivity().Window.AddFlags(WindowManagerFlags.Fullscreen);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((Activity)Context).Window.Attributes.Flags.HasFlag(WindowManagerFlags.Fullscreen))
|
||||
((Activity)Context).Window.ClearFlags(WindowManagerFlags.Fullscreen);
|
||||
if (Context.GetActivity().Window.Attributes.Flags.HasFlag(WindowManagerFlags.Fullscreen))
|
||||
Context.GetActivity().Window.ClearFlags(WindowManagerFlags.Fullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
_embedded = embedded;
|
||||
_context = context ?? throw new ArgumentNullException(nameof(context), "Somehow we're getting a null context passed in");
|
||||
PackageName = context.PackageName;
|
||||
_activity = context as Activity;
|
||||
_activity = context.GetActivity();
|
||||
|
||||
if (!embedded)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
if (e.Action != MotionEventActions.Up)
|
||||
return base.DispatchTouchEvent(e);
|
||||
|
||||
global::Android.Views.View currentView = ((Activity)Context).CurrentFocus;
|
||||
global::Android.Views.View currentView = Context.GetActivity().CurrentFocus;
|
||||
bool result = base.DispatchTouchEvent(e);
|
||||
|
||||
do
|
||||
|
@ -39,7 +39,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
if (!(currentView is EditText))
|
||||
break;
|
||||
|
||||
global::Android.Views.View newCurrentView = ((Activity)Context).CurrentFocus;
|
||||
global::Android.Views.View newCurrentView = Context.GetActivity().CurrentFocus;
|
||||
|
||||
if (currentView != newCurrentView)
|
||||
break;
|
||||
|
@ -61,7 +61,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
break;
|
||||
|
||||
Context.HideKeyboard(currentView);
|
||||
((Activity)Context).Window.DecorView.ClearFocus();
|
||||
Context.GetActivity().Window.DecorView.ClearFocus();
|
||||
} while (false);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
AddView(_masterLayout);
|
||||
|
||||
var activity = Context as Activity;
|
||||
var activity = Context.GetActivity();
|
||||
activity?.ActionBar?.SetDisplayShowHomeEnabled(true);
|
||||
activity?.ActionBar?.SetHomeButtonEnabled(true);
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
SoftInput _startingInputMode;
|
||||
|
||||
public TNativeView Control { get; private set; }
|
||||
protected virtual AView ControlUsedForAutomation => Control;
|
||||
|
||||
AView ITabStop.TabStop => Control;
|
||||
|
||||
|
@ -108,7 +109,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
if (isInViewCell)
|
||||
{
|
||||
Window window = ((Activity)Context).Window;
|
||||
Window window = Context.GetActivity().Window;
|
||||
if (hasFocus)
|
||||
{
|
||||
_startingInputMode = window.Attributes.SoftInputMode;
|
||||
|
@ -143,6 +144,12 @@ namespace Xamarin.Forms.Platform.Android
|
|||
{
|
||||
Control.OnFocusChangeListener = null;
|
||||
}
|
||||
|
||||
if (Element != null && _focusChangeHandler != null)
|
||||
{
|
||||
Element.FocusChangeRequested -= _focusChangeHandler;
|
||||
}
|
||||
_focusChangeHandler = null;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
|
@ -158,17 +165,8 @@ namespace Xamarin.Forms.Platform.Android
|
|||
}
|
||||
_container = null;
|
||||
}
|
||||
|
||||
if (Element != null && _focusChangeHandler != null)
|
||||
{
|
||||
Element.FocusChangeRequested -= _focusChangeHandler;
|
||||
|
||||
}
|
||||
_focusChangeHandler = null;
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<TView> e)
|
||||
|
@ -224,7 +222,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
}
|
||||
|
||||
ContentDescription = id + "_Container";
|
||||
AutomationPropertiesProvider.SetAutomationId(Control, Element, id);
|
||||
AutomationPropertiesProvider.SetAutomationId(ControlUsedForAutomation, Element, id);
|
||||
}
|
||||
|
||||
protected override void SetContentDescription()
|
||||
|
@ -236,7 +234,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
}
|
||||
|
||||
AutomationPropertiesProvider.SetContentDescription(
|
||||
Control, Element, ref _defaultContentDescription, ref _defaultHint);
|
||||
ControlUsedForAutomation, Element, ref _defaultContentDescription, ref _defaultHint);
|
||||
}
|
||||
|
||||
protected override void SetFocusable()
|
||||
|
@ -247,7 +245,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
return;
|
||||
}
|
||||
|
||||
AutomationPropertiesProvider.SetFocusable(Control, Element, ref _defaultFocusable);
|
||||
AutomationPropertiesProvider.SetFocusable(ControlUsedForAutomation, Element, ref _defaultFocusable);
|
||||
}
|
||||
|
||||
protected void SetNativeControl(TNativeView control)
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Text;
|
|||
|
||||
namespace Xamarin.Forms.Sandbox
|
||||
{
|
||||
public partial class App
|
||||
public partial class App
|
||||
{
|
||||
// This code is called from the App Constructor so just initialize the main page of the application here
|
||||
void InitializeMainPage()
|
||||
|
|
Загрузка…
Ссылка в новой задаче