summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradrianknight89 <adrianknight89@outlook.com>2017-01-26 11:24:37 -0600
committerE.Z. Hart <hartez@users.noreply.github.com>2017-01-26 10:24:37 -0700
commitc013452734ea5c8745f3ee849a40e0c65332fb82 (patch)
treeff5e6de8e61e6f69d9bf52c573f338345e860307
parent52fc04724fc163c68c54cf33a5931871f8c1ee8e (diff)
downloadxamarin-forms-c013452734ea5c8745f3ee849a40e0c65332fb82.tar.gz
xamarin-forms-c013452734ea5c8745f3ee849a40e0c65332fb82.tar.bz2
xamarin-forms-c013452734ea5c8745f3ee849a40e0c65332fb82.zip
[Android] Keyboard should not change layout while dismissing on Entry and Editor (#663)
* handle keyboard on entry * add sample code * editor changes * change text * better fix * changes
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43867.cs49
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs13
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs13
4 files changed, 62 insertions, 14 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43867.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43867.cs
new file mode 100644
index 00000000..938200c0
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43867.cs
@@ -0,0 +1,49 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+using Xamarin.Forms.PlatformConfiguration;
+using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 43867, "Numeric keyboard shows text / default keyboard when back button is hit", PlatformAffected.Android)]
+ public class Bugzilla43867 : TestContentPage // or TestMasterDetailPage, etc ...
+ {
+ protected override void Init()
+ {
+ Application.Current.On<Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
+
+ Content = new StackLayout
+ {
+ Spacing = 10,
+ VerticalOptions = LayoutOptions.Center,
+ Children =
+ {
+ new Label
+ {
+ Text = "Focus and unfocus each element 10 times using the Back button. Observe that the soft keyboard does not show different characters while hiding. Now repeat the test by tapping off of the element."
+ },
+ new Entry
+ {
+ WidthRequest = 250,
+ HeightRequest = 50,
+ BackgroundColor = Color.AntiqueWhite,
+ Keyboard = Keyboard.Numeric
+ },
+ new Editor
+ {
+ WidthRequest = 250,
+ HeightRequest = 50,
+ BackgroundColor = Color.BurlyWood,
+ Keyboard = Keyboard.Numeric
+ }
+ }
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 23bb7879..68193dc1 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -142,6 +142,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla43516.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla43941.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla43663.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla43867.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla43735.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44453.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44944.cs" />
diff --git a/Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs b/Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs
index 24273121..4a6428eb 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/EditorEditText.cs
@@ -23,13 +23,12 @@ namespace Xamarin.Forms.Platform.Android
public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
{
- if (keyCode == Keycode.Back && e.Action == KeyEventActions.Down)
- {
- EventHandler handler = OnBackKeyboardPressed;
- if (handler != null)
- handler(this, EventArgs.Empty);
- }
- return base.OnKeyPreIme(keyCode, e);
+ if (keyCode != Keycode.Back || e.Action != KeyEventActions.Down)
+ return base.OnKeyPreIme(keyCode, e);
+
+ this.HideKeyboard();
+ OnBackKeyboardPressed?.Invoke(this, EventArgs.Empty);
+ return true;
}
public override bool RequestFocus(FocusSearchDirection direction, Rect previouslyFocusedRect)
diff --git a/Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs b/Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs
index de03a414..5c0b7c0e 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/EntryEditText.cs
@@ -23,13 +23,12 @@ namespace Xamarin.Forms.Platform.Android
public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
{
- if (keyCode == Keycode.Back && e.Action == KeyEventActions.Down)
- {
- EventHandler handler = OnKeyboardBackPressed;
- if (handler != null)
- handler(this, EventArgs.Empty);
- }
- return base.OnKeyPreIme(keyCode, 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)