Skip to content

Commit

Permalink
Revert "Hide Keyboard in Android Entry and Editor when back key is pr…
Browse files Browse the repository at this point in the history
…essed (#4827)" (#5019)

This reverts commit 3551378.
  • Loading branch information
PureWeen authored Mar 2, 2022
1 parent eec992b commit a7b8329
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ void UpdateInputType()

abstract protected void UpdatePlaceholderColor();

[PortHandler]
void OnKeyboardBackPressed(object sender, EventArgs eventArgs)
{
Control?.ClearFocus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public FormsEditText(Context context) : base(context)
{
}

[PortHandler]

public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
{
if (keyCode != Keycode.Back || e.Action != KeyEventActions.Down)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#nullable disable
using System;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Views.InputMethods;
using Android.Widget;
using Microsoft.Maui.Essentials;
using AView = Android.Views.View;

namespace Microsoft.Maui.Platform
namespace Microsoft.Maui.Controls.Platform
{
public static class KeyboardManager
internal static class KeyboardManager
{
public static void HideKeyboard(this AView inputView, bool overrideValidation = false)
internal static void HideKeyboard(this AView inputView, bool overrideValidation = false)
{
if (inputView == null)
throw new ArgumentNullException(nameof(inputView) + " must be set before the keyboard can be hidden.");
Expand All @@ -27,7 +26,7 @@ public static void HideKeyboard(this AView inputView, bool overrideValidation =
}
}

public static void ShowKeyboard(this TextView inputView)
internal static void ShowKeyboard(this TextView inputView)
{
if (inputView == null)
throw new ArgumentNullException(nameof(inputView) + " must be set before the keyboard can be shown.");
Expand All @@ -41,7 +40,7 @@ public static void ShowKeyboard(this TextView inputView)
}
}

public static void ShowKeyboard(this SearchView searchView)
internal static void ShowKeyboard(this SearchView searchView)
{
if (searchView == null)
{
Expand Down Expand Up @@ -74,7 +73,7 @@ public static void ShowKeyboard(this SearchView searchView)
}
}

public static void ShowKeyboard(this AView view)
internal static void ShowKeyboard(this AView view)
{
switch (view)
{
Expand All @@ -101,7 +100,7 @@ void ShowKeyboard()
view.ShowKeyboard();
};

MainThread.BeginInvokeOnMainThread(ShowKeyboard);
Device.BeginInvokeOnMainThread(ShowKeyboard);
}
}
}
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Editor/EditorHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class EditorHandler : ViewHandler<IEditor, AppCompatEditText>

protected override AppCompatEditText CreatePlatformView()
{
var editText = new MauiEditText(Context)
var editText = new AppCompatEditText(Context)
{
ImeOptions = ImeAction.Done,
Gravity = GravityFlags.Top,
Expand Down
20 changes: 2 additions & 18 deletions src/Core/src/Handlers/Entry/EntryHandler.Android.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Android.Content.Res;
using Android.Content.Res;
using Android.Graphics.Drawables;
using Android.Runtime;
using Android.Text;
Expand All @@ -20,7 +19,7 @@ public partial class EntryHandler : ViewHandler<IEntry, AppCompatEditText>

protected override AppCompatEditText CreatePlatformView()
{
var nativeEntry = new MauiEditText(Context);
var nativeEntry = new AppCompatEditText(Context);
_defaultPlaceholderColors = nativeEntry.HintTextColors;
return nativeEntry;
}
Expand All @@ -35,11 +34,6 @@ protected override void ConnectHandler(AppCompatEditText platformView)
platformView.FocusChange += OnFocusedChange;
platformView.Touch += OnTouch;
platformView.EditorAction += OnEditorAction;

if (platformView is IMauiEditText mauiEditText)
{
mauiEditText.OnKeyboardBackPressed += OnKeyboardBackPressed;
}
}

protected override void DisconnectHandler(AppCompatEditText platformView)
Expand All @@ -49,11 +43,6 @@ protected override void DisconnectHandler(AppCompatEditText platformView)
platformView.FocusChange -= OnFocusedChange;
platformView.Touch -= OnTouch;
platformView.EditorAction -= OnEditorAction;

if (platformView is IMauiEditText mauiEditText)
{
mauiEditText.OnKeyboardBackPressed -= OnKeyboardBackPressed;
}
}

public static void MapBackground(IEntryHandler handler, IEntry entry) =>
Expand Down Expand Up @@ -143,10 +132,5 @@ void OnEditorAction(object? sender, EditorActionEventArgs e)

e.Handled = true;
}

void OnKeyboardBackPressed(object? sender, EventArgs eventArgs)
{
PlatformView?.ClearFocus();
}
}
}
12 changes: 0 additions & 12 deletions src/Core/src/Platform/Android/IMauiEditText.cs

This file was deleted.

36 changes: 0 additions & 36 deletions src/Core/src/Platform/Android/MauiEditText.cs

This file was deleted.

0 comments on commit a7b8329

Please sign in to comment.