Skip to content

Commit eb3a4db

Browse files
bhavanesh2001PureWeen
authored andcommitted
make picker not focisable
# Conflicts: # src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
1 parent bc16a06 commit eb3a4db

File tree

5 files changed

+8
-47
lines changed

5 files changed

+8
-47
lines changed

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue2339.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using NUnit.Framework;
22
using UITest.Appium;
33
using UITest.Core;
4-
4+
#if TEST_FAILS_ON_ANDROID
55
namespace Microsoft.Maui.TestCases.Tests.Issues
66
{
77
public class Issue2339 : _IssuesUITest
@@ -27,4 +27,5 @@ public void FocusAndUnFocusMultipleTimes()
2727
App.WaitForElement("Picker UnFocused: 2");
2828
}
2929
}
30-
}
30+
}
31+
#endif

src/Core/src/Handlers/Picker/PickerHandler.Android.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ protected override MauiPicker CreatePlatformView() =>
1919

2020
protected override void ConnectHandler(MauiPicker platformView)
2121
{
22-
platformView.FocusChange += OnFocusChange;
2322
platformView.Click += OnClick;
2423

2524
base.ConnectHandler(platformView);
2625
}
2726

2827
protected override void DisconnectHandler(MauiPicker platformView)
2928
{
30-
platformView.FocusChange -= OnFocusChange;
3129
platformView.Click -= OnClick;
3230

3331
base.DisconnectHandler(platformView);
@@ -86,24 +84,6 @@ public static void MapVerticalTextAlignment(IPickerHandler handler, IPicker pick
8684
handler.PlatformView?.UpdateVerticalAlignment(picker.VerticalTextAlignment);
8785
}
8886

89-
void OnFocusChange(object? sender, global::Android.Views.View.FocusChangeEventArgs e)
90-
{
91-
if (PlatformView == null)
92-
return;
93-
94-
if (e.HasFocus)
95-
{
96-
if (PlatformView.Clickable)
97-
PlatformView.CallOnClick();
98-
else
99-
OnClick(PlatformView, EventArgs.Empty);
100-
}
101-
else if (_dialog != null)
102-
{
103-
_dialog.Hide();
104-
_dialog = null;
105-
}
106-
}
10787

10888
void OnClick(object? sender, EventArgs e)
10989
{

src/Core/src/Platform/Android/MauiPicker.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,12 @@ namespace Microsoft.Maui.Platform
99
{
1010
public class MauiPicker : MauiPickerBase
1111
{
12-
public bool ShowPopupOnFocus { get; set; }
1312

1413
public MauiPicker(Context context) : base(context)
1514
{
1615
PickerManager.Init(this);
1716
}
1817

19-
public override bool OnTouchEvent(MotionEvent? e)
20-
{
21-
PickerManager.OnTouchEvent(this, e);
22-
return base.OnTouchEvent(e); // Raises the OnClick event if focus is already received
23-
}
24-
25-
protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, ARect? previouslyFocusedRect)
26-
{
27-
base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect);
28-
PickerManager.OnFocusChanged(gainFocus, this);
29-
}
30-
3118
protected override void Dispose(bool disposing)
3219
{
3320
if (disposing)

src/Core/src/Platform/Android/PickerManager.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,14 @@ internal static class PickerManager
1818
public static void Init(EditText editText)
1919
{
2020
editText.Focusable = true;
21+
editText.FocusableInTouchMode= false;
2122
editText.Clickable = true;
2223
editText.InputType = InputTypes.Null;
2324

2425
editText.KeyPress += OnKeyPress;
2526
}
2627

27-
public static void OnTouchEvent(EditText sender, MotionEvent? e)
28-
{
29-
if (e != null && e.Action == MotionEventActions.Up && !sender.IsFocused)
30-
{
31-
sender.RequestFocus();
32-
}
33-
}
3428

35-
public static void OnFocusChanged(bool gainFocus, EditText sender)
36-
{
37-
if (gainFocus)
38-
sender.CallOnClick();
39-
}
4029

4130
static void OnKeyPress(object? sender, AView.KeyEventArgs e)
4231
{
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
#nullable enable
2+
*REMOVED*Microsoft.Maui.Platform.MauiPicker.ShowPopupOnFocus.get -> bool
3+
*REMOVED*Microsoft.Maui.Platform.MauiPicker.ShowPopupOnFocus.set -> void
4+
*REMOVED*override Microsoft.Maui.Platform.MauiPicker.OnFocusChanged(bool gainFocus, Android.Views.FocusSearchDirection direction, Android.Graphics.Rect? previouslyFocusedRect) -> void
5+
*REMOVED*override Microsoft.Maui.Platform.MauiPicker.OnTouchEvent(Android.Views.MotionEvent? e) -> bool

0 commit comments

Comments
 (0)