Skip to content

Commit

Permalink
[Android] Fix Keyboard.Numeric issue (#16163)
Browse files Browse the repository at this point in the history
* Fix Keyboard.Numeric issue on DisplayPromptAsync on Android

* Remove AlertsPage sample

---------

Co-authored-by: Rachel Kang <rachel.j.kang@gmail.com>
  • Loading branch information
jsuarezruiz and rachelkang authored Aug 25, 2023
1 parent be144c7 commit 5ac1e80
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ bool IsDecimalPointChar(char c)
}
}

return stripped ?? filterFormatted ?? new String("");
return stripped ?? filterFormatted;
}
#pragma warning restore CS8602 // Dereference of a possibly null reference.
}
Expand Down

1 comment on commit 5ac1e80

@sillerjp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
I've tried creating a custom LocalizeDigitsKeyListener in .NET 7 Maui application since we cannot migrate to .NET 8 yet. I added the code for this file which is supposed to fix the ability to input ',' or different decimal characters when the app is in a different language.

Then I set the KeyListener of the input to use this instead of the one built in with Maui .NET 7

ie)
PlatformView.KeyListener = LocalizedDigitsKeyListenerFixed.Create(handler.PlatformView.InputType);

This didn't have any effect on the input. I was also able to troubleshoot the code in LocalizedDigitsKeyListener and the InputTypes are different between .NET 7 and .NET 8 for a the same Entry using Keyboard="Numeric" which changes the execution of the code inside this class. ie)

.NET 7
Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextFlagMultiLine
vs
.NET 8
Android.Text.InputTypes.ClassNumber | Android.Text.InputTypes.NumberFlagDecimal | Android.Text.InputTypes.NumberFlagSigned | Android.Text.InputTypes.TextFlagAutoCorrect

Regardless, I ended up setting the same InputTypes in the .NET 7 app manually to match those that .NET 8 shows by default and it still didn't let me input a ',' when being on a different language (German).

Are you sure this is what fixed the issue in .NET 8? Seems like something else must have fixed it. If you can point me to the correct fix to see if I can implement it in my .NET 7 app I would appreciate it.

Please sign in to comment.