Blog edition accessibility
This commit is contained in:
parent
a131a6ddf8
commit
f1c23965b2
14 changed files with 656 additions and 16 deletions
|
|
@ -44,6 +44,28 @@ public class MainActivity : AvaloniaMainActivity
|
|||
|
||||
private void OnScreenAwakeChanged() => RunOnUiThread(UpdateScreenAwake);
|
||||
|
||||
internal static void ShowSoftKeyboard()
|
||||
{
|
||||
if (Current is not { } activity || !IsForeground)
|
||||
{
|
||||
global::Android.Util.Log.Warn("PostIt", "Cannot show the keyboard without a foreground activity.");
|
||||
return;
|
||||
}
|
||||
|
||||
activity.RunOnUiThread(() =>
|
||||
{
|
||||
if (activity.CurrentFocus is not { } view
|
||||
|| activity.GetSystemService(InputMethodService) is not global::Android.Views.InputMethods.InputMethodManager inputMethod)
|
||||
{
|
||||
global::Android.Util.Log.Warn("PostIt", "Cannot show the keyboard without a focused native view and input method.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!inputMethod.ShowSoftInput(view, global::Android.Views.InputMethods.ShowFlags.Implicit))
|
||||
global::Android.Util.Log.Warn("PostIt", "The input method did not accept the keyboard activation request.");
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateScreenAwake()
|
||||
{
|
||||
if (Window is not { } window) return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue