summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradrianknight89 <adrianknight89@outlook.com>2017-01-26 11:24:37 -0600
committerKangho Hur <kangho.hur@samsung.com>2017-03-24 13:15:53 +0900
commit7787b8bac9e78bd16b3519ab865a22efa564c125 (patch)
treeb5f63ed713c520da0834d7f6b01a5bbbd47a5fb7
parent30ff03b0a6c62aade8cc2b347f0e316e9709a8ce (diff)
downloadxamarin-forms-7787b8bac9e78bd16b3519ab865a22efa564c125.tar.gz
xamarin-forms-7787b8bac9e78bd16b3519ab865a22efa564c125.tar.bz2
xamarin-forms-7787b8bac9e78bd16b3519ab865a22efa564c125.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 2d6ddb58..a8270fd5 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)Bugzilla51536.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)