-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't set editor action to handled #11386
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,36 +2,38 @@ | |
using Android.App; | ||
using Android.Content; | ||
using Android.OS; | ||
using Android.Views; | ||
using Android.Views.InputMethods; | ||
using Android.Widget; | ||
using AndroidX.Core.View; | ||
using AView = Android.Views.View; | ||
|
||
namespace Microsoft.Maui.Controls.Platform | ||
namespace Microsoft.Maui.Platform | ||
{ | ||
internal static class KeyboardManager | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this to |
||
{ | ||
internal static void HideKeyboard(this AView inputView, bool overrideValidation = false) | ||
{ | ||
if (inputView == null) | ||
if (inputView?.Context == null) | ||
throw new ArgumentNullException(nameof(inputView) + " must be set before the keyboard can be hidden."); | ||
|
||
using (var inputMethodManager = (InputMethodManager)inputView.Context.GetSystemService(Context.InputMethodService)) | ||
using (var inputMethodManager = (InputMethodManager)inputView.Context.GetSystemService(Context.InputMethodService)!) | ||
{ | ||
if (!overrideValidation && !(inputView is EditText || inputView is TextView || inputView is SearchView)) | ||
throw new ArgumentException("inputView should be of type EditText, SearchView, or TextView"); | ||
|
||
IBinder windowToken = inputView.WindowToken; | ||
var windowToken = inputView.WindowToken; | ||
if (windowToken != null && inputMethodManager != null) | ||
inputMethodManager.HideSoftInputFromWindow(windowToken, HideSoftInputFlags.None); | ||
} | ||
} | ||
|
||
internal static void ShowKeyboard(this TextView inputView) | ||
{ | ||
if (inputView == null) | ||
if (inputView?.Context == null) | ||
throw new ArgumentNullException(nameof(inputView) + " must be set before the keyboard can be shown."); | ||
|
||
using (var inputMethodManager = (InputMethodManager)inputView.Context.GetSystemService(Context.InputMethodService)) | ||
using (var inputMethodManager = (InputMethodManager)inputView.Context.GetSystemService(Context.InputMethodService)!) | ||
{ | ||
// The zero value for the second parameter comes from | ||
// https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#showSoftInput(android.view.View,%20int) | ||
|
@@ -42,7 +44,7 @@ internal static void ShowKeyboard(this TextView inputView) | |
|
||
internal static void ShowKeyboard(this SearchView searchView) | ||
{ | ||
if (searchView == null) | ||
if (searchView?.Context == null || searchView?.Resources == null) | ||
{ | ||
throw new ArgumentNullException(nameof(searchView)); | ||
} | ||
|
@@ -64,7 +66,7 @@ internal static void ShowKeyboard(this SearchView searchView) | |
return; | ||
} | ||
|
||
using (var inputMethodManager = (InputMethodManager)searchView.Context.GetSystemService(Context.InputMethodService)) | ||
using (var inputMethodManager = (InputMethodManager)searchView.Context.GetSystemService(Context.InputMethodService)!) | ||
{ | ||
// The zero value for the second parameter comes from | ||
// https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#showSoftInput(android.view.View,%20int) | ||
|
@@ -102,5 +104,15 @@ void ShowKeyboard() | |
|
||
view.Post(ShowKeyboard); | ||
} | ||
|
||
public static bool IsSoftKeyboardVisible(this AView view) | ||
{ | ||
var insets = ViewCompat.GetRootWindowInsets(view); | ||
if (insets == null) | ||
return false; | ||
|
||
var result = insets.IsVisible(WindowInsetsCompat.Type.Ime()); | ||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Core/tests/DeviceTests/Stubs/VerticalStackLayoutStub.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui.Layouts; | ||
|
||
namespace Microsoft.Maui.DeviceTests.Stubs | ||
{ | ||
public class VerticalStackLayoutStub : LayoutStub, IStackLayout | ||
{ | ||
public double Spacing => 0; | ||
|
||
protected override ILayoutManager CreateLayoutManager() | ||
{ | ||
return new VerticalStackLayoutManager(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only SDK change