summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/FormsEditText.cs
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-05-31 16:37:39 -0600
committerJason Smith <jason.smith@xamarin.com>2017-05-31 15:37:39 -0700
commit4cde4ecb6c26318faeba8988ccb2bb162dded560 (patch)
treee88ad437aa8ba44f9209da54dfe02f966a4f5e3c /Xamarin.Forms.Platform.Android/Renderers/FormsEditText.cs
parent27f6cfbda80fc2b0feb6f6c513e925891d8a645b (diff)
downloadxamarin-forms-4cde4ecb6c26318faeba8988ccb2bb162dded560.tar.gz
xamarin-forms-4cde4ecb6c26318faeba8988ccb2bb162dded560.tar.bz2
xamarin-forms-4cde4ecb6c26318faeba8988ccb2bb162dded560.zip
[Android] Correctly size content after toggling soft keyboard in Resize mode (#927)
* Repro of 45215 * Consolidate base class for Entry/Editor; add missing Dispose implementations * Fixed problem with hiding the keyboard and child layout in ScrollViewer * Force page layout update when navigating back from a keyboard-resized page * Explanatory comments * Fix namespace * Fix possible NRE after device rotation
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/FormsEditText.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/FormsEditText.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/FormsEditText.cs b/Xamarin.Forms.Platform.Android/Renderers/FormsEditText.cs
new file mode 100644
index 00000000..92c3600b
--- /dev/null
+++ b/Xamarin.Forms.Platform.Android/Renderers/FormsEditText.cs
@@ -0,0 +1,44 @@
+using System;
+using Android.Content;
+using Android.Graphics;
+using Android.Views;
+using Android.Widget;
+
+namespace Xamarin.Forms.Platform.Android
+{
+ public class FormsEditText : EditText, IDescendantFocusToggler
+ {
+ DescendantFocusToggler _descendantFocusToggler;
+
+ internal FormsEditText(Context context) : base(context)
+ {
+ }
+
+ bool IDescendantFocusToggler.RequestFocus(global::Android.Views.View control, Func<bool> baseRequestFocus)
+ {
+ _descendantFocusToggler = _descendantFocusToggler ?? new DescendantFocusToggler();
+
+ return _descendantFocusToggler.RequestFocus(control, baseRequestFocus);
+ }
+
+ public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
+ {
+ if (keyCode != Keycode.Back || e.Action != KeyEventActions.Down)
+ {
+ return base.OnKeyPreIme(keyCode, e);
+ }
+
+ this.HideKeyboard();
+
+ OnKeyboardBackPressed?.Invoke(this, EventArgs.Empty);
+ return true;
+ }
+
+ public override bool RequestFocus(FocusSearchDirection direction, Rect previouslyFocusedRect)
+ {
+ return (this as IDescendantFocusToggler).RequestFocus(this, () => base.RequestFocus(direction, previouslyFocusedRect));
+ }
+
+ internal event EventHandler OnKeyboardBackPressed;
+ }
+} \ No newline at end of file